Basic feature implemented, very basic poc

This commit is contained in:
David Schärer 2024-07-16 20:22:59 +02:00
parent 216089a3e7
commit 48c0067076
118 changed files with 2113 additions and 20 deletions

15
.irbrc_history Normal file
View file

@ -0,0 +1,15 @@
Check.last
Check.find(5)
exit
Element.delete_all
Element.delete_all
SuccessCriteria.all
SuccessCriterion.all
Element.delete_all
Element.destroy_all
Element.all
Element.all
Element.find(5)
Report.destroy_all
Report.all
exit

View file

@ -4,6 +4,7 @@ require:
AllCops:
Exclude:
- '.bundle/**/*.rb'
- 'config/**/*.rb'
- 'db/**/*.rb'
- 'vendor/**/*.rb'

View file

@ -48,6 +48,7 @@ gem 'bootsnap', require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"
gem 'bootstrap_form'
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem

View file

@ -83,6 +83,9 @@ GEM
bindex (0.8.1)
bootsnap (1.18.3)
msgpack (~> 1.2)
bootstrap_form (5.4.0)
actionpack (>= 6.1)
activemodel (>= 6.1)
builder (3.3.0)
capybara (3.40.0)
addressable
@ -301,6 +304,7 @@ PLATFORMS
DEPENDENCIES
bootsnap
bootstrap_form
capybara
cssbundling-rails
debug

View file

@ -24,8 +24,8 @@ $font-family-sans-serif:
// Emoji fonts
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default;
$primary: #0074d9;
$danger: #ff4136;
@import 'bootstrap/scss/bootstrap';
@import 'bootstrap-icons/font/bootstrap-icons';
@import "rails_bootstrap_forms.css";
@import "./layout.scss";

View file

@ -0,0 +1,14 @@
.action-row {
@extend .d-flex;
@extend .p-2;
@extend .mt-3;
// background-color: map-get($theme-colors, "primary");
background-color: var(--bs-tertiary-bg);
background-color: var(--bs-secondary-bg);
* {
@extend .me-2;
@extend .my-auto;
}
}

View file

@ -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

View 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

View 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

View 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

View 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

View 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

View file

@ -0,0 +1,2 @@
module ChecklistsHelper
end

View file

@ -0,0 +1,2 @@
module ChecksHelper
end

View file

@ -0,0 +1,2 @@
module ElementsHelper
end

View file

@ -0,0 +1,2 @@
module ReportsHelper
end

View file

@ -0,0 +1,2 @@
module SuccessCriteriaHelper
end

View file

@ -9,3 +9,6 @@ application.register("hello", HelloController)
import SetThemeController from "./set_theme_controller"
application.register("set-theme", SetThemeController)
import ThemeSwitcherController from "./theme_switcher_controller"
application.register("theme-switcher", ThemeSwitcherController)

View file

@ -0,0 +1,28 @@
import { Controller } from "@hotwired/stimulus"
import Cookie from "../lib/cookies"
// Connects to data-controller="theme-switcher"
export default class extends Controller {
COOKIE_NAME = "modeTheme"
connect() {
console.log("connect switcher")
}
switch() {
const cookieValue = Cookie.get(this.COOKIE_NAME);
const newThemeValue = cookieValue == "dark" ? "light" : "dark";
Cookie.set("modeTheme", newThemeValue);
window.document.getElementsByTagName("html")[0].setAttribute("data-bs-theme", newThemeValue);
const icon = this.element.getElementsByTagName("i")[0];
if(newThemeValue == "dark") {
icon.classList.remove("bi-sun-fill")
icon.classList.add("bi-moon-stars-fill")
} else {
icon.classList.add("bi-sun-fill")
icon.classList.remove("bi-moon-stars-fill")
}
}
}

5
app/models/check.rb Normal file
View file

@ -0,0 +1,5 @@
class Check < ApplicationRecord
enum :level, %i[A AA AAA]
validates :position, :name, :success_criterion, :level, presence: true
validates :position, numericality: { less_than: 200 }
end

6
app/models/checklist.rb Normal file
View file

@ -0,0 +1,6 @@
class Checklist < ApplicationRecord
has_many :checklist_entries, -> { order(position: :asc) }, dependent: :destroy, inverse_of: :checklist
has_many :checks, through: :checklist_entries
accepts_nested_attributes_for :checklist_entries
end

View file

@ -0,0 +1,4 @@
class ChecklistEntry < ApplicationRecord
belongs_to :checklist
belongs_to :check
end

6
app/models/element.rb Normal file
View file

@ -0,0 +1,6 @@
class Element < ApplicationRecord
attr_accessor :checklist_id
belongs_to :report
has_many :success_criteria, dependent: :destroy
end

3
app/models/report.rb Normal file
View file

@ -0,0 +1,3 @@
class Report < ApplicationRecord
has_many :elements, dependent: :destroy
end

View file

@ -0,0 +1,4 @@
class SuccessCriterion < ApplicationRecord
enum :result, %i[passed failed not_applicable]
belongs_to :element
end

View file

@ -0,0 +1,28 @@
<div id="<%= dom_id checklist %>">
<p>
<strong>Code:</strong>
<%= checklist.code %>
</p>
<p>
<strong>Name:</strong>
<%= checklist.name %>
</p>
<p>
<strong>Description:</strong>
<%= checklist.description %>
</p>
<p>
<strong>Checks</strong>
<ul>
<% checklist.checklist_entries.each do |entry| %>
<li>
<%= entry.position %> <%= entry.check.name %>
</li>
<% end %>
</ul>
</p>
</div>

View file

@ -0,0 +1,2 @@
json.extract! checklist, :id, :code, :name, :description, :created_at, :updated_at
json.url checklist_url(checklist, format: :json)

View file

