Some UX improvements

This commit is contained in:
David Schärer 2024-07-19 02:29:18 +02:00
parent 48c0067076
commit 8c81237501
81 changed files with 791 additions and 151 deletions

1
.gitignore vendored
View file

@ -38,3 +38,4 @@
!/app/assets/builds/.keep
/node_modules
/.irbrc_history

View file

@ -42,7 +42,7 @@ RUN \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update -yqq && \
apt-get install -yqq --no-install-recommends \
sqlite3 nodejs npm sassc yarn && \
sqlite3 nodejs npm sassc yarn libvips && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && \
truncate -s 0 /var/log/*log && \

View file

@ -47,8 +47,9 @@ gem 'tzinfo-data', platforms: %i[windows jruby]
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'
gem 'image_processing', '~> 1.2'
gem 'prawn-rails'
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem

View file

@ -107,10 +107,19 @@ GEM
reline (>= 0.3.8)
drb (2.2.1)
erubi (1.13.0)
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-arm-linux-gnu)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86-linux-gnu)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
image_processing (1.12.2)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
io-console (0.7.2)
irb (1.14.0)
rdoc (>= 4.0.0)
@ -133,6 +142,7 @@ GEM
net-smtp
marcel (1.0.4)
matrix (0.4.2)
mini_magick (4.13.2)
mini_mime (1.1.5)
minitest (5.24.1)
msgpack (1.7.2)
@ -163,6 +173,17 @@ GEM
parser (3.3.4.0)
ast (~> 2.4.1)
racc
pdf-core (0.10.0)
prawn (2.5.0)
matrix (~> 0.4)
pdf-core (~> 0.10.0)
ttfunk (~> 1.8)
prawn-rails (1.4.2)
actionview (>= 3.1.0)
prawn
prawn-table
prawn-table (0.2.2)
prawn (>= 1.3.0, < 3.0.0)
prism (0.30.0)
psych (5.1.2)
stringio
@ -246,6 +267,8 @@ GEM
ruby-lsp-rails (0.3.10)
ruby-lsp (>= 0.17.2, < 0.18.0)
ruby-progressbar (1.13.0)
ruby-vips (2.2.1)
ffi (~> 1.12)
rubyzip (2.3.2)
selenium-webdriver (4.22.0)
base64 (~> 0.2)
@ -273,6 +296,8 @@ GEM
strscan (3.1.0)
thor (1.3.1)
timeout (0.4.1)
ttfunk (1.8.0)
bigdecimal (~> 3.1)
turbo-rails (2.0.5)
actionpack (>= 6.0.0)
activejob (>= 6.0.0)
@ -308,8 +333,10 @@ DEPENDENCIES
capybara
cssbundling-rails
debug
image_processing (~> 1.2)
jbuilder
jsbundling-rails
prawn-rails
puma (>= 5.0)
rails (~> 7.1.3, >= 7.1.3.4)
rubocop

View file

@ -0,0 +1,65 @@
/*
* Provides a drop-in pointer for the default Trix stylesheet that will format the toolbar and
* the trix-editor content (whether displayed or under editing). Feel free to incorporate this
* inclusion directly in any other asset bundle and remove this file.
*
*= require trix
*/
/*
* We need to override trix.csss image gallery styles to accommodate the
* <action-text-attachment> element we wrap around attachments. Otherwise,
* images in galleries will be squished by the max-width: 33%; rule.
*/
.trix-content .attachment-gallery > action-text-attachment,
.trix-content .attachment-gallery > .attachment {
flex: 1 0 33%;
padding: 0 0.5em;
max-width: 33%;
}
.trix-content .attachment-gallery.attachment-gallery--2 > action-text-attachment,
.trix-content .attachment-gallery.attachment-gallery--2 > .attachment, .trix-content .attachment-gallery.attachment-gallery--4 > action-text-attachment,
.trix-content .attachment-gallery.attachment-gallery--4 > .attachment {
flex-basis: 50%;
max-width: 50%;
}
.trix-content action-text-attachment .attachment {
padding: 0 !important;
max-width: 100% !important;
}
/* Fix trix dark mode */
.trix-button-row {
.trix-button-group {
border: var(--bs-border-width) solid var(--bs-border-color);
.trix-button {
border: 0;
padding: var(--bs-padding)
}
}
}
[data-bs-theme=dark] {
.trix-button-row {
.trix-button-group {
.trix-button {
background-color: transparent;
filter: invert(100%);
}
}
}
}
/* end fix trix dark mode */
.trix-content {
pre {
background-color: var(--bs-secondary-bg) !important;
color: var(--bs-secondary-color) !important;
border: var(--bs-border-width) solid var(--bs-border-color) !important;
border-radius: var(--bs-border-radius) !important;
}
}

View file

@ -28,4 +28,7 @@ $font-family-sans-serif:
@import 'bootstrap-icons/font/bootstrap-icons';
@import "rails_bootstrap_forms.css";
@import './actiontext.css';
@import 'trix.css';
@import "./layout.scss";

View file

