From 8c812375015ae50970beecf47e13f3c218375f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Sch=C3=A4rer?= Date: Fri, 19 Jul 2024 02:29:18 +0200 Subject: [PATCH] Some UX improvements --- .gitignore | 1 + Dockerfile | 2 +- Gemfile | 3 +- Gemfile.lock | 27 ++++++++ app/assets/stylesheets/actiontext.css | 65 +++++++++++++++++++ .../stylesheets/application.bootstrap.scss | 3 + app/assets/stylesheets/layout.scss | 34 +++++++++- app/controllers/application_controller.rb | 2 +- .../checklist_entries_controller.rb | 59 +++++++++++++++++ app/controllers/checklists_controller.rb | 3 +- app/controllers/checks_controller.rb | 2 +- app/controllers/elements_controller.rb | 12 ++-- app/controllers/reports_controller.rb | 2 +- .../success_criteria_controller.rb | 25 +++---- app/helpers/checklist_entries_helper.rb | 2 + app/javascript/application.js | 3 + app/models/check.rb | 4 +- app/models/checklist.rb | 4 +- app/models/element.rb | 2 + app/models/report.rb | 2 + app/models/success_criterion.rb | 4 ++ app/views/active_storage/blobs/_blob.html.erb | 14 ++++ .../_checklist_entry.html.erb | 8 +++ .../_checklist_entry.json.jbuilder | 2 + app/views/checklist_entries/_form.html.erb | 6 ++ app/views/checklist_entries/edit.html.erb | 11 ++++ app/views/checklist_entries/index.html.erb | 33 ++++++++++ .../checklist_entries/index.json.jbuilder | 1 + app/views/checklist_entries/new.html.erb | 9 +++ app/views/checklist_entries/show.html.erb | 11 ++++ .../checklist_entries/show.json.jbuilder | 1 + app/views/checklists/_checklist.html.erb | 4 +- app/views/checklists/_checklist.json.jbuilder | 2 +- app/views/checklists/_form.html.erb | 11 +--- app/views/checklists/edit.html.erb | 20 +++++- app/views/checklists/index.html.erb | 5 +- app/views/checklists/show.html.erb | 6 +- app/views/checks/_check.html.erb | 4 +- app/views/checks/_check.json.jbuilder | 2 +- app/views/checks/_form.html.erb | 2 +- app/views/checks/index.html.erb | 4 +- app/views/checks/show.html.erb | 2 +- app/views/elements/_element.html.erb | 6 +- app/views/elements/_element.json.jbuilder | 2 +- app/views/elements/_form.html.erb | 13 ++-- app/views/elements/index.html.erb | 4 +- app/views/elements/new.html.erb | 5 +- app/views/elements/show.html.erb | 2 +- app/views/home/show.html.erb | 3 +- app/views/layouts/_navigation.html.erb | 2 +- .../action_text/contents/_content.html.erb | 3 + app/views/reports/_form.html.erb | 6 +- app/views/reports/_report.html.erb | 2 +- app/views/reports/_report.json.jbuilder | 2 +- app/views/reports/index.html.erb | 8 +-- app/views/reports/show.html.erb | 29 +++++++-- app/views/reports/show.pdf.prawn | 14 ++++ app/views/reports/work.html.erb | 21 ------ app/views/success_criteria/_form.html.erb | 27 +++++--- .../_success_criterion.html.erb | 22 ++++--- .../_success_criterion.json.jbuilder | 3 +- app/views/success_criteria/edit.html.erb | 4 +- app/views/success_criteria/index.html.erb | 8 +-- app/views/success_criteria/show.html.erb | 6 +- config/locales/activerecord.yml | 2 +- config/routes.rb | 15 ++--- db/migrate/20240715123847_create_checks.rb | 1 - .../20240715192449_create_checklists.rb | 1 - db/migrate/20240715203351_create_reports.rb | 1 - db/migrate/20240715210937_create_elements.rb | 1 - .../20240715211614_create_success_criteria.rb | 2 - ...te_active_storage_tables.active_storage.rb | 57 ++++++++++++++++ ...3_create_action_text_tables.action_text.rb | 26 ++++++++ db/schema.rb | 42 +++++++++++- lib/tasks/import.rake | 54 +++++++++++++++ lib/templates/erb/scaffold/show.html.erb.tt | 2 +- package.json | 6 +- .../checklist_entries_controller_test.rb | 48 ++++++++++++++ test/fixtures/action_text/rich_texts.yml | 4 ++ test/system/checklist_entries_test.rb | 45 +++++++++++++ yarn.lock | 24 +++++++ 81 files changed, 791 insertions(+), 151 deletions(-) create mode 100644 app/assets/stylesheets/actiontext.css create mode 100644 app/controllers/checklist_entries_controller.rb create mode 100644 app/helpers/checklist_entries_helper.rb create mode 100644 app/views/active_storage/blobs/_blob.html.erb create mode 100644 app/views/checklist_entries/_checklist_entry.html.erb create mode 100644 app/views/checklist_entries/_checklist_entry.json.jbuilder create mode 100644 app/views/checklist_entries/_form.html.erb create mode 100644 app/views/checklist_entries/edit.html.erb create mode 100644 app/views/checklist_entries/index.html.erb create mode 100644 app/views/checklist_entries/index.json.jbuilder create mode 100644 app/views/checklist_entries/new.html.erb create mode 100644 app/views/checklist_entries/show.html.erb create mode 100644 app/views/checklist_entries/show.json.jbuilder create mode 100644 app/views/layouts/action_text/contents/_content.html.erb create mode 100644 app/views/reports/show.pdf.prawn create mode 100644 db/migrate/20240716182332_create_active_storage_tables.active_storage.rb create mode 100644 db/migrate/20240716182333_create_action_text_tables.action_text.rb create mode 100644 lib/tasks/import.rake create mode 100644 test/controllers/checklist_entries_controller_test.rb create mode 100644 test/fixtures/action_text/rich_texts.yml create mode 100644 test/system/checklist_entries_test.rb diff --git a/.gitignore b/.gitignore index 288c5a2..50d55f6 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ !/app/assets/builds/.keep /node_modules +/.irbrc_history diff --git a/Dockerfile b/Dockerfile index 87dfcae..2968489 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 && \ diff --git a/Gemfile b/Gemfile index 4e90674..9fcf1cb 100644 --- a/Gemfile +++ b/Gemfile @@ -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 diff --git a/Gemfile.lock b/Gemfile.lock index 4984631..98d77fb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/assets/stylesheets/actiontext.css b/app/assets/stylesheets/actiontext.css new file mode 100644 index 0000000..7786117 --- /dev/null +++ b/app/assets/stylesheets/actiontext.css @@ -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.css’s image gallery styles to accommodate the + * 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; + } +} diff --git a/app/assets/stylesheets/application.bootstrap.scss b/app/assets/stylesheets/application.bootstrap.scss index 9c980a6..32022f7 100644 --- a/app/assets/stylesheets/application.bootstrap.scss +++ b/app/assets/stylesheets/application.bootstrap.scss @@ -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"; \ No newline at end of file diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 29de506..927375b 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -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; } -} \ No newline at end of file +} + +// // 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); +// } \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7593990..3ce22a9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/app/controllers/checklist_entries_controller.rb b/app/controllers/checklist_entries_controller.rb new file mode 100644 index 0000000..f4d3ce4 --- /dev/null +++ b/app/controllers/checklist_entries_controller.rb @@ -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 diff --git a/app/controllers/checklists_controller.rb b/app/controllers/checklists_controller.rb index 9418bff..02a20b8 100644 --- a/app/controllers/checklists_controller.rb +++ b/app/controllers/checklists_controller.rb @@ -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 diff --git a/app/controllers/checks_controller.rb b/app/controllers/checks_controller.rb index 3757ca8..7f26d7e 100644 --- a/app/controllers/checks_controller.rb +++ b/app/controllers/checks_controller.rb @@ -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 diff --git a/app/controllers/elements_controller.rb b/app/controllers/elements_controller.rb index e78b27d..3ffdf98 100644 --- a/app/controllers/elements_controller.rb +++ b/app/controllers/elements_controller.rb @@ -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 diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index b92bfac..206a387 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -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 diff --git a/app/controllers/success_criteria_controller.rb b/app/controllers/success_criteria_controller.rb index 9251457..73802b9 100644 --- a/app/controllers/success_criteria_controller.rb +++ b/app/controllers/success_criteria_controller.rb @@ -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 diff --git a/app/helpers/checklist_entries_helper.rb b/app/helpers/checklist_entries_helper.rb new file mode 100644 index 0000000..09d2b52 --- /dev/null +++ b/app/helpers/checklist_entries_helper.rb @@ -0,0 +1,2 @@ +module ChecklistEntriesHelper +end diff --git a/app/javascript/application.js b/app/javascript/application.js index 3016c21..5630ff0 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -2,3 +2,6 @@ import "@hotwired/turbo-rails" import "./controllers" import * as bootstrap from "bootstrap" + +import "trix" +import "@rails/actiontext" diff --git a/app/models/check.rb b/app/models/check.rb index a67436e..f4079d2 100644 --- a/app/models/check.rb +++ b/app/models/check.rb @@ -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 diff --git a/app/models/checklist.rb b/app/models/checklist.rb index 3bb1335..b5b2a02 100644 --- a/app/models/checklist.rb +++ b/app/models/checklist.rb @@ -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 diff --git a/app/models/element.rb b/app/models/element.rb index eabfad8..afa8796 100644 --- a/app/models/element.rb +++ b/app/models/element.rb @@ -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 diff --git a/app/models/report.rb b/app/models/report.rb index 3c752ea..d2a3e60 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,3 +1,5 @@ class Report < ApplicationRecord has_many :elements, dependent: :destroy + + has_rich_text :comment_html end diff --git a/app/models/success_criterion.rb b/app/models/success_criterion.rb index 34c3b8a..524baa3 100644 --- a/app/models/success_criterion.rb +++ b/app/models/success_criterion.rb @@ -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 diff --git a/app/views/active_storage/blobs/_blob.html.erb b/app/views/active_storage/blobs/_blob.html.erb new file mode 100644 index 0000000..49ba357 --- /dev/null +++ b/app/views/active_storage/blobs/_blob.html.erb @@ -0,0 +1,14 @@ +
attachment--<%= blob.filename.extension %>"> + <% if blob.representable? %> + <%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %> + <% end %> + +
+ <% if caption = blob.try(:caption) %> + <%= caption %> + <% else %> + <%= blob.filename %> + <%= number_to_human_size blob.byte_size %> + <% end %> +
+
diff --git a/app/views/checklist_entries/_checklist_entry.html.erb b/app/views/checklist_entries/_checklist_entry.html.erb new file mode 100644 index 0000000..ab9404e --- /dev/null +++ b/app/views/checklist_entries/_checklist_entry.html.erb @@ -0,0 +1,8 @@ +
+

