Basic feature implemented, very basic poc
This commit is contained in:
parent
216089a3e7
commit
48c0067076
118 changed files with 2113 additions and 20 deletions
|
|
@ -6,9 +6,12 @@ class ApplicationController < ActionController::Base
|
|||
private
|
||||
|
||||
def initialize_navbar
|
||||
@nav_path = controller_name
|
||||
@navbar_items = [
|
||||
{ label: 'Dashboard', path: :root },
|
||||
{ label: 'Home', path: :home }
|
||||
{ label: 'Dashboard', icon: :speedometer2, path: :root },
|
||||
{ label: Report.model_name.human(count: 2), icon: :'journal-text', path: :reports },
|
||||
{ label: Checklist.model_name.human(count: 2), icon: :'list-check', path: :checklists },
|
||||
{ label: Check.model_name.human(count: 2), icon: :check, path: :checks }
|
||||
]
|
||||
@search_url = nil # root_url
|
||||
end
|
||||
|
|
|
|||
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
|
||||
80
app/controllers/checks_controller.rb
Normal file
80
app/controllers/checks_controller.rb
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
class ChecksController < ApplicationController
|
||||
before_action :set_check, only: %i[show edit update destroy]
|
||||
|
||||
# GET /checks or /checks.json
|
||||
def index
|
||||
@checks = Check.all
|
||||
end
|
||||
|
||||
# GET /checks/1 or /checks/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /checks/new
|
||||
def new
|
||||
@check = Check.new
|
||||
end
|
||||
|
||||
# GET /checks/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /checks or /checks.json
|
||||
def create
|
||||
@check = Check.new(check_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @check.save
|
||||
format.html do
|
||||
redirect_to check_url(@check),
|
||||
notice: t('scaffold.model_created_successfully', model: @check.model_name.human)
|
||||
end
|
||||
format.json { render :show, status: :created, location: @check }
|
||||
else
|
||||
flash[:alert] = t('there_were_errors', count: @check.errors.size)
|
||||
format.html { render :new, status: :unprocessable_entity }
|
||||
format.json { render json: @check.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /checks/1 or /checks/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @check.update(check_params)
|
||||
format.html do
|
||||
redirect_to check_url(@check),
|
||||
notice: t('scaffold.model_updated_successfully', model: @check.model_name.human)
|
||||
end
|
||||
format.json { render :show, status: :ok, location: @check }
|
||||
else
|
||||
format.html { render :edit, status: :unprocessable_entity }
|
||||
format.json { render json: @check.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /checks/1 or /checks/1.json
|
||||
def destroy
|
||||
@check.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
redirect_to checks_url, notice: t('scaffold.model_destroyed_successfully', model: @check.model_name.human)
|
||||
end
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_check
|
||||
@check = Check.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def check_params
|
||||
params.require(:check).permit(:position, :name, :success_criterion, :level)
|
||||
end
|
||||
end
|
||||
64
app/controllers/elements_controller.rb
Normal file
64
app/controllers/elements_controller.rb
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
class ElementsController < ApplicationController
|
||||
before_action :set_element, only: %i[show edit update destroy]
|
||||
|
||||
# GET /elements
|
||||
def index
|
||||
@elements = Element.all
|
||||
end
|
||||
|
||||
# GET /elements/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /elements/new
|
||||
def new
|
||||
@element = Element.new
|
||||
end
|
||||
|
||||
# GET /elements/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /elements
|
||||
def create
|
||||
checklist_id = element_params.delete(:checklist_id)
|
||||
checklist = Checklist.find(checklist_id)
|
||||
@element = Element.new(element_params.merge(title: checklist.name))
|
||||
|
||||
if @element.save
|
||||
checklist.checks.each do |check|
|
||||
@element.success_criteria.create!(title: check.name, description: check.success_criterion, level: check.level)
|
||||
end
|
||||
redirect_to [:work, @element.report], notice: 'Element was successfully created.'
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /elements/1
|
||||
def update
|
||||
if @element.update(element_params)
|
||||
redirect_to @element, notice: 'Element was successfully updated.', status: :see_other
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /elements/1
|
||||
def destroy
|
||||
@element.destroy!
|
||||
redirect_to elements_url, notice: 'Element was successfully destroyed.', status: :see_other
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_element
|
||||
@element = Element.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def element_params
|
||||
params.require(:element).permit(:report_id, :path, :title, :description, :checklist_id)
|
||||
end
|
||||
end
|
||||
63
app/controllers/reports_controller.rb
Normal file
63
app/controllers/reports_controller.rb
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
class ReportsController < ApplicationController
|
||||
before_action :set_report, only: %i[show edit update destroy work]
|
||||
|
||||
# GET /reports
|
||||
def index
|
||||
@reports = Report.all
|
||||
end
|
||||
|
||||
# GET /reports/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /reports/new
|
||||
def new
|
||||
@report = Report.new
|
||||
end
|
||||
|
||||
# GET /reports/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /reports
|
||||
def create
|
||||
@report = Report.new(report_params)
|
||||
|
||||
if @report.save
|
||||
redirect_to @report, notice: 'Report was successfully created.'
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /reports/1
|
||||
def update
|
||||
if @report.update(report_params)
|
||||
redirect_to @report, notice: 'Report was successfully updated.', status: :see_other
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /reports/1
|
||||
def destroy
|
||||
@report.destroy!
|
||||
redirect_to reports_url, notice: 'Report was successfully destroyed.', status: :see_other
|
||||
end
|
||||
|
||||
def work
|
||||
@report
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_report
|
||||
@report = Report.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def report_params
|
||||
params.require(:report).permit(:name, :comment)
|
||||
end
|
||||
end
|
||||
58
app/controllers/success_criteria_controller.rb
Normal file
58
app/controllers/success_criteria_controller.rb
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
class SuccessCriteriaController < ApplicationController
|
||||
before_action :set_success_criterion, only: %i[ show edit update destroy ]
|
||||
|
||||
# GET /success_criteria
|
||||
def index
|
||||
@success_criteria = SuccessCriterion.all
|
||||
end
|
||||
|
||||
# GET /success_criteria/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /success_criteria/new
|
||||
def new
|
||||
@success_criterion = SuccessCriterion.new
|
||||
end
|
||||
|
||||
# GET /success_criteria/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /success_criteria
|
||||
def create
|
||||
@success_criterion = SuccessCriterion.new(success_criterion_params)
|
||||
|
||||
if @success_criterion.save
|
||||
redirect_to @success_criterion, notice: "Success criterion was successfully created."
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /success_criteria/1
|
||||
def update
|
||||
if @success_criterion.update(success_criterion_params)
|
||||
redirect_to @success_criterion, notice: "Success criterion was successfully updated.", status: :see_other
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /success_criteria/1
|
||||
def destroy
|
||||
@success_criterion.destroy!
|
||||
redirect_to success_criteria_url, notice: "Success criterion was successfully destroyed.", status: :see_other
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_success_criterion
|
||||
@success_criterion = SuccessCriterion.find(params[:id])
|
||||
end
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def success_criterion_params
|
||||
params.require(:success_criterion).permit(:element_id, :title, :description, :level, :result, :comment)
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue