From 5b92a8378d496f305b4f4d37f9a98ef45ad98eb1 Mon Sep 17 00:00:00 2001 From: Kat Date: Wed, 16 Oct 2024 12:20:37 +0100 Subject: [PATCH] Refactor 2 question pages --- app/models/form/sales/pages/age1.rb | 1 + app/models/form/sales/pages/person_age.rb | 2 +- app/models/form/sales/questions/age2.rb | 2 +- .../form/sales/questions/buyer2_age_known.rb | 2 +- app/models/form/sales/questions/person_age.rb | 2 +- .../form/sales/questions/person_age_known.rb | 3 +- .../sales/household_characteristics.en.yml | 119 +++++++++--------- .../sales/household_characteristics.en.yml | 119 +++++++++--------- 8 files changed, 118 insertions(+), 132 deletions(-) diff --git a/app/models/form/sales/pages/age1.rb b/app/models/form/sales/pages/age1.rb index caa0948ee..12fc8c4d2 100644 --- a/app/models/form/sales/pages/age1.rb +++ b/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, diff --git a/app/models/form/sales/pages/person_age.rb b/app/models/form/sales/pages/person_age.rb index 0554b485b..af7daa606 100644 --- a/app/models/form/sales/pages/person_age.rb +++ b/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 diff --git a/app/models/form/sales/questions/age2.rb b/app/models/form/sales/questions/age2.rb index 09ba7f40e..29d955291 100644 --- a/app/models/form/sales/questions/age2.rb +++ b/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 = [{ diff --git a/app/models/form/sales/questions/buyer2_age_known.rb b/app/models/form/sales/questions/buyer2_age_known.rb index 787c5b637..ecd6c91f0 100644 --- a/app/models/form/sales/questions/buyer2_age_known.rb +++ b/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 = { diff --git a/app/models/form/sales/questions/person_age.rb b/app/models/form/sales/questions/person_age.rb index 9ed689de1..1638f6103 100644 --- a/app/models/form/sales/questions/person_age.rb +++ b/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 }, diff --git a/app/models/form/sales/questions/person_age_known.rb b/app/models/form/sales/questions/person_age_known.rb index 6d7733457..1bcdc6c67 100644 --- a/app/models/form/sales/questions/person_age_known.rb +++ b/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], } diff --git a/config/locales/forms/2023/sales/household_characteristics.en.yml b/config/locales/forms/2023/sales/household_characteristics.en.yml index 32b99f3ca..a49a817dc 100644 --- a/config/locales/forms/2023/sales/household_characteristics.en.yml +++ b/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: "" diff --git a/config/locales/forms/2024/sales/household_characteristics.en.yml b/config/locales/forms/2024/sales/household_characteristics.en.yml index 6ad6f0641..94f904c9d 100644 --- a/config/locales/forms/2024/sales/household_characteristics.en.yml +++ b/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: ""