+ <%= 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" }) %> +

+
diff --git a/app/views/checklist_entries/_checklist_entry.json.jbuilder b/app/views/checklist_entries/_checklist_entry.json.jbuilder new file mode 100644 index 0000000..ef3eaed --- /dev/null +++ b/app/views/checklist_entries/_checklist_entry.json.jbuilder @@ -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) diff --git a/app/views/checklist_entries/_form.html.erb b/app/views/checklist_entries/_form.html.erb new file mode 100644 index 0000000..3f5a7e7 --- /dev/null +++ b/app/views/checklist_entries/_form.html.erb @@ -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 %> \ No newline at end of file diff --git a/app/views/checklist_entries/edit.html.erb b/app/views/checklist_entries/edit.html.erb new file mode 100644 index 0000000..25e960f --- /dev/null +++ b/app/views/checklist_entries/edit.html.erb @@ -0,0 +1,11 @@ +

<%= t("scaffold.pagetitle_edit", model: ChecklistEntry.model_name.human) %>

+ +<%= turbo_frame_tag dom_id(@checklist_entry, :frame) do %> + <%= render "form", checklist_entry: @checklist_entry %> + <%= link_to "cancel", @checklist_entry %> +<% end %> + +
+ <%= 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 %> +
diff --git a/app/views/checklist_entries/index.html.erb b/app/views/checklist_entries/index.html.erb new file mode 100644 index 0000000..d2cffb6 --- /dev/null +++ b/app/views/checklist_entries/index.html.erb @@ -0,0 +1,33 @@ +

