You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
class CheckErrorsController < ApplicationController |
|
include DuplicateLogsHelper |
|
|
|
before_action :authenticate_user! |
|
before_action :find_resource_by_named_id |
|
|
|
def confirm_clear_answer |
|
return render_not_found unless @log |
|
|
|
@related_question_ids = params[@log.model_name.param_key].keys.reject { |id| id == "page_id" } |
|
@page = @log.form.get_page(params[@log.model_name.param_key]["page_id"]) |
|
|
|
if params["clear_all"] |
|
@questions_to_clear = @related_question_ids.map { |id| |
|
question = @log.form.get_question(id, @log) |
|
next if question.subsection.id == "setup" |
|
|
|
question.page.questions.map(&:id) |
|
}.flatten.compact |
|
|
|
render :confirm_clear_all_answers |
|
else |
|
question_id = @related_question_ids.find { |id| !params[id].nil? } |
|
@question = @log.form.get_question(question_id, @log) |
|
end |
|
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
|
|
|