a11yist/app/controllers/checklists_controller.rb

64 lines
1.5 KiB
Ruby
Raw Permalink Normal View History

2024-09-05 22:54:38 +02:00
# frozen_string_literal: true
class ChecklistsController < ApplicationController
2024-09-22 21:57:05 +02:00
include BackofficeMenu
before_action :set_checklist, only: %i[show edit update destroy]
# GET /checklists
def index
@checklists = Checklist.all
end
# GET /checklists/1
2024-09-05 22:54:38 +02:00
def show; end
# GET /checklists/new
def new
@checklist = Checklist.new
end
# GET /checklists/1/edit
2024-09-05 22:54:38 +02:00
def edit; end
# POST /checklists
def create
@checklist = Checklist.new(checklist_params)
if @checklist.save
2024-09-05 22:54:38 +02:00
redirect_to @checklist, notice: "Checklist was successfully created."
else
render :new, status: :unprocessable_entity
end
end
# PATCH/PUT /checklists/1
def update
if @checklist.update(checklist_params)
2024-09-05 22:54:38 +02:00
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!
2024-09-05 22:54:38 +02:00
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-11-01 00:50:15 +01:00
check_ids: [],
checklist_entries_attributes: %i[id check_id position _destroy])
end
end