2024-07-16 20:22:59 +02:00
|
|
|
class ChecklistsController < ApplicationController
|
|
|
|
|
before_action :set_checklist, only: %i[show edit update destroy]
|
|
|
|
|
|
|
|
|
|
# GET /checklists
|
|
|
|
|
def index
|
|
|
|
|
@checklists = Checklist.all
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# GET /checklists/1
|
|
|
|
|
def show
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# GET /checklists/new
|
|
|
|
|
def new
|
|
|
|
|
@checklist = Checklist.new
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# GET /checklists/1/edit
|
|
|
|
|
def edit
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# POST /checklists
|
|
|
|
|
def create
|
|
|
|
|
@checklist = Checklist.new(checklist_params)
|
|
|
|
|
|
|
|
|
|
if @checklist.save
|
2024-07-22 22:40:56 +02:00
|
|
|
redirect_to @checklist, notice: 'Checklist was successfully created.'
|
2024-07-16 20:22:59 +02:00
|
|
|
else
|
|
|
|
|
render :new, status: :unprocessable_entity
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# PATCH/PUT /checklists/1
|
|
|
|
|
def update
|
|
|
|
|
if @checklist.update(checklist_params)
|
|
|
|
|
redirect_to @checklist, notice: 'Checklist was successfully updated.', status: :see_other
|
|
|
|
|
else
|
|
|
|
|
render :edit, status: :unprocessable_entity
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# DELETE /checklists/1
|
|
|
|
|
def destroy
|
|
|
|
|
@checklist.destroy!
|
|
|
|
|
redirect_to checklists_url, notice: 'Checklist was successfully destroyed.', status: :see_other
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
|
|
|
def set_checklist
|
|
|
|
|
@checklist = Checklist.find(params[:id])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Only allow a list of trusted parameters through.
|
|
|
|
|
def checklist_params
|
2024-07-19 02:29:18 +02:00
|
|
|
params.require(:checklist).permit(:code, :name, :description, :description_html,
|
2024-07-16 20:22:59 +02:00
|
|
|
checklist_entries_attributes: %i[id check_id position _destroy])
|
|
|
|
|
end
|
|
|
|
|
end
|