diff --git a/app/components/check_answers_summary_list_card_component.html.erb b/app/components/check_answers_summary_list_card_component.html.erb index aa2b0e4e5..4f3df47fa 100644 --- a/app/components/check_answers_summary_list_card_component.html.erb +++ b/app/components/check_answers_summary_list_card_component.html.erb @@ -36,7 +36,7 @@ <% if @log.collection_period_open_for_editing? %> <% row.with_action( text: question.action_text(log, correcting_hard_validation: @correcting_hard_validation), - href: action_href(question, log, correcting_hard_validation: @correcting_hard_validation), + href: @correcting_hard_validation ? correct_validation_action_href(question, log, applicable_questions.map(&:id)) : action_href(question, log), visually_hidden_text: question.check_answer_label.to_s.downcase, ) %> <% end %> diff --git a/app/components/check_answers_summary_list_card_component.rb b/app/components/check_answers_summary_list_card_component.rb index 825ab04b1..b37e226b0 100644 --- a/app/components/check_answers_summary_list_card_component.rb +++ b/app/components/check_answers_summary_list_card_component.rb @@ -29,16 +29,16 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base "Person #{question.check_answers_card_number}" end - def action_href(question, log, correcting_hard_validation: false) - if correcting_hard_validation - if question.displayed_as_answered?(log) - lettings_log_confirm_clear_answer_path(log, question_id: question.id, related_question_ids: request.query_parameters["related_question_ids"], original_page_id: request.query_parameters["original_page_id"]) - else - send("#{log.model_name.param_key}_#{question.page.id}_path", log, referrer: "check_your_errors", related_question_ids: request.query_parameters["related_question_ids"], original_page_id: request.query_parameters["original_page_id"]) - end + def action_href(question, log) + referrer = question.displayed_as_answered?(log) ? "check_answers" : "check_answers_new_answer" + send("#{log.model_name.param_key}_#{question.page.id}_path", log, referrer:) + end + + def correct_validation_action_href(question, log, related_question_ids) + if question.displayed_as_answered?(log) + lettings_log_confirm_clear_answer_path(log, question_id: question.id) else - referrer = question.displayed_as_answered?(log) ? "check_answers" : "check_answers_new_answer" - send("#{log.model_name.param_key}_#{question.page.id}_path", log, referrer:) + send("#{log.model_name.param_key}_#{question.page.id}_path", log, referrer: "check_errors", related_question_ids: request.query_parameters["related_question_ids"], original_page_id: request.query_parameters["original_page_id"]) end end diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index a8d8fca48..c2890fb89 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -30,10 +30,16 @@ class FormController < ApplicationController mandatory_questions_with_no_response.map do |question| @log.errors.add question.id.to_sym, question.unanswered_error_message, category: :not_answered end - Rails.logger.info "User triggered validation(s) on: #{@log.errors.map(&:attribute).join(', ')}" + error_attributes = @log.errors.map(&:attribute) + Rails.logger.info "User triggered validation(s) on: #{error_attributes.join(', ')}" @subsection = form.subsection_for_page(@page) restore_error_field_values(@page&.questions) - render "form/page" + if params["check_errors"] + @questions = @log.form.questions.select { |q| error_attributes.include?(q.id.to_sym) } + render "form/check_errors" + else + render "form/page" + end end else render_not_found diff --git a/app/helpers/form_page_error_helper.rb b/app/helpers/form_page_error_helper.rb index 035c34f0a..8a46accca 100644 --- a/app/helpers/form_page_error_helper.rb +++ b/app/helpers/form_page_error_helper.rb @@ -7,8 +7,4 @@ module FormPageErrorHelper def all_questions_affected_by_errors(log) log.errors.map(&:attribute) - [:base] end - - def check_your_errors_link(log, related_question_ids, original_page_id) - govuk_link_to "See all related answers", lettings_log_check_your_errors_path(log, related_question_ids:, original_page_id:), method: :post - end end diff --git a/app/views/check_your_errors/index.html.erb b/app/views/form/check_errors.html.erb similarity index 78% rename from app/views/check_your_errors/index.html.erb rename to app/views/form/check_errors.html.erb index 55ddac172..e498a0d40 100644 --- a/app/views/check_your_errors/index.html.erb +++ b/app/views/form/check_errors.html.erb @@ -1,11 +1,15 @@