Browse Source

feat: update person known behaviour

pull/1103/head
natdeanlewissoftwire 3 years ago
parent
commit
42cc7d2b06
  1. 2
      app/models/form/sales/pages/person.rb
  2. 8
      app/models/form/sales/pages/person_age.rb
  3. 8
      app/models/form/sales/pages/person_known.rb
  4. 8
      app/models/form/sales/pages/person_working_situation.rb
  5. 5
      app/models/form/sales/questions/person.rb
  6. 6
      app/models/form/sales/questions/person_known.rb
  7. 12
      app/models/form/sales/subsections/household_characteristics.rb
  8. 2
      config/forms/2021_2022.json
  9. 2
      config/forms/2022_2023.json

2
app/models/form/sales/pages/person.rb

@ -17,6 +17,8 @@ class Form::Sales::Pages::Person < ::Form::Page
end end
def field_for_person(field, suffix = "") def field_for_person(field, suffix = "")
return [field, person_display_number, suffix].join if field == "details_known_"
[field, @person_index, suffix].join [field, @person_index, suffix].join
end end
end end

8
app/models/form/sales/pages/person_age.rb

@ -4,7 +4,7 @@ class Form::Sales::Pages::PersonAge < Form::Sales::Pages::Person
@header = "" @header = ""
@description = "" @description = ""
@subsection = subsection @subsection = subsection
@depends_on = page_depends_on @depends_on = [{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }]
end end
def questions def questions
@ -13,10 +13,4 @@ class Form::Sales::Pages::PersonAge < Form::Sales::Pages::Person
Form::Sales::Questions::PersonAge.new(field_for_person("age"), nil, self, person_index: @person_index), Form::Sales::Questions::PersonAge.new(field_for_person("age"), nil, self, person_index: @person_index),
] ]
end end
def page_depends_on
return (person_display_number..4).map { |index| { "hholdcount" => index, "jointpur" => joint_purchase? ? 1 : 2 } } if person_display_number == 1
[{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }]
end
end end

8
app/models/form/sales/pages/person_known.rb

@ -1,11 +1,11 @@
class Form::Sales::Pages::PersonKnown < Form::Sales::Pages::Person class Form::Sales::Pages::PersonKnown < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:) def initialize(id, hsh, subsection, person_index:)
super super
@header_partial = "#{id}_page" @header_partial = "person_#{person_display_number}_known_page"
@header = "" @header = ""
@description = "" @description = ""
@subsection = subsection @subsection = subsection
@depends_on = page_depends_on @depends_on = (person_display_number..4).map { |index| { "hholdcount" => index, "jointpur" => joint_purchase? ? 1 : 2 } }
end end
def questions def questions
@ -13,8 +13,4 @@ class Form::Sales::Pages::PersonKnown < Form::Sales::Pages::Person
Form::Sales::Questions::PersonKnown.new(field_for_person("details_known_"), nil, self, person_index: @person_index), Form::Sales::Questions::PersonKnown.new(field_for_person("details_known_"), nil, self, person_index: @person_index),
] ]
end end
def page_depends_on
(@person_index..4).map { |index| { "hholdcount" => index } }
end
end end

8
app/models/form/sales/pages/person_working_situation.rb

@ -4,7 +4,7 @@ class Form::Sales::Pages::PersonWorkingSituation < Form::Sales::Pages::Person
@header = "" @header = ""
@description = "" @description = ""
@subsection = subsection @subsection = subsection
@depends_on = page_depends_on @depends_on = [{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }]
end end
def questions def questions
@ -12,10 +12,4 @@ class Form::Sales::Pages::PersonWorkingSituation < Form::Sales::Pages::Person
Form::Sales::Questions::PersonWorkingSituation.new(field_for_person("ecstat"), nil, self, person_index: @person_index), Form::Sales::Questions::PersonWorkingSituation.new(field_for_person("ecstat"), nil, self, person_index: @person_index),
] ]
end end
def page_depends_on
return (person_display_number..4).map { |index| { "hholdcount" => index, "jointpur" => joint_purchase? ? 1 : 2 } } if person_display_number == 1
[{ details_known_question_id => 1, "jointpur" => joint_purchase? ? 1 : 2 }]
end
end end

5
app/models/form/sales/questions/person.rb

@ -13,6 +13,7 @@ class Form::Sales::Questions::Person < ::Form::Question
end end
def field_for_person(field, suffix = "") def field_for_person(field, suffix = "")
[field, @person_index, suffix].join return [field, person_display_number, suffix].join if field == "details_known_"
end
[field, @person_index, suffix].join end
end end

6
app/models/form/sales/questions/person_known.rb