@ -5,10 +5,40 @@
// 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;
}
}
}
// // Fix trix dark mode
// .trix-button-row {
// .trix-button-group {
// border: var(--bs-border-width) solid var(--bs-border-color);
// .trix-button {
// border: 0;
// }
// }
// }
// [data-bs-theme=dark] {
// .trix-button-row {
// .trix-button-group {
// .trix-button {
// background-color: transparent;
// filter: invert(100%);
// }
// }
// }
// }
// // end fix trix dark mode
// .trix-content pre {
// background-color: var(--bs-secondary-bg);
// color: var(--bs-secondary-color);
// border: var(--bs-border-width) solid var(--bs-border-color);
// border-radius: var(--bs-border-radius);
// padding: var(--bs-padding);
// }

View file

@ -11,7 +11,7 @@ class ApplicationController < ActionController::Base
{ 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 }
{ label: Check.model_name.human(count: 2), icon: :check2, path: :checks }
]
@search_url = nil # root_url
end

View file

@ -0,0 +1,59 @@
class ChecklistEntriesController < ApplicationController
before_action :set_checklist_entry, only: %i[show edit update destroy]
# GET /checklist_entries
def index
@checklist_entries = ChecklistEntry.all
end
# GET /checklist_entries/1
def show
end
# GET /checklist_entries/new
def new
@checklist_entry = ChecklistEntry.new(checklist_id: params[:checklist_id])
end
# GET /checklist_entries/1/edit
def edit
end
# POST /checklist_entries
def create
@checklist_entry = ChecklistEntry.new(checklist_entry_params)
if @checklist_entry.save
redirect_to @checklist_entry, notice: 'Checklist entry was successfully created.'
else
render :new, status: :unprocessable_entity
end
end
# PATCH/PUT /checklist_entries/1
def update
if @checklist_entry.update(checklist_entry_params)
redirect_to @checklist_entry, notice: 'Checklist entry was successfully updated.', status: :see_other
else
render :edit, status: :unprocessable_entity
end
end
# DELETE /checklist_entries/1
def destroy
@checklist_entry.destroy!
redirect_to checklist_entries_url, notice: 'Checklist entry was successfully destroyed.', status: :see_other
end
private
# Use callbacks to share common setup or constraints between actions.
def set_checklist_entry
@checklist_entry = ChecklistEntry.find(params[:id])
end
# Only allow a list of trusted parameters through.
def checklist_entry_params
params.require(:checklist_entry).permit(:checklist_id, :check_id, :position)
end
end

View file

@ -17,7 +17,6 @@ class ChecklistsController < ApplicationController
# GET /checklists/1/edit
def edit
@checklist.checklist_entries.build
end
# POST /checklists
@ -55,7 +54,7 @@ class ChecklistsController < ApplicationController
# Only allow a list of trusted parameters through.
def checklist_params
params.require(:checklist).permit(:code, :name, :description,
params.require(:checklist).permit(:code, :name, :description, :description_html,
checklist_entries_attributes: %i[id check_id position _destroy])
end
end

View file

@ -75,6 +75,6 @@ class ChecksController < ApplicationController
# Only allow a list of trusted parameters through.
def check_params
params.require(:check).permit(:position, :name, :success_criterion, :level)
params.require(:check).permit(:position, :name, :success_criterion, :success_criterion_html, :level)
end
end

View file

@ -12,7 +12,7 @@ class ElementsController < ApplicationController
# GET /elements/new
def new
@element = Element.new
@element = Element.new(report_id: params[:report_id])
end
# GET /elements/1/edit
@ -23,13 +23,15 @@ class ElementsController < ApplicationController
def create
checklist_id = element_params.delete(:checklist_id)
checklist = Checklist.find(checklist_id)
@element = Element.new(element_params.merge(title: checklist.name))
@element = Element.new(element_params)
@element.title = checklist.name if @element.title.blank?
if @element.save
checklist.checks.each do |check|
@element.success_criteria.create!(title: check.name, description: check.success_criterion, level: check.level)
@element.success_criteria.create!(title: check.name, description_html: check.success_criterion_html,
level: check.level)
end
redirect_to [:work, @element.report], notice: 'Element was successfully created.'
redirect_to @element.report, notice: 'Element was successfully created.'
else
render :new, status: :unprocessable_entity
end
@ -59,6 +61,6 @@ class ElementsController < ApplicationController
# Only allow a list of trusted parameters through.
def element_params
params.require(:element).permit(:report_id, :path, :title, :description, :checklist_id)
params.require(:element).permit(:report_id, :path, :title, :description_html, :checklist_id)
end
end

View file

@ -58,6 +58,6 @@ class ReportsController < ApplicationController
# Only allow a list of trusted parameters through.
def report_params
params.require(:report).permit(:name, :comment)
params.require(:report).permit(:name, :comment_html)
end
end

View file

@ -1,5 +1,5 @@
class SuccessCriteriaController < ApplicationController
before_action :set_success_criterion, only: %i[ show edit update destroy ]
before_action :set_success_criterion, only: %i[show edit update destroy]
# GET /success_criteria
def index
@ -24,7 +24,7 @@ class SuccessCriteriaController < ApplicationController
@success_criterion = SuccessCriterion.new(success_criterion_params)
if @success_criterion.save
redirect_to @success_criterion, notice: "Success criterion was successfully created."
redirect_to @success_criterion, notice: 'Success criterion was successfully created.'
else
render :new, status: :unprocessable_entity
end
@ -33,7 +33,7 @@ class SuccessCriteriaController < ApplicationController
# 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
redirect_to @success_criterion, notice: 'Success criterion was successfully updated.', status: :see_other
else
render :edit, status: :unprocessable_entity
end
@ -42,17 +42,18 @@ class SuccessCriteriaController < ApplicationController
# DELETE /success_criteria/1
def destroy
@success_criterion.destroy!
redirect_to success_criteria_url, notice: "Success criterion was successfully destroyed.", status: :see_other
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
# 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_html, :level, :result, :comment_html)
end
end

View file

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

View file

@ -2,3 +2,6 @@
import "@hotwired/turbo-rails"
import "./controllers"
import * as bootstrap from "bootstrap"
import "trix"
import "@rails/actiontext"

View file

@ -1,5 +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 }
has_rich_text :success_criterion_html
end