<%= t("scaffold.pagetitle_index", model: ChecklistEntry.model_name.human(count: 2)) %>

+ + + + + + + + + + + + + + + <% @checklist_entries.each do |checklist_entry| %> + + + + + + + + + + + <% end %> + +
<%= ChecklistEntry.human_attribute_name(:id) %><%= ChecklistEntry.human_attribute_name(:checklist_id) %><%= ChecklistEntry.human_attribute_name(:check_id) %><%= ChecklistEntry.human_attribute_name(:position) %>
<%= link_to(checklist_entry.id, url_for(checklist_entry)) %><%= link_to(checklist_entry.checklist_id, url_for(checklist_entry)) %><%= link_to(checklist_entry.check_id, url_for(checklist_entry)) %><%= link_to(checklist_entry.position, url_for(checklist_entry)) %>
+ +
+ <%= link_to t("scaffold.link_new", model: ChecklistEntry.model_name.human), new_checklist_entry_path %> +
\ No newline at end of file diff --git a/app/views/checklist_entries/index.json.jbuilder b/app/views/checklist_entries/index.json.jbuilder new file mode 100644 index 0000000..be6f6df --- /dev/null +++ b/app/views/checklist_entries/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @checklist_entries, partial: "checklist_entries/checklist_entry", as: :checklist_entry diff --git a/app/views/checklist_entries/new.html.erb b/app/views/checklist_entries/new.html.erb new file mode 100644 index 0000000..7fedce1 --- /dev/null +++ b/app/views/checklist_entries/new.html.erb @@ -0,0 +1,9 @@ +

