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 4a26b8c8d..aa2b0e4e5 100644 --- a/app/components/check_answers_summary_list_card_component.html.erb +++ b/app/components/check_answers_summary_list_card_component.html.erb @@ -35,8 +35,8 @@ <% if @log.collection_period_open_for_editing? %> <% row.with_action( - text: question.action_text(log), - href: action_href(question, log), + text: question.action_text(log, correcting_hard_validation: @correcting_hard_validation), + href: action_href(question, log, correcting_hard_validation: @correcting_hard_validation), 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 205a8516e..952266aa3 100644 --- a/app/components/check_answers_summary_list_card_component.rb +++ b/app/components/check_answers_summary_list_card_component.rb @@ -1,10 +1,11 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base attr_reader :questions, :log, :user - def initialize(questions:, log:, user:) + def initialize(questions:, log:, user:, correcting_hard_validation: false) @questions = questions @log = log @user = user + @correcting_hard_validation = correcting_hard_validation super end @@ -28,9 +29,13 @@ class CheckAnswersSummaryListCardComponent < ViewComponent::Base "Person #{question.check_answers_card_number}" 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:) + def action_href(question, log, correcting_hard_validation: false) + if correcting_hard_validation + lettings_log_confirm_clear_answer_path(log, question_id: question.id, related_question_ids: request.query_parameters["related_question_ids"], original_question_id: request.query_parameters["original_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:) + end end private diff --git a/app/controllers/check_your_errors_controller.rb b/app/controllers/check_your_errors_controller.rb new file mode 100644 index 000000000..ca5e23349 --- /dev/null +++ b/app/controllers/check_your_errors_controller.rb @@ -0,0 +1,23 @@ +class CheckYourErrorsController < ApplicationController + include DuplicateLogsHelper + + before_action :authenticate_user! + before_action :find_resource_by_named_id + + def index + return render_not_found unless @log + + related_question_ids = params[:related_question_ids] + @questions = @log.form.questions.select { |q| related_question_ids.include?(q.id.to_s) } + end + +private + + def find_resource_by_named_id + @log = if params[:sales_log_id].present? + current_user.sales_logs.visible.find_by(id: params[:sales_log_id]) + else + current_user.lettings_logs.visible.find_by(id: params[:lettings_log_id]) + end + end +end diff --git a/app/models/form/question.rb b/app/models/form/question.rb index aa019c1c6..7637b1acd 100644 --- a/app/models/form/question.rb +++ b/app/models/form/question.rb @@ -111,8 +111,10 @@ class Form::Question end end - def action_text(log) - displayed_as_answered?(log) ? "Change" : "Answer" + def action_text(log, correcting_hard_validation: false) + return "Answer" unless displayed_as_answered?(log) + + correcting_hard_validation ? "Clear" : "Change" end def displayed_as_answered?(log) diff --git a/app/views/check_your_errors/index.html.erb b/app/views/check_your_errors/index.html.erb new file mode 100644 index 000000000..4e304c5c6 --- /dev/null +++ b/app/views/check_your_errors/index.html.erb @@ -0,0 +1,16 @@ +