@ -1,8 +1,8 @@
class Form::Sales::Questions::PersonKnown < Form::Sales::Questions::Person class Form::Sales::Questions::PersonKnown < Form::Sales::Questions::Person
def initialize(id, hsh, page, person_index:) def initialize(id, hsh, page, person_index:)
super super
@check_answer_label = "Details known for person #{person_index}?" @check_answer_label = "Details known for person #{person_display_number}?"
@header = "Do you know the details for person #{person_index}?" @header = "Do you know the details for person #{person_display_number}?"
@type = "radio" @type = "radio"
@answer_options = ANSWER_OPTIONS @answer_options = ANSWER_OPTIONS
@page = page @page = page
@ -14,7 +14,7 @@ class Form::Sales::Questions::PersonKnown < Form::Sales::Questions::Person
}, },
], ],
} }
@check_answers_card_number = person_index + 2 @check_answers_card_number = person_index
end end
ANSWER_OPTIONS = { ANSWER_OPTIONS = {

12
app/models/form/sales/subsections/household_characteristics.rb

@ -29,7 +29,8 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self), Form::Sales::Pages::Buyer2WorkingSituation.new(nil, nil, self),
Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self), Form::Sales::Pages::Buyer2LiveInProperty.new(nil, nil, self),
Form::Sales::Pages::NumberOfOthersInProperty.new(nil, nil, self), Form::Sales::Pages::NumberOfOthersInProperty.new(nil, nil, self),
Form::Sales::Pages::PersonKnown.new("person_1_known", nil, self, person_index: 1), Form::Sales::Pages::PersonKnown.new("person_1_known", nil, self, person_index: 2),
Form::Sales::Pages::PersonKnown.new("person_1_known_joint_purchase", nil, self, person_index: 3),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_1_relationship_to_buyer_1", nil, self, person_index: 2), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_1_relationship_to_buyer_1", nil, self, person_index: 2),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_1_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 3), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_1_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 3),
Form::Sales::Pages::PersonAge.new("person_1_age", nil, self, person_index: 2), Form::Sales::Pages::PersonAge.new("person_1_age", nil, self, person_index: 2),
@ -38,21 +39,24 @@ class Form::Sales::Subsections::HouseholdCharacteristics < ::Form::Subsection
Form::Sales::Pages::Person1GenderIdentityJointPurchase.new(nil, nil, self), Form::Sales::Pages::Person1GenderIdentityJointPurchase.new(nil, nil, self),
Form::Sales::Pages::PersonWorkingSituation.new("person_1_working_situation", nil, self, person_index: 2), Form::Sales::Pages::PersonWorkingSituation.new("person_1_working_situation", nil, self, person_index: 2),
Form::Sales::Pages::PersonWorkingSituation.new("person_1_working_situation_joint_purchase", nil, self, person_index: 3), Form::Sales::Pages::PersonWorkingSituation.new("person_1_working_situation_joint_purchase", nil, self, person_index: 3),
Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 2), Form::Sales::Pages::PersonKnown.new("person_2_known", nil, self, person_index: 3),
Form::Sales::Pages::PersonKnown.new("person_2_known_joint_purchase", nil, self, person_index: 4),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1", nil, self, person_index: 3), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1", nil, self, person_index: 3),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 4), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_2_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 4),
Form::Sales::Pages::PersonAge.new("person_2_age", nil, self, person_index: 3), Form::Sales::Pages::PersonAge.new("person_2_age", nil, self, person_index: 3),
Form::Sales::Pages::PersonAge.new("person_2_age_joint_purchase", nil, self, person_index: 4), Form::Sales::Pages::PersonAge.new("person_2_age_joint_purchase", nil, self, person_index: 4),
Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation", nil, self, person_index: 3), Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation", nil, self, person_index: 3),
Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation_joint_purchase", nil, self, person_index: 4), Form::Sales::Pages::PersonWorkingSituation.new("person_2_working_situation_joint_purchase", nil, self, person_index: 4),
Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 3), Form::Sales::Pages::PersonKnown.new("person_3_known", nil, self, person_index: 4),
Form::Sales::Pages::PersonKnown.new("person_3_known_joint_purchase", nil, self, person_index: 5),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1", nil, self, person_index: 4), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1", nil, self, person_index: 4),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 5), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_3_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 5),
Form::Sales::Pages::PersonAge.new("person_3_age", nil, self, person_index: 4), Form::Sales::Pages::PersonAge.new("person_3_age", nil, self, person_index: 4),
Form::Sales::Pages::PersonAge.new("person_3_age_joint_purchase", nil, self, person_index: 5), Form::Sales::Pages::PersonAge.new("person_3_age_joint_purchase", nil, self, person_index: 5),
Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation", nil, self, person_index: 4), Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation", nil, self, person_index: 4),
Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation_joint_purchase", nil, self, person_index: 5), Form::Sales::Pages::PersonWorkingSituation.new("person_3_working_situation_joint_purchase", nil, self, person_index: 5),
Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 4), Form::Sales::Pages::PersonKnown.new("person_4_known", nil, self, person_index: 5),
Form::Sales::Pages::PersonKnown.new("person_4_known_joint_purchase", nil, self, person_index: 6),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1", nil, self, person_index: 5), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1", nil, self, person_index: 5),
Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 6), Form::Sales::Pages::PersonRelationshipToBuyer1.new("person_4_relationship_to_buyer_1_joint_purchase", nil, self, person_index: 6),
Form::Sales::Pages::PersonAge.new("person_4_age", nil, self, person_index: 5), Form::Sales::Pages::PersonAge.new("person_4_age", nil, self, person_index: 5),

2
config/forms/2021_2022.json

@ -4624,7 +4624,7 @@
} }
}, },
"person_7_known": { "person_7_known": {
"header": "You’ve given us the details for 7 people in the household", "header": "You’ve given us the details for 6 people in the household",
"description": "", "description": "",
"questions": { "questions": {
"details_known_7": { "details_known_7": {

2
config/forms/2022_2023.json

@ -4623,7 +4623,7 @@
} }
}, },
"person_7_known": { "person_7_known": {
"header": "You’ve given us the details for 7 people in the household", "header": "You’ve given us the details for 6 people in the household",
"description": "", "description": "",
"questions": { "questions": {
"details_known_7": { "details_known_7": {

Loading…
Cancel
Save