diff --git a/app/input_objects/pages/secondary_skip_input.rb b/app/input_objects/pages/secondary_skip_input.rb index 3c7e3a647..3db0ce50a 100644 --- a/app/input_objects/pages/secondary_skip_input.rb +++ b/app/input_objects/pages/secondary_skip_input.rb @@ -55,13 +55,13 @@ def routing_page_options pages_after_current_page(FormRepository.pages(form), page).map { |p| OpenStruct.new(id: p.id, question_text: p.question_with_number) } end - def page_name(page_id) + def question_name(page_id) target_page = FormRepository.pages(form).find { |page| page.id == page_id } - page_name = target_page.question_text + question_text = target_page.question_text page_position = target_page.position - I18n.t("page_route_card.page_name", page_position:, page_name:) + I18n.t("page_route_card.question_name_long", page_position:, question_text:) end def end_page_name @@ -73,7 +73,7 @@ def answer_value end def continue_to - page.has_next_page? ? page_name(page.next_page) : end_page_name + page.has_next_page? ? question_name(page.next_page) : end_page_name end def assign_values diff --git a/app/presenters/route_summary_card_data_presenter.rb b/app/presenters/route_summary_card_data_presenter.rb index 3f77d98ab..8c8d7ef6a 100644 --- a/app/presenters/route_summary_card_data_presenter.rb +++ b/app/presenters/route_summary_card_data_presenter.rb @@ -33,7 +33,7 @@ def conditional_route_cards end def conditional_route_card(routing_condition, index) - goto_page_name = routing_condition.skip_to_end ? end_page_name : page_name(routing_condition.goto_page_id) + goto_page_name = routing_condition.skip_to_end ? end_page_name : goto_question_name(routing_condition.goto_page_id) { card: { @@ -57,7 +57,7 @@ def conditional_route_card(routing_condition, index) end def secondary_skip_card - continue_to_name = page.has_next_page? ? page_name(page.next_page) : end_page_name + continue_to_name = page.has_next_page? ? question_name(page.next_page) : end_page_name actions = if FeatureService.new(group: form.group).enabled?(:branch_routing) && secondary_skip [ @@ -106,8 +106,8 @@ def secondary_skip_rows end end - goto_page_name = secondary_skip.skip_to_end ? end_page_name : page_name(secondary_skip.goto_page_id) - routing_page_name = page_name(secondary_skip.routing_page_id) + goto_page_name = secondary_skip.skip_to_end ? end_page_name : goto_question_name(secondary_skip.goto_page_id) + routing_page_name = question_name(secondary_skip.routing_page_id) [ { @@ -121,17 +121,19 @@ def secondary_skip_rows ] end - def page_name(page_id) + def question_name(page_id) target_page = pages.find { |page| page.id == page_id } - if target_page.present? - page_name = target_page.question_text - page_position = target_page.position + return if target_page.blank? - I18n.t("page_route_card.page_name", page_position:, page_name:) - else - I18n.t("page_route_card.page_name_not_exist") - end + question_text = target_page.question_text + page_position = target_page.position + + I18n.t("page_route_card.question_name_long", page_position:, question_text:) + end + + def goto_question_name(page_id) + question_name(page_id) || I18n.t("page_route_card.goto_page_invalid") end def end_page_name diff --git a/app/views/pages/routes/show.html.erb b/app/views/pages/routes/show.html.erb index cc05a9fac..8513dcde0 100644 --- a/app/views/pages/routes/show.html.erb +++ b/app/views/pages/routes/show.html.erb @@ -11,7 +11,7 @@ <%= govuk_summary_list(actions: false) do |summary_list| summary_list.with_row do |row| - row.with_key { t("page_route_card.question_title", position: page.position) } + row.with_key { t("page_route_card.question_name_short", position: page.position) } row.with_value { "#{page.question_text}" } end; end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 269e426d0..3fe9be784 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1053,10 +1053,10 @@ en: delete: Delete delete_route: Delete routes edit: Edit + goto_page_invalid: Edit this route to select the question or page you want to take the person to, or delete the route if_answer_is: If the answer is - page_name: "%{page_position}. %{page_name}" - page_name_not_exist: Edit this route to select the question or page you want to take the person to, or delete the route - question_title: Question %{position} + question_name_long: "%{page_position}. %{question_text}" + question_name_short: Question %{position} route_title: Route %{index} secondary_skip_after: Then after the person answers secondary_skip_then: take them to diff --git a/spec/presenters/route_summary_card_data_presenter_spec.rb b/spec/presenters/route_summary_card_data_presenter_spec.rb index 1c6c4018b..2f736fabd 100644 --- a/spec/presenters/route_summary_card_data_presenter_spec.rb +++ b/spec/presenters/route_summary_card_data_presenter_spec.rb @@ -40,7 +40,7 @@ it "uses placeholder text instead of question text" do result = service.summary_card_data - expect(result[0][:rows][1][:value][:text]).to eq(I18n.t("page_route_card.page_name_not_exist")) + expect(result[0][:rows][1][:value][:text]).to eq(I18n.t("page_route_card.goto_page_invalid")) end end end