Browse Source

remove list of question ids from the form that should not be cleared, this information should be held on the questions themselves

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

6
app/models/form.rb

@ -238,12 +238,10 @@ class Form
end
def routed_and_not_routed_questions_by_type(log, type: nil, current_user: nil)
# we're already treating these fields as a special case and reset their values upon saving a log
callback_questions = %w[postcode_known la ppcodenk previous_la_known prevloc postcode_full ppostcode_full location_id address_line1 address_line2 town_or_city county]
questions_to_categorise = if type
questions.reject { |q| q.type != type || callback_questions.include?(q.id) }
questions.reject { |q| q.type != type || q.do_not_clear }
else
questions.reject { |q| %w[radio checkbox].include?(q.type) || callback_questions.include?(q.id) }
questions.reject { |q| %w[radio checkbox].include?(q.type) || q.do_not_clear }
end
valid, invalid = questions_to_categorise.partition { |q| q.page.routed_to?(log, current_user) || q.derived? }
{ valid:, invalid: }

1
app/models/form/lettings/questions/address_line1.rb

@ -7,6 +7,7 @@ class Form::Lettings::Questions::AddressLine1 < ::Form::Question
@type = "text"
@plain_label = true
@check_answer_label = "Q12 - Address"
@do_not_clear = true
end
def answer_label(log, _current_user = nil)

1
app/models/form/lettings/questions/address_line2.rb

@ -5,6 +5,7 @@ class Form::Lettings::Questions::AddressLine2 < ::Form::Question
@header = "Address line 2 (optional)"
@type = "text"
@plain_label = true
@do_not_clear = true
end
def hidden_in_check_answers?(_log = nil, _current_user = nil)

1
app/models/form/lettings/questions/county.rb

@ -5,6 +5,7 @@ class Form::Lettings::Questions::County < ::Form::Question
@header = "County (optional)"
@type = "text"
@plain_label = true
@do_not_clear = true
end
def hidden_in_check_answers?(_log = nil, _current_user = nil)

1
app/models/form/lettings/questions/la.rb

@ -8,6 +8,7 @@ class Form::Lettings::Questions::La < ::Form::Question
@check_answers_card_number = 0
@hint_text = ""
@question_number = 13
@do_not_clear = true
end
def answer_options

6
app/models/form/lettings/questions/location_id.rb

@ -1,6 +1,7 @@
class Form::Lettings::Questions::LocationId < ::Form::Question
def initialize(_id, hsh, page)
super("location_id", hsh, page)
def initialize(id, hsh, page)
super
@id = "location_id"
@check_answer_label = "Location"
@header = header_text
@type = "radio"
@ -11,6 +12,7 @@ class Form::Lettings::Questions::LocationId < ::Form::Question
},
}
@question_number = 10
@do_not_clear = true
end
def answer_options

1
app/models/form/lettings/questions/postcode_for_full_address.rb

@ -17,6 +17,7 @@ class Form::Lettings::Questions::PostcodeForFullAddress < ::Form::Question
},
}
@plain_label = true
@do_not_clear = true
end
def hidden_in_check_answers?(_log = nil, _current_user = nil)

1
app/models/form/lettings/questions/postcode_full.rb

@ -10,5 +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
end
end

1
app/models/form/lettings/questions/postcode_known.rb

@ -8,6 +8,7 @@ class Form::Lettings::Questions::PostcodeKnown < ::Form::Question
@check_answers_card_number = 0
@hint_text = ""
@answer_options = ANSWER_OPTIONS
@do_not_clear = true
@conditional_for = { "postcode_full" => [1] }
@hidden_in_check_answers = { "depends_on" => [{ "postcode_known" => 0 }, { "postcode_known" => 1 }] }
end

1
app/models/form/lettings/questions/ppcodenk.rb

@ -11,6 +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
end
ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze

1
app/models/form/lettings/questions/ppostcode_full.rb

@ -11,5 +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
end
end

