Submit social housing lettings and sales data (CORE)
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.

41 lines
1.0 KiB

3 years ago
class CaseLogsController < ApplicationController
def index
@submitted_case_logs = CaseLog.where(status: 1)
@in_progress_case_logs = CaseLog.where(status: 0)
end
3 years ago
def create
@case_log = CaseLog.create!
redirect_to @case_log
end
# We don't have a dedicated non-editable show view
3 years ago
def show
edit
3 years ago
end
def edit
@form = Form.new(2021, 2022)
@case_log = CaseLog.find(params[:id])
render :edit, locals: { form: @form }
end
def next_page
form = Form.new(2021, 2022)
@case_log = CaseLog.find(params[:case_log_id])
previous_page = params[:previous_page]
previous_answer = params[previous_page]
@case_log.update!(previous_page => previous_answer)
next_page = form.next_page(previous_page)
redirect_to(send("case_log_#{next_page}_path", @case_log))
3 years ago
end
form = Form.new(2021, 2022)
form.all_pages.keys.map do |page|
define_method(page) do
3 years ago
@case_log = CaseLog.find(params[:case_log_id])
render "form/pages/#{page}", locals: { case_log_id: @case_log.id, form: form }
3 years ago
end
end
3 years ago
end