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)
return true unless depends_on
depends_on.any? do |conditions_set|
conditions_set.all? do |subsection_id, dependent_status|
form.get_subsection(subsection_id).status(log) == dependent_status.to_sym
end
end
form.depends_on_met(depends_on, log)
end
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)
end
def non_location_setup_questions_completed?
[needstype, renewal, rent_type, startdate, owning_organisation_id, created_by_id].all?(&:present?)
end
private
PIO = PostcodeService.new

4
app/models/log.rb

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

12
config/forms/2021_2022.json

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

20
config/forms/2022_2023.json

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

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

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

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

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

Loading…
Cancel
Save