Browse Source

Refactor 2 question pages

pull/2702/head
Kat 2 years ago committed by Kat
parent
commit
5b92a8378d
  1. 1
      app/models/form/sales/pages/age1.rb
  2. 2
      app/models/form/sales/pages/person_age.rb
  3. 2
      app/models/form/sales/questions/age2.rb
  4. 2
      app/models/form/sales/questions/buyer2_age_known.rb
  5. 2
      app/models/form/sales/questions/person_age.rb
  6. 3
      app/models/form/sales/questions/person_age_known.rb
  7. 119
      config/locales/forms/2023/sales/household_characteristics.en.yml
  8. 119
      config/locales/forms/2024/sales/household_characteristics.en.yml

1
app/models/form/sales/pages/age1.rb

@ -2,6 +2,7 @@ class Form::Sales::Pages::Age1 < ::Form::Page
def initialize(id, hsh, subsection)
super
@id = "buyer_1_age"
@copy_key = "sales.household_characteristics.age1"
@depends_on = [
{
"buyer_has_seen_privacy_notice?" => true,

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

@ -1,7 +1,7 @@
class Form::Sales::Pages::PersonAge < Form::Sales::Pages::Person
def initialize(id, hsh, subsection, person_index:)
super
@copy_key = "sales.household_characteristics.age2.person" if person_index == 2
@copy_key = person_index == 2 ? "sales.household_characteristics.age2.person" : "sales.household_characteristics.age#{person_index}"
@depends_on = [{ "details_known_#{person_index}" => 1 }]
end

2
app/models/form/sales/questions/age2.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::Age2 < ::Form::Question
def initialize(id, hsh, page)
super
@id = "age2"
@copy_key = "sales.household_characteristics.age2.buyer"
@copy_key = "sales.household_characteristics.age2.buyer.age2"
@type = "numeric"
@width = 2
@inferred_check_answers_value = [{

2
app/models/form/sales/questions/buyer2_age_known.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::Buyer2AgeKnown < ::Form::Question
def initialize(id, hsh, page)
super
@id = "age2_known"
@copy_key = "sales.household_characteristics.age2_known.buyer"
@copy_key = "sales.household_characteristics.age2.buyer.age2_known"
@type = "radio"
@answer_options = ANSWER_OPTIONS
@conditional_for = {

2
app/models/form/sales/questions/person_age.rb

@ -2,7 +2,7 @@ class Form::Sales::Questions::PersonAge < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@type = "numeric"
@copy_key = "sales.household_characteristics.age2.person" if person_index == 2
@copy_key = person_index == 2 ? "sales.household_characteristics.age2.person.age2" : "sales.household_characteristics.age#{person_index}.age#{person_index}"
@width = 3
@inferred_check_answers_value = [{
"condition" => { "age#{person_index}_known" => 1 },

3
app/models/form/sales/questions/person_age_known.rb

@ -2,8 +2,7 @@ class Form::Sales::Questions::PersonAgeKnown < ::Form::Question
def initialize(id, hsh, page, person_index:)
super(id, hsh, page)
@type = "radio"
@copy_key = "sales.household_characteristics.age2_known.person" if person_index == 2
@answer_options = ANSWER_OPTIONS
@copy_key = person_index == 2 ? "sales.household_characteristics.age2.person.age2_known" : "sales.household_characteristics.age#{person_index}.age#{person_index}_known"
@conditional_for = {
"age#{person_index}" => [0],
}

119
config/locales/forms/2023/sales/household_characteristics.en.yml

@ -27,17 +27,16 @@ en:
hint_text: ""
question_text: "Declaration"
age1_known:
page_header: ""
check_answer_label: "Buyer 1’s age"
hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
question_text: "Do you know buyer 1’s age?"
age1:
page_header: ""
check_answer_label: "Buyer 1’s age"
hint_text: ""
question_text: "Age"
age1_known:
check_answer_label: "Buyer 1’s age"
hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
question_text: "Do you know buyer 1’s age?"
age1:
check_answer_label: "Buyer 1’s age"
hint_text: ""
question_text: "Age"
sex1:
page_header: ""
@ -108,29 +107,27 @@ en:
hint_text: ""
question_text: "What is Person 2’s relationship to Buyer 1?"
age2_known:
buyer:
page_header: ""
check_answer_label: "Buyer 2’s age"
hint_text: ""
question_text: "Do you know buyer 2’s age?"
person:
page_header: ""
check_answer_label: "Person 2’s age known?"
hint_text: ""
question_text: "Do you know person 2’s age?"
age2:
buyer:
page_header: ""
check_answer_label: "Buyer 2’s age"
hint_text: ""
question_text: "Age"
age2_known:
check_answer_label: "Buyer 2’s age"
hint_text: ""
question_text: "Do you know buyer 2’s age?"
age2:
check_answer_label: "Buyer 2’s age"
hint_text: ""
question_text: "Age"
person:
page_header: ""
check_answer_label: "Person 2’s age"
hint_text: ""
question_text: "Age"
age2_known:
check_answer_label: "Person 2’s age known?"
hint_text: ""
question_text: "Do you know person 2’s age?"
age:
check_answer_label: "Person 2’s age"
hint_text: ""
question_text: "Age"
sex2:
buyer:
@ -231,17 +228,16 @@ en:
hint_text: ""
question_text: "What is Person 3’s relationship to Buyer 1?"
age3_known:
page_header: ""
check_answer_label: "Person 3’s age known?"
hint_text: ""
question_text: "Do you know person 3’s age?"
age3:
page_header: ""
check_answer_label: "Person 3’s age"
hint_text: ""
question_text: "Age"
age3_known:
check_answer_label: "Person 3’s age known?"
hint_text: ""
question_text: "Do you know person 3’s age?"
age3:
check_answer_label: "Person 3’s age"
hint_text: ""
question_text: "Age"
sex3:
page_header: ""
@ -267,17 +263,16 @@ en:
hint_text: ""
question_text: "What is Person 4’s relationship to Buyer 1?"
age4_known:
page_header: ""
check_answer_label: "Person 4’s age known?"
hint_text: ""
question_text: "Do you know person 4’s age?"
age4:
page_header: ""
check_answer_label: "Person 4’s age"
hint_text: ""
question_text: "Age"
age4_known:
check_answer_label: "Person 4’s age known?"
hint_text: ""
question_text: "Do you know person 4’s age?"
age4:
check_answer_label: "Person 4’s age"
hint_text: ""
question_text: "Age"
sex4:
page_header: ""
@ -303,17 +298,16 @@ en:
hint_text: ""
question_text: "What is Person 5’s relationship to Buyer 1?"
age5_known:
page_header: ""
check_answer_label: "Person 5’s age known?"
hint_text: ""
question_text: "Do you know person 5’s age?"
age5:
page_header: ""
check_answer_label: "Person 5’s age"
hint_text: ""
question_text: "Age"
age5_known:
check_answer_label: "Person 5’s age known?"
hint_text: ""
question_text: "Do you know person 5’s age?"
age5:
check_answer_label: "Person 5’s age"
hint_text: ""
question_text: "Age"
sex5:
page_header: ""
@ -339,17 +333,16 @@ en:
hint_text: ""
question_text: "What is Person 6’s relationship to Buyer 1?"
age6_known:
page_header: ""
check_answer_label: "Person 6’s age known?"
hint_text: ""
question_text: "Do you know person 6’s age?"
age6:
page_header: ""
check_answer_label: "Person 6’s age"
hint_text: ""
question_text: "Age"
age6_known:
check_answer_label: "Person 6’s age known?"
hint_text: ""
question_text: "Do you know person 6’s age?"
age6:
check_answer_label: "Person 6’s age"
hint_text: ""
question_text: "Age"
sex6:
page_header: ""

119
config/locales/forms/2024/sales/household_characteristics.en.yml

@ -3,17 +3,16 @@ en:
2024:
sales:
household_characteristics:
age1_known:
page_header: ""
check_answer_label: "Buyer 1’s age"
hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
question_text: "Do you know buyer 1’s age?"
age1:
page_header: ""
check_answer_label: "Buyer 1’s age"
hint_text: ""
question_text: "Age"
age1_known:
check_answer_label: "Buyer 1’s age"
hint_text: "Buyer 1 is the person in the household who does the most paid work. If it’s a joint purchase and the buyers do the same amount of paid work, buyer 1 is whoever is the oldest."
question_text: "Do you know buyer 1’s age?"
age1:
check_answer_label: "Buyer 1’s age"
hint_text: ""
question_text: "Age"
sex1:
page_header: ""
@ -90,29 +89,27 @@ en:
hint_text: ""
question_text: "What is Person 2’s relationship to Buyer 1?"
age2_known:
buyer:
page_header: ""
check_answer_label: "Buyer 2’s age"
hint_text: ""
question_text: "Do you know buyer 2’s age?"
person:
page_header: ""
check_answer_label: "Person 2’s age known?"
hint_text: ""
question_text: "Do you know person 2’s age?"
age2:
buyer:
page_header: ""
check_answer_label: "Buyer 2’s age"
hint_text: ""
question_text: "Age"
age2_known:
check_answer_label: "Buyer 2’s age"
hint_text: ""
question_text: "Do you know buyer 2’s age?"
age2:
check_answer_label: "Buyer 2’s age"
hint_text: ""
question_text: "Age"
person:
page_header: ""
check_answer_label: "Person 2’s age"
hint_text: "Answer 1 for children aged under 1 year old"
question_text: "Age"
age2_known:
check_answer_label: "Person 2’s age known?"
hint_text: ""
question_text: "Do you know person 2’s age?"
age:
check_answer_label: "Person 2’s age"
hint_text: ""
question_text: "Age"
sex2:
buyer:
@ -219,17 +216,16 @@ en:
hint_text: ""
question_text: "What is Person 3’s relationship to Buyer 1?"
age3_known:
page_header: ""
check_answer_label: "Person 3’s age known?"
hint_text: ""
question_text: "Do you know person 3’s age?"
age3:
page_header: ""
check_answer_label: "Person 3’s age"
hint_text: "Answer 1 for children aged under 1 year old"
question_text: "Age"
age3_known:
check_answer_label: "Person 3’s age known?"
hint_text: ""
question_text: "Do you know person 3’s age?"
age3:
check_answer_label: "Person 3’s age"
hint_text: ""
question_text: "Age"
sex3:
page_header: ""
@ -255,17 +251,16 @@ en:
hint_text: ""
question_text: "What is Person 4’s relationship to Buyer 1?"
age4_known:
page_header: ""
check_answer_label: "Person 4’s age known?"
hint_text: ""
question_text: "Do you know person 4’s age?"
age4:
page_header: ""
check_answer_label: "Person 4’s age"
hint_text: "Answer 1 for children aged under 1 year old"
question_text: "Age"
age4_known:
check_answer_label: "Person 4’s age known?"
hint_text: ""
question_text: "Do you know person 4’s age?"
age4:
check_answer_label: "Person 4’s age"
hint_text: ""
question_text: "Age"
sex4:
page_header: ""
@ -291,17 +286,16 @@ en:
hint_text: ""
question_text: "What is Person 5’s relationship to Buyer 1?"
age5_known:
page_header: ""
check_answer_label: "Person 5’s age known?"
hint_text: ""
question_text: "Do you know person 5’s age?"
age5:
page_header: ""
check_answer_label: "Person 5’s age"
hint_text: "Answer 1 for children aged under 1 year old"
question_text: "Age"
age5_known:
check_answer_label: "Person 5’s age known?"
hint_text: ""
question_text: "Do you know person 5’s age?"
age5:
check_answer_label: "Person 5’s age"
hint_text: ""
question_text: "Age"
sex5:
page_header: ""
@ -327,17 +321,16 @@ en:
hint_text: ""
question_text: "What is Person 6’s relationship to Buyer 1?"
age6_known:
page_header: ""
check_answer_label: "Person 6’s age known?"
hint_text: ""
question_text: "Do you know person 6’s age?"
age6:
page_header: ""
check_answer_label: "Person 6’s age"
hint_text: "Answer 1 for children aged under 1 year old"
question_text: "Age"
age6_known:
check_answer_label: "Person 6’s age known?"
hint_text: ""
question_text: "Do you know person 6’s age?"
age6:
check_answer_label: "Person 6’s age"
hint_text: ""
question_text: "Age"
sex6:
page_header: ""

Loading…
Cancel
Save