diff --git a/app/models/form.rb b/app/models/form.rb index 1cb41c209..cc73d2ca6 100644 --- a/app/models/form.rb +++ b/app/models/form.rb @@ -239,9 +239,9 @@ class Form def routed_and_not_routed_questions_by_type(log, type: nil, current_user: nil) questions_by_type = if type - questions.reject { |q| q.type != type || q.do_not_clear } + questions.reject { |q| q.type != type || q.disable_clearing_if_not_routed_or_dynamic_answer_options } else - questions.reject { |q| %w[radio checkbox].include?(q.type) || q.do_not_clear } + questions.reject { |q| %w[radio checkbox].include?(q.type) || q.disable_clearing_if_not_routed_or_dynamic_answer_options } end routed, not_routed = questions_by_type.partition { |q| q.page.routed_to?(log, current_user) || q.derived? } { routed:, not_routed: } diff --git a/app/models/form/lettings/questions/address_line1.rb b/app/models/form/lettings/questions/address_line1.rb index dcac5c7ae..ef197e4fd 100644 --- a/app/models/form/lettings/questions/address_line1.rb +++ b/app/models/form/lettings/questions/address_line1.rb @@ -7,7 +7,7 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question @type = "text" @plain_label = true @check_answer_label = "Q12 - Address" - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def answer_label(log, _current_user = nil) diff --git a/app/models/form/lettings/questions/address_line2.rb b/app/models/form/lettings/questions/address_line2.rb index 34a845745..3b2c36dbc 100644 --- a/app/models/form/lettings/questions/address_line2.rb +++ b/app/models/form/lettings/questions/address_line2.rb @@ -5,7 +5,7 @@ class Form::Lettings::Questions::AddressLine2 < ::Form::Question @header = "Address line 2 (optional)" @type = "text" @plain_label = true - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def hidden_in_check_answers?(_log = nil, _current_user = nil) diff --git a/app/models/form/lettings/questions/county.rb b/app/models/form/lettings/questions/county.rb index bea234cf1..9f0dc7138 100644 --- a/app/models/form/lettings/questions/county.rb +++ b/app/models/form/lettings/questions/county.rb @@ -5,7 +5,7 @@ class Form::Lettings::Questions::County < ::Form::Question @header = "County (optional)" @type = "text" @plain_label = true - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def hidden_in_check_answers?(_log = nil, _current_user = nil) diff --git a/app/models/form/lettings/questions/la.rb b/app/models/form/lettings/questions/la.rb index 8c4ebade0..5c483d786 100644 --- a/app/models/form/lettings/questions/la.rb +++ b/app/models/form/lettings/questions/la.rb @@ -8,7 +8,7 @@ class Form::Lettings::Questions::La < ::Form::Question @check_answers_card_number = 0 @hint_text = "" @question_number = 13 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def answer_options diff --git a/app/models/form/lettings/questions/location_id.rb b/app/models/form/lettings/questions/location_id.rb index ab852cb31..80c2516e8 100644 --- a/app/models/form/lettings/questions/location_id.rb +++ b/app/models/form/lettings/questions/location_id.rb @@ -12,7 +12,7 @@ class Form::Lettings::Questions::LocationId < ::Form::Question }, } @question_number = 10 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def answer_options diff --git a/app/models/form/lettings/questions/postcode_for_full_address.rb b/app/models/form/lettings/questions/postcode_for_full_address.rb index 9ac90b7d8..4f41867d7 100644 --- a/app/models/form/lettings/questions/postcode_for_full_address.rb +++ b/app/models/form/lettings/questions/postcode_for_full_address.rb @@ -17,7 +17,7 @@ class Form::Lettings::Questions::PostcodeForFullAddress < ::Form::Question }, } @plain_label = true - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def hidden_in_check_answers?(_log = nil, _current_user = nil) diff --git a/app/models/form/lettings/questions/postcode_full.rb b/app/models/form/lettings/questions/postcode_full.rb index b3b5f6f21..fc7d7691b 100644 --- a/app/models/form/lettings/questions/postcode_full.rb +++ b/app/models/form/lettings/questions/postcode_full.rb @@ -10,6 +10,6 @@ class Form::Lettings::Questions::PostcodeFull < ::Form::Question @check_answers_card_number = 0 @hint_text = "" @inferred_answers = { "la" => { "is_la_inferred" => true } } - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end end diff --git a/app/models/form/lettings/questions/postcode_known.rb b/app/models/form/lettings/questions/postcode_known.rb index 649c30098..ea9adb06b 100644 --- a/app/models/form/lettings/questions/postcode_known.rb +++ b/app/models/form/lettings/questions/postcode_known.rb @@ -8,7 +8,7 @@ class Form::Lettings::Questions::PostcodeKnown < ::Form::Question @check_answers_card_number = 0 @hint_text = "" @answer_options = ANSWER_OPTIONS - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true @conditional_for = { "postcode_full" => [1] } @hidden_in_check_answers = { "depends_on" => [{ "postcode_known" => 0 }, { "postcode_known" => 1 }] } end diff --git a/app/models/form/lettings/questions/ppcodenk.rb b/app/models/form/lettings/questions/ppcodenk.rb index 3edc11cc6..25557a166 100644 --- a/app/models/form/lettings/questions/ppcodenk.rb +++ b/app/models/form/lettings/questions/ppcodenk.rb @@ -11,7 +11,7 @@ class Form::Lettings::Questions::Ppcodenk < ::Form::Question @conditional_for = { "ppostcode_full" => [1] } @hidden_in_check_answers = { "depends_on" => [{ "ppcodenk" => 0 }, { "ppcodenk" => 1 }] } @question_number = 80 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze diff --git a/app/models/form/lettings/questions/ppostcode_full.rb b/app/models/form/lettings/questions/ppostcode_full.rb index 14aa1ece4..86b4c7b31 100644 --- a/app/models/form/lettings/questions/ppostcode_full.rb +++ b/app/models/form/lettings/questions/ppostcode_full.rb @@ -11,6 +11,6 @@ class Form::Lettings::Questions::PpostcodeFull < ::Form::Question @hint_text = "" @inferred_answers = { "prevloc" => { "is_previous_la_inferred" => true } } @question_number = 80 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end end diff --git a/app/models/form/lettings/questions/previous_la_known.rb b/app/models/form/lettings/questions/previous_la_known.rb index e93e52ea1..eb80eda4a 100644 --- a/app/models/form/lettings/questions/previous_la_known.rb +++ b/app/models/form/lettings/questions/previous_la_known.rb @@ -11,7 +11,7 @@ class Form::Lettings::Questions::PreviousLaKnown < ::Form::Question @conditional_for = { "prevloc" => [1] } @hidden_in_check_answers = { "depends_on" => [{ "previous_la_known" => 0 }, { "previous_la_known" => 1 }] } @question_number = 81 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze diff --git a/app/models/form/lettings/questions/prevloc.rb b/app/models/form/lettings/questions/prevloc.rb index 75e1411dc..e0082602e 100644 --- a/app/models/form/lettings/questions/prevloc.rb +++ b/app/models/form/lettings/questions/prevloc.rb @@ -9,7 +9,7 @@ class Form::Lettings::Questions::Prevloc < ::Form::Question @check_answers_card_number = 0 @hint_text = "Select ‘Northern Ireland’, ‘Scotland’, ‘Wales’ or ‘Outside the UK’ if the household’s last settled home was outside England." @question_number = 81 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def answer_options diff --git a/app/models/form/lettings/questions/town_or_city.rb b/app/models/form/lettings/questions/town_or_city.rb index 5f0f38491..501e9bec4 100644 --- a/app/models/form/lettings/questions/town_or_city.rb +++ b/app/models/form/lettings/questions/town_or_city.rb @@ -5,7 +5,7 @@ class Form::Lettings::Questions::TownOrCity < ::Form::Question @header = "Town or city" @type = "text" @plain_label = true - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def hidden_in_check_answers?(_log = nil, _current_user = nil) diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 151e88506..d4b7c9d76 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -1,5 +1,5 @@ class Form::Question - attr_accessor :id, :header, :hint_text, :description, :questions, :do_not_clear, + attr_accessor :id, :header, :hint_text, :description, :questions, :disable_clearing_if_not_routed_or_dynamic_answer_options, :type, :min, :max, :step, :width, :fields_to_add, :result_field, :conditional_for, :readonly, :answer_options, :page, :check_answer_label, :inferred_answers, :hidden_in_check_answers, :inferred_check_answers_value, @@ -42,7 +42,7 @@ class Form::Question @unresolved_hint_text = hsh["unresolved_hint_text"] @question_number = hsh["question_number"] @plain_label = hsh["plain_label"] - @do_not_clear = hsh["do_not_clear"] + @disable_clearing_if_not_routed_or_dynamic_answer_options = hsh["disable_clearing_if_not_routed_or_dynamic_answer_options"] end end diff --git a/app/models/form/sales/questions/address_line1.rb b/app/models/form/sales/questions/address_line1.rb index d0077fb29..edee2e7ee 100644 --- a/app/models/form/sales/questions/address_line1.rb +++ b/app/models/form/sales/questions/address_line1.rb @@ -7,7 +7,7 @@ class Form::Sales::Questions::AddressLine1 < ::Form::Question @type = "text" @plain_label = true @check_answer_label = "Q15 - Address" - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def answer_label(log, _current_user = nil) diff --git a/app/models/form/sales/questions/address_line2.rb b/app/models/form/sales/questions/address_line2.rb index 80ba4f92d..94396a2af 100644 --- a/app/models/form/sales/questions/address_line2.rb +++ b/app/models/form/sales/questions/address_line2.rb @@ -5,7 +5,7 @@ class Form::Sales::Questions::AddressLine2 < ::Form::Question @header = "Address line 2 (optional)" @type = "text" @plain_label = true - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def hidden_in_check_answers?(_log = nil, _current_user = nil) diff --git a/app/models/form/sales/questions/county.rb b/app/models/form/sales/questions/county.rb index c27f9773b..6586cb9e6 100644 --- a/app/models/form/sales/questions/county.rb +++ b/app/models/form/sales/questions/county.rb @@ -5,7 +5,7 @@ class Form::Sales::Questions::County < ::Form::Question @header = "County (optional)" @type = "text" @plain_label = true - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def hidden_in_check_answers?(_log = nil, _current_user = nil) diff --git a/app/models/form/sales/questions/postcode.rb b/app/models/form/sales/questions/postcode.rb index 0e9ac9303..55e33199a 100644 --- a/app/models/form/sales/questions/postcode.rb +++ b/app/models/form/sales/questions/postcode.rb @@ -17,6 +17,6 @@ class Form::Sales::Questions::Postcode < ::Form::Question "is_la_inferred" => true, }, } - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end end diff --git a/app/models/form/sales/questions/postcode_for_full_address.rb b/app/models/form/sales/questions/postcode_for_full_address.rb index 33aef09d6..5d3b9f122 100644 --- a/app/models/form/sales/questions/postcode_for_full_address.rb +++ b/app/models/form/sales/questions/postcode_for_full_address.rb @@ -17,7 +17,7 @@ class Form::Sales::Questions::PostcodeForFullAddress < ::Form::Question }, } @plain_label = true - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def hidden_in_check_answers?(_log = nil, _current_user = nil) diff --git a/app/models/form/sales/questions/previous_la_known.rb b/app/models/form/sales/questions/previous_la_known.rb index 60e3052a4..1a4a2f438 100644 --- a/app/models/form/sales/questions/previous_la_known.rb +++ b/app/models/form/sales/questions/previous_la_known.rb @@ -21,7 +21,7 @@ class Form::Sales::Questions::PreviousLaKnown < ::Form::Question "prevloc" => [1], } @question_number = 58 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end ANSWER_OPTIONS = { diff --git a/app/models/form/sales/questions/previous_postcode.rb b/app/models/form/sales/questions/previous_postcode.rb index 4bac3e867..5eb8e6d54 100644 --- a/app/models/form/sales/questions/previous_postcode.rb +++ b/app/models/form/sales/questions/previous_postcode.rb @@ -18,6 +18,6 @@ class Form::Sales::Questions::PreviousPostcode < ::Form::Question }, } @question_number = 57 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end end diff --git a/app/models/form/sales/questions/previous_postcode_known.rb b/app/models/form/sales/questions/previous_postcode_known.rb index 0aee9cebf..f53f52bf0 100644 --- a/app/models/form/sales/questions/previous_postcode_known.rb +++ b/app/models/form/sales/questions/previous_postcode_known.rb @@ -21,7 +21,7 @@ class Form::Sales::Questions::PreviousPostcodeKnown < ::Form::Question ], } @question_number = 57 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end ANSWER_OPTIONS = { diff --git a/app/models/form/sales/questions/prevloc.rb b/app/models/form/sales/questions/prevloc.rb index 4bd034bf4..71606aa34 100644 --- a/app/models/form/sales/questions/prevloc.rb +++ b/app/models/form/sales/questions/prevloc.rb @@ -12,7 +12,7 @@ class Form::Sales::Questions::Prevloc < ::Form::Question "value" => "Not known", }] @question_number = 58 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def answer_options diff --git a/app/models/form/sales/questions/property_local_authority.rb b/app/models/form/sales/questions/property_local_authority.rb index 8716dc130..df3fe5e88 100644 --- a/app/models/form/sales/questions/property_local_authority.rb +++ b/app/models/form/sales/questions/property_local_authority.rb @@ -6,7 +6,7 @@ class Form::Sales::Questions::PropertyLocalAuthority < ::Form::Question @header = "What is the property’s local authority?" @type = "select" @question_number = 16 - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def answer_options diff --git a/app/models/form/sales/questions/town_or_city.rb b/app/models/form/sales/questions/town_or_city.rb index 635ccd90a..25acfe036 100644 --- a/app/models/form/sales/questions/town_or_city.rb +++ b/app/models/form/sales/questions/town_or_city.rb @@ -5,7 +5,7 @@ class Form::Sales::Questions::TownOrCity < ::Form::Question @header = "Town or city" @type = "text" @plain_label = true - @do_not_clear = true + @disable_clearing_if_not_routed_or_dynamic_answer_options = true end def hidden_in_check_answers?(_log = nil, _current_user = nil) diff --git a/config/forms/2021_2022.json b/config/forms/2021_2022.json index 167396196..3caedd8cb 100644 --- a/config/forms/2021_2022.json +++ b/config/forms/2021_2022.json @@ -24,7 +24,7 @@ "header": "Do you know the property’s postcode?", "hint_text": "", "type": "radio", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "1": { "value": "Yes" @@ -55,7 +55,7 @@ "hint_text": "", "type": "text", "width": 5, - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "inferred_answers": { "la": { "is_la_inferred": true @@ -84,7 +84,7 @@ "header": "What is the local authority of the property?", "hint_text": "", "type": "select", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "": "Select an option", "E07000223": "Adur", @@ -6485,7 +6485,7 @@ "header": "Do you know the postcode of the household’s last settled accommodation?", "hint_text": "This is also known as the household’s ‘last settled home’.", "type": "radio", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "1": { "value": "Yes" @@ -6516,7 +6516,7 @@ "hint_text": "", "type": "text", "width": 5, - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "inferred_answers": { "prevloc": { "is_previous_la_inferred": true @@ -6540,7 +6540,7 @@ "header": "Do you know the local authority of the household’s last settled accommodation?", "hint_text": "This is also known as the household’s ‘last settled home’.", "type": "radio", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "hidden_in_check_answers": { "depends_on": [ { @@ -6570,7 +6570,7 @@ "header": "Select a local authority", "hint_text": "Select ‘Northern Ireland’, ‘Scotland’, ‘Wales’ or ‘Outside the UK’ if the household’s last settled home was outside England.", "type": "select", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "": "Select an option", "S12000033": "Aberdeen City", diff --git a/config/forms/2022_2023.json b/config/forms/2022_2023.json index 9b30a73fb..abb9064fe 100644 --- a/config/forms/2022_2023.json +++ b/config/forms/2022_2023.json @@ -24,7 +24,7 @@ "header": "Do you know the property’s postcode?", "hint_text": "", "type": "radio", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "1": { "value": "Yes" @@ -55,7 +55,7 @@ "hint_text": "", "type": "text", "width": 5, - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "inferred_answers": { "la": { "is_la_inferred": true @@ -84,7 +84,7 @@ "header": "What is the local authority of the property?", "hint_text": "", "type": "select", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "": "Select an option", "E07000223": "Adur", @@ -6438,7 +6438,7 @@ "header": "Do you know the postcode of the household’s last settled accommodation?", "hint_text": "This is also known as the household’s ‘last settled home’.", "type": "radio", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "1": { "value": "Yes" @@ -6469,7 +6469,7 @@ "hint_text": "", "type": "text", "width": 5, - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "inferred_answers": { "prevloc": { "is_previous_la_inferred": true @@ -6493,7 +6493,7 @@ "header": "Do you know the local authority of the household’s last settled accommodation?", "hint_text": "This is also known as the household’s ‘last settled home’.", "type": "radio", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "hidden_in_check_answers": { "depends_on": [ { @@ -6523,7 +6523,7 @@ "header": "Select a local authority", "hint_text": "Select ‘Northern Ireland’, ‘Scotland’, ‘Wales’ or ‘Outside the UK’ if the household’s last settled home was outside England.", "type": "select", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "": "Select an option", "S12000033": "Aberdeen City", diff --git a/spec/fixtures/forms/2021_2022.json b/spec/fixtures/forms/2021_2022.json index b007189be..69f23bbd6 100644 --- a/spec/fixtures/forms/2021_2022.json +++ b/spec/fixtures/forms/2021_2022.json @@ -411,7 +411,7 @@ "hint_text": "Type ahead to filter the options", "type": "select", "check_answer_label": "Accessible Select", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "": "Select an option", "E07000223": "Adur", @@ -474,7 +474,7 @@ "hint_text": "Type ahead to filter the options", "type": "select", "check_answer_label": "Accessible Select", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "": "Select an option", "E07000223": "Adur", @@ -502,7 +502,7 @@ "header": "Do you know the property’s postcode?", "hint_text": "", "type": "radio", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "1": { "value": "Yes" @@ -524,7 +524,7 @@ "hint_text": "", "type": "text", "width": 5, - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "inferred_answers": { "la": { "is_la_inferred": true @@ -548,7 +548,7 @@ "header": "Do you know what local authority the property is located in?", "hint_text": "", "type": "radio", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "answer_options": { "0": { "value": "No" @@ -1156,7 +1156,7 @@ "header": "Postcode for the previous accommodation", "hint_text": "If the household has moved from settled accommodation immediately prior to being re-housed", "type": "text", - "do_not_clear": true, + "disable_clearing_if_not_routed_or_dynamic_answer_options": true, "width": 5 } }