@ -0,0 +1,13 @@
<%= bootstrap_form_with(model: checklist) do |form| %>
<%= form.text_field :code %>
<%= form.text_field :name %>
<%= form.text_area :description %>
<h2>Checks</h2>
<% checklist.checklist_entries.each do |entry| %>
<%= form.fields_for(:checklist_entries, entry) do |eform| %>
<%= eform.number_field :position %>
<%= eform.collection_select :check_id, Check.all, :id, :name %>
<% end %>
<% end %>
<%= form.submit %>
<% end %>

View file

@ -0,0 +1,8 @@
<h1><%= t("scaffold.pagetitle_edit", model: Checklist.model_name.human) %></h1>
<%= render "form", checklist: @checklist %>
<div class="action-row">
<%= link_to t("scaffold.link_show", model: Checklist.model_name.human), @checklist %>
<%= link_to t("scaffold.link_index", model: Checklist.model_name.human(count: 2)), checklists_path %>
</div>

View file

@ -0,0 +1,33 @@
<h1><%= t("scaffold.pagetitle_index", model: Checklist.model_name.human(count: 2)) %></h1>
<table class="table table-striped">
<thead>
<tr>
<th><%= Checklist.human_attribute_name(:id) %></th>
<th><%= Checklist.human_attribute_name(:code) %></th>
<th><%= Checklist.human_attribute_name(:name) %></th>
<th><%= Checklist.human_attribute_name(:description) %></th>
</thead>
<tbody>
<% @checklists.each do |checklist| %>
<tr>
<td><%= link_to(checklist.id, url_for(checklist)) %></td>
<td><%= link_to(checklist.code, url_for(checklist)) %></td>
<td><%= link_to(checklist.name, url_for(checklist)) %></td>
<td><%= link_to(checklist.description, url_for(checklist)) %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="action-row">
<%= link_to t("scaffold.link_new", model: Checklist.model_name.human), new_checklist_path %>
</div>

View file

@ -0,0 +1 @@
json.array! @checklists, partial: "checklists/checklist", as: :checklist

View file

@ -0,0 +1,7 @@
<h1><%= t("scaffold.pagetitle_new", model: Checklist.model_name.human) %></h1>
<%= render "form", checklist: @checklist %>
<div class="action-row">
<%= link_to t("scaffold.link_index", model: Checklist.model_name.human(count: 2)), checklists_path %>
</div>

View file

@ -0,0 +1,9 @@
<h1><%= t("scaffold.pagetitle_show", model: @checklist.class.model_name.human) %></h1>
<%= render @checklist %>
<div class="action-row">
<%= link_to t("scaffold.link_edit", model: @checklist.model_name.human), edit_checklist_path(@checklist) %>
<%= link_to t("scaffold.link_index", model: @checklist.model_name.human(count: 2)), checklists_path %>
<%= button_to t("scaffold.link_destroy", model: @checklist.model_name.human), @checklist, method: :delete, class: "btn btn-warning" %>
</div>

View file

@ -0,0 +1 @@
json.partial! "checklists/checklist", checklist: @checklist

View file

@ -0,0 +1,22 @@
<div id="<%= dom_id check %>">
<p>
<strong><%= Check.human_attribute_name(:position) %>:</strong>
<%= check.position %>
</p>
<p>
<strong><%= Check.human_attribute_name(:name) %>:</strong>
<%= check.name %>
</p>
<p>
<strong><%= Check.human_attribute_name(:success_criterion) %>:</strong>
<%= check.success_criterion %>
</p>
<p>
<strong><%= Check.human_attribute_name(:level) %>:</strong>
<%= check.level %>
</p>
</div>

View file

@ -0,0 +1,2 @@
json.extract! check, :id, :position, :name, :success_criterion, :level, :created_at, :updated_at
json.url check_url(check, format: :json)

View file

@ -0,0 +1,7 @@
<%= bootstrap_form_with(model: check, remote: true) do |form| %>
<%= form.text_field :position %>
<%= form.text_field :name %>
<%= form.text_area :success_criterion %>
<%= form.select :level, Check.levels.keys, add_blank: !form.object.level.present? %>
<%= form.submit %>
<% end %>

View file

@ -0,0 +1,10 @@
<h1><%= t("scaffold.pagetitle_edit", model: @check.class.model_name.human) %></h1>
<%= render "form", check: @check %>
<br>
<div class="action-row">
<%= link_to t("scaffold.link_show", model: @check.class.model_name.human), @check %>
<%= link_to t("scaffold.link_index", model: @check.class.model_name.human(count: 2)), checks_path %>
</div>

View file

@ -0,0 +1,25 @@
<h1><%= t("scaffold.pagetitle_index", model: Check.model_name.human(count: 2)) %></h1>
<table class="table table-striped">
<thead>
<tr>
<th><%= Check.human_attribute_name(:id) %></th>
<th><%= Check.human_attribute_name(:level) %></th>
<th><%= Check.human_attribute_name(:name) %></th>
<th><%= Check.human_attribute_name(:success_criterion) %></th>
</thead>
<tbody>
<% @checks.each do |check| %>
<tr>
<td><%= check.id %></td>
<td><%= check.level %></td>
<td><%= link_to(check.name, url_for(check)) %></td>
<td><%= link_to(truncate(check.success_criterion), url_for(check)) %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="action-row">
<%= link_to t("scaffold.link_new", model: Check.model_name.human), new_check_path %>
</div>

View file

@ -0,0 +1 @@
json.array! @checks, partial: "checks/check", as: :check

View file

@ -0,0 +1,7 @@
<h1><%= t("scaffold.pagetitle_new", model: @check.class.model_name.human) %></h1>
<%= render "form", check: @check %>
<div class="action-row">
<%= link_to t("scaffold.link_index", model: Check.model_name.human(count: 2)), checks_path %>
</div>

View file

@ -0,0 +1,9 @@
<h1><%= t("scaffold.pagetitle_show", model: @check.class.model_name.human) %></h1>
<%= render @check %>
<div class="action-row">
<%= link_to t("scaffold.link_edit", model: @check.model_name.human), edit_check_path(@check) %>
<%= link_to t("scaffold.link_index", model: @check.model_name.human(count: 2)), checks_path %>
<%= button_to t("scaffold.link_destroy", model: @check.model_name.human), @check, method: :delete, class: "btn btn-warning" %>
</div>

