a11yist/app/controllers/checklists_controller.rb
david 6db0b64f4c
Some checks failed
/ Run tests (push) Failing after 1m13s
/ Run system tests (push) Failing after 1m15s
/ Build, push and deploy image (push) Has been skipped
Cosmetics
2024-11-01 00:50:15 +01:00

63 lines
1.5 KiB
Ruby

# frozen_string_literal: true
class ChecklistsController < ApplicationController
include BackofficeMenu
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
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)
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
params.require(:checklist).permit(:code, :name, :description, :description_html,
check_ids: [],
checklist_entries_attributes: %i[id check_id position _destroy])
end
end