View file

@ -2,5 +2,7 @@ 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
has_rich_text :description_html
accepts_nested_attributes_for :checklist_entries, reject_if: :all_blank, allow_destroy: true
end

View file

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

View file

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

View file

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

View file

@ -0,0 +1,14 @@
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
<% if blob.representable? %>
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
<% end %>
<figcaption class="attachment__caption">
<% if caption = blob.try(:caption) %>
<%= caption %>
<% else %>
<span class="attachment__name"><%= blob.filename %></span>
<span class="attachment__size"><%= number_to_human_size blob.byte_size %></span>
<% end %>
</figcaption>
</figure>

View file

@ -0,0 +1,8 @@
<div id="<%= dom_id checklist_entry %>">
<p>
<%= button_to tag.i(class: "bi bi-trash"), checklist_entry_path(checklist_entry), method: :delete, class: "btn btn-link p-0 ps-3 float-end" %>
<%= link_to "edit", edit_checklist_entry_path(checklist_entry), class: "float-end" %>
<%= checklist_entry.position %>
<%= link_to(checklist_entry.check.name, checklist_entry.check, data: { turbo_frame: "_top" }) %>
</p>
</div>

View file

@ -0,0 +1,2 @@
json.extract! checklist_entry, :id, :checklist_id, :check_id, :position, :created_at, :updated_at
json.url checklist_entry_url(checklist_entry, format: :json)

View file

@ -0,0 +1,6 @@
<%= bootstrap_form_with(model: checklist_entry, layout: :horizontal) do |form| %>
<%= form.hidden_field :checklist_id %>
<%= form.collection_select :check_id, Check.all.order(:name), :id, :name %>
<%= form.number_field :position %>
<%= form.submit %>
<% end %>

View file

@ -0,0 +1,11 @@
<h1><%= t("scaffold.pagetitle_edit", model: ChecklistEntry.model_name.human) %></h1>
<%= turbo_frame_tag dom_id(@checklist_entry, :frame) do %>
<%= render "form", checklist_entry: @checklist_entry %>
<%= link_to "cancel", @checklist_entry %>
<% end %>
<div class="action-row">
<%= link_to t("scaffold.link_show", model: ChecklistEntry.model_name.human), @checklist_entry %>
<%= link_to t("scaffold.link_index", model: ChecklistEntry.model_name.human(count: 2)), checklist_entries_path %>
</div>

View file

@ -0,0 +1,33 @@
<h1><%= t("scaffold.pagetitle_index", model: ChecklistEntry.model_name.human(count: 2)) %></h1>
<table class="table table-striped">
<thead>
<tr>
<th><%= ChecklistEntry.human_attribute_name(:id) %></th>
<th><%= ChecklistEntry.human_attribute_name(:checklist_id) %></th>
<th><%= ChecklistEntry.human_attribute_name(:check_id) %></th>
<th><%= ChecklistEntry.human_attribute_name(:position) %></th>
</thead>
<tbody>
<% @checklist_entries.each do |checklist_entry| %>
<tr>
<td><%= link_to(checklist_entry.id, url_for(checklist_entry)) %></td>
<td><%= link_to(checklist_entry.checklist_id, url_for(checklist_entry)) %></td>
<td><%= link_to(checklist_entry.check_id, url_for(checklist_entry)) %></td>
<td><%= link_to(checklist_entry.position, url_for(checklist_entry)) %></td>
</tr>
<% end %>
</tbody>
</table>
<div class="action-row">
<%= link_to t("scaffold.link_new", model: ChecklistEntry.model_name.human), new_checklist_entry_path %>
</div>

View file

@ -0,0 +1 @@
json.array! @checklist_entries, partial: "checklist_entries/checklist_entry", as: :checklist_entry

View file

@ -0,0 +1,9 @@
<h1><%= t("scaffold.pagetitle_new", model: ChecklistEntry.model_name.human) %></h1>
<%= turbo_frame_tag "new_checklist_entry" do %>
<%= render "form", checklist_entry: @checklist_entry %>
<% end %>
<div class="action-row">
<%= link_to t("scaffold.link_index", model: ChecklistEntry.model_name.human(count: 2)), checklist_entries_path %>
</div>

View file

