Skip to content

Commit

Permalink
Change name of translation keys for page_route_card
Browse files Browse the repository at this point in the history
Use question instead of page where appropriate
  • Loading branch information
lfdebrux committed Feb 26, 2025
1 parent 12a583f commit da0602b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
8 changes: 4 additions & 4 deletions app/input_objects/pages/secondary_skip_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
26 changes: 14 additions & 12 deletions app/presenters/route_summary_card_data_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
[
Expand Down Expand Up @@ -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)

[
{
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/views/pages/routes/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
6 changes: 3 additions & 3 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/presenters/route_summary_card_data_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit da0602b

Please sign in to comment.