<%= t("scaffold.pagetitle_new", model: ChecklistEntry.model_name.human) %>

+ +<%= turbo_frame_tag "new_checklist_entry" do %> + <%= render "form", checklist_entry: @checklist_entry %> +<% end %> + +
+ <%= link_to t("scaffold.link_index", model: ChecklistEntry.model_name.human(count: 2)), checklist_entries_path %> +
diff --git a/app/views/checklist_entries/show.html.erb b/app/views/checklist_entries/show.html.erb new file mode 100644 index 0000000..55b7a1c --- /dev/null +++ b/app/views/checklist_entries/show.html.erb @@ -0,0 +1,11 @@ +

<%= t("scaffold.pagetitle_show", model: @checklist_entry.class.model_name.human) %>

+ +<%= turbo_frame_tag dom_id(@checklist_entry, :frame) do %> + <%= render @checklist_entry %> +<% end %> + +
+ <%= 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" %> +
diff --git a/app/views/checklist_entries/show.json.jbuilder b/app/views/checklist_entries/show.json.jbuilder new file mode 100644 index 0000000..f479642 --- /dev/null +++ b/app/views/checklist_entries/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "checklist_entries/checklist_entry", checklist_entry: @checklist_entry diff --git a/app/views/checklists/_checklist.html.erb b/app/views/checklists/_checklist.html.erb index 527b498..70e1a96 100644 --- a/app/views/checklists/_checklist.html.erb +++ b/app/views/checklists/_checklist.html.erb @@ -10,8 +10,8 @@

- Description: - <%= checklist.description %> + Description (formatted): + <%= checklist.description_html %>

