diff --git a/app/models/form/page.rb b/app/models/form/page.rb index bc9edefe0..465f21ee7 100644 --- a/app/models/form/page.rb +++ b/app/models/form/page.rb @@ -24,10 +24,12 @@ class Form::Page delegate :form, to: :subsection - def header - return @header if @copy_key.nil? + def copy_key + @copy_key ||= "#{form.type}.#{subsection.id}.#{questions[0].id}" + end - I18n.t("forms.#{form.start_date.year}.#{@copy_key}.page_header") + def header + @header ||= I18n.t("forms.#{form.start_date.year}.#{copy_key}.page_header") end def routed_to?(log, _current_user) diff --git a/app/models/form/question.rb b/app/models/form/question.rb index 57ed70e66..065639c98 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -48,22 +48,20 @@ class Form::Question delegate :subsection, to: :page delegate :form, to: :subsection - def check_answer_label - return @check_answer_label if @copy_key.nil? + def copy_key + @copy_key ||= "#{form.type}.#{subsection.id}.#{id}" + end - I18n.t("forms.#{form.start_date.year}.#{@copy_key}.check_answer_label") + def check_answer_label + @check_answer_label ||= I18n.t("forms.#{form.start_date.year}.#{copy_key}.check_answer_label") end def header - return @header if @copy_key.nil? - - I18n.t("forms.#{form.start_date.year}.#{@copy_key}.question_text") + @header ||= I18n.t("forms.#{form.start_date.year}.#{copy_key}.question_text") end def hint_text - return @hint_text if @copy_key.nil? - - I18n.t("forms.#{form.start_date.year}.#{@copy_key}.hint_text") + @hint_text ||= I18n.t("forms.#{form.start_date.year}.#{copy_key}.hint_text") end def answer_label(log, user = nil) diff --git a/app/models/form/sales/pages/buyer_company.rb b/app/models/form/sales/pages/buyer_company.rb index cc2d962fe..dbe1afcec 100644 --- a/app/models/form/sales/pages/buyer_company.rb +++ b/app/models/form/sales/pages/buyer_company.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::BuyerCompany < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_company" - @copy_key = "sales.setup.companybuy" @depends_on = [{ "outright_sale?" => true, }] diff --git a/app/models/form/sales/pages/buyer_live.rb b/app/models/form/sales/pages/buyer_live.rb index 6606f8ed4..d0b772355 100644 --- a/app/models/form/sales/pages/buyer_live.rb +++ b/app/models/form/sales/pages/buyer_live.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::BuyerLive < ::Form::Page def initialize(id, hsh, subsection) super @id = "buyer_live" - @copy_key = "sales.setup.buylivein" @depends_on = [{ "companybuy" => 2, }] diff --git a/app/models/form/sales/pages/created_by.rb b/app/models/form/sales/pages/created_by.rb index b84764804..e68fc6a30 100644 --- a/app/models/form/sales/pages/created_by.rb +++ b/app/models/form/sales/pages/created_by.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::CreatedBy < ::Form::Page def initialize(id, hsh, subsection) super @id = "assigned_to" - @copy_key = "sales.setup.assigned_to_id" end def questions diff --git a/app/models/form/sales/pages/discounted_ownership_type.rb b/app/models/form/sales/pages/discounted_ownership_type.rb index 346ad4467..5998e6019 100644 --- a/app/models/form/sales/pages/discounted_ownership_type.rb +++ b/app/models/form/sales/pages/discounted_ownership_type.rb @@ -3,7 +3,6 @@ class Form::Sales::Pages::DiscountedOwnershipType < ::Form::Page super @id = "discounted_ownership_type" @copy_key = "sales.setup.type.discounted_ownership" - @header = header @depends_on = [{ "ownershipsch" => 2, }] diff --git a/app/models/form/sales/pages/joint_purchase.rb b/app/models/form/sales/pages/joint_purchase.rb index e3b0156b7..bec7c88c1 100644 --- a/app/models/form/sales/pages/joint_purchase.rb +++ b/app/models/form/sales/pages/joint_purchase.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::JointPurchase < ::Form::Page def initialize(id, hsh, subsection) super @id = "joint_purchase" - @copy_key = "sales.setup.jointpur" @depends_on = [ { "ownershipsch" => 1 }, { "ownershipsch" => 2 }, diff --git a/app/models/form/sales/pages/managing_organisation.rb b/app/models/form/sales/pages/managing_organisation.rb index bbb046f6b..3d8e59383 100644 --- a/app/models/form/sales/pages/managing_organisation.rb +++ b/app/models/form/sales/pages/managing_organisation.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::ManagingOrganisation < ::Form::Page def initialize(id, hsh, subsection) super @id = "managing_organisation" - @copy_key = "sales.setup.managing_organisation_id" end def questions diff --git a/app/models/form/sales/pages/number_joint_buyers.rb b/app/models/form/sales/pages/number_joint_buyers.rb index 456fb61e9..3a8c3475d 100644 --- a/app/models/form/sales/pages/number_joint_buyers.rb +++ b/app/models/form/sales/pages/number_joint_buyers.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::NumberJointBuyers < ::Form::Page def initialize(id, hsh, subsection) super @id = "number_joint_buyers" - @copy_key = "sales.setup.jointmore" @depends_on = [{ "joint_purchase?" => true, }] diff --git a/app/models/form/sales/pages/outright_ownership_type.rb b/app/models/form/sales/pages/outright_ownership_type.rb index 5d714153b..35194102a 100644 --- a/app/models/form/sales/pages/outright_ownership_type.rb +++ b/app/models/form/sales/pages/outright_ownership_type.rb @@ -2,7 +2,7 @@ class Form::Sales::Pages::OutrightOwnershipType < ::Form::Page def initialize(id, hsh, subsection) super @id = "outright_ownership_type" - @header = header + @copy_key = "sales.setup.type.outright_ownership" @depends_on = [{ "ownershipsch" => 3, }] diff --git a/app/models/form/sales/pages/ownership_scheme.rb b/app/models/form/sales/pages/ownership_scheme.rb index 6e1ca5cfe..d92e56600 100644 --- a/app/models/form/sales/pages/ownership_scheme.rb +++ b/app/models/form/sales/pages/ownership_scheme.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::OwnershipScheme < ::Form::Page def initialize(id, hsh, subsection) super @id = "ownership_scheme" - @copy_key = "sales.setup.ownershipsch" end def questions diff --git a/app/models/form/sales/pages/owning_organisation.rb b/app/models/form/sales/pages/owning_organisation.rb index e3b093b83..f0c9e4e68 100644 --- a/app/models/form/sales/pages/owning_organisation.rb +++ b/app/models/form/sales/pages/owning_organisation.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::OwningOrganisation < ::Form::Page def initialize(id, hsh, subsection) super @id = "owning_organisation" - @copy_key = "sales.setup.owning_organisation_id" end def questions diff --git a/app/models/form/sales/pages/privacy_notice.rb b/app/models/form/sales/pages/privacy_notice.rb index 1bd9e22de..cf6a7bbbc 100644 --- a/app/models/form/sales/pages/privacy_notice.rb +++ b/app/models/form/sales/pages/privacy_notice.rb @@ -1,7 +1,7 @@ class Form::Sales::Pages::PrivacyNotice < ::Form::Page def initialize(id, hsh, subsection, joint_purchase:) super(id, hsh, subsection) - @header = "Ministry of Housing, Communities and Local Government privacy notice" + @copy_key = "sales.setup.privacynotice.#{joint_purchase ? 'joint_purchase' : 'not_joint_purchase'}" @joint_purchase = joint_purchase end diff --git a/app/models/form/sales/pages/purchaser_code.rb b/app/models/form/sales/pages/purchaser_code.rb index ec61d50dd..8282453ad 100644 --- a/app/models/form/sales/pages/purchaser_code.rb +++ b/app/models/form/sales/pages/purchaser_code.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::PurchaserCode < ::Form::Page def initialize(id, hsh, subsection) super @id = "purchaser_code" - @copy_key = "sales.setup.purchid" end def questions diff --git a/app/models/form/sales/pages/sale_date.rb b/app/models/form/sales/pages/sale_date.rb index 3a9432623..036e04907 100644 --- a/app/models/form/sales/pages/sale_date.rb +++ b/app/models/form/sales/pages/sale_date.rb @@ -2,7 +2,6 @@ class Form::Sales::Pages::SaleDate < ::Form::Page def initialize(id, hsh, subsection) super @id = "completion_date" - @copy_key = "sales.setup.saledate" end def questions diff --git a/app/models/form/sales/pages/shared_ownership_type.rb b/app/models/form/sales/pages/shared_ownership_type.rb index 304c58730..a156abb17 100644 --- a/app/models/form/sales/pages/shared_ownership_type.rb +++ b/app/models/form/sales/pages/shared_ownership_type.rb @@ -3,7 +3,6 @@ class Form::Sales::Pages::SharedOwnershipType < ::Form::Page super @id = "shared_ownership_type" @copy_key = "sales.setup.type.shared_ownership" - @header = header @depends_on = [{ "ownershipsch" => 1, }] diff --git a/app/models/form/sales/questions/buyer_company.rb b/app/models/form/sales/questions/buyer_company.rb index 9ca551e70..a5dc69d8d 100644 --- a/app/models/form/sales/questions/buyer_company.rb +++ b/app/models/form/sales/questions/buyer_company.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::BuyerCompany < ::Form::Question def initialize(id, hsh, page) super @id = "companybuy" - @copy_key = "sales.setup.companybuy" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/buyer_live.rb b/app/models/form/sales/questions/buyer_live.rb index 794b3c7bc..315329088 100644 --- a/app/models/form/sales/questions/buyer_live.rb +++ b/app/models/form/sales/questions/buyer_live.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::BuyerLive < ::Form::Question def initialize(id, hsh, page) super @id = "buylivein" - @copy_key = "sales.setup.buylivein" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/created_by_id.rb b/app/models/form/sales/questions/created_by_id.rb index f4a40daff..516afd2bc 100644 --- a/app/models/form/sales/questions/created_by_id.rb +++ b/app/models/form/sales/questions/created_by_id.rb @@ -4,7 +4,6 @@ class Form::Sales::Questions::CreatedById < ::Form::Question def initialize(id, hsh, page) super @id = "assigned_to_id" - @copy_key = "sales.setup.assigned_to_id" @derived = true @type = "select" end diff --git a/app/models/form/sales/questions/joint_purchase.rb b/app/models/form/sales/questions/joint_purchase.rb index 9e47ca7a3..7e876a4cc 100644 --- a/app/models/form/sales/questions/joint_purchase.rb +++ b/app/models/form/sales/questions/joint_purchase.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::JointPurchase < ::Form::Question def initialize(id, hsh, page) super @id = "jointpur" - @copy_key = "sales.setup.jointpur" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/managing_organisation.rb b/app/models/form/sales/questions/managing_organisation.rb index f934a0cc7..17884687f 100644 --- a/app/models/form/sales/questions/managing_organisation.rb +++ b/app/models/form/sales/questions/managing_organisation.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::ManagingOrganisation < ::Form::Question def initialize(id, hsh, page) super @id = "managing_organisation_id" - @copy_key = "sales.setup.managing_organisation_id" @derived = true @type = "select" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/number_joint_buyers.rb b/app/models/form/sales/questions/number_joint_buyers.rb index 147f78ef5..d86e37a93 100644 --- a/app/models/form/sales/questions/number_joint_buyers.rb +++ b/app/models/form/sales/questions/number_joint_buyers.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::NumberJointBuyers < ::Form::Question def initialize(id, hsh, page) super @id = "jointmore" - @copy_key = "sales.setup.jointmore" @type = "radio" @answer_options = ANSWER_OPTIONS @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/other_ownership_type.rb b/app/models/form/sales/questions/other_ownership_type.rb index a6e98d784..84742b7ea 100644 --- a/app/models/form/sales/questions/other_ownership_type.rb +++ b/app/models/form/sales/questions/other_ownership_type.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::OtherOwnershipType < ::Form::Question def initialize(id, hsh, page) super @id = "othtype" - @check_answer_label = "Type of other sale" - @header = "What type of sale is it?" + @copy_key = "sales.setup.type.outright_ownership.othtype" @type = "text" @width = 10 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/outright_ownership_type.rb b/app/models/form/sales/questions/outright_ownership_type.rb index 8831367b6..f56b63d78 100644 --- a/app/models/form/sales/questions/outright_ownership_type.rb +++ b/app/models/form/sales/questions/outright_ownership_type.rb @@ -2,8 +2,7 @@ class Form::Sales::Questions::OutrightOwnershipType < ::Form::Question def initialize(id, hsh, page) super @id = "type" - @check_answer_label = "Type of outright sale" - @header = "What is the type of outright sale?" + @copy_key = "sales.setup.type.outright_ownership.type" @type = "radio" @top_guidance_partial = guidance_partial @answer_options = ANSWER_OPTIONS diff --git a/app/models/form/sales/questions/ownership_scheme.rb b/app/models/form/sales/questions/ownership_scheme.rb index 38a97e824..6b33a2566 100644 --- a/app/models/form/sales/questions/ownership_scheme.rb +++ b/app/models/form/sales/questions/ownership_scheme.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::OwnershipScheme < ::Form::Question def initialize(id, hsh, page) super @id = "ownershipsch" - @copy_key = "sales.setup.ownershipsch" @type = "radio" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/app/models/form/sales/questions/owning_organisation_id.rb b/app/models/form/sales/questions/owning_organisation_id.rb index adf777b48..aacccecd3 100644 --- a/app/models/form/sales/questions/owning_organisation_id.rb +++ b/app/models/form/sales/questions/owning_organisation_id.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::OwningOrganisationId < ::Form::Question def initialize(id, hsh, page) super @id = "owning_organisation_id" - @copy_key = "sales.setup.owning_organisation_id" @derived = true @type = "select" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/purchaser_code.rb b/app/models/form/sales/questions/purchaser_code.rb index 527dd659a..fd3b126e9 100644 --- a/app/models/form/sales/questions/purchaser_code.rb +++ b/app/models/form/sales/questions/purchaser_code.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::PurchaserCode < ::Form::Question def initialize(id, hsh, page) super @id = "purchid" - @copy_key = "sales.setup.purchid" @type = "text" @width = 10 @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] diff --git a/app/models/form/sales/questions/sale_date.rb b/app/models/form/sales/questions/sale_date.rb index f969c32f2..00f0c86dd 100644 --- a/app/models/form/sales/questions/sale_date.rb +++ b/app/models/form/sales/questions/sale_date.rb @@ -2,7 +2,6 @@ class Form::Sales::Questions::SaleDate < ::Form::Question def initialize(id, hsh, page) super @id = "saledate" - @copy_key = "sales.setup.saledate" @type = "date" @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end diff --git a/config/locales/forms/2024/sales/setup.en.yml b/config/locales/forms/2024/sales/setup.en.yml index 2f7ab0620..b88691a0d 100644 --- a/config/locales/forms/2024/sales/setup.en.yml +++ b/config/locales/forms/2024/sales/setup.en.yml @@ -99,12 +99,12 @@ en: privacynotice: joint_purchase: - page_header: "" + page_header: "Ministry of Housing, Communities and Local Government privacy notice" check_answer_label: "Buyers have seen the privacy notice?" hint_text: "" question_text: "Declaration" not_joint_purchase: - page_header: "" + page_header: "Ministry of Housing, Communities and Local Government privacy notice" check_answer_label: "Buyer has seen the privacy notice?" hint_text: "" question_text: "Declaration"