-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathforms_controller.rb
More file actions
35 lines (30 loc) · 1.22 KB
/
forms_controller.rb
File metadata and controls
35 lines (30 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class FormsController < ApplicationController
after_action :verify_authorized
def show
authorize current_form, :can_view_form?
task_service = FormTaskListService.call(form: current_form, current_user:)
@task_list = task_service.all_sections
@task_status_counts = task_service.task_counts
render :show, locals: { current_form: }
end
def mark_pages_section_completed
authorize current_form, :can_view_form?
@pages = FormRepository.pages(current_form)
@mark_complete_input = Forms::MarkPagesSectionCompleteInput.new(mark_complete_input_params)
if @mark_complete_input.submit
success_message = if @mark_complete_input.mark_complete == "true"
t("banner.success.form.pages_saved_and_section_completed")
else
t("banner.success.form.pages_saved")
end
redirect_to form_path(current_form.id), success: success_message
else
@mark_complete_input.mark_complete = "false"
render "pages/index", locals: { current_form: }, status: :unprocessable_entity
end
end
private
def mark_complete_input_params
params.require(:forms_mark_pages_section_complete_input).permit(:mark_complete).merge(form: current_form)
end
end