View file

@ -0,0 +1 @@
json.partial! "checks/check", check: @check

View file

@ -0,0 +1,12 @@
<div id="<%= dom_id element %>" class="mt-3">
<h2><i class="bi bi-card-checklist me-2"></i>
<%= element.title %></h2>
<p>
<strong>Path:</strong>
<%= element.path %>
</p>
<% element.success_criteria.each do |sc| %>
<%= render sc %>
<% end %>
</div>

View file

@ -0,0 +1,2 @@
json.extract! element, :id, :report_id, :path, :title, :description, :created_at, :updated_at
json.url element_url(element, format: :json)

View file

@ -0,0 +1,7 @@
<%= bootstrap_form_with(model: element) do |form| %>
<%= form.text_field :report_id %>
<%= form.text_field :path %>
<%= form.text_field :title %>
<%= form.text_area :description %>
<%= form.submit %>
<% end %>

View file

@ -0,0 +1,8 @@
<h1><%= t("scaffold.pagetitle_edit", model: Element.model_name.human) %></h1>
<%= render "form", element: @element %>
<div class="action-row">
<%= link_to t("scaffold.link_show", model: Element.model_name.human), @element %>
<%= link_to t("scaffold.link_index", model: Element.model_name.human(count: 2)), elements_path %>
</div>

View file

@ -0,0 +1,37 @@
<h1><%= t("scaffold.pagetitle_index", model: Element.model_name.human(count: 2)) %></h1>
<table class="table table-striped">
<thead>
<tr>
<th><%= Element.human_attribute_name(:id) %></th>
<th><%= Element.human_attribute_name(:report_id) %></th>
<th><%= Element.human_attribute_name(:path) %></th>
<th><%= Element.human_attribute_name(:title) %></th>
<th><%= Element.human_attribute_name(:description) %></th>
</thead>
<tbody>
<% @elements.each do |element| %>
<tr>
<td><%= link_to(element.id, url_for(element)) %></td>
<td><%= link_to(element.report_id, url_for(element)) %></td>
<td><%= link_to(element.path, url_for(element)) %></td>
<td><%= link_to(element.title, url_for(element)) %></td>
<td><%= link_to(element.description, url_for(element)) %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="action-row">
<%= link_to t("scaffold.link_new", model: Element.model_name.human), new_element_path %>
</div>

View file

@ -0,0 +1 @@
json.array! @elements, partial: "elements/element", as: :element

View file

@ -0,0 +1,7 @@
<h1><%= t("scaffold.pagetitle_new", model: Element.model_name.human) %></h1>
<%= render "form", element: @element %>
<div class="action-row">
<%= link_to t("scaffold.link_index", model: Element.model_name.human(count: 2)), elements_path %>
</div>

View file

@ -0,0 +1,9 @@
<h1><%= t("scaffold.pagetitle_show", model: @element.class.model_name.human) %></h1>
<%= render @element %>
<div class="action-row">
<%= link_to t("scaffold.link_edit", model: @element.model_name.human), edit_element_path(@element) %>
<%= link_to t("scaffold.link_index", model: @element.model_name.human(count: 2)), elements_path %>
<%= button_to t("scaffold.link_destroy", model: @element.model_name.human), @element, method: :delete, class: "btn btn-warning" %>
</div>

View file

@ -0,0 +1 @@
json.partial! "elements/element", element: @element

View file

@ -1,3 +1,17 @@
<h1>Welcome</h1>
<p>Find me in app/views/home/show.html.erb</p>
<button class="btn btn-primary">Test</button>
<h1>Dashboard</h1>
<h2>Data</h2>
<p>
<i class="bi bi-journal-text"></i>
<%= Report.count %>
<%= link_to Report.model_name.human(count: Report.count), :reports %>
</p>
<p>
<i class="bi bi-list-check"></i>
<%= Checklist.count %>
<%= link_to Checklist.model_name.human(count: Checklist.count), :checklists %>
</p>
<p>
<i class="bi bi-check"></i>
<%= Check.count %>
<%= link_to Check.model_name.human(count: Check.count), :checks %>
</p>

View file

@ -0,0 +1,16 @@
<% if flash[:alert] || flash[:notice] %>
<div class="container mt-3 mb-3">
<% if flash[:alert] %>
<div class="alert alert-danger" role="alert">
<%= flash[:alert] %><% flash.delete(:alert) %>
</div>
<% end %>
<% if flash[:notice] %>
<div class="alert alert-info" role="alert">
<%= flash[:notice] %>
<% flash.delete(:notice) %>
</div>
<% end %>
</div>
<% end %>

View file

@ -9,7 +9,12 @@
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<% @navbar_items.each do |navbar_item| %>
<li class="nav-item">
<a class="nav-link <%= current_page?(navbar_item[:path]) && "active" %>" <%= current_page?(navbar_item[:path]) && "aria-current=\"page\"" %> href="<%= url_for(navbar_item[:path]) %>"><%= navbar_item[:label] %></a>
<a class="nav-link <%= @nav_path.to_s == navbar_item[:path].to_s && "active" %>" <%= @nav_path.to_s == navbar_item[:path].to_s && "aria-current=\"page\"" %> href="<%= url_for(navbar_item[:path]) %>">
<% if navbar_item[:icon] %>
<span aria-hidden="true" class="bi-<%= navbar_item[:icon] %>"></span>
<% end %>
<%= navbar_item[:label] %>
</a>
</li>
<% end %>
<%# <li class="nav-item">
@ -39,6 +44,19 @@
<button class="btn btn-outline-success" type="submit" name="<%= @search_name || "q" %>"><%= @search_placeholder || "Suchen" %></button>
</form>
<% end %>
<ul class="navbar-nav flex-row flex-wrap ms-md-auto">
<li class="nav-item">
<button class="btn btn-link nav-link py-2 px-0 px-lg-2 d-flex align-items-center"
data-controller="theme-switcher"
data-action="theme-switcher#switch"
id="bd-theme"
type="button"
data-bs-display="static"
aria-label="Toggle theme (auto)">
<i class="bi <%= cookies[:modeTheme] == "dark" ? "bi-moon-stars-fill" : "bi-sun-fill" %> my-1"></i>
</button>
</li>
</ul>
</div>
</div>
</nav>

