Browse Source

Change enabled? subsection method to check depends on using log questions and methods instead of a subsection status

pull/990/head
Kat 4 years ago
parent
commit
ef46c6c227
  1. 6
      app/models/form/subsection.rb
  2. 4
      app/models/lettings_log.rb
  3. 4
      app/models/log.rb
  4. 12
      config/forms/2021_2022.json
  5. 20
      config/forms/2022_2023.json
  6. 7
      spec/fixtures/forms/2021_2022.json
  7. 2
      spec/fixtures/forms/2022_2023.json

6
app/models/form/subsection.rb

@ -20,11 +20,7 @@ class Form::Subsection
def enabled?(log) def enabled?(log)
return true unless depends_on return true unless depends_on
depends_on.any? do |conditions_set| form.depends_on_met(depends_on, log)
conditions_set.all? do |subsection_id, dependent_status|
form.get_subsection(subsection_id).status(log) == dependent_status.to_sym
end
end
end end
def status(log) def status(log)

4
app/models/lettings_log.rb

@ -507,6 +507,10 @@ class LettingsLog < Log
form.get_question("rent_type", self)&.label_from_value(rent_type) form.get_question("rent_type", self)&.label_from_value(rent_type)
end end
def non_location_setup_questions_completed?
[needstype, renewal, rent_type, startdate, owning_organisation_id, created_by_id].all?(&:present?)
end
private private
PIO = PostcodeService.new PIO = PostcodeService.new

4
app/models/log.rb

@ -40,6 +40,10 @@ class Log < ApplicationRecord
ethnic_group == 17 ethnic_group == 17
end end
def managing_organisation_provider_type
managing_organisation&.provider_type
end
private private
def update_status! def update_status!

12
config/forms/2021_2022.json

@ -10,7 +10,7 @@
"label": "Property information", "label": "Property information",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {
@ -952,7 +952,7 @@
"label": "Tenancy information", "label": "Tenancy information",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {
@ -1133,7 +1133,7 @@
"label": "Household characteristics", "label": "Household characteristics",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {
@ -5671,7 +5671,7 @@
"label": "Household needs", "label": "Household needs",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {
@ -6060,7 +6060,7 @@
"label": "Household situation", "label": "Household situation",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {
@ -7302,7 +7302,7 @@
"label": "Income, benefits and outgoings", "label": "Income, benefits and outgoings",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {

20
config/forms/2022_2023.json

@ -10,7 +10,7 @@
"label": "Property information", "label": "Property information",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {
@ -952,7 +952,7 @@
"label": "Tenancy information", "label": "Tenancy information",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {
@ -1168,7 +1168,7 @@
"label": "Household characteristics", "label": "Household characteristics",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {
@ -5670,7 +5670,7 @@
"label": "Household needs", "label": "Household needs",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {
@ -6062,7 +6062,7 @@
"label": "Household situation", "label": "Household situation",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {
@ -7070,7 +7070,7 @@
}, },
"depends_on": [ "depends_on": [
{ {
"managing_organisation.provider_type": "LA", "managing_organisation_provider_type": "LA",
"needstype": 1, "needstype": 1,
"renewal": 0 "renewal": 0
} }
@ -7127,7 +7127,7 @@
}, },
"depends_on": [ "depends_on": [
{ {
"managing_organisation.provider_type": "PRP", "managing_organisation_provider_type": "PRP",
"needstype": 1, "needstype": 1,
"renewal": 0 "renewal": 0
} }
@ -7184,7 +7184,7 @@
}, },
"depends_on": [ "depends_on": [
{ {
"managing_organisation.provider_type": "LA", "managing_organisation_provider_type": "LA",
"needstype": 2, "needstype": 2,
"renewal": 0 "renewal": 0
} }
@ -7244,7 +7244,7 @@
}, },
"depends_on": [ "depends_on": [
{ {
"managing_organisation.provider_type": "PRP", "managing_organisation_provider_type": "PRP",
"needstype": 2, "needstype": 2,
"renewal": 0 "renewal": 0
} }
@ -7261,7 +7261,7 @@
"label": "Income, benefits and outgoings", "label": "Income, benefits and outgoings",
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
], ],
"pages": { "pages": {

7
spec/fixtures/forms/2021_2022.json vendored

@ -1099,9 +1099,10 @@
"label": "Declaration", "label": "Declaration",
"depends_on": [ "depends_on": [
{ {
"household_characteristics": "completed", "armedforces": 1
"household_needs": "completed", },
"property_information": "completed" {
"armedforces": 3
} }
], ],
"pages": { "pages": {

2
spec/fixtures/forms/2022_2023.json vendored

@ -47,7 +47,7 @@
}, },
"depends_on": [ "depends_on": [
{ {
"setup": "completed" "non_location_setup_questions_completed?": true
} }
] ]
} }

Loading…
Cancel
Save