@ -0,0 +1,11 @@
<h1><%= t("scaffold.pagetitle_show", model: @checklist_entry.class.model_name.human) %></h1>
<%= turbo_frame_tag dom_id(@checklist_entry, :frame) do %>
<%= render @checklist_entry %>
<% end %>
<div class="action-row">
<%= link_to t("scaffold.link_edit", model: @checklist_entry.model_name.human), edit_checklist_entry_path(@checklist_entry) %>
<%= link_to t("scaffold.link_index", model: @checklist_entry.model_name.human(count: 2)), checklist_entries_path %>
<%= button_to t("scaffold.link_destroy", model: @checklist_entry.model_name.human), @checklist_entry, method: :delete, class: "btn btn-outline-danger" %>
</div>

View file

@ -0,0 +1 @@
json.partial! "checklist_entries/checklist_entry", checklist_entry: @checklist_entry

View file

@ -10,8 +10,8 @@
</p>
<p>
<strong>Description:</strong>
<%= checklist.description %>
<strong>Description (formatted):</strong>
<%= checklist.description_html %>
</p>
<p>

View file

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

View file

@ -1,13 +1,6 @@
<%= 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.rich_text_area :description_html %>
<%= form.submit %>
<% end %>
<% end %>

View file

@ -1,6 +1,24 @@
<h1><%= t("scaffold.pagetitle_edit", model: Checklist.model_name.human) %></h1>
<%= render "form", checklist: @checklist %>
<div class="row">
<div class="col">
<%= render "form", checklist: @checklist %>
</div>
<div class="col">
<h2>Checks</h2>
<div class="mb-2">
<%= turbo_frame_tag "new_checklist_entry" do %>
<%= link_to tag.i(class: "bi bi-plus"), new_checklist_entry_path(checklist_id: @checklist.id), class: "btn btn-primary", data: { turbo_frame: "new_checklist_entry"} %>
<% end %>
</div>
<% @checklist.checklist_entries.each do |entry| %>
<%= turbo_frame_tag dom_id(entry, :frame) do %>
<%= render entry %>
<% end %>
<% end %>
</div>
</div>
<div class="action-row">
<%= link_to t("scaffold.link_show", model: Checklist.model_name.human), @checklist %>

View file

@ -9,7 +9,7 @@
<th><%= Checklist.human_attribute_name(:name) %></th>
<th><%= Checklist.human_attribute_name(:description) %></th>
<th><%= Checklist.human_attribute_name(:description_html) %></th>
</thead>
<tbody>
@ -21,8 +21,7 @@
<td><%= link_to(checklist.name, url_for(checklist)) %></td>
<td><%= link_to(checklist.description, url_for(checklist)) %></td>
<td><%= link_to(truncate(strip_tags(checklist.description_html.to_s)), url_for(checklist)) %></td>
</tr>
<% end %>
</tbody>

View file

@ -1,9 +1,11 @@
<h1><%= t("scaffold.pagetitle_show", model: @checklist.class.model_name.human) %></h1>
<%= render @checklist %>
<pre>Dashboard
is
sidebar</pre>
<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" %>
<%= button_to t("scaffold.link_destroy", model: @checklist.model_name.human), @checklist, method: :delete, class: "btn btn-outline-danger" %>
</div>

View file

@ -10,8 +10,8 @@
</p>
<p>
<strong><%= Check.human_attribute_name(:success_criterion) %>:</strong>
<%= check.success_criterion %>
<strong><%= Check.human_attribute_name(:success_criterion_html) %>:</strong>
<%= check.success_criterion_html %>
</p>
<p>

View file

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

View file

@ -1,7 +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.rich_text_area :success_criterion_html %>
<%= form.select :level, Check.levels.keys, add_blank: !form.object.level.present? %>
<%= form.submit %>
<% end %>

View file

@ -6,7 +6,7 @@
<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>
<th><%= Check.human_attribute_name(:success_criterion_html) %></th>
</thead>
<tbody>
<% @checks.each do |check| %>
@ -14,7 +14,7 @@
<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>
<td><%= link_to(truncate(strip_tags(check.success_criterion_html.to_s)), url_for(check)) %></td>
</tr>
<% end %>
</tbody>

View file

@ -5,5 +5,5 @@
<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" %>
<%= button_to t("scaffold.link_destroy", model: @check.model_name.human), @check, method: :delete, class: "btn btn-outline-danger" %>
</div>

View file

@ -6,7 +6,11 @@
<%= element.path %>
</p>
<%= element.description_html %>
<% element.success_criteria.each do |sc| %>
<%= render sc %>
<%= turbo_frame_tag(dom_id(sc, :frame)) do %>
<%= render sc %>
<% end %>
<% end %>
</div>

View file

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

View file

@ -1,7 +1,8 @@
<%= 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 %>
<%= bootstrap_form_with(model: element, data: { turbo_frame: "_top"}) do |form| %>
<%= form.hidden_field :report_id %>
<%= form.collection_select(:checklist_id, Checklist.all, :id, :name) %>
<%= form.text_field :path %>
<%= form.text_field :title %>
<%= form.rich_text_area :description_html %>
<%= form.submit %>
<% end %>

View file

@ -11,7 +11,7 @@
<th><%= Element.human_attribute_name(:title) %></th>
<th><%= Element.human_attribute_name(:description) %></th>
<th><%= Element.human_attribute_name(:description_html) %></th>
</thead>
<tbody>
@ -25,7 +25,7 @@
<td><%= link_to(element.title, url_for(element)) %></td>
<td><%= link_to(element.description, url_for(element)) %></td>
<td><%= link_to(truncate(strip_tags(element.description_html)), url_for(element)) %></td>
</tr>
<% end %>

