From 92277b8571440800b6483d0087a33cf86b35a3a3 Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 6 Jul 2022 10:44:10 +0100 Subject: [PATCH] only display relevant property information questions --- .../derived_variables/case_log_variables.rb | 14 ++++---- app/views/case_logs/_tasklist.html.erb | 16 +++++---- config/forms/2021_2022.json | 35 +++++++++++++++---- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/app/models/derived_variables/case_log_variables.rb b/app/models/derived_variables/case_log_variables.rb index 65ac1f005..cbf6fd8d0 100644 --- a/app/models/derived_variables/case_log_variables.rb +++ b/app/models/derived_variables/case_log_variables.rb @@ -71,12 +71,14 @@ module DerivedVariables::CaseLogVariables if scheme.locations.size == 1 self.location = scheme.locations.first end - self.la = location.county - self.postcode_full = location.postcode - self.unittype_gn = form.questions.find { |x| x.id == "unittype_gn" }.answer_options.select { |_key, value| value["value"] == location.type_of_unit }.keys.first - self.builtype = form.questions.find { |x| x.id == "builtype" }.answer_options.select { |_key, value| value["value"] == location.type_of_building }.keys.first - wheelchair_adaptation_map = { 1 => 1, 0 => 2 } - self.wchair = wheelchair_adaptation_map[location.wheelchair_adaptation.to_i] + if location + self.la = location.county + self.postcode_full = location.postcode + self.unittype_gn = form.questions.find { |x| x.id == "unittype_gn" }.answer_options.select { |_key, value| value["value"] == location.type_of_unit }.keys.first + self.builtype = form.questions.find { |x| x.id == "builtype" }.answer_options.select { |_key, value| value["value"] == location.type_of_building }.keys.first + wheelchair_adaptation_map = { 1 => 1, 0 => 2 } + self.wchair = wheelchair_adaptation_map[location.wheelchair_adaptation.to_i] + end if is_renewal? self.voiddate = startdate end diff --git a/app/views/case_logs/_tasklist.html.erb b/app/views/case_logs/_tasklist.html.erb index 14ff87274..ff64d5b74 100644 --- a/app/views/case_logs/_tasklist.html.erb +++ b/app/views/case_logs/_tasklist.html.erb @@ -9,13 +9,15 @@ <% end %> diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 49c38f47c..d93f04e22 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -54,7 +54,12 @@ "value": "Not known" } } - } + }, + "depends_on": [ + { + "needstype": 1 + } + ] }, "property_local_authority": { "header": "", @@ -388,7 +393,8 @@ }, "depends_on": [ { - "is_la_inferred": false + "is_la_inferred": false, + "needstype": 1 } ] }, @@ -617,7 +623,12 @@ } } } - } + }, + "depends_on": [ + { + "needstype": 1 + } + ] }, "property_building_type": { "header": "", @@ -637,7 +648,12 @@ } } } - } + }, + "depends_on": [ + { + "needstype": 1 + } + ] }, "property_wheelchair_accessible": { "header": "", @@ -657,7 +673,12 @@ } } } - } + }, + "depends_on": [ + { + "needstype": 1 + } + ] }, "property_number_of_bedrooms": { "header": "", @@ -6840,7 +6861,9 @@ }, "net_income_value_check": { "depends_on": [{ "net_income_soft_validation_triggered?": true }], - "title_text": { "translation": "soft_validations.net_income.title_text" }, + "title_text": { + "translation": "soft_validations.net_income.title_text" + }, "informative_text": { "translation": "soft_validations.net_income.hint_text", "arguments": [