2024-09-05 22:54:38 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2024-07-19 02:29:18 +02:00
|
|
|
class ChecklistEntriesController < ApplicationController
|
|
|
|
|
before_action :set_checklist_entry, only: %i[show edit update destroy]
|
|
|
|
|
|
|
|
|
|
# GET /checklist_entries
|
|
|
|
|
def index
|
|
|
|
|
@checklist_entries = ChecklistEntry.all
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# GET /checklist_entries/1
|
2024-09-05 22:54:38 +02:00
|
|
|
def show; end
|
2024-07-19 02:29:18 +02:00
|
|
|
|
|
|
|
|
# GET /checklist_entries/new
|
|
|
|
|
def new
|
|
|
|
|
@checklist_entry = ChecklistEntry.new(checklist_id: params[:checklist_id])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# GET /checklist_entries/1/edit
|
2024-09-05 22:54:38 +02:00
|
|
|
def edit; end
|
2024-07-19 02:29:18 +02:00
|
|
|
|
|
|
|
|
# POST /checklist_entries
|
|
|
|
|
def create
|
|
|
|
|
@checklist_entry = ChecklistEntry.new(checklist_entry_params)
|
|
|
|
|
|
|
|
|
|
if @checklist_entry.save
|
2024-09-05 22:54:38 +02:00
|
|
|
redirect_to @checklist_entry.checklist, notice: "Checklist entry was successfully created."
|
2024-07-19 02:29:18 +02:00
|
|
|
else
|
|
|
|
|
render :new, status: :unprocessable_entity
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# PATCH/PUT /checklist_entries/1
|
|
|
|
|
def update
|
|
|
|
|
if @checklist_entry.update(checklist_entry_params)
|
2024-10-27 22:37:11 +01:00
|
|
|
respond_to do |format|
|
|
|
|
|
format.turbo_stream
|
|
|
|
|
format.html do
|
|
|
|
|
redirect_to @checklist_entry.checklist, notice: "Checklist entry was successfully updated.",
|
|
|
|
|
status: :see_other
|
|
|
|
|
end
|
|
|
|
|
end
|
2024-07-19 02:29:18 +02:00
|
|
|
else
|
|
|
|
|
render :edit, status: :unprocessable_entity
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# DELETE /checklist_entries/1
|
|
|
|
|
def destroy
|
|
|
|
|
@checklist_entry.destroy!
|
2024-07-20 16:52:12 +02:00
|
|
|
respond_to do |format|
|
|
|
|
|
format.html do
|
2024-09-05 22:54:38 +02:00
|
|
|
redirect_to checklist_entries_url, notice: "Checklist entry was successfully destroyed.", status: :see_other
|
2024-07-20 16:52:12 +02:00
|
|
|
end
|
|
|
|
|
format.turbo_stream
|
|
|
|
|
end
|
2024-07-19 02:29:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
|
|
|
def set_checklist_entry
|
|
|
|
|
@checklist_entry = ChecklistEntry.find(params[:id])
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# Only allow a list of trusted parameters through.
|
|
|
|
|
def checklist_entry_params
|
|
|
|
|
params.require(:checklist_entry).permit(:checklist_id, :check_id, :position)
|
|
|
|
|
end
|
|
|
|
|
end
|