diff --git a/app/views/checklists/_checklist.json.jbuilder b/app/views/checklists/_checklist.json.jbuilder index bc0abb5..d3ffcaa 100644 --- a/app/views/checklists/_checklist.json.jbuilder +++ b/app/views/checklists/_checklist.json.jbuilder @@ -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) diff --git a/app/views/checklists/_form.html.erb b/app/views/checklists/_form.html.erb index bc5117d..55696ca 100644 --- a/app/views/checklists/_form.html.erb +++ b/app/views/checklists/_form.html.erb @@ -1,13 +1,6 @@ <%= bootstrap_form_with(model: checklist) do |form| %> <%= form.text_field :code %> <%= form.text_field :name %> - <%= form.text_area :description %> -

Checks

- <% 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 %> \ No newline at end of file diff --git a/app/views/checklists/edit.html.erb b/app/views/checklists/edit.html.erb index a334aff..7ffb0eb 100644 --- a/app/views/checklists/edit.html.erb +++ b/app/views/checklists/edit.html.erb @@ -1,6 +1,24 @@

<%= t("scaffold.pagetitle_edit", model: Checklist.model_name.human) %>

-<%= render "form", checklist: @checklist %> + +
+
+ <%= render "form", checklist: @checklist %> +
+
+

Checks

+
+ <%= 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 %> +
+ <% @checklist.checklist_entries.each do |entry| %> + <%= turbo_frame_tag dom_id(entry, :frame) do %> + <%= render entry %> + <% end %> + <% end %> +
+
<%= link_to t("scaffold.link_show", model: Checklist.model_name.human), @checklist %> diff --git a/app/views/checklists/index.html.erb b/app/views/checklists/index.html.erb index 746ac4b..89d5781 100644 --- a/app/views/checklists/index.html.erb +++ b/app/views/checklists/index.html.erb @@ -9,7 +9,7 @@ <%= Checklist.human_attribute_name(:name) %> - <%= Checklist.human_attribute_name(:description) %> + <%= Checklist.human_attribute_name(:description_html) %> @@ -21,8 +21,7 @@ <%= link_to(checklist.name, url_for(checklist)) %> - <%= link_to(checklist.description, url_for(checklist)) %> - + <%= link_to(truncate(strip_tags(checklist.description_html.to_s)), url_for(checklist)) %> <% end %> diff --git a/app/views/checklists/show.html.erb b/app/views/checklists/show.html.erb index b8cfe07..165fd7d 100644 --- a/app/views/checklists/show.html.erb +++ b/app/views/checklists/show.html.erb @@ -1,9 +1,11 @@

<%= t("scaffold.pagetitle_show", model: @checklist.class.model_name.human) %>

<%= render @checklist %> - +
Dashboard
+  is
+  sidebar
<%= 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" %>
diff --git a/app/views/checks/_check.html.erb b/app/views/checks/_check.html.erb index 2e866b9..0df1c67 100644 --- a/app/views/checks/_check.html.erb +++ b/app/views/checks/_check.html.erb @@ -10,8 +10,8 @@

- <%= Check.human_attribute_name(:success_criterion) %>: - <%= check.success_criterion %> + <%= Check.human_attribute_name(:success_criterion_html) %>: + <%= check.success_criterion_html %>

diff --git a/app/views/checks/_check.json.jbuilder b/app/views/checks/_check.json.jbuilder index b8ecfaa..128c258 100644 --- a/app/views/checks/_check.json.jbuilder +++ b/app/views/checks/_check.json.jbuilder @@ -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) diff --git a/app/views/checks/_form.html.erb b/app/views/checks/_form.html.erb index f1eb076..ab0d482 100644 --- a/app/views/checks/_form.html.erb +++ b/app/views/checks/_form.html.erb @@ -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 %> diff --git a/app/views/checks/index.html.erb b/app/views/checks/index.html.erb index 38b462f..bf029ef 100644 --- a/app/views/checks/index.html.erb +++ b/app/views/checks/index.html.erb @@ -6,7 +6,7 @@ <%= Check.human_attribute_name(:id) %> <%= Check.human_attribute_name(:level) %> <%= Check.human_attribute_name(:name) %> - <%= Check.human_attribute_name(:success_criterion) %> + <%= Check.human_attribute_name(:success_criterion_html) %> <% @checks.each do |check| %> @@ -14,7 +14,7 @@ <%= check.id %> <%= check.level %> <%= link_to(check.name, url_for(check)) %> - <%= link_to(truncate(check.success_criterion), url_for(check)) %> + <%= link_to(truncate(strip_tags(check.success_criterion_html.to_s)), url_for(check)) %> <% end %> diff --git a/app/views/checks/show.html.erb b/app/views/checks/show.html.erb index 06be642..e15c1b1 100644 --- a/app/views/checks/show.html.erb +++ b/app/views/checks/show.html.erb @@ -5,5 +5,5 @@