View file

@ -1,6 +1,9 @@
<h1><%= t("scaffold.pagetitle_new", model: Element.model_name.human) %></h1>
<%= render "form", element: @element %>
<%= turbo_frame_tag "new_element_frame" do %>
<h2><i class="bi bi-plus"></i>Element hinzufügen</h2>
<%= render "form", element: @element %>
<% end %>
<div class="action-row">
<%= link_to t("scaffold.link_index", model: Element.model_name.human(count: 2)), elements_path %>

View file

@ -5,5 +5,5 @@
<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" %>
<%= button_to t("scaffold.link_destroy", model: @element.model_name.human), @element, method: :delete, class: "btn btn-outline-danger" %>
</div>

View file

@ -1,5 +1,4 @@
<h1>Dashboard</h1>
<h2>Data</h2>
<p>
<i class="bi bi-journal-text"></i>
<%= Report.count %>
@ -11,7 +10,7 @@
<%= link_to Checklist.model_name.human(count: Checklist.count), :checklists %>
</p>
<p>
<i class="bi bi-check"></i>
<i class="bi bi-check2"></i>
<%= Check.count %>
<%= link_to Check.model_name.human(count: Check.count), :checks %>
</p>

View file

@ -1,6 +1,6 @@
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="<%= root_path %>">A11Yist</a>
<a class="navbar-brand" href="<%= root_path %>">A11yist</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>

View file

@ -0,0 +1,3 @@
<div class="trix-content">
<%= yield -%>
</div>

View file

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

View file

@ -6,7 +6,7 @@
<p>
<strong>Comment:</strong>
<%= report.comment %>
<%= report.comment_html %>
</p>
</div>

View file

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

View file

@ -7,17 +7,17 @@
<th><%= Report.human_attribute_name(:name) %></th>
<th><%= Report.human_attribute_name(:comment) %></th>
<th><%= Report.human_attribute_name(:comment_html) %></th>
</thead>
<tbody>
<% @reports.each do |report| %>
<tr>
<td><%= link_to(report.id, url_for([:work, report])) %></td>
<td><%= link_to(report.id, url_for(report)) %></td>
<td><%= link_to(report.name, url_for([:work, report])) %></td>
<td><%= link_to(report.name, url_for(report)) %></td>
<td><%= link_to(report.comment, url_for([:work, report])) %></td>
<td><%= link_to(truncate(strip_tags(report.comment)), url_for(report)) if report.comment %></td>
</tr>
<% end %>

View file

@ -1,9 +1,24 @@
<h1><%= t("scaffold.pagetitle_show", model: @report.class.model_name.human) %></h1>
<div class="container">
<h1><i class="bi bi-journal-text me-2"></i><%= @report.name %></h1>
<%= render @report %>
<%= @report.comment_html %>
<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 class="my-5">
<%= turbo_frame_tag "new_element_frame" do %>
<%= link_to "#{tag.i(class: "bi bi-plus-lg")} Element".html_safe, new_element_path(report_id: @report.id), class: "btn btn-primary" %>
<% end %>
</div>
<% @report.elements.each do |element| %>
<%= turbo_frame_tag dom_id(element, :frame) do %>
<%= render element %>
<% end %>
<% 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-outline-danger" %>
</div>
</div>

View file

@ -0,0 +1,14 @@
prawn_document do |pdf|
pdf.text @report.name
@report.elements.each do |element|
pdf.text element.title
pdf.text element.path
pdf.text element.description_html, inline_format: true
element.success_criteria.each do |success_criterion|
pdf.text success_criterion.title
pdf.text success_criterion.description_html, inline_format: true
pdf.text success_criterion.comment_html, inline_format: true
end
end
end

View file

@ -1,21 +0,0 @@
<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

@ -1,9 +1,18 @@
<%= 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 %>
<div id="<%= dom_id success_criterion %>" class="card mt-3">
<div class="card-header">
<h3><i class="bi bi-check2 me-2"></i><%= success_criterion.title %></h3>
<%= link_to "cancel", success_criterion %>
</div>
<div class="card-body">
<%= bootstrap_form_with(model: success_criterion) do |form| %>
<%= form.text_field :title %>
<%= form.rich_text_area :description_html %>
<%= form.number_field :level %>
<%= form.select :result, SuccessCriterion.results.keys, include_blank: true %>
<%= form.rich_text_area :comment_html %>
<%= form.submit %>
<% end %>
</div>
<%# <%= link_to "edit", url_for([:edit, success_criterion]) %>
</div>

View file

@ -1,15 +1,19 @@
<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>
<h3><i class="bi bi-check2 me-2"></i><%= success_criterion.title %></h3>
<%= link_to "edit", [:edit, success_criterion]%>
</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 %>
<%= success_criterion.description_html %>
<p class="mt-3">
<strong>Level</strong>: <%= success_criterion.level %>
</p>
<p>
<strong>Resultat</strong>: <%= success_criterion.result %>
</p>
<% if success_criterion.comment_html.present? %>
<h4 class="mt-3">Kommentar</h4>
<%= success_criterion.comment_html %>
<% end %>
</div>
</div>

View file

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

View file