View file

@ -12,13 +12,11 @@
</head>
<body class="">
<%= render partial: "layouts/sidebar" %>
<%= render partial: "layouts/navigation" %>
<main class="">
<%= render partial: "layouts/sidebar" %>
<div class="p-3">
<%= yield %>
</div>
<%= render partial: "layouts/flash" %>
<main class="p-3">
<%= yield %>
</main>
</body>
</html>

View file

@ -0,0 +1,5 @@
<%= bootstrap_form_with(model: report) do |form| %>
<%= form.text_field :name %>
<%= form.text_area :comment %>
<%= form.submit %>
<% end %>

View file

@ -0,0 +1,12 @@
<div id="<%= dom_id report %>">
<p>
<strong>Name:</strong>
<%= report.name %>
</p>
<p>
<strong>Comment:</strong>
<%= report.comment %>
</p>
</div>

View file

@ -0,0 +1,2 @@
json.extract! report, :id, :name, :comment, :created_at, :updated_at
json.url report_url(report, format: :json)

View file

@ -0,0 +1,8 @@
<h1><%= t("scaffold.pagetitle_edit", model: Report.model_name.human) %></h1>
<%= render "form", report: @report %>
<div class="action-row">
<%= link_to t("scaffold.link_show", model: Report.model_name.human), @report %>
<%= link_to t("scaffold.link_index", model: Report.model_name.human(count: 2)), reports_path %>
</div>

View file

@ -0,0 +1,29 @@
<h1><%= t("scaffold.pagetitle_index", model: Report.model_name.human(count: 2)) %></h1>
<table class="table table-striped">
<thead>
<tr>
<th><%= Report.human_attribute_name(:id) %></th>
<th><%= Report.human_attribute_name(:name) %></th>
<th><%= Report.human_attribute_name(:comment) %></th>
</thead>
<tbody>
<% @reports.each do |report| %>
<tr>
<td><%= link_to(report.id, url_for([:work, report])) %></td>
<td><%= link_to(report.name, url_for([:work, report])) %></td>
<td><%= link_to(report.comment, url_for([:work, report])) %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="action-row">
<%= link_to t("scaffold.link_new", model: Report.model_name.human), new_report_path %>
</div>

View file

@ -0,0 +1 @@
json.array! @reports, partial: "reports/report", as: :report

View file

@ -0,0 +1,7 @@
<h1><%= t("scaffold.pagetitle_new", model: Report.model_name.human) %></h1>
<%= render "form", report: @report %>
<div class="action-row">
<%= link_to t("scaffold.link_index", model: Report.model_name.human(count: 2)), reports_path %>
</div>

View file

@ -0,0 +1,9 @@
<h1><%= t("scaffold.pagetitle_show", model: @report.class.model_name.human) %></h1>
<%= render @report %>
<div class="action-row">
<%= link_to t("scaffold.link_edit", model: @report.model_name.human), edit_report_path(@report) %>
<%= link_to t("scaffold.link_index", model: @report.model_name.human(count: 2)), reports_path %>
<%= button_to t("scaffold.link_destroy", model: @report.model_name.human), @report, method: :delete, class: "btn btn-warning" %>
</div>

View file

@ -0,0 +1 @@
json.partial! "reports/report", report: @report

View file

@ -0,0 +1,21 @@
<div class="container">
<h1><i class="bi bi-journal-text me-2"></i><%= @report.name %></h1>
<% @report.elements.each do |element| %>
<%= render element %>
<% end %>
<hr>
<h2><i class="bi bi-plus"></i>Element hinzufügen</h2>
<%= bootstrap_form_with(model: @report.elements.build, layout: :horizontal) do |form| %>
<%= form.collection_select(:checklist_id, Checklist.all, :id, :name) %>
<%= form.hidden_field :report_id %>
<%= form.text_field :path %>
<%= form.submit %>
<% end %>
<div class="action-row">
<%= link_to t("scaffold.link_edit", model: @report.model_name.human), edit_report_path(@report) %>
<%= link_to t("scaffold.link_index", model: @report.model_name.human(count: 2)), reports_path %>
<%= button_to t("scaffold.link_destroy", model: @report.model_name.human), @report, method: :delete, class: "btn btn-warning" %>
</div>
</div>

View file

@ -0,0 +1,9 @@
<%= bootstrap_form_with(model: success_criterion) do |form| %>
<%= form.text_field :element_id %>
<%= form.text_field :title %>
<%= form.text_area :description %>
<%= form.number_field :level %>
<%= form.number_field :result %>
<%= form.text_area :comment %>
<%= form.submit %>
<% end %>

View file

@ -0,0 +1,15 @@
<div id="<%= dom_id success_criterion %>" class="card mt-3">
<div class="card-header">
<h3><i class="bi bi-check me-2"></i><%= success_criterion.title %></h3>
</div>
<div class="card-body">
<p>
<%= success_criterion.description %>
</p>
<%= bootstrap_form_with(model: success_criterion, layout: :horizontal) do |form| %>
<%= form.select :result, SuccessCriterion.results, include_blank: true %>
<%= form.text_area :comment %>
<%= form.submit(class: "btn btn-secondary") %>
<% end %>
</div>
</div>

View file

@ -0,0 +1,2 @@
json.extract! success_criterion, :id, :element_id, :title, :description, :level, :result, :comment, :created_at, :updated_at
json.url success_criterion_url(success_criterion, format: :json)

View file

@ -0,0 +1,8 @@
<h1><%= t("scaffold.pagetitle_edit", model: SuccessCriterion.model_name.human) %></h1>
<%= render "form", success_criterion: @success_criterion %>
<div class="action-row">
<%= link_to t("scaffold.link_show", model: SuccessCriterion.model_name.human), @success_criterion %>
<%= link_to t("scaffold.link_index", model: SuccessCriterion.model_name.human(count: 2)), success_criteria_path %>
</div>

View file

@ -0,0 +1,45 @@
<h1><%= t("scaffold.pagetitle_index", model: SuccessCriterion.model_name.human(count: 2)) %></h1>
<table class="table table-striped">
<thead>
<tr>
<th><%= SuccessCriterion.human_attribute_name(:id) %></th>
<th><%= SuccessCriterion.human_attribute_name(:element_id) %></th>
<th><%= SuccessCriterion.human_attribute_name(:title) %></th>
<th><%= SuccessCriterion.human_attribute_name(:description) %></th>
<th><%= SuccessCriterion.human_attribute_name(:level) %></th>
<th><%= SuccessCriterion.human_attribute_name(:result) %></th>
<th><%= SuccessCriterion.human_attribute_name(:comment) %></th>
</thead>
<tbody>
<% @success_criteria.each do |success_criterion| %>
<tr>
<td><%= link_to(success_criterion.id, url_for(success_criterion)) %></td>
<td><%= link_to(success_criterion.element_id, url_for(success_criterion)) %></td>
<td><%= link_to(success_criterion.title, url_for(success_criterion)) %></td>
<td><%= link_to(success_criterion.description, url_for(success_criterion)) %></td>
<td><%= link_to(success_criterion.level, url_for(success_criterion)) %></td>
<td><%= link_to(success_criterion.result, url_for(success_criterion)) %></td>
<td><%= link_to(success_criterion.comment, url_for(success_criterion)) %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="action-row">
<%= link_to t("scaffold.link_new", model: SuccessCriterion.model_name.human), new_success_criterion_path %>
</div>

View file

@ -0,0 +1 @@
json.array! @success_criteria, partial: "success_criteria/success_criterion", as: :success_criterion

View file

@ -0,0 +1,7 @@
<h1><%= t("scaffold.pagetitle_new", model: SuccessCriterion.model_name.human) %></h1>
<%= render "form", success_criterion: @success_criterion %>
<div class="action-row">
<%= link_to t("scaffold.link_index", model: SuccessCriterion.model_name.human(count: 2)), success_criteria_path %>
</div>

View file

@ -0,0 +1,9 @@
<h1><%= t("scaffold.pagetitle_show", model: @success_criterion.class.model_name.human) %></h1>
<%= render @success_criterion %>
<div class="action-row">
<%= link_to t("scaffold.link_edit", model: @success_criterion.model_name.human), edit_success_criterion_path(@success_criterion) %>
<%= link_to t("scaffold.link_index", model: @success_criterion.model_name.human(count: 2)), success_criteria_path %>
<%= button_to t("scaffold.link_destroy", model: @success_criterion.model_name.human), @success_criterion, method: :delete, class: "btn btn-warning" %>
</div>

View file

@ -0,0 +1 @@
json.partial! "success_criteria/success_criterion", success_criterion: @success_criterion

View file

@ -73,4 +73,6 @@ Rails.application.configure do
# Raise error when a before_action's only/except options reference missing actions
config.action_controller.raise_on_missing_callback_actions = true
config.web_console.permissions = ['192.168.0.0/16', '10.10.0.0/16']
end

View file

@ -11,6 +11,6 @@
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym "RESTful"
# end
ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.irregular "criterion", "criteria"
end

View file

@ -0,0 +1,9 @@
# Where the I18n library should search for translation files
# I18n.load_path += Dir[Rails.root.join('lib', 'locale', '*.{rb,yml}')]
# Permitted locales available for the application
I18n.available_locales = [:"de-CH"]
# Set default locale to something other than :en
I18n.default_locale = :"de-CH"

View file

@ -0,0 +1,18 @@
de-CH:
activerecord:
attributes:
check:
id: ID
level: Stufe
position: Position
success_criterion: Erfolgskriterium
models:
check:
one: Check
other: Checks
checklist:
one: Checkliste
other: Checklisten
report:
one: Prüfbericht
other: Prüfberichte

222
config/locales/de-CH.yml Normal file
View file

@ -0,0 +1,222 @@
---
de-CH:
activerecord:
errors:
messages:
record_invalid: 'Gültigkeitsprüfung ist fehlgeschlagen: %{errors}'
restrict_dependent_destroy:
has_one: Datensatz kann nicht gelöscht werden, da ein abhängiger %{record}-Datensatz
existiert.
has_many: Datensatz kann nicht gelöscht werden, da abhängige %{record} existieren.
date:
abbr_day_names:
- So
- Mo
- Di
- Mi
- Do
- Fr
- Sa
abbr_month_names:
-
- Jan
- Feb
- Mär
- Apr
- Mai
- Jun
- Jul
- Aug
- Sep
- Okt
- Nov
- Dez
day_names:
- Sonntag
- Montag
- Dienstag
- Mittwoch
- Donnerstag
- Freitag
- Samstag
formats:
default: "%d.%m.%Y"
long: "%e. %B %Y"
short: "%e. %b"
month_names:
-
- Januar
- Februar
- März
- April
- Mai
- Juni
- Juli
- August
- September
- Oktober
- November
- Dezember
order:
- :day
- :month
- :year
datetime:
distance_in_words:
about_x_hours:
one: etwa eine Stunde
other: etwa %{count} Stunden
about_x_months:
one: etwa ein Monat
other: etwa %{count} Monate
about_x_years:
one: etwa ein Jahr
other: etwa %{count} Jahre
almost_x_years:
one: fast ein Jahr
other: fast %{count} Jahre
half_a_minute: eine halbe Minute
less_than_x_seconds:
one: weniger als eine Sekunde
other: weniger als %{count} Sekunden
less_than_x_minutes:
one: weniger als eine Minute
other: weniger als %{count} Minuten
over_x_years:
one: mehr als ein Jahr
other: mehr als %{count} Jahre
x_seconds:
one: eine Sekunde
other: "%{count} Sekunden"
x_minutes:
one: eine Minute
other: "%{count} Minuten"
x_days:
one: ein Tag
other: "%{count} Tage"
x_months:
one: ein Monat
other: "%{count} Monate"
prompts:
second: Sekunde
minute: Minute
hour: Stunde
day: Tag
month: Monat
year: Jahr
errors:
format: "%{attribute} %{message}"
messages:
accepted: muss akzeptiert werden
blank: muss ausgefüllt werden
confirmation: stimmt nicht mit %{attribute} überein
empty: muss ausgefüllt werden
equal_to: muss genau %{count} sein
even: muss gerade sein
exclusion: ist nicht verfügbar
greater_than: muss grösser als %{count} sein
greater_than_or_equal_to: muss grösser oder gleich %{count} sein
inclusion: ist kein gültiger Wert
invalid: ist nicht gültig
less_than: muss kleiner als %{count} sein
less_than_or_equal_to: muss kleiner oder gleich %{count} sein
model_invalid: 'Gültigkeitsprüfung ist fehlgeschlagen: %{errors}'
not_a_number: ist keine Zahl
not_an_integer: muss ganzzahlig sein
odd: muss ungerade sein
other_than: darf nicht gleich %{count} sein
present: darf nicht ausgefüllt werden
required: muss ausgefüllt werden
taken: ist bereits vergeben
too_long:
one: ist zu lang (mehr als %{count} Zeichen)
other: ist zu lang (mehr als %{count} Zeichen)
too_short:
one: ist zu kurz (weniger als %{count} Zeichen)
other: ist zu kurz (weniger als %{count} Zeichen)
wrong_length:
one: hat die falsche Länge (muss genau %{count} Zeichen haben)
other: hat die falsche Länge (muss genau %{count} Zeichen haben)
template:
body: 'Bitte überprüfen Sie die folgenden Felder:'
header:
one: 'Konnte %{model} nicht speichern: ein Fehler.'
other: 'Konnte %{model} nicht speichern: %{count} Fehler.'
helpers:
select:
prompt: Bitte wählen
submit:
create: "%{model} erstellen"
submit: "%{model} speichern"
update: "%{model} aktualisieren"
number:
currency:
format:
delimiter: "'"
format: "%u %n"
precision: 2
separator: "."
significant: false
strip_insignificant_zeros: false
unit: CHF
format:
delimiter: "'"
precision: 2
round_mode: default
separator: "."
significant: false
strip_insignificant_zeros: false
human:
decimal_units:
format: "%n %u"
units:
billion:
one: Milliarde
other: Milliarden
million:
one: Million
other: Millionen
quadrillion:
one: Billiarde
other: Billiarden
thousand: Tausend
trillion:
one: Billion
other: Billionen
unit: ''
format:
delimiter: ''
precision: 1
significant: true
strip_insignificant_zeros: true
storage_units:
format: "%n %u"
units:
byte:
one: Byte
other: Bytes
eb: EB
gb: GB
kb: KB
mb: MB
pb: PB
tb: TB
percentage:
format:
delimiter: ''
format: "%n%"
precision:
format:
delimiter: ''
support:
array:
last_word_connector: " und "
two_words_connector: " und "
words_connector: ", "
time:
am: vormittags
formats:
default: "%A, %d. %B %Y, %H:%M Uhr"
long: "%A, %d. %B %Y, %H:%M Uhr"
short: "%d. %b, %H:%M Uhr"
pm: nachmittags

View file

@ -27,5 +27,21 @@
# "yes": yup
# enabled: "ON"
en:
hello: "Hello world"
de-CH:
scaffold:
model_saved_successfully: "%{model} wurde erfolgreich gespeichert."
model_updated_successfully: "%{model} wurde erfolgreich aktualisiert."
model_created_successfully: "%{model} wurde erfolgreich erstellt."
model_destroyed_successfully: "%{model} wurde erfolgreich gelöscht."
there_were_errors:
one: "Beim Speichern ist ein Fehler aufgetreten."
other: "Beim Speichern sind %{count} Fehler aufgetreten."
pagetitle_new: "%{model} hinzufügen"
pagetitle_show: "%{model} anzeigen"
pagetitle_edit: "%{model} bearbeiten"
pagetitle_index: "%{model}"
link_new: "%{model} hinzufügen"
link_show: "%{model} anzeigen"
link_edit: "%{model} bearbeiten"
link_destroy: "%{model} löschen"
link_index: "%{model} Liste"

View file

@ -1,4 +1,13 @@
Rails.application.routes.draw do
resources :success_criteria
resources :elements
resources :reports do
member do
get :work
end
end
resources :checklists
resources :checks
get 'home/show', as: :home
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html

View file

@ -0,0 +1,12 @@
class CreateChecks < ActiveRecord::Migration[7.1]
def change
create_table :checks do |t|
t.string :position
t.string :name
t.text :success_criterion
t.integer :level
t.timestamps
end
end
end

View file

@ -0,0 +1,11 @@
class CreateChecklists < ActiveRecord::Migration[7.1]
def change
create_table :checklists do |t|
t.string :code
t.string :name
t.text :description
t.timestamps
end
end
end

View file

@ -0,0 +1,11 @@
class CreateChecklistEntries < ActiveRecord::Migration[7.1]
def change
create_table :checklist_entries do |t|
t.references :checklist, null: false, foreign_key: true
t.references :check, null: false, foreign_key: true
t.integer :position
t.timestamps
end
end
end

View file

@ -0,0 +1,10 @@
class CreateReports < ActiveRecord::Migration[7.1]
def change
create_table :reports do |t|
t.string :name
t.text :comment
t.timestamps
end
end
end

View file

@ -0,0 +1,12 @@
class CreateElements < ActiveRecord::Migration[7.1]
def change
create_table :elements do |t|
t.references :report, null: false, foreign_key: true
t.string :path
t.string :title
t.text :description
t.timestamps
end
end
end

View file

@ -0,0 +1,14 @@
class CreateSuccessCriteria < ActiveRecord::Migration[7.1]
def change
create_table :success_criteria do |t|
t.references :element, null: false, foreign_key: true
t.string :title
t.text :description
t.integer :level
t.integer :result
t.text :comment
t.timestamps
end
end
end

74
db/schema.rb generated Normal file
View file

@ -0,0 +1,74 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.1].define(version: 2024_07_15_211614) do
create_table "checklist_entries", force: :cascade do |t|
t.integer "checklist_id", null: false
t.integer "check_id", null: false
t.integer "position"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["check_id"], name: "index_checklist_entries_on_check_id"
t.index ["checklist_id"], name: "index_checklist_entries_on_checklist_id"
end
create_table "checklists", force: :cascade do |t|
t.string "code"
t.string "name"
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "checks", force: :cascade do |t|
t.string "position"
t.string "name"
t.text "success_criterion"
t.integer "level"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "elements", force: :cascade do |t|
t.integer "report_id", null: false
t.string "path"
t.string "title"
t.text "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["report_id"], name: "index_elements_on_report_id"
end
create_table "reports", force: :cascade do |t|
t.string "name"
t.text "comment"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "success_criteria", force: :cascade do |t|
t.integer "element_id", null: false
t.string "title"
t.text "description"
t.integer "level"
t.integer "result"
t.text "comment"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["element_id"], name: "index_success_criteria_on_element_id"
end
add_foreign_key "checklist_entries", "checklists"
add_foreign_key "checklist_entries", "checks"
add_foreign_key "elements", "reports"
add_foreign_key "success_criteria", "elements"
end

View file

@ -0,0 +1,13 @@
<%%= bootstrap_form_with(model: <%= model_resource_name %>) do |form| %>
<% attributes.each do |attribute| -%>
<% if attribute.password_digest? -%>
<%%= form.password_field :password %>
<%%= form.password_field :password_confirmation %>
<% elsif attribute.attachments? -%>
<%%= form.<%= attribute.field_type %> :<%= attribute.column_name %>, multiple: true %>
<% else -%>
<%%= form.<%= attribute.field_type %> :<%= attribute.column_name %> %>
<% end -%>
<% end -%>
<%%= form.submit %>
<%% end %>

View file

@ -0,0 +1,8 @@
<h1><%%= t("scaffold.pagetitle_edit", model: <%= class_name %>.model_name.human) %></h1>
<%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %>
<div class="action-row">
<%%= link_to t("scaffold.link_show", model: <%= class_name %>.model_name.human), <%= model_resource_name(prefix: "@") %> %>
<%%= link_to t("scaffold.link_index", model: <%= class_name %>.model_name.human(count: 2)), <%= index_helper(type: :path) %> %>
</div>

View file

@ -0,0 +1,25 @@
<h1><%%= t("scaffold.pagetitle_index", model: <%= class_name %>.model_name.human(count: 2)) %></h1>
<table class="table table-striped">
<thead>
<tr>
<th><%%= <%= class_name %>.human_attribute_name(:id) %></th>
<% attributes.each do |attribute| %>
<th><%%= <%= class_name %>.human_attribute_name(:<%= attribute.column_name %>) %></th>
<% end %>
</thead>
<tbody>
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
<tr>
<td><%%= link_to(<%= singular_table_name %>.id, url_for(<%= singular_table_name %>)) %></td>
<% attributes.each do |attribute| %>
<td><%%= link_to(<%= singular_table_name %>.<%= attribute.column_name %>, url_for(<%= singular_table_name %>)) %></td>
<% end %>
</tr>
<%% end %>
</tbody>
</table>
<div class="action-row">
<%%= link_to t("scaffold.link_new", model: <%= class_name %>.model_name.human), new_<%= singular_table_name %>_path %>
</div>

View file

@ -0,0 +1,7 @@
<h1><%%= t("scaffold.pagetitle_new", model: <%= class_name %>.model_name.human) %></h1>
<%%= render "form", <%= singular_table_name %>: @<%= singular_table_name %> %>
<div class="action-row">
<%%= link_to t("scaffold.link_index", model: <%= class_name %>.model_name.human(count: 2)), <%= plural_table_name %>_path %>
</div>

View file

@ -0,0 +1,17 @@
<div id="<%%= dom_id <%= singular_name %> %>">
<% attributes.reject(&:password_digest?).each do |attribute| -%>
<p>
<strong><%= attribute.human_name %>:</strong>
<% if attribute.attachment? -%>
<%%= link_to <%= singular_name %>.<%= attribute.column_name %>.filename, <%= singular_name %>.<%= attribute.column_name %> if <%= singular_name %>.<%= attribute.column_name %>.attached? %>
<% elsif attribute.attachments? -%>
<%% <%= singular_name %>.<%= attribute.column_name %>.each do |<%= attribute.singular_name %>| %>
<div><%%= link_to <%= attribute.singular_name %>.filename, <%= attribute.singular_name %> %></div>
<%% end %>
<% else -%>
<%%= <%= singular_name %>.<%= attribute.column_name %> %>
<% end -%>
</p>
<% end -%>
</div>

View file

@ -0,0 +1,9 @@
<h1><%%= t("scaffold.pagetitle_show", model: @<%= singular_table_name %>.class.model_name.human) %></h1>
<%%= render @<%= singular_table_name %> %>
<div class="action-row">
<%%= link_to t("scaffold.link_edit", model: @<%= singular_table_name %>.model_name.human), <%= edit_helper(type: :path) %> %>
<%%= link_to t("scaffold.link_index", model: @<%= singular_table_name %>.model_name.human(count: 2)), <%= index_helper(type: :path) %> %>
<%%= button_to t("scaffold.link_destroy", model: @<%= singular_table_name %>.model_name.human), <%= model_resource_name(prefix: "@") %>, method: :delete, class: "btn btn-warning" %>
</div>