<%= 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" %>
diff --git a/app/views/elements/_element.html.erb b/app/views/elements/_element.html.erb index 1555037..579fdb2 100644 --- a/app/views/elements/_element.html.erb +++ b/app/views/elements/_element.html.erb @@ -6,7 +6,11 @@ <%= element.path %>

+ <%= element.description_html %> + <% element.success_criteria.each do |sc| %> - <%= render sc %> + <%= turbo_frame_tag(dom_id(sc, :frame)) do %> + <%= render sc %> + <% end %> <% end %>
diff --git a/app/views/elements/_element.json.jbuilder b/app/views/elements/_element.json.jbuilder index 903afbc..1656599 100644 --- a/app/views/elements/_element.json.jbuilder +++ b/app/views/elements/_element.json.jbuilder @@ -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) diff --git a/app/views/elements/_form.html.erb b/app/views/elements/_form.html.erb index 2e3bcc3..f3fa56e 100644 --- a/app/views/elements/_form.html.erb +++ b/app/views/elements/_form.html.erb @@ -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 %> diff --git a/app/views/elements/index.html.erb b/app/views/elements/index.html.erb index c377143..2b6b800 100644 --- a/app/views/elements/index.html.erb +++ b/app/views/elements/index.html.erb @@ -11,7 +11,7 @@ <%= Element.human_attribute_name(:title) %> - <%= Element.human_attribute_name(:description) %> + <%= Element.human_attribute_name(:description_html) %> @@ -25,7 +25,7 @@ <%= link_to(element.title, url_for(element)) %> - <%= link_to(element.description, url_for(element)) %> + <%= link_to(truncate(strip_tags(element.description_html)), url_for(element)) %> <% end %> diff --git a/app/views/elements/new.html.erb b/app/views/elements/new.html.erb index 12ac16d..32cb059 100644 --- a/app/views/elements/new.html.erb +++ b/app/views/elements/new.html.erb @@ -1,6 +1,9 @@

<%= t("scaffold.pagetitle_new", model: Element.model_name.human) %>

-<%= render "form", element: @element %> +<%= turbo_frame_tag "new_element_frame" do %> +

Element hinzufügen

+ <%= render "form", element: @element %> +<% end %>
<%= link_to t("scaffold.link_index", model: Element.model_name.human(count: 2)), elements_path %> diff --git a/app/views/elements/show.html.erb b/app/views/elements/show.html.erb index 75299c7..36ba6d6 100644 --- a/app/views/elements/show.html.erb +++ b/app/views/elements/show.html.erb @@ -5,5 +5,5 @@
<%= 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" %>
diff --git a/app/views/home/show.html.erb b/app/views/home/show.html.erb index 6868dd0..b2993c1 100644 --- a/app/views/home/show.html.erb +++ b/app/views/home/show.html.erb @@ -1,5 +1,4 @@

Dashboard

-

Data

<%= Report.count %> @@ -11,7 +10,7 @@ <%= link_to Checklist.model_name.human(count: Checklist.count), :checklists %>

- + <%= Check.count %> <%= link_to Check.model_name.human(count: Check.count), :checks %>

\ No newline at end of file diff --git a/app/views/layouts/_navigation.html.erb b/app/views/layouts/_navigation.html.erb index bdbbfbe..ceff512 100644 --- a/app/views/layouts/_navigation.html.erb +++ b/app/views/layouts/_navigation.html.erb @@ -1,6 +1,6 @@