1
app/models/form/lettings/questions/previous_la_known.rb

@ -11,6 +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
end
ANSWER_OPTIONS = { "1" => { "value" => "Yes" }, "0" => { "value" => "No" } }.freeze

1
app/models/form/lettings/questions/prevloc.rb

@ -9,6 +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
end
def answer_options

1
app/models/form/lettings/questions/town_or_city.rb

@ -5,6 +5,7 @@ class Form::Lettings::Questions::TownOrCity < ::Form::Question
@header = "Town or city"
@type = "text"
@plain_label = true
@do_not_clear = true
end
def hidden_in_check_answers?(_log = nil, _current_user = nil)

3
app/models/form/question.rb

@ -1,5 +1,5 @@
class Form::Question
attr_accessor :id, :header, :hint_text, :description, :questions,
attr_accessor :id, :header, :hint_text, :description, :questions, :do_not_clear,
: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,6 +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"]
end
end

3
app/models/form/sales/pages/extra_borrowing_value_check.rb

@ -9,8 +9,7 @@ class Form::Sales::Pages::ExtraBorrowingValueCheck < Form::Page
@title_text = {
"translation" => "soft_validations.extra_borrowing.title",
}
@informative_text = {
}
@informative_text = {}
end
def questions

1
app/models/form/sales/questions/address_line1.rb

@ -7,6 +7,7 @@ class Form::Sales::Questions::AddressLine1 < ::Form::Question
@type = "text"
@plain_label = true
@check_answer_label = "Q15 - Address"
@do_not_clear = true
end
def answer_label(log, _current_user = nil)

1
app/models/form/sales/questions/address_line2.rb

@ -5,6 +5,7 @@ class Form::Sales::Questions::AddressLine2 < ::Form::Question
@header = "Address line 2 (optional)"
@type = "text"
@plain_label = true
@do_not_clear = true
end
def hidden_in_check_answers?(_log = nil, _current_user = nil)

1
app/models/form/sales/questions/county.rb

@ -5,6 +5,7 @@ class Form::Sales::Questions::County < ::Form::Question
@header = "County (optional)"
@type = "text"
@plain_label = true
@do_not_clear = true
end
def hidden_in_check_answers?(_log = nil, _current_user = nil)

1
app/models/form/sales/questions/postcode.rb

@ -17,5 +17,6 @@ class Form::Sales::Questions::Postcode < ::Form::Question
"is_la_inferred" => true,
},
}
@do_not_clear = true
end
end

1
app/models/form/sales/questions/postcode_for_full_address.rb

@ -17,6 +17,7 @@ class Form::Sales::Questions::PostcodeForFullAddress < ::Form::Question
},
}
@plain_label = true
@do_not_clear = true
end
def hidden_in_check_answers?(_log = nil, _current_user = nil)

1
app/models/form/sales/questions/previous_la_known.rb

@ -21,6 +21,7 @@ class Form::Sales::Questions::PreviousLaKnown < ::Form::Question
"prevloc" => [1],
}
@question_number = 58
@do_not_clear = true
end
ANSWER_OPTIONS = {

1
app/models/form/sales/questions/previous_postcode.rb

@ -18,5 +18,6 @@ class Form::Sales::Questions::PreviousPostcode < ::Form::Question
},
}
@question_number = 57
@do_not_clear = true
end
end

1
app/models/form/sales/questions/previous_postcode_known.rb

@ -21,6 +21,7 @@ class Form::Sales::Questions::PreviousPostcodeKnown < ::Form::Question
],
}
@question_number = 57
@do_not_clear = true
end
ANSWER_OPTIONS = {

1
app/models/form/sales/questions/prevloc.rb

@ -12,6 +12,7 @@ class Form::Sales::Questions::Prevloc < ::Form::Question
"value" => "Not known",
}]
@question_number = 58
@do_not_clear = true
end
def answer_options