View file

@ -0,0 +1,64 @@
<% module_namespacing do -%>
class <%= controller_class_name %>Controller < ApplicationController
before_action :set_<%= singular_table_name %>, only: %i[ show edit update destroy ]
# GET <%= route_url %>
def index
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
end
# GET <%= route_url %>/1
def show
end
# GET <%= route_url %>/new
def new
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
end
# GET <%= route_url %>/1/edit
def edit
end
# POST <%= route_url %>
def create
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
if @<%= orm_instance.save %>
redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully created.") %>
else
render :new, status: :unprocessable_entity
end
end
# PATCH/PUT <%= route_url %>/1
def update
if @<%= orm_instance.update("#{singular_table_name}_params") %>
redirect_to <%= redirect_resource_name %>, notice: <%= %("#{human_name} was successfully updated.") %>, status: :see_other
else
render :edit, status: :unprocessable_entity
end
end
# DELETE <%= route_url %>/1
def destroy
@<%= orm_instance.destroy %>
redirect_to <%= index_helper %>_url, notice: <%= %("#{human_name} was successfully destroyed.") %>, status: :see_other
end
private
# Use callbacks to share common setup or constraints between actions.
def set_<%= singular_table_name %>
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
end
# Only allow a list of trusted parameters through.
def <%= "#{singular_table_name}_params" %>
<%- if attributes_names.empty? -%>
params.fetch(:<%= singular_table_name %>, {})
<%- else -%>
params.require(:<%= singular_table_name %>).permit(<%= permitted_params %>)
<%- end -%>
end
end
<% end -%>

View file

@ -0,0 +1,48 @@
require "test_helper"
class ChecklistsControllerTest < ActionDispatch::IntegrationTest
setup do
@checklist = checklists(:one)
end
test "should get index" do
get checklists_url
assert_response :success
end
test "should get new" do
get new_checklist_url
assert_response :success
end
test "should create checklist" do
assert_difference("Checklist.count") do
post checklists_url, params: { checklist: { code: @checklist.code, description: @checklist.description, name: @checklist.name } }
end
assert_redirected_to checklist_url(Checklist.last)
end
test "should show checklist" do
get checklist_url(@checklist)
assert_response :success
end
test "should get edit" do
get edit_checklist_url(@checklist)
assert_response :success
end
test "should update checklist" do
patch checklist_url(@checklist), params: { checklist: { code: @checklist.code, description: @checklist.description, name: @checklist.name } }
assert_redirected_to checklist_url(@checklist)
end
test "should destroy checklist" do
assert_difference("Checklist.count", -1) do
delete checklist_url(@checklist)
end
assert_redirected_to checklists_url
end
end

View file

@ -0,0 +1,48 @@
require "test_helper"
class ChecksControllerTest < ActionDispatch::IntegrationTest
setup do
@check = checks(:one)
end
test "should get index" do
get checks_url
assert_response :success
end
test "should get new" do
get new_check_url
assert_response :success
end
test "should create check" do
assert_difference("Check.count") do
post checks_url, params: { check: { level: @check.level, name: @check.name, position: @check.position, success_criterion: @check.success_criterion } }
end
assert_redirected_to check_url(Check.last)
end
test "should show check" do
get check_url(@check)
assert_response :success
end
test "should get edit" do
get edit_check_url(@check)
assert_response :success
end
test "should update check" do
patch check_url(@check), params: { check: { level: @check.level, name: @check.name, position: @check.position, success_criterion: @check.success_criterion } }
assert_redirected_to check_url(@check)
end
test "should destroy check" do
assert_difference("Check.count", -1) do
delete check_url(@check)
end
assert_redirected_to checks_url
end
end

View file

@ -0,0 +1,48 @@
require "test_helper"
class ElementsControllerTest < ActionDispatch::IntegrationTest
setup do
@element = elements(:one)
end
test "should get index" do
get elements_url
assert_response :success
end
test "should get new" do
get new_element_url
assert_response :success
end
test "should create element" do
assert_difference("Element.count") do
post elements_url, params: { element: { description: @element.description, path: @element.path, report_id: @element.report_id, title: @element.title } }
end
assert_redirected_to element_url(Element.last)
end
test "should show element" do
get element_url(@element)
assert_response :success
end
test "should get edit" do
get edit_element_url(@element)
assert_response :success
end
test "should update element" do
patch element_url(@element), params: { element: { description: @element.description, path: @element.path, report_id: @element.report_id, title: @element.title } }
assert_redirected_to element_url(@element)
end
test "should destroy element" do
assert_difference("Element.count", -1) do
delete element_url(@element)
end
assert_redirected_to elements_url
end
end

View file

@ -0,0 +1,48 @@
require "test_helper"
class ReportsControllerTest < ActionDispatch::IntegrationTest
setup do
@report = reports(:one)
end
test "should get index" do
get reports_url
assert_response :success
end
test "should get new" do
get new_report_url
assert_response :success
end
test "should create report" do
assert_difference("Report.count") do
post reports_url, params: { report: { comment: @report.comment, name: @report.name } }
end
assert_redirected_to report_url(Report.last)
end
test "should show report" do
get report_url(@report)
assert_response :success
end
test "should get edit" do
get edit_report_url(@report)
assert_response :success
end
test "should update report" do
patch report_url(@report), params: { report: { comment: @report.comment, name: @report.name } }
assert_redirected_to report_url(@report)
end
test "should destroy report" do
assert_difference("Report.count", -1) do
delete report_url(@report)
end
assert_redirected_to reports_url
end
end

Some files were not shown because too many files have changed in this diff Show more