Basic feature implemented, very basic poc
This commit is contained in:
parent
216089a3e7
commit
48c0067076
118 changed files with 2113 additions and 20 deletions
61
app/controllers/checklists_controller.rb
Normal file
61
app/controllers/checklists_controller.rb
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
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
|
||||
@checklist.checklist_entries.build
|
||||
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,
|
||||
checklist_entries_attributes: %i[id check_id position _destroy])
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue