Browse Source

CLDC-3863 Enable adding question numbers to page headers (#2930)

* CLDC-3863 Enable adding question numbers to page headers

* Test page headers

* Lint

* Lint
pull/2937/head
Manny Dinssa 4 days ago committed by GitHub
parent
commit
410e1750b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      app/models/form/lettings/pages/address_fallback.rb
  2. 3
      app/models/form/page.rb
  3. 3
      app/models/form/sales/pages/address_fallback.rb
  4. 2
      app/views/form/page.html.erb
  5. 2
      config/locales/forms/2024/lettings/property_information.en.yml
  6. 2
      config/locales/forms/2024/sales/property_information.en.yml
  7. 2
      config/locales/forms/2025/lettings/property_information.en.yml
  8. 2
      config/locales/forms/2025/sales/property_information.en.yml
  9. 24
      spec/features/sales_log_spec.rb

3
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

3
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"]

3
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

2
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 %>
</h1>
<% end %>

2
config/locales/forms/2024/lettings/property_information.en.yml

@ -51,7 +51,7 @@ en:
question_text: "Select the correct address"
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"

2
config/locales/forms/2024/sales/property_information.en.yml

@ -44,7 +44,7 @@ en:
question_text: "Select the correct address"
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"

2
config/locales/forms/2025/lettings/property_information.en.yml

@ -51,7 +51,7 @@ en:
question_text: "Select the correct address"
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"

2
config/locales/forms/2025/sales/property_information.en.yml

@ -44,7 +44,7 @@ en:
question_text: "Select the correct address"
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"

24
spec/features/sales_log_spec.rb

@ -228,6 +228,30 @@ RSpec.describe "Sales Log Features" do
expect(page).to have_current_path("/sales-logs/csv-download?codes_only=false&search=1")
end
end
context "when displaying the question number in the page header" do
let(:sales_log) { FactoryBot.create(:sales_log, :shared_ownership_setup_complete, jointpur: 2, owning_organisation: user.organisation, assigned_to: user) }
context "when visiting the address page" do
before do
visit("/sales-logs/#{sales_log.id}/address")
end
it "displays the question number in the page header" do
expect(page).to have_content("Q16")
end
end
context "when visiting the about staircasing page" do
before do
visit("/sales-logs/#{sales_log.id}/about-staircasing-not-joint-purchase")
end
it "displays the question number in the page header" do
expect(page).to have_content(/Shared ownership scheme\s*About the staircasing transaction/)
end
end
end
end
end

Loading…
Cancel
Save