1
app/models/form/sales/questions/property_local_authority.rb

@ -6,6 +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
end
def answer_options

1
app/models/form/sales/questions/town_or_city.rb

@ -5,6 +5,7 @@ class Form::Sales::Questions::TownOrCity < ::Form::Question
@header = "Town or city"
@type = "text"
@plain_label = true
@do_not_clear = true
end
def hidden_in_check_answers?(_log = nil, _current_user = nil)

7
config/forms/2021_2022.json

@ -24,6 +24,7 @@
"header": "Do you know the property’s postcode?",
"hint_text": "",
"type": "radio",
"do_not_clear": true,
"answer_options": {
"1": {
"value": "Yes"
@ -54,6 +55,7 @@
"hint_text": "",
"type": "text",
"width": 5,
"do_not_clear": true,
"inferred_answers": {
"la": {
"is_la_inferred": true
@ -82,6 +84,7 @@
"header": "What is the local authority of the property?",
"hint_text": "",
"type": "select",
"do_not_clear": true,
"answer_options": {
"": "Select an option",
"E07000223": "Adur",
@ -6482,6 +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,
"answer_options": {
"1": {
"value": "Yes"
@ -6512,6 +6516,7 @@
"hint_text": "",
"type": "text",
"width": 5,
"do_not_clear": true,
"inferred_answers": {
"prevloc": {
"is_previous_la_inferred": true
@ -6535,6 +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,
"hidden_in_check_answers": {
"depends_on": [
{
@ -6564,6 +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,
"answer_options": {
"": "Select an option",
"S12000033": "Aberdeen City",

7
config/forms/2022_2023.json

@ -24,6 +24,7 @@
"header": "Do you know the property’s postcode?",
"hint_text": "",
"type": "radio",
"do_not_clear": true,
"answer_options": {
"1": {
"value": "Yes"
@ -54,6 +55,7 @@
"hint_text": "",
"type": "text",
"width": 5,
"do_not_clear": true,
"inferred_answers": {
"la": {
"is_la_inferred": true
@ -82,6 +84,7 @@
"header": "What is the local authority of the property?",
"hint_text": "",
"type": "select",
"do_not_clear": true,
"answer_options": {
"": "Select an option",
"E07000223": "Adur",
@ -6435,6 +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,
"answer_options": {
"1": {
"value": "Yes"
@ -6465,6 +6469,7 @@
"hint_text": "",
"type": "text",
"width": 5,
"do_not_clear": true,
"inferred_answers": {
"prevloc": {
"is_previous_la_inferred": true
@ -6488,6 +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,
"hidden_in_check_answers": {
"depends_on": [
{
@ -6517,6 +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,
"answer_options": {
"": "Select an option",
"S12000033": "Aberdeen City",

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

@ -411,6 +411,7 @@
"hint_text": "Type ahead to filter the options",
"type": "select",
"check_answer_label": "Accessible Select",
"do_not_clear": true,
"answer_options": {
"": "Select an option",
"E07000223": "Adur",
@ -473,6 +474,7 @@
"hint_text": "Type ahead to filter the options",
"type": "select",
"check_answer_label": "Accessible Select",
"do_not_clear": true,
"answer_options": {
"": "Select an option",
"E07000223": "Adur",
@ -500,6 +502,7 @@
"header": "Do you know the property’s postcode?",
"hint_text": "",
"type": "radio",
"do_not_clear": true,
"answer_options": {
"1": {
"value": "Yes"
@ -521,6 +524,7 @@
"hint_text": "",
"type": "text",
"width": 5,
"do_not_clear": true,
"inferred_answers": {
"la": {
"is_la_inferred": true
@ -544,6 +548,7 @@
"header": "Do you know what local authority the property is located in?",
"hint_text": "",
"type": "radio",
"do_not_clear": true,
"answer_options": {
"0": {
"value": "No"
@ -1151,6 +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,
"width": 5
}
}

Loading…
Cancel
Save