@ -1,6 +1,8 @@
<h1><%= t("scaffold.pagetitle_edit", model: SuccessCriterion.model_name.human) %></h1>
<%= render "form", success_criterion: @success_criterion %>
<%= turbo_frame_tag(dom_id(@success_criterion, :frame)) do %>
<%= render "form", success_criterion: @success_criterion %>
<% end %>
<div class="action-row">
<%= link_to t("scaffold.link_show", model: SuccessCriterion.model_name.human), @success_criterion %>

View file

@ -9,13 +9,13 @@
<th><%= SuccessCriterion.human_attribute_name(:title) %></th>
<th><%= SuccessCriterion.human_attribute_name(:description) %></th>
<th><%= SuccessCriterion.human_attribute_name(:description_html) %></th>
<th><%= SuccessCriterion.human_attribute_name(:level) %></th>
<th><%= SuccessCriterion.human_attribute_name(:result) %></th>
<th><%= SuccessCriterion.human_attribute_name(:comment) %></th>
<th><%= SuccessCriterion.human_attribute_name(:comment_html) %></th>
</thead>
<tbody>
@ -27,13 +27,13 @@
<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(truncate(strip_tags(success_criterion.description_html)), 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>
<td><%= link_to(truncate(strip_tags(success_criterion.comment_html)), url_for(success_criterion)) %></td>
</tr>
<% end %>

View file

@ -1,9 +1,11 @@
<h1><%= t("scaffold.pagetitle_show", model: @success_criterion.class.model_name.human) %></h1>
<%= render @success_criterion %>
<%= turbo_frame_tag(dom_id(@success_criterion, :frame)) do %>
<% render @success_criterion %>
<% end %>
<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" %>
<%= button_to t("scaffold.link_destroy", model: @success_criterion.model_name.human), @success_criterion, method: :delete, class: "btn btn-outline-danger" %>
</div>

View file

@ -5,7 +5,7 @@ de-CH:
id: ID
level: Stufe
position: Position
success_criterion: Erfolgskriterium
success_criterion_html: Erfolgskriterium
models:
check:
one: Check

View file

@ -1,15 +1,14 @@
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
Rails.application.routes.draw do
resources :success_criteria
resources :elements
resources :reports do
member do
get :work
end
end
resources :reports
resources :checklists
resources :checks
resources :checklist_entries
resources :success_criteria
resources :elements
get 'home/show', as: :home
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.

View file

@ -3,7 +3,6 @@ class CreateChecks < ActiveRecord::Migration[7.1]
create_table :checks do |t|
t.string :position
t.string :name
t.text :success_criterion
t.integer :level
t.timestamps

View file

@ -3,7 +3,6 @@ class CreateChecklists < ActiveRecord::Migration[7.1]
create_table :checklists do |t|
t.string :code
t.string :name
t.text :description
t.timestamps
end

View file

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

View file

@ -4,7 +4,6 @@ class CreateElements < ActiveRecord::Migration[7.1]
t.references :report, null: false, foreign_key: true
t.string :path
t.string :title
t.text :description
t.timestamps
end

View file

@ -3,10 +3,8 @@ class CreateSuccessCriteria < ActiveRecord::Migration[7.1]
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

View file

@ -0,0 +1,57 @@
# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[7.0]
def change
# Use Active Record's configured type for primary and foreign keys
primary_key_type, foreign_key_type = primary_and_foreign_key_types
create_table :active_storage_blobs, id: primary_key_type do |t|
t.string :key, null: false
t.string :filename, null: false
t.string :content_type
t.text :metadata
t.string :service_name, null: false
t.bigint :byte_size, null: false
t.string :checksum
if connection.supports_datetime_with_precision?
t.datetime :created_at, precision: 6, null: false
else
t.datetime :created_at, null: false
end
t.index [ :key ], unique: true
end
create_table :active_storage_attachments, id: primary_key_type do |t|
t.string :name, null: false
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
t.references :blob, null: false, type: foreign_key_type
if connection.supports_datetime_with_precision?
t.datetime :created_at, precision: 6, null: false
else
t.datetime :created_at, null: false
end
t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
create_table :active_storage_variant_records, id: primary_key_type do |t|
t.belongs_to :blob, null: false, index: false, type: foreign_key_type
t.string :variation_digest, null: false
t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end
private
def primary_and_foreign_key_types
config = Rails.configuration.generators
setting = config.options[config.orm][:primary_key_type]
primary_key_type = setting || :primary_key
foreign_key_type = setting || :bigint
[primary_key_type, foreign_key_type]
end
end

View file

@ -0,0 +1,26 @@
# This migration comes from action_text (originally 20180528164100)
class CreateActionTextTables < ActiveRecord::Migration[6.0]
def change
# Use Active Record's configured type for primary and foreign keys
primary_key_type, foreign_key_type = primary_and_foreign_key_types
create_table :action_text_rich_texts, id: primary_key_type do |t|
t.string :name, null: false
t.text :body, size: :long
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
t.timestamps
t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
end
end
private
def primary_and_foreign_key_types
config = Rails.configuration.generators
setting = config.options[config.orm][:primary_key_type]
primary_key_type = setting || :primary_key
foreign_key_type = setting || :bigint
[primary_key_type, foreign_key_type]
end
end

42
db/schema.rb generated
View file

@ -10,7 +10,45 @@
#
# 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
ActiveRecord::Schema[7.1].define(version: 2024_07_16_182333) do
create_table "action_text_rich_texts", force: :cascade do |t|
t.string "name", null: false
t.text "body"
t.string "record_type", null: false
t.bigint "record_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["record_type", "record_id", "name"], name: "index_action_text_rich_texts_uniqueness", unique: true
end
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
t.bigint "record_id", null: false
t.bigint "blob_id", null: false
t.datetime "created_at", null: false
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
end
create_table "active_storage_blobs", force: :cascade do |t|
t.string "key", null: false
t.string "filename", null: false
t.string "content_type"
t.text "metadata"
t.string "service_name", null: false
t.bigint "byte_size", null: false
t.string "checksum"
t.datetime "created_at", null: false
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end
create_table "active_storage_variant_records", force: :cascade do |t|
t.bigint "blob_id", null: false
t.string "variation_digest", null: false
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end
create_table "checklist_entries", force: :cascade do |t|
t.integer "checklist_id", null: false
t.integer "check_id", null: false
@ -67,6 +105,8 @@ ActiveRecord::Schema[7.1].define(version: 2024_07_15_211614) do
t.index ["element_id"], name: "index_success_criteria_on_element_id"
end
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "checklist_entries", "checklists"
add_foreign_key "checklist_entries", "checks"
add_foreign_key "elements", "reports"

54
lib/tasks/import.rake Normal file
View file

@ -0,0 +1,54 @@
namespace :import do
desc 'Import WCAG2.1 in german'
task wcag21de: :environment do
URL = 'https://outline-rocks.github.io/wcag/translations/WCAG21-de/'
doc = Nokogiri::HTML5(URI.open(URL))
# standard = Standard.find_or_create_by(url: URL)
# standard.name = 'WCAG 2.1'
# standard.description = doc.css('#abstract p').map(&:to_s).join
# standard.save!
doc.css('section.principle').each do |principle_node|
_principle_id = principle_node.attributes['id'].value
_principle_title = principle_node.css('h2').first.content
# principle = standard.principles.find_or_create_by(code: principle_id)
# principle.name = principle_title.scan(/\d+\. (.*)/).first.last
# principle.number = principle_title.scan(/(\d+)\..*/).first.last
# principle.save!
principle_node.css('section').each do |guideline_node|
next unless guideline_node.css('h3').first
guideline_title = guideline_node.css('h3').first.content
guideline_text = guideline_node.css('p').first
_guideline_number = guideline_title.scan(/Richtlinie \d+\.(\d+).*/).first.last
# guideline = principle.guidelines.find_or_create_by(number: guideline_number)
# guideline.title = guideline_title.scan(/Richtlinie \d+\.\d+(.*)/).first.last
# guideline.text = guideline_text
# guideline.save!
guideline_node.css('section').each do |sc|
sc_title = sc.css('h4').first.content.scan(/Erfolgskriterium \d+\.\d+\.\d+(.*)/).first.last
sc_level = sc.css('p').first.content.scan(/\(Stufe (A+)\)/).first.last
# sc_hints = sc.css('div p').map { ReverseMarkdown.convert(_1.to_s) }
# _sc_number = sc_title.scan(/Erfolgskriterium \d+\.\d+\.(\d+).*/).first.last
success_criterion = Check.find_or_create_by(name: sc_title)
success_criterion.name = sc_title
text = "<div>#{guideline_text}<br>#{sc.css('p')[1]}"
text += "<p>#{sc.css('dl').first&.to_s}</p>" if sc.css('dl').first
success_criterion.success_criterion_html = "#{text}</div>".gsub('href="#', %(href="#{URL}#))
success_criterion.level = sc_level
success_criterion.save!
end
end
end
@output
end
end

View file

@ -5,5 +5,5 @@
<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" %>
<%%= button_to t("scaffold.link_destroy", model: @<%= singular_table_name %>.model_name.human), <%= model_resource_name(prefix: "@") %>, method: :delete, class: "btn btn-outline-danger" %>
</div>

View file

@ -5,6 +5,7 @@
"@hotwired/stimulus": "^3.2.2",
"@hotwired/turbo-rails": "^8.0.4",
"@popperjs/core": "^2.11.8",
"@rails/actiontext": "^7.1.3-4",
"autoprefixer": "^10.4.19",
"bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3",
@ -12,7 +13,8 @@
"nodemon": "^3.1.4",
"postcss": "^8.4.39",
"postcss-cli": "^11.0.0",
"sass": "^1.77.8"
"sass": "^1.77.8",
"trix": "^2.1.3"
},
"scripts": {
"build": "esbuild app/javascript/*.* --bundle --sourcemap --format=esm --outdir=app/assets/builds --public-path=/assets",
@ -24,4 +26,4 @@
"browserslist": [
"defaults"
]
}
}

View file

@ -0,0 +1,48 @@
require "test_helper"
class ChecklistEntriesControllerTest < ActionDispatch::IntegrationTest
setup do
@checklist_entry = checklist_entries(:one)
end
test "should get index" do
get checklist_entries_url
assert_response :success
end
test "should get new" do
get new_checklist_entry_url
assert_response :success
end
test "should create checklist_entry" do
assert_difference("ChecklistEntry.count") do
post checklist_entries_url, params: { checklist_entry: { check_id: @checklist_entry.check_id, checklist_id: @checklist_entry.checklist_id, position: @checklist_entry.position } }
end
assert_redirected_to checklist_entry_url(ChecklistEntry.last)
end
test "should show checklist_entry" do
get checklist_entry_url(@checklist_entry)
assert_response :success
end
test "should get edit" do
get edit_checklist_entry_url(@checklist_entry)
assert_response :success
end
test "should update checklist_entry" do
patch checklist_entry_url(@checklist_entry), params: { checklist_entry: { check_id: @checklist_entry.check_id, checklist_id: @checklist_entry.checklist_id, position: @checklist_entry.position } }
assert_redirected_to checklist_entry_url(@checklist_entry)
end
test "should destroy checklist_entry" do
assert_difference("ChecklistEntry.count", -1) do
delete checklist_entry_url(@checklist_entry)
end
assert_redirected_to checklist_entries_url
end
end

View file

@ -0,0 +1,4 @@
# one:
# record: name_of_fixture (ClassOfFixture)
# name: content
# body: <p>In a <i>million</i> stars!</p>

View file

@ -0,0 +1,45 @@
require "application_system_test_case"
class ChecklistEntriesTest < ApplicationSystemTestCase
setup do
@checklist_entry = checklist_entries(:one)
end
test "visiting the index" do
visit checklist_entries_url
assert_selector "h1", text: "Checklist entries"
end
test "should create checklist entry" do
visit checklist_entries_url
click_on "New checklist entry"
fill_in "Check", with: @checklist_entry.check_id
fill_in "Checklist", with: @checklist_entry.checklist_id
fill_in "Position", with: @checklist_entry.position
click_on "Create Checklist entry"
assert_text "Checklist entry was successfully created"
click_on "Back"
end
test "should update Checklist entry" do
visit checklist_entry_url(@checklist_entry)
click_on "Edit this checklist entry", match: :first
fill_in "Check", with: @checklist_entry.check_id
fill_in "Checklist", with: @checklist_entry.checklist_id
fill_in "Position", with: @checklist_entry.position
click_on "Update Checklist entry"
assert_text "Checklist entry was successfully updated"
click_on "Back"
end
test "should destroy Checklist entry" do
visit checklist_entry_url(@checklist_entry)
click_on "Destroy this checklist entry", match: :first
assert_text "Checklist entry was successfully destroyed"
end
end

View file

@ -171,6 +171,20 @@
resolved "https://registry.yarnpkg.com/@rails/actioncable/-/actioncable-7.1.3.tgz#4db480347775aeecd4dde2405659eef74a458881"
integrity sha512-ojNvnoZtPN0pYvVFtlO7dyEN9Oml1B6IDM+whGKVak69MMYW99lC2NOWXWeE3bmwEydbP/nn6ERcpfjHVjYQjA==
"@rails/actiontext@^7.1.3-4":
version "7.1.3-4"
resolved "https://registry.yarnpkg.com/@rails/actiontext/-/actiontext-7.1.3-4.tgz#6717c4cbe146e04677c1c403d144a4fd9e9227f9"
integrity sha512-Yt0aFwV4vmQDH0SPMKACF5WnZ88vn8KHpCbPJIGnFcj4likev+SkmdCLu/TpcHrFQwHWXt+GwKE924Ny92YXAg==
dependencies:
"@rails/activestorage" ">= 7.1.0-alpha"
"@rails/activestorage@>= 7.1.0-alpha":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@rails/activestorage/-/activestorage-7.1.3.tgz#e83ece6c5fd94b3ddf30a8cf3b8f78cad049e596"
integrity sha512-B+RFYAU8vdTPFg0IJcRp2ey0Qw9hpcUOqHHcWqftDJ76ZMBi9+m/UUeMJlNsSd0l9eD+1HLlFSo1X//cY4yiDw==
dependencies:
spark-md5 "^3.0.1"
"@sindresorhus/merge-streams@^2.1.0":
version "2.3.0"
resolved "https://registry.yarnpkg.com/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz#719df7fb41766bc143369eaa0dd56d8dc87c9958"
@ -703,6 +717,11 @@ slash@^5.0.0, slash@^5.1.0:
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.0.tgz#16b809c162517b5b8c3e7dcd315a2a5c2612b2af"
integrity sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==
spark-md5@^3.0.1:
version "3.0.2"
resolved "https://registry.yarnpkg.com/spark-md5/-/spark-md5-3.0.2.tgz#7952c4a30784347abcee73268e473b9c0167e3fc"
integrity sha512-wcFzz9cDfbuqe0FZzfi2or1sgyIrsDwmPwfZC4hiNidPdPINjeUwNfv5kldczoEAcjl9Y1L3SM7Uz2PUEQzxQw==
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
@ -743,6 +762,11 @@ touch@^3.1.0:
resolved "https://registry.yarnpkg.com/touch/-/touch-3.1.1.tgz#097a23d7b161476435e5c1344a95c0f75b4a5694"
integrity sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==
trix@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/trix/-/trix-2.1.3.tgz#38c8725cd1864ca5e9784aed7d043fa11669ba81"
integrity sha512-LqMp67LiKMQytAHKqNL1Jgmfz69ViW+WBOQTPA2BlMIuxic1mw5vHgDtOE0bvvojUdjAxh0EJtLpJn6BC/2JKw==
undefsafe@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"