Check show ansicht
Some checks failed
/ Run system tests (push) Waiting to run
/ Build, push and deploy image (push) Blocked by required conditions
/ Run tests (push) Has been cancelled

This commit is contained in:
david 2024-09-11 22:04:55 +02:00
parent 4f98673205
commit 29a2bd7466
9 changed files with 74 additions and 25 deletions

View file

@ -48,6 +48,7 @@ gem "tzinfo-data", platforms: %i[windows jruby]
gem "bootsnap", require: false gem "bootsnap", require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
gem "activerecord-enhancedsqlite3-adapter"
gem "bootstrap_form" gem "bootstrap_form"
gem "caxlsx" gem "caxlsx"
gem "caxlsx_rails" gem "caxlsx_rails"
@ -58,7 +59,7 @@ gem "pandoc-ruby"
gem "prawn-markup" gem "prawn-markup"
gem "prawn-rails" gem "prawn-rails"
gem "sablon" gem "sablon"
gem "activerecord-enhancedsqlite3-adapter" gem "ransack"
gem "slim" gem "slim"
group :development, :test do group :development, :test do

View file

@ -258,6 +258,10 @@ GEM
zeitwerk (~> 2.6) zeitwerk (~> 2.6)
rainbow (3.1.1) rainbow (3.1.1)
rake (13.2.1) rake (13.2.1)
ransack (4.2.1)
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
i18n
rbs (3.5.2) rbs (3.5.2)
logger logger
rdoc (6.7.0) rdoc (6.7.0)
@ -396,6 +400,7 @@ DEPENDENCIES
prawn-rails prawn-rails
puma (>= 5.0) puma (>= 5.0)
rails (~> 7.2) rails (~> 7.2)
ransack
rubocop rubocop
rubocop-capybara rubocop-capybara
rubocop-rails rubocop-rails

View file

@ -18,4 +18,10 @@ module ApplicationHelper
safe_join(fields) safe_join(fields)
end end
end end
def safe_display(value, &block)
return unless value
yield(value)
end
end end

View file

@ -52,16 +52,26 @@ class Check < ApplicationRecord
:standard_text, :standard_text,
:powerpoint_text :powerpoint_text
after_create { update(number: id) }
scope(:search, lambda do |term| scope(:search, lambda do |term|
# TODO: Search only fields for current locale. # TODO: Search only fields for current locale.
joins("INNER JOIN action_text_rich_texts ON action_text_rich_texts.record_id = checks.id AND record_type = 'Check'").where("checks.name_de LIKE :term OR checks.name_de LIKE :term OR action_text_rich_texts.body LIKE :term", term: "%#{term}%").distinct joins("INNER JOIN action_text_rich_texts ON action_text_rich_texts.record_id = checks.id AND record_type = 'Check'").where("checks.name_de LIKE :term OR checks.name_de LIKE :term OR action_text_rich_texts.body LIKE :term", term: "%#{term}%").distinct
end) end)
def self.ransackable_attributes(auth_object = nil)
[ "applicable_to_app", "applicable_to_web", "auditory", "cognitive", "conformity_level", "created_at", "external_number", "external_url", "id", "level", "manual_test", "name", "name_de", "name_en", "number", "physical", "position", "principle_id", "priority", "test_url", "updated_at", "visual" ]
end
def self.ransackable_associations(auth_object = nil)
[ "links", "principle", "rich_text_comment", "rich_text_conformity_notice_de", "rich_text_conformity_notice_en", "rich_text_criterion_de", "rich_text_criterion_details_de", "rich_text_criterion_details_en", "rich_text_criterion_en", "rich_text_example_de", "rich_text_example_en", "rich_text_exemption_details_de", "rich_text_exemption_details_en", "rich_text_powerpoint_text_de", "rich_text_powerpoint_text_en", "rich_text_quick_criterion_de", "rich_text_quick_criterion_en", "rich_text_quick_fail_de", "rich_text_quick_fail_en", "rich_text_quick_fix_de", "rich_text_quick_fix_en", "rich_text_standard_text_de", "rich_text_standard_text_en", "rich_text_test_instructions", "standards" ]
end
def display_target_disabilities def display_target_disabilities
%i[visual auditory physical cognitive].select { |d| send(:"#{d}?") }.map { |d| I18n.t("disability.#{d}") }.map(&:first).join(", ") %i[visual auditory physical cognitive].select { |d| send(:"#{d}?") }.map { |d| I18n.t("disability.#{d}") }.join(", ")
end end
def display_applicabilities def display_applicabilities
%i[applicable_to_app applicable_to_web].select { |a| send(:"#{a}?") }.map { |a| I18n.t("applicability.#{a}") }.map(&:first).join(", ") %i[applicable_to_app applicable_to_web].select { |a| send(:"#{a}?") }.map { |a| I18n.t("applicability.#{a}") }.join(", ")
end end
end end

