From 8d9891e50b3d85107af9812381e0d6efc0cf8fc0 Mon Sep 17 00:00:00 2001 From: Manny Dinssa <44172848+Dinssa@users.noreply.github.com> Date: Tue, 4 Feb 2025 16:34:54 +0000 Subject: [PATCH] Enable adding question numbers to page headers --- app/models/form/lettings/pages/address_fallback.rb | 3 +++ app/models/form/page.rb | 3 ++- app/models/form/sales/pages/address_fallback.rb | 3 +++ app/views/form/page.html.erb | 2 +- config/locales/forms/2024/lettings/property_information.en.yml | 2 +- config/locales/forms/2024/sales/property_information.en.yml | 2 +- config/locales/forms/2025/lettings/property_information.en.yml | 2 +- config/locales/forms/2025/sales/property_information.en.yml | 2 +- 8 files changed, 13 insertions(+), 6 deletions(-) diff --git a/app/models/form/lettings/pages/address_fallback.rb b/app/models/form/lettings/pages/address_fallback.rb index 2d5249671..763f9d3da 100644 --- a/app/models/form/lettings/pages/address_fallback.rb +++ b/app/models/form/lettings/pages/address_fallback.rb @@ -11,6 +11,7 @@ class Form::Lettings::Pages::AddressFallback < ::Form::Page { "is_supported_housing?" => false, "uprn_known" => 0, "address_options_present?" => false }, { "is_supported_housing?" => false, "uprn_confirmed" => 0, "address_options_present?" => false }, ] + @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end def questions @@ -22,4 +23,6 @@ class Form::Lettings::Pages::AddressFallback < ::Form::Page Form::Lettings::Questions::PostcodeForFullAddress.new(nil, nil, self), ] end + + QUESTION_NUMBER_FROM_YEAR = { 2024 => 13, 2025 => 13 }.freeze end diff --git a/app/models/form/page.rb b/app/models/form/page.rb index c1c09c362..6aa93d766 100644 --- a/app/models/form/page.rb +++ b/app/models/form/page.rb @@ -1,7 +1,7 @@ class Form::Page attr_accessor :id, :header_partial, :description, :questions, :depends_on, :title_text, :informative_text, :subsection, :hide_subsection_label, :next_unresolved_page_id, - :skip_text, :interruption_screen_question_ids, :submit_text + :skip_text, :interruption_screen_question_ids, :submit_text, :question_number def initialize(id, hsh, subsection) @id = id @@ -11,6 +11,7 @@ class Form::Page @header_partial = hsh["header_partial"] @description = hsh["description"] @questions = hsh["questions"].map { |q_id, q| Form::Question.new(q_id, q, self) } + @question_number = hsh["question_number"] @depends_on = hsh["depends_on"] @title_text = hsh["title_text"] @informative_text = hsh["informative_text"] diff --git a/app/models/form/sales/pages/address_fallback.rb b/app/models/form/sales/pages/address_fallback.rb index 1f0a3f1e8..b6818ae0c 100644 --- a/app/models/form/sales/pages/address_fallback.rb +++ b/app/models/form/sales/pages/address_fallback.rb @@ -11,6 +11,7 @@ class Form::Sales::Pages::AddressFallback < ::Form::Page { "uprn_known" => 0, "address_options_present?" => false }, { "uprn_confirmed" => 0, "address_options_present?" => false }, ] + @question_number = QUESTION_NUMBER_FROM_YEAR[form.start_date.year] || QUESTION_NUMBER_FROM_YEAR[QUESTION_NUMBER_FROM_YEAR.keys.max] end def questions @@ -22,4 +23,6 @@ class Form::Sales::Pages::AddressFallback < ::Form::Page Form::Sales::Questions::PostcodeForFullAddress.new(nil, nil, self), ] end + + QUESTION_NUMBER_FROM_YEAR = { 2024 => 16, 2025 => 16 }.freeze end diff --git a/app/views/form/page.html.erb b/app/views/form/page.html.erb index 6d74fadea..7c56b2184 100644 --- a/app/views/form/page.html.erb +++ b/app/views/form/page.html.erb @@ -27,7 +27,7 @@ <% if @page.header_partial.present? %> <%= render partial: "form/headers/#{@page.header_partial}", locals: { log: @log } %> <% else %> - <%= @page.header %> + <%= @page.question_number ? "Q#{@page.question_number} - #{@page.header}" : @page.header %> <% end %> <% end %> diff --git a/config/locales/forms/2024/lettings/property_information.en.yml b/config/locales/forms/2024/lettings/property_information.en.yml index b2a899973..44c2e0d98 100644 --- a/config/locales/forms/2024/lettings/property_information.en.yml +++ b/config/locales/forms/2024/lettings/property_information.en.yml @@ -58,7 +58,7 @@ en: question_text: "Search by address or UPRN" address: - page_header: "Q12 - What is the property's address?" + page_header: "What is the property's address?" address_line1: check_answer_label: "Address lines 1 and 2" check_answer_prompt: "Enter address lines 1 and 2" diff --git a/config/locales/forms/2024/sales/property_information.en.yml b/config/locales/forms/2024/sales/property_information.en.yml index d2825b40f..69c965eeb 100644 --- a/config/locales/forms/2024/sales/property_information.en.yml +++ b/config/locales/forms/2024/sales/property_information.en.yml @@ -51,7 +51,7 @@ en: question_text: "Search by address or UPRN" address: - page_header: "Q12 - What is the property's address?" + page_header: "What is the property's address?" address_line1: check_answer_label: "Address lines 1 and 2" check_answer_prompt: "Enter address lines 1 and 2" diff --git a/config/locales/forms/2025/lettings/property_information.en.yml b/config/locales/forms/2025/lettings/property_information.en.yml index 35fc58e07..c2acc52d8 100644 --- a/config/locales/forms/2025/lettings/property_information.en.yml +++ b/config/locales/forms/2025/lettings/property_information.en.yml @@ -58,7 +58,7 @@ en: question_text: "Search by address or UPRN" address: - page_header: "Q12 - What is the property's address?" + page_header: "What is the property's address?" address_line1: check_answer_label: "Address lines 1 and 2" check_answer_prompt: "Enter address lines 1 and 2" diff --git a/config/locales/forms/2025/sales/property_information.en.yml b/config/locales/forms/2025/sales/property_information.en.yml index 30b75f099..7366d72aa 100644 --- a/config/locales/forms/2025/sales/property_information.en.yml +++ b/config/locales/forms/2025/sales/property_information.en.yml @@ -51,7 +51,7 @@ en: question_text: "Search by address or UPRN" address: - page_header: "Q12 - What is the property's address?" + page_header: "What is the property's address?" address_line1: check_answer_label: "Address lines 1 and 2" check_answer_prompt: "Enter address lines 1 and 2"