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

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