Browse Source

rename instance variable to be nice and long

pull/1469/head
Arthur Campbell 3 years ago
parent
commit
ba6bb0e6f4
  1. 4
      app/models/form.rb
  2. 2
      app/models/form/lettings/questions/address_line1.rb
  3. 2
      app/models/form/lettings/questions/address_line2.rb
  4. 2
      app/models/form/lettings/questions/county.rb
  5. 2
      app/models/form/lettings/questions/la.rb
  6. 2
      app/models/form/lettings/questions/location_id.rb
  7. 2
      app/models/form/lettings/questions/postcode_for_full_address.rb
  8. 2
      app/models/form/lettings/questions/postcode_full.rb
  9. 2
      app/models/form/lettings/questions/postcode_known.rb
  10. 2
      app/models/form/lettings/questions/ppcodenk.rb
  11. 2
      app/models/form/lettings/questions/ppostcode_full.rb
  12. 2
      app/models/form/lettings/questions/previous_la_known.rb
  13. 2
      app/models/form/lettings/questions/prevloc.rb
  14. 2
      app/models/form/lettings/questions/town_or_city.rb
  15. 4
      app/models/form/question.rb
  16. 2
      app/models/form/sales/questions/address_line1.rb
  17. 2
      app/models/form/sales/questions/address_line2.rb
  18. 2
      app/models/form/sales/questions/county.rb
  19. 2
      app/models/form/sales/questions/postcode.rb
  20. 2
      app/models/form/sales/questions/postcode_for_full_address.rb
  21. 2
      app/models/form/sales/questions/previous_la_known.rb
  22. 2
      app/models/form/sales/questions/previous_postcode.rb
  23. 2
      app/models/form/sales/questions/previous_postcode_known.rb
  24. 2
      app/models/form/sales/questions/prevloc.rb
  25. 2
      app/models/form/sales/questions/property_local_authority.rb
  26. 2
      app/models/form/sales/questions/town_or_city.rb
  27. 14
      config/forms/2021_2022.json
  28. 14
      config/forms/2022_2023.json
  29. 12
      spec/fixtures/forms/2021_2022.json

4
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: }

2
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)

2
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)

2
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)

2
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

2
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

2
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)

2
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

2
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

2
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

2
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

2
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

2
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

2
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)

4
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

2
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)

2
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)

2
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)

2
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

2
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)

2
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 = {

2
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

2
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 = {

2
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

2
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

2
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)

14
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",

14
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",

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

@ -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
}
}

Loading…
Cancel
Save