View file

@ -4,15 +4,15 @@ div id=dom_id(check)
tr tr
th = Check.human_attribute_name(:id) th = Check.human_attribute_name(:id)
td = check.id td = check.id
tr
th = Principle.model_name.human
td = check.principle&.t_name
tr
th = Check.human_attribute_name(:number)
td = check.number
tr tr
th = Check.human_attribute_name(:name) th = Check.human_attribute_name(:name)
td = check.t_name td = check.t_name
tr
th = Check.human_attribute_name(:number)
td = check.number
tr
th = Principle.model_name.human
td = check.principle&.t_name
tr tr
th = Standard.model_name.human(count: check.standard_ids.size) th = Standard.model_name.human(count: check.standard_ids.size)
td = check.standards.map(&:t_name).join(", ") td = check.standards.map(&:t_name).join(", ")
@ -25,36 +25,48 @@ div id=dom_id(check)
tr tr
th = Check.human_attribute_name(:external_number) th = Check.human_attribute_name(:external_number)
td = check.external_number td = check.external_number
tr
th = Check.human_attribute_name(:external_url)
td = check.external_url
tr tr
th = Check.human_attribute_name(:conformity_level) th = Check.human_attribute_name(:conformity_level)
td = check.conformity_level td = check.conformity_level
tr tr
th = Check.human_attribute_name(:conformity_notice_de) th = Check.human_attribute_name(:conformity_notice_de)
td = check.conformity_notice_de td = check.conformity_notice_de
tr
th = Check.human_attribute_name(:conformity_notice_en)
td = check.conformity_notice_en
tr tr
th = Check.human_attribute_name(:priority) th = Check.human_attribute_name(:priority)
td = check.priority td = safe_display(check.priority) { I18n.t("priority.#{_1}") }
tr tr
th = Check.human_attribute_name(:quick_criterion_de) th = Check.human_attribute_name(:quick_criterion_de)
td = check.quick_criterion_de td = check.quick_criterion_de
tr
th = Check.human_attribute_name(:quick_criterion_en)
td = check.quick_criterion_en
tr tr
th = Check.human_attribute_name(:quick_fail_de) th = Check.human_attribute_name(:quick_fail_de)
td = check.quick_fail_de td = check.quick_fail_de
tr
th = Check.human_attribute_name(:quick_fail_en)
td = check.quick_fail_en
tr tr
th = Check.human_attribute_name(:quick_fix_de) th = Check.human_attribute_name(:quick_fix_de)
td = check.quick_fix_de td = check.quick_fix_de
tr tr
th = Check.human_attribute_name(:quick_fix_en) th = Check.human_attribute_name(:criterion_de)
td = check.quick_fix_en td = check.criterion_de
tr
th = Check.human_attribute_name(:criterion_details_de)
td = check.criterion_details_de
tr
th = Check.human_attribute_name(:example_de)
td = check.example_de
tr
th = Check.human_attribute_name(:exemption_details_de)
td = check.exemption_details_de
tr
th = Check.human_attribute_name(:test_instructions)
td = check.test_instructions
tr
th = Check.human_attribute_name(:powerpoint_text_de)
td = check.powerpoint_text_de
tr
th = Check.human_attribute_name(:comment)
td = check.comment
tr tr
th = Link.model_name.human(count: check.links.size) th = Link.model_name.human(count: check.links.size)
td td

View file

