Browse Source

Only show check errors journey for question on different pages

pull/2826/head
Kat 6 months ago
parent
commit
5059fa643d
  1. 5
      app/helpers/form_page_error_helper.rb
  2. 4
      app/views/form/page.html.erb

5
app/helpers/form_page_error_helper.rb

@ -13,7 +13,8 @@ module FormPageErrorHelper
end
end
def all_questions_affected_by_errors(log)
(log.errors.map(&:attribute) - [:base]).uniq
def all_pages_affected_by_errors(log)
question_ids = (log.errors.map(&:attribute) - [:base]).uniq
question_ids.map { |id| log.form.get_question(id, log).page.id }.uniq
end
end

4
app/views/form/page.html.erb

@ -16,7 +16,7 @@
<%= form_with model: @log, url: request.original_url, method: "post", local: true do |f| %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<% all_questions_with_errors = all_questions_affected_by_errors(@log) %>
<% all_pages_with_errors = all_pages_affected_by_errors(@log) %>
<% remove_other_page_errors(@log, @page) %>
<%= f.govuk_error_summary %>
@ -76,7 +76,7 @@
<%= f.hidden_field :check_errors, value: @check_errors %>
<% end %>
<% if all_questions_with_errors.count > 1 %>
<% if all_pages_with_errors.count > 1 %>
<div class="govuk-button-group">
<%= f.submit "See all related answers", name: "check_errors", class: "govuk-body govuk-link submit-button-link" %>
</div>

Loading…
Cancel
Save