|
9 | 9 | <%= t("page_titles.routes") %> |
10 | 10 | </h1> |
11 | 11 |
|
12 | | - <%= form_with(model: @routes_input, url: routes_path(@routes_input.form)) do |f| %> |
13 | | - <% if @routes_input&.errors&.present? %> |
14 | | - <%= f.govuk_error_summary(presenter: ErrorSummaryPresenter.new(@routes_input.errors)) %> |
15 | | - <% end %> |
| 12 | + <%if @routes_input.form.pages.length < 2 %> |
| 13 | + <%= t(".not_enough_pages_html", pages_link: form_pages_path(@current_form)) %> |
| 14 | + <% else %> |
| 15 | + <%= form_with(model: @routes_input, url: routes_path(@routes_input.form)) do |f| %> |
| 16 | + <% if @routes_input&.errors&.present? %> |
| 17 | + <%= f.govuk_error_summary(presenter: ErrorSummaryPresenter.new(@routes_input.errors)) %> |
| 18 | + <% end %> |
16 | 19 |
|
17 | | - <%= govuk_summary_list(actions: false) do |summary_list| |
| 20 | + <%= govuk_summary_list(actions: false) do |summary_list| |
18 | 21 |
|
19 | | - @routes_input.routes.group_by(&:page).each do |page, routes| |
20 | | - summary_list.with_row do |row| |
21 | | - row.with_key(classes: "app-routes-list__key", html_attributes: { id: page.page_position_id}) { page.position.to_s } |
22 | | - row.with_value do |
23 | | - capture do %> |
24 | | - <p> <%= page.question_text %> </p> |
25 | | - <% if @routes_input.form.next_page_after(page).present? %> |
26 | | - <ul class="govuk-list"> |
27 | | - <% routes.each do |route| %> |
28 | | - <li> |
29 | | - <%= f.fields_for :routes, route do |route_form| |
30 | | - route_form.hidden_field(:id) + |
31 | | - route_form.hidden_field(:page_id) + |
32 | | - route_form.hidden_field(:answer_value) + |
33 | | - route_form.govuk_select(:goto, options_for_select(route_form.object.goto_options, route_form.object.goto), label: route_form.object.label) |
34 | | - end %> |
35 | | - </li> |
| 22 | + @routes_input.routes.group_by(&:page).each do |page, routes| |
| 23 | + summary_list.with_row do |row| |
| 24 | + row.with_key(classes: "app-routes-list__key", html_attributes: { id: page.page_position_id}) { page.position.to_s } |
| 25 | + row.with_value do |
| 26 | + capture do %> |
| 27 | + <p> <%= page.question_text %> </p> |
| 28 | + <% if @routes_input.form.next_page_after(page).present? %> |
| 29 | + <ul class="govuk-list"> |
| 30 | + <% routes.each do |route| %> |
| 31 | + <li> |
| 32 | + <%= f.fields_for :routes, route do |route_form| |
| 33 | + route_form.hidden_field(:id) + |
| 34 | + route_form.hidden_field(:page_id) + |
| 35 | + route_form.hidden_field(:answer_value) + |
| 36 | + route_form.govuk_select(:goto, options_for_select(route_form.object.goto_options, route_form.object.goto), label: route_form.object.label) |
| 37 | + end %> |
| 38 | + </li> |
| 39 | + <% end %> |
| 40 | + </ul> |
| 41 | + <% if page.answer_type == "selection" && |
| 42 | + page.answer_settings.only_one_option == "true" && |
| 43 | + @routes_input.class.too_many_selection_options?(page) %> |
| 44 | + <%= t(".too_many_options_html") %> |
36 | 45 | <% end %> |
37 | | - </ul> |
38 | | - <% if page.answer_type == "selection" && |
39 | | - page.answer_settings.only_one_option == "true" && |
40 | | - @routes_input.class.too_many_selection_options?(page) %> |
41 | | - <%= t(".too_many_options_html") %> |
42 | 46 | <% end %> |
43 | 47 | <% end %> |
44 | 48 | <% end %> |
45 | 49 | <% end %> |
46 | 50 | <% end %> |
47 | 51 | <% end %> |
48 | | - <% end %> |
49 | 52 |
|
50 | | - <%= f.govuk_submit t("save_and_continue") %> |
| 53 | + <%= f.govuk_submit t("save_and_continue") %> |
51 | 54 |
|
| 55 | + <% end %> |
52 | 56 | <% end %> |
53 | 57 | </div> |
54 | 58 | </div> |
0 commit comments