Skip to content

Commit 225fd29

Browse files
authored
Merge pull request #1954 from alphagov/updte-conditions-for-exit-pages
Update content for routing when exit_pages on
2 parents 6c0536f + 5d68de8 commit 225fd29

File tree

5 files changed

+70
-4
lines changed

5 files changed

+70
-4
lines changed

app/views/pages/conditions/_routing_options.html.erb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
<% branch_routing_enabled = FeatureService.new(group: form.group).enabled?(:branch_routing) %>
2-
<% body_text = branch_routing_enabled ? t("routing_page.branch_routing.body_html") : t("routing_page.body_html") %>
3-
<% hint_text = branch_routing_enabled ? t("routing_page.branch_routing.legend_hint_text") : t("routing_page.legend_hint_text") %>
2+
<% exit_pages_enabled = FeatureService.new(group: form.group).enabled?(:exit_pages) %>
3+
4+
<% if exit_pages_enabled %>
5+
<% body_text = t("routing_page.exit_pages.body_html") %>
6+
<% hint_text = t("routing_page.exit_pages.legend_hint_text") %>
7+
<% elsif branch_routing_enabled %>
8+
<% body_text = t("routing_page.branch_routing.body_html") %>
9+
<% hint_text = t("routing_page.branch_routing.legend_hint_text") %>
10+
<% else %>
11+
<% body_text = t("routing_page.body_html") %>
12+
<% hint_text = t("routing_page.legend_hint_text") %>
13+
<% end %>
414

515
<%= form_with(model: routing_page_input, url: set_routing_page_path(form.id), method: 'POST') do |f| %>
616
<% if routing_page_input&.errors.any? %>

app/views/pages/conditions/routing_page.html.erb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
<div class="govuk-grid-row">
44
<div class="govuk-grid-column-two-thirds">
55
<% branch_routing_enabled = FeatureService.new(group: form.group).enabled?(:branch_routing) %>
6-
<% prefix = branch_routing_enabled ? 'branch_routing.' : '' %>
6+
<% exit_pages_enabled = FeatureService.new(group: form.group).enabled?(:exit_pages) %>
7+
8+
<% if exit_pages_enabled %>
9+
<% prefix = 'exit_pages.' %>
10+
<% elsif branch_routing_enabled %>
11+
<% prefix = 'branch_routing.' %>
12+
<% else %>
13+
<% prefix = '' %>
14+
<% end %>
715

816
<% if policy(form).can_add_page_routing_conditions? %>
917
<%= render partial: "pages/conditions/routing_options", locals: {form:, routing_page_input:} %>

config/i18n-tasks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ ignore_unused:
132132
- 'errors.*'
133133
- 'date.formats.*'
134134
- 'helpers.*'
135-
- 'routing_page.branch_routing.*'
135+
- 'routing_page.{branch_routing,exit_pages}.*'
136136

137137
## Exclude these keys from the `i18n-tasks eq-base' report:
138138
# ignore_eq_base:

config/locales/en.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,32 @@ en:
14821482
14831483
<p>It’s usually easiest to create all your form’s questions first, then add the routes you need.</p>
14841484
dropdown_default_text: Select a question to start your route from
1485+
exit_pages:
1486+
body_html: |
1487+
<p> You can add a route to a question so if someone selects one specific answer, they’ll be skipped to: </p>
1488+
1489+
<ul class="govuk-list govuk-list--bullet">
1490+
<li> a later question </li>
1491+
<li> the end of the form </li>
1492+
<li> an ‘exit page’ to remove them from the form - for example, because they’re not eligible </li>
1493+
</ul>
1494+
1495+
<p> People who select any other answer will continue to the next question and through the rest of the form. </p>
1496+
legend_hint_text: A route can only start from a question where people select one option from a list. Go back to your questions if you need to edit an existing route.
1497+
no_remaining_routes_html: |
1498+
<h2 class="govuk-heading-m">You have no more questions to add a route from</h2>
1499+
<p>A route can only start from a question where people select one option from a list. If you need to edit an existing route, go back to your questions.</p>
1500+
routing_requirements_not_met_html: |
1501+
<h2 class="govuk-heading-m">You cannot add a route yet</h2>
1502+
1503+
<p>A route can only start from a question that:</p>
1504+
1505+
<ul class="govuk-list govuk-list--bullet">
1506+
<li>asks people to select only one option from a list</li>
1507+
<li>has at least one question after it</li>
1508+
</ul>
1509+
1510+
<p>It’s usually easiest to create all your form’s questions first, then add the routes you need.</p>
14851511
legend_hint_text: A route can only start from a question where people select one item from a list. You can only add one route from each question.
14861512
legend_text: Which question do you want to add a route from?
14871513
no_remaining_routes_html: |

spec/views/pages/conditions/routing_page.html.erb_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
end
3535
end
3636

37+
context "when exit pages are enabled", :feature_exit_pages do
38+
it "contains content for exit pages" do
39+
expect(rendered).to have_text "an ‘exit page’ to remove them from the form - for example, because they’re not eligible ", normalize_ws: true
40+
end
41+
end
42+
3743
context "when branch routing is not enabled", feature_branch_routing: false do
3844
it "does not contain content explaining branch routing" do
3945
expect(rendered).not_to have_text "You can add a route from a question where people can select only one answer from a list."
@@ -107,5 +113,21 @@
107113
expect(rendered).to have_text(guidance, normalize_ws: true)
108114
end
109115
end
116+
117+
context "when exit_pages is enabled", :feature_exit_pages do
118+
it "explains to the user what is required for them to be able to add a new routes" do
119+
guidance = Capybara.string(I18n.t("routing_page.exit_pages.routing_requirements_not_met_html")).text(normalize_ws: true)
120+
expect(rendered).to have_text(guidance, normalize_ws: true)
121+
end
122+
123+
context "when all qualifying questions have a route" do
124+
let(:all_routes_created) { true }
125+
126+
it "explains to the user that they have created all available routes" do
127+
guidance = Capybara.string(I18n.t("routing_page.exit_pages.no_remaining_routes_html")).text(normalize_ws: true)
128+
expect(rendered).to have_text(guidance, normalize_ws: true)
129+
end
130+
end
131+
end
110132
end
111133
end

0 commit comments

Comments
 (0)