Browse Source

Add tenant_code and propcode as optional fields and consider subsection completed it they are not filled in'

pull/282/head
Kat 3 years ago
parent
commit
8510b66f62
  1. 1
      app/models/case_log.rb
  2. 2
      app/models/constants/case_log.rb
  3. 4
      app/models/form/subsection.rb

1
app/models/case_log.rb

@ -144,7 +144,6 @@ class CaseLog < ApplicationRecord
enum declaration: POLAR, _suffix: true
AUTOGENERATED_FIELDS = %w[id status created_at updated_at discarded_at].freeze
OPTIONAL_FIELDS = %w[postcode_known la_known first_time_property_let_as_social_housing].freeze
def form
FormHandler.instance.get_form(form_name)

2
app/models/constants/case_log.rb

@ -1123,4 +1123,6 @@ module Constants::CaseLog
"Sheltered accomodation",
"Home Office Asylum Support",
"Other"].freeze
OPTIONAL_FIELDS = %w[postcode_known la_known first_time_property_let_as_social_housing tenant_code propcode].freeze
end

4
app/models/form/subsection.rb

@ -1,4 +1,6 @@
class Form::Subsection
include Constants::CaseLog
attr_accessor :id, :label, :section, :pages, :depends_on, :form
def initialize(id, hsh, section)
@ -30,7 +32,7 @@ class Form::Subsection
return :cannot_start_yet
end
qs = applicable_questions(case_log)
qs = applicable_questions(case_log).reject { |q| OPTIONAL_FIELDS.include?(q.id) }
return :not_started if qs.all? { |question| case_log[question.id].blank? || question.read_only? }
return :completed if qs.all? { |question| question.completed?(case_log) }

Loading…
Cancel
Save