@ -5,23 +5,26 @@
.row .row
= form.collection_radio_buttons(:principle_id, Principle.all.sort_by(&:t_name), :id, :t_name) { |b| b.label(class: "col-md-2") { b.radio_button + b.text } } = form.collection_radio_buttons(:principle_id, Principle.all.sort_by(&:t_name), :id, :t_name) { |b| b.label(class: "col-md-2") { b.radio_button + b.text } }
= form.collection_check_boxes :standard_ids, Standard.all.sort_by{ _1.t_name.downcase }, :id, :t_name, include_blank: true = form.collection_check_boxes :standard_ids, Standard.all.sort_by{ _1.t_name.downcase }, :id, :t_name, include_blank: true
h2 Zugänglichkeit h2 Zugänglichkeit
.row .row
- %w[visual auditory physical cognitive].sort_by { |d| t("disability.#{d}") }.each do |d| - %w[visual auditory physical cognitive].sort_by { |d| t("disability.#{d}") }.each do |d|
.col-md-3 .col-md-3
= form.check_box d, label: t("disability.#{d}").capitalize = form.check_box d, label: t("disability.#{d}").capitalize
h2 Anwendbarkeit h2 Anwendbarkeit
.row .row
- %w[applicable_to_web applicable_to_app].sort_by { |d| t("applicability.#{d}") }.each do |d| - %w[applicable_to_web applicable_to_app].sort_by { |d| t("applicability.#{d}") }.each do |d|
.col-md-6 .col-md-6
= form.check_box d, label: t("applicability.#{d}").capitalize = form.check_box d, label: t("applicability.#{d}").capitalize
h2 Richtlinie h2 Richtlinie
= form.text_field :external_number = form.text_field :external_number
= form.text_field :external_url = form.text_field :external_url
= form.select :conformity_level, Check.conformity_levels.keys, include_blank: true = form.select :conformity_level, Check.conformity_levels.keys, include_blank: true
= multilang_form_field(form, :conformity_notice, as: :rich_text_area) = multilang_form_field(form, :conformity_notice, as: :rich_text_area)
= form.select :priority, Check.priorities.keys.map{ [t("priority.#{_1}"), _1] }, include_blank: true = form.select :priority, Check.priorities.keys.map{ [t("priority.#{_1}"), _1] }, include_blank: true
h2 Quick Infos h2 Quick Infos
= multilang_form_field(form, :quick_criterion, as: :rich_text_area) = multilang_form_field(form, :quick_criterion, as: :rich_text_area)
= multilang_form_field(form, :quick_fail, as: :rich_text_area) = multilang_form_field(form, :quick_fail, as: :rich_text_area)

View file

@ -1,5 +1,16 @@
h1 h1
= t("scaffold.pagetitle_index", model: Check.model_name.human(count: 2)) = t("scaffold.pagetitle_index", model: Check.model_name.human(count: 2))
/= search_form_for @q do |f|
= f.search_field :name_cont
/= f.select :principle_id_in, options_from_collection_for_select(Principle.all.sort_by(&:name_de), :id, :name_de, filter_params[:principle_id_in]), { include_blank: false }, { multiple: true, class: "form-select" }
= f.label :principle_id_in, "Prinzip"
.d-flex.flex-row.mb-3
- Principle.all.sort_by(&:name_de).each do |principle|
.me-3
= f.check_box :principle_id_in, checked: @q[:principle_id_in].include?(principle.id), label: principle.name_de, id: "principle_id_in_#{principle.id}"
= f.submit
= bootstrap_form_with(url: checks_path(page: params[:page]), method: :get, scope: :filter) do |form| = bootstrap_form_with(url: checks_path(page: params[:page]), method: :get, scope: :filter) do |form|
= form.hidden_field :page, value: params[:page] if params[:page] = form.hidden_field :page, value: params[:page] if params[:page]
.row .row

View file

@ -1,5 +1,7 @@
require_relative 'boot' require_relative 'boot'
ENV['RANSACK_FORM_BUILDER'] = '::BootstrapForm::FormBuilder'
require 'rails' require 'rails'
# Pick the frameworks you want: # Pick the frameworks you want:
require 'active_model/railtie' require 'active_model/railtie'

View file

@ -1,7 +1,6 @@
class FinalizeCheckFields < ActiveRecord::Migration[7.2] class FinalizeCheckFields < ActiveRecord::Migration[7.2]
def change def change
add_column :checks, :number, :integer add_column :checks, :number, :string
add_index :checks, :number, unique: true
add_column :checks, :name_de, :string add_column :checks, :name_de, :string
add_column :checks, :name_en, :string add_column :checks, :name_en, :string
@ -23,6 +22,6 @@ class FinalizeCheckFields < ActiveRecord::Migration[7.2]
add_column :checks, :manual_test, :boolean, null: false, default: true add_column :checks, :manual_test, :boolean, null: false, default: true
add_column :checks, :test_url, :string, null: true add_column :checks, :test_url, :string, null: true
add_column :checks, :external_url, :string, null: true add_column :checks, :external_url, :string, null: false
end end
end end