A lot :)
Some checks failed
/ Run tests (push) Successful in 8m56s
/ Run system tests (push) Failing after 1h0m48s
/ Build, push and deploy image (push) Successful in 7m47s

This commit is contained in:
david 2024-09-05 22:54:38 +02:00
parent aad67af0d1
commit 63fc206c27
153 changed files with 2043 additions and 646 deletions

View file

@ -115,6 +115,4 @@ $enable-rounded: false;
overflow-y: auto;
} */
@import "./layout";

View file

@ -1,8 +1,10 @@
# frozen_string_literal: true
module Admin
class BackupsController < ApplicationController
# GET /admin/backups/1
def show
send_file Backup.db_xlsx, filename: 'backup.xlsx', disposition: :attachment
send_file Backup.db_xlsx, filename: "backup.xlsx", disposition: :attachment
end
end
end

View file

@ -3,20 +3,24 @@
class ApplicationController < ActionController::Base
include Pagy::Backend
# allow_browser versions: :modern
before_action :initialize_navbar
private
def initialize_navbar
@nav_path = controller_name
return unless request.get?
@navbar_items = [
{ 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: :check2, path: :checks },
{ label: Link.model_name.human(count: 2), icon: :link, path: :links },
{ label: LinkCategory.model_name.human(count: 2), icon: :"folder", path: :link_categories }
{ 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: :check2, path: :checks },
{ label: Link.model_name.human(count: 2), icon: :link, path: :links },
{ label: LinkCategory.model_name.human(count: 2), icon: :folder, path: :link_categories }
]
@search_url = nil # root_url
@nav_path = controller_name
@search_url = nil
end
end

View file

@ -0,0 +1,213 @@
class BenchmarkingController < ApplicationController
protect_from_forgery with: :null_session
before_action :set_user_update_last_seen_at
# POST /benchmarking/read_heavy
def read_heavy
act_and_respond(
link_create: 0.1,
link_destroy: 0.1,
link_show: 0.4,
links_index: 0.4,
)
end
# POST /benchmarking/write_heavy
def write_heavy
act_and_respond(
link_create: 0.4,
link_destroy: 0.4,
link_show: 0.1,
links_index: 0.1,
)
end
# POST /benchmarking/balanced
def balanced
act_and_respond(
link_create: 0.25,
link_destroy: 0.25,
link_show: 0.25,
links_index: 0.25,
)
end
def link_create
link = LinkCategory.create!(name: "Benchmark #{request.uuid}", description_html: "<pre>#{format(request:)}</pre>")
redirect_to link
end
def link_destroy
link = LinkCategory.where("id >= ?", rand(LinkCategory.minimum(:id)..LinkCategory.maximum(:id))).limit(1).first
link.destroy!
redirect_to links_path
end
def link_show
@link_category = LinkCategory.where("id >= ?", rand(LinkCategory.minimum(:id)..LinkCategory.maximum(:id))).limit(1).first
render "link_categories/show", status: :ok
end
def links_index
@link_categories = LinkCategory.where("id >= ?", rand(LinkCategory.minimum(:id)..LinkCategory.maximum(:id))).limit(100)
render "link_categories/index", status: :ok
end
private
def set_user_update_last_seen_at
# @user = User.where("id >= ?", rand(User.minimum(:id)..User.maximum(:id))).limit(1).first
# @user.update!(last_seen_at: Time.now)
end
def act_and_respond(actions_with_weighted_distribution)
action = actions_with_weighted_distribution.max_by { |_, weight| rand ** (1.0 / weight) }.first
send(action)
end
def format(request:)
request.headers.to_h.slice(
"GATEWAY_INTERFACE",
"HTTP_ACCEPT",
"HTTP_HOST",
"HTTP_USER_AGENT",
"HTTP_VERSION",
"ORIGINAL_FULLPATH",
"ORIGINAL_SCRIPT_NAME",
"PATH_INFO",
"QUERY_STRING",
"REMOTE_ADDR",
"REQUEST_METHOD",
"REQUEST_PATH",
"REQUEST_URI",
"SCRIPT_NAME",
"SERVER_NAME",
"SERVER_PORT",
"SERVER_PROTOCOL",
"SERVER_SOFTWARE",
"action_dispatch.request_id",
"puma.request_body_wait",
).map { _1.join(": ") }.join("\n")
end
end
# class BenchmarkingController < ApplicationController
# skip_before_action :verify_authenticity_token
# skip_before_action :ensure_user_authenticated!
# before_action :set_user_update_last_seen_at
# # POST /benchmarking/read_heavy
# def read_heavy
# act_and_respond(
# link_create: 0.10,
# comment_create: 0.10,
# post_destroy: 0.02,
# comment_destroy: 0.03,
# post_show: 0.25,
# posts_index: 0.25,
# user_show: 0.25,
# )
# end
# # POST /benchmarking/write_heavy
# def write_heavy
# act_and_respond(
# link_create: 0.25,
# comment_create: 0.25,
# post_destroy: 0.05,
# comment_destroy: 0.20,
# post_show: 0.05,
# posts_index: 0.15,
# user_show: 0.05,
# )
# end
# # POST /benchmarking/balanced
# def balanced
# act_and_respond(
# link_create: 0.17,
# comment_create: 0.17,
# post_destroy: 0.05,
# comment_destroy: 0.11,
# post_show: 0.17,
# posts_index: 0.17,
# user_show: 0.16,
# )
# end
# def link_create
# post = Post.create!(user: @user, title: "Post #{request.uuid}", description: format(request:))
# redirect_to post
# end
# def comment_create
# post = Post.where("id >= ?", rand(Post.minimum(:id)..Post.maximum(:id))).limit(1).first
# comment = Comment.create!(user: @user, post: post, body: "Comment #{request.uuid}")
# redirect_to comment.post
# end
# def post_destroy
# post = Post.where("id >= ?", rand(Post.minimum(:id)..Post.maximum(:id))).limit(1).first
# post.destroy!
# redirect_to posts_path
# end
# def comment_destroy
# comment = Comment.where("id >= ?", rand(Comment.minimum(:id)..Comment.maximum(:id))).limit(1).first
# comment.destroy!
# redirect_to comment.post
# end
# def post_show
# @post = Post.where("id >= ?", rand(Post.minimum(:id)..Post.maximum(:id))).limit(1).first
# render "posts/show", status: :ok
# end
# def posts_index
# @posts = Post.where("id >= ?", rand(Post.minimum(:id)..Post.maximum(:id))).limit(100)
# render "posts/index", status: :ok
# end
# def user_show
# render "users/show", status: :ok
# end
# private
# def set_user_update_last_seen_at
# @user = User.where("id >= ?", rand(User.minimum(:id)..User.maximum(:id))).limit(1).first
# @user.update!(last_seen_at: Time.now)
# end
# def act_and_respond(actions_with_weighted_distribution)
# action = actions_with_weighted_distribution.max_by { |_, weight| rand ** (1.0 / weight) }.first
# send(action)
# end
# def format(request:)
# request.headers.to_h.slice(
# "GATEWAY_INTERFACE",
# "HTTP_ACCEPT",
# "HTTP_HOST",
# "HTTP_USER_AGENT",
# "HTTP_VERSION",
# "ORIGINAL_FULLPATH",
# "ORIGINAL_SCRIPT_NAME",
# "PATH_INFO",
# "QUERY_STRING",
# "REMOTE_ADDR",
# "REQUEST_METHOD",
# "REQUEST_PATH",
# "REQUEST_URI",
# "SCRIPT_NAME",
# "SERVER_NAME",
# "SERVER_PORT",
# "SERVER_PROTOCOL",
# "SERVER_SOFTWARE",
# "action_dispatch.request_id",
# "puma.request_body_wait",
# ).map { _1.join(": ") }.join("\n")
# end
# end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ChecklistEntriesController < ApplicationController
before_action :set_checklist_entry, only: %i[show edit update destroy]
@ -7,8 +9,7 @@ class ChecklistEntriesController < ApplicationController
end
# GET /checklist_entries/1
def show
end
def show; end
# GET /checklist_entries/new
def new
@ -16,15 +17,14 @@ class ChecklistEntriesController < ApplicationController
end
# GET /checklist_entries/1/edit
def edit
end
def edit; end
# POST /checklist_entries
def create
@checklist_entry = ChecklistEntry.new(checklist_entry_params)
if @checklist_entry.save
redirect_to @checklist_entry.checklist, notice: 'Checklist entry was successfully created.'
redirect_to @checklist_entry.checklist, notice: "Checklist entry was successfully created."
else
render :new, status: :unprocessable_entity
end
@ -33,7 +33,7 @@ class ChecklistEntriesController < ApplicationController
# PATCH/PUT /checklist_entries/1
def update
if @checklist_entry.update(checklist_entry_params)
redirect_to @checklist_entry.checklist, notice: 'Checklist entry was successfully updated.',
redirect_to @checklist_entry.checklist, notice: "Checklist entry was successfully updated.",
status: :see_other
else
render :edit, status: :unprocessable_entity
@ -45,7 +45,7 @@ class ChecklistEntriesController < ApplicationController
@checklist_entry.destroy!
respond_to do |format|
format.html do
redirect_to checklist_entries_url, notice: 'Checklist entry was successfully destroyed.', status: :see_other
redirect_to checklist_entries_url, notice: "Checklist entry was successfully destroyed.", status: :see_other
end
format.turbo_stream
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ChecklistsController < ApplicationController
before_action :set_checklist, only: %i[show edit update destroy]
@ -7,8 +9,7 @@ class ChecklistsController < ApplicationController
end
# GET /checklists/1
def show
end
def show; end
# GET /checklists/new
def new
@ -16,15 +17,14 @@ class ChecklistsController < ApplicationController
end
# GET /checklists/1/edit
def edit
end
def edit; end
# POST /checklists
def create
@checklist = Checklist.new(checklist_params)
if @checklist.save
redirect_to @checklist, notice: 'Checklist was successfully created.'
redirect_to @checklist, notice: "Checklist was successfully created."
else
render :new, status: :unprocessable_entity
end
@ -33,7 +33,7 @@ class ChecklistsController < ApplicationController
# PATCH/PUT /checklists/1
def update
if @checklist.update(checklist_params)
redirect_to @checklist, notice: 'Checklist was successfully updated.', status: :see_other
redirect_to @checklist, notice: "Checklist was successfully updated.", status: :see_other
else
render :edit, status: :unprocessable_entity
end
@ -42,7 +42,7 @@ class ChecklistsController < ApplicationController
# DELETE /checklists/1
def destroy
@checklist.destroy!
redirect_to checklists_url, notice: 'Checklist was successfully destroyed.', status: :see_other
redirect_to checklists_url, notice: "Checklist was successfully destroyed.", status: :see_other
end
private

View file

@ -1,14 +1,19 @@
# frozen_string_literal: true
class ChecksController < ApplicationController
before_action :set_check, only: %i[show edit update destroy]
# GET /checks or /checks.json
def index
@pagy, @checks = pagy(Check.search(filter_params[:s]))
@pagy, @checks = if filter_params[:s]
pagy(Check.search(filter_params[:s]).order(:conformity_level))
else
pagy(Check.all.order(:conformity_level))
end
end
# GET /checks/1 or /checks/1.json
def show
end
def show; end
# GET /checks/new
def new
@ -16,8 +21,7 @@ class ChecksController < ApplicationController
end
# GET /checks/1/edit
def edit
end
def edit; end
# POST /checks or /checks.json
def create
@ -27,11 +31,11 @@ class ChecksController < ApplicationController
if @check.save
format.html do
redirect_to check_url(@check),
notice: t('scaffold.model_created_successfully', model: @check.model_name.human)
notice: t("scaffold.model_created_successfully", model: @check.model_name.human)
end
format.json { render :show, status: :created, location: @check }
else
flash[:alert] = t('there_were_errors', count: @check.errors.size)
flash[:alert] = t("there_were_errors", count: @check.errors.size)
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @check.errors, status: :unprocessable_entity }
end
@ -44,7 +48,7 @@ class ChecksController < ApplicationController
if @check.update(check_params)
format.html do
redirect_to check_url(@check),
notice: t('scaffold.model_updated_successfully', model: @check.model_name.human)
notice: t("scaffold.model_updated_successfully", model: @check.model_name.human)
end
format.json { render :show, status: :ok, location: @check }
else
@ -60,7 +64,7 @@ class ChecksController < ApplicationController
respond_to do |format|
format.html do
redirect_to checks_url, notice: t('scaffold.model_destroyed_successfully', model: @check.model_name.human)
redirect_to checks_url, notice: t("scaffold.model_destroyed_successfully", model: @check.model_name.human)
end
format.json { head :no_content }
end
@ -79,6 +83,43 @@ class ChecksController < ApplicationController
# Only allow a list of trusted parameters through.
def check_params
params.require(:check).permit(:position, :name, :success_criterion, :success_criterion_html, :level)
params.require(:check).permit(:principle_id,
:number,
:name_de,
:name_en,
:standard_id,
:visual,
:auditory,
:physical,
:cognitive,
:applicable_to_app,
:applicable_to_web,
:external_number,
:conformity_level,
:conformity_notice_de,
:conformity_notice_en,
:priority,
:quick_criterion_de,
:quick_criterion_en,
:quick_fail_de,
:quick_fail_en,
:quick_fix_de,
:quick_fix_en,
:criterion_de,
:criterion_en,
:criterion_details_de,
:criterion_details_en,
:example_de,
:example_en,
:exemption_details_de,
:exemption_details_en,
:standard_text_de,
:standard_text_en,
:test_instructions,
:powerpoint_text_de,
:powerpoint_text_en,
:comment,
link_ids: [],
standard_ids: [])
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ElementsController < ApplicationController
before_action :set_element, only: %i[show edit update destroy]
@ -7,8 +9,7 @@ class ElementsController < ApplicationController
end
# GET /elements/1
def show
end
def show; end
# GET /elements/new
def new
@ -16,8 +17,7 @@ class ElementsController < ApplicationController
end
# GET /elements/1/edit
def edit
end
def edit; end
# POST /elements
def create
@ -28,11 +28,11 @@ class ElementsController < ApplicationController
if @element.save
checklist.checks.each do |check|
@element.success_criteria.create!(title: check.name, description_html: check.success_criterion_html,
@element.success_criteria.create!(title: check.t_name, description_html: check.t_criterion,
level: check.level)
end
respond_to do |format|
format.html { redirect_to @element.report, notice: 'Element was successfully created.' }
format.html { redirect_to @element.report, notice: "Element was successfully created." }
format.turbo_stream
end
else
@ -43,7 +43,7 @@ class ElementsController < ApplicationController
# PATCH/PUT /elements/1
def update
if @element.update(element_params)
redirect_to @element, notice: 'Element was successfully updated.', status: :see_other
redirect_to @element, notice: "Element was successfully updated.", status: :see_other
else
render :edit, status: :unprocessable_entity
end
@ -52,7 +52,7 @@ class ElementsController < ApplicationController
# DELETE /elements/1
def destroy
@element.destroy!
redirect_to elements_url, notice: 'Element was successfully destroyed.', status: :see_other
redirect_to elements_url, notice: "Element was successfully destroyed.", status: :see_other
end
private

View file

@ -1,5 +1,6 @@
# frozen_string_literal: true
class HomeController < ApplicationController
def show; end
def show
end
end

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true
class LinkCategoriesController < ApplicationController
before_action :set_link_category, only: %i[ show edit update destroy ]
before_action :set_link_category, only: %i[show edit update destroy]
# GET /link_categories
def index
@ -7,8 +9,7 @@ class LinkCategoriesController < ApplicationController
end
# GET /link_categories/1
def show
end
def show; end
# GET /link_categories/new
def new
@ -16,8 +17,7 @@ class LinkCategoriesController < ApplicationController
end
# GET /link_categories/1/edit
def edit
end
def edit; end
# POST /link_categories
def create
@ -46,13 +46,14 @@ class LinkCategoriesController < ApplicationController
end
private
# Use callbacks to share common setup or constraints between actions.
def set_link_category
@link_category = LinkCategory.find(params[:id])
end
# Only allow a list of trusted parameters through.
def link_category_params
params.require(:link_category).permit(:name, :description, :rich_text)
end
# Use callbacks to share common setup or constraints between actions.
def set_link_category
@link_category = LinkCategory.find(params[:id])
end
# Only allow a list of trusted parameters through.
def link_category_params
params.require(:link_category).permit(:name, :description, :rich_text)
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class LinksController < ApplicationController
before_action :set_link, only: %i[show edit update destroy]
@ -7,8 +9,7 @@ class LinksController < ApplicationController
end
# GET /links/1
def show
end
def show; end
# GET /links/new
def new
@ -16,15 +17,14 @@ class LinksController < ApplicationController
end
# GET /links/1/edit
def edit
end
def edit; end
# POST /links
def create
@link = Link.new(link_params)
if @link.save
redirect_to @link, notice: 'Link was successfully created.'
redirect_to @link, notice: "Link was successfully created."
else
render :new, status: :unprocessable_entity
end
@ -33,7 +33,7 @@ class LinksController < ApplicationController
# PATCH/PUT /links/1
def update
if @link.update(link_params)
redirect_to @link, notice: 'Link was successfully updated.', status: :see_other
redirect_to @link, notice: "Link was successfully updated.", status: :see_other
else
render :edit, status: :unprocessable_entity
end
@ -42,7 +42,7 @@ class LinksController < ApplicationController
# DELETE /links/1
def destroy
@link.destroy!
redirect_to links_url, notice: 'Link was successfully destroyed.', status: :see_other
redirect_to links_url, notice: "Link was successfully destroyed.", status: :see_other
end
private

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class ReportsController < ApplicationController
before_action :set_report, only: %i[show edit update destroy work]
@ -12,26 +14,56 @@ class ReportsController < ApplicationController
format.html
format.pdf
format.xlsx do
response.headers['Content-Disposition'] = %(attachment; filename="#{filename(@report, extension: 'xlsx')}")
response.headers["Content-Disposition"] = %(attachment; filename="#{filename(@report, extension: 'xlsx')}")
render
end
format.xml do
response.headers['Content-Disposition'] = %(attachment; filename="#{filename(@report, extension: 'html')}")
render formats: [:odt], layout: false
response.headers["Content-Disposition"] = %(attachment; filename="#{filename(@report, extension: 'html')}")
render formats: [ :odt ], layout: false
end
format.rtf do
html = render_to_string(template: 'reports/show', formats: [:odt],
html = render_to_string(template: "reports/show", formats: [ :odt ],
layout: false)
rtf = "{\\rtf1\n#{PandocRuby.html(html).to_rtf}}"
send_data rtf, filename: filename(@report, extension: 'rtf')
send_data rtf, filename: filename(@report, extension: "rtf")
end
format.odt do
html = render_to_string(layout: false)
odt = PandocRuby.html(html).to_odt
send_data odt, filename: filename(@report, extension: 'odt')
send_data odt, filename: filename(@report, extension: "odt")
end
format.docx do
template = Sablon.template(Rails.root.join('lib/templates/docx/report.docx'))
send_file(Docx::Document.new.generate do |document|
document.heading1(@report.name)
document.paragraph(@report.comment_html)
# document.heading1("slfkj")
# document.paragraph("sldkfj")
@report.elements.each do |element|
document.heading2(element.title)
element.success_criteria.each do |sc|
document.heading3(sc.title)
document.paragraph(sc.description_html)
end
end
end, filename: filename(@report, extension: "docx"),
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
return
text = OpenXml::Docx::Elements::Text.new(@report.name)
run = OpenXml::Docx::Elements::Run.new
run.bold = true
run << text
paragraph = OpenXml::Docx::Elements::Paragraph.new
paragraph << run
document = OpenXml::Docx::Package.new
document.document << paragraph
document.save(Rails.root.join("tmp", "output.docx"))
send_file Rails.root.join("tmp", "output.docx")
return
template = Sablon.template(Rails.root.join("lib/templates/docx/report.docx"))
context = {
person: OpenStruct.new(first_name: @report.name),
skills: [],
@ -40,10 +72,10 @@ class ReportsController < ApplicationController
referees: []
}
template.render_to_file(Rails.root.join('tmp/output.docx'), context)
send_file Rails.root.join('tmp/output.docx'),
filename: filename(@report, extension: 'docx'),
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
template.render_to_file(Rails.root.join("tmp/output.docx"), context)
send_file Rails.root.join("tmp/output.docx"),
filename: filename(@report, extension: "docx"),
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
end
end
end
@ -54,15 +86,14 @@ class ReportsController < ApplicationController
end
# GET /reports/1/edit
def edit
end
def edit; end
# POST /reports
def create
@report = Report.new(report_params)
if @report.save
redirect_to @report, notice: 'Report was successfully created.'
redirect_to @report, notice: "Report was successfully created."
else
render :new, status: :unprocessable_entity
end
@ -71,7 +102,7 @@ class ReportsController < ApplicationController
# PATCH/PUT /reports/1
def update
if @report.update(report_params)
redirect_to @report, notice: 'Report was successfully updated.', status: :see_other
redirect_to @report, notice: "Report was successfully updated.", status: :see_other
else
render :edit, status: :unprocessable_entity
end
@ -80,7 +111,7 @@ class ReportsController < ApplicationController
# DELETE /reports/1
def destroy
@report.destroy!
redirect_to reports_url, notice: 'Report was successfully destroyed.', status: :see_other
redirect_to reports_url, notice: "Report was successfully destroyed.", status: :see_other
end
def work
@ -99,7 +130,7 @@ class ReportsController < ApplicationController
params.require(:report).permit(:name, :comment_html)
end
def filename(report, extension: 'html')
def filename(report, extension: "html")
"#{report.name}-#{Time.current.strftime('%Y%m%d%H%M')}.#{extension}"
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SuccessCriteriaController < ApplicationController
before_action :set_success_criterion, only: %i[show edit update destroy]
@ -7,8 +9,7 @@ class SuccessCriteriaController < ApplicationController
end
# GET /success_criteria/1
def show
end
def show; end
# GET /success_criteria/new
def new
@ -16,15 +17,14 @@ class SuccessCriteriaController < ApplicationController
end
# GET /success_criteria/1/edit
def edit
end
def edit; end
# POST /success_criteria
def create
@success_criterion = SuccessCriterion.new(success_criterion_params)
if @success_criterion.save
redirect_to @success_criterion, notice: 'Erfolgskriterium was successfully created.'
redirect_to @success_criterion, notice: "Erfolgskriterium 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: 'Erfolgskriterium was successfully updated.', status: :see_other
redirect_to @success_criterion, notice: "Erfolgskriterium was successfully updated.", status: :see_other
else
render :edit, status: :unprocessable_entity
end
@ -44,7 +44,7 @@ class SuccessCriteriaController < ApplicationController
@success_criterion.destroy!
respond_to do |format|
format.html do
redirect_to success_criteria_url, notice: 'Erfolgskriterium was successfully destroyed.', status: :see_other
redirect_to success_criteria_url, notice: "Erfolgskriterium was successfully destroyed.", status: :see_other
end
format.turbo_stream
end

View file

@ -4,4 +4,16 @@ module ApplicationHelper
include Pagy::Frontend
delegate :filter_params, to: :controller
def multilang_form_field(form, attribute, as: :text_field)
col_width = as == :rich_text_area ? 12 : 12 / I18n.available_locales.count
tag.div(class: "row") do
fields = I18n.available_locales.map { _1.to_s.split("-").first }.map do |lang|
tag.div(class: "col-lg-#{col_width}") do
form.send(as, "#{attribute}_#{lang}")
end
end
safe_join(fields)
end
end
end

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
module ChecklistEntriesHelper
end

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
module ChecklistsHelper
end

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
module ChecksHelper
end

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
module ElementsHelper
end

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
module LinkCategoriesHelper
end

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
module LinksHelper
end

View file

@ -1,17 +1,19 @@
# frozen_string_literal: true
module PdfHelper
def prepare_rich_text(rich_text)
return rich_text
{ del: 'strikethrough' }.each do |tag, replacement|
{ del: "strikethrough" }.each do |tag, replacement|
rich_text = rich_text.to_s.gsub("<#{tag}", "<#{replacement}")
rich_text = rich_text.to_s.gsub("</#{tag}>", "</#{replacement}>")
end
%w[div p del blockquote pre code].each do |tag|
rich_text = rich_text.to_s.gsub(%r{<#{tag}.*?>|</#{tag}>}, '')
rich_text = rich_text.to_s.gsub(%r{<#{tag}.*?>|</#{tag}>}, "")
end
rich_text.gsub!(/<h1.*?>/, '')
rich_text.gsub!(%r{</h1>}, '<br><br>')
rich_text.gsub!(/<h1.*?>/, "")
rich_text.gsub!(%r{</h1>}, "<br><br>")
rich_text
end
end

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
module ReportsHelper
end

View file

@ -1,13 +1,15 @@
# frozen_string_literal: true
module SuccessCriteriaHelper
def success_criterion_result_icon_classes(sc)
if sc.passed?
'bi bi-check text-success'
"bi bi-check text-success"
elsif sc.failed?
'bi bi-exclamation-lg text-danger'
"bi bi-exclamation-lg text-danger"
elsif sc.not_applicable?
'bi bi-dash text-muted'
"bi bi-dash text-muted"
else
'bi bi-question text-warning'
"bi bi-question text-warning"
end
end
@ -16,13 +18,13 @@ module SuccessCriteriaHelper
if edit_mode
success_criterion
else
[:edit,
success_criterion]
[ :edit,
success_criterion ]
end
else
else
success_criterion.element
end
link_to tag.i(class: 'bi bi-pencil'),
end
link_to tag.i(class: "bi bi-pencil"),
path,
class: "btn btn-#{edit_mode ? 'link text-warning' : 'link text-secondary'}"
end

View file

@ -5,3 +5,4 @@ import * as bootstrap from "bootstrap"
import "trix"
import "@rails/actiontext"

View file

@ -21,3 +21,4 @@ application.register("set-theme", SetThemeController)
import ThemeSwitcherController from "./theme_switcher_controller"
application.register("theme-switcher", ThemeSwitcherController)

133
app/lib/docx/document.rb Normal file
View file

@ -0,0 +1,133 @@
module Docx
class Document
include OpenXml::Docx::Elements
def initialize
end
def generate
yield(self)
tmpfile = Tempfile.new("#{Time.current.to_f}.xlsx", Rails.root.join("tmp"))
_document.save(tmpfile.path)
tmpfile.path
end
def heading1(text)
paragraph = create_paragraph(text)
paragraph.paragraph_style = "Heading 1"
_document.document << paragraph
end
def heading2(text)
paragraph = create_paragraph(text)
paragraph.paragraph_style = "Heading 2"
_document.document << paragraph
end
def heading3(text)
paragraph = create_paragraph(text)
paragraph.paragraph_style = "Heading 3"
_document.document << paragraph
end
def paragraph(text)
html = Nokogiri::HTML5.fragment(text)
html.search(".trix-content").each do |node|
node.children.each do |child|
Rails.logger.debug { "content kids: #{child.class}: #{child.name} (#{child.children.size}): #{child.text}" }
case child
when Nokogiri::XML::Text
paragraph = create_paragraph(child.text)
_document.document << paragraph
when Nokogiri::XML::Element
case child.name
when "h1"
paragraph = create_paragraph(child.text)
paragraph.paragraph_style = "Heading 3"
when "div"
paragraph = Paragraph.new
paragraph.paragraph_style = "Body Text"
child.children.each do |node|
Rails.logger.debug { "div kids: #{node.class}: #{node.name} (#{node.children.size}): #{node.text}" }
case node.name
when "strong"
paragraph << create_run(node.text, bold: true)
when "em"
paragraph << create_run(node.text, italic: true)
when "del"
paragraph << create_run(node.text, strike_through: true)
when "br"
paragraph << create_run("\n")
else
paragraph << create_run(node.text)
end
end
when "ul"
# paragraph = Paragraph.new
# paragraph.paragraph_style = "Body Text"
# # Create an abstract numbering that describes a bulleted list:
# abstract_numbering = AbstractNumbering.new(0)
# # Each numbering can have multiple levels. Define the first level as a bulleted list:
# level_0 = Level.new
# level_0.level = 0
# level_0.start = 1
# level_0.number_format = :bullet
# # This is the default bullet Word uses
# level_0.level_text = "\u00B7".encode("UTF-8")
# level_0.alignment = :left
# level_0.character_style.font.ascii = "Symbol"
# level_0.character_style.font.high_ansi = "Symbol"
# level_0.character_style.font.hint = :default
# level_0.paragraph_style.indentation.left = 720
# level_0.paragraph_style.indentation.hanging = 360
# abstract_numbering << level_0
# _document.numbering << abstract_numbering
when "ol"
else
paragraph = create_paragraph(child.text)
paragraph.paragraph_style = "Body Text"
end
_document.document << paragraph
end
end
end
end
private
def create_run(content, bold: false, italic: false, strike_through: false)
text = Text.new(content)
text.space = :preserve
run = Run.new
run.bold = bold
run.italics = italic
run.strikethrough = strike_through
run << text
run
end
def create_paragraph(content)
text = case content
when String
Text.new(content)
when ActionText::RichText
Text.new(content.to_plain_text)
else
Text.new(content.to_s)
end
run = Run.new
run << text
paragraph = Paragraph.new
paragraph << run
paragraph
end
def _document
@_document ||= OpenXml::Docx::Package.new
end
end
end

View file

@ -1,7 +1,12 @@
# frozen_string_literal: true
module LinkChecker
UA = "Mozilla/5.0 (Android 4.4; Mobile; rv:41.0) Gecko/41.0 Firefox/41.0"
module_function def http(input)
response = Net::HTTP.get_response(URI.parse(input), {"User-Agent": UA})
module_function
def http(input)
response = Net::HTTP.get_response(URI.parse(input), { 'User-Agent': UA })
# debugger
case response
when Net::HTTPSuccess
@ -13,4 +18,3 @@ module LinkChecker
end
end
end

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
default from: "from@example.com"
layout "mailer"
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module ActionText
class RichText < Record
before_save do

View file

@ -1,10 +1,12 @@
# frozen_string_literal: true
module Admin
class Backup
class << self
def zip
create_records_xlsx
ZipFileGenerator.new(Rails.root.join('storage')).write
ZipFileGenerator.new(Rails.root.join("storage")).write
end
def db_xlsx
@ -21,7 +23,7 @@ module Admin
end
end
end
path = Rails.root.join('storage/data.xls')
path = Rails.root.join("storage/data.xls")
xlsx.serialize(path)
path
end
@ -29,7 +31,7 @@ module Admin
private
def file_path(name)
Rails.root.join('storage', name)
Rails.root.join("storage", name)
end
end
end
@ -53,9 +55,9 @@ module Admin
# Zip the input directory.
def write
entries = Dir.entries(@input_dir) - %w[. ..]
path = Rails.root.join('tmp', Time.now.to_i.to_s)
path = Rails.root.join("tmp", Time.now.to_i.to_s)
::Zip::File.open(path, create: true) do |zipfile|
write_entries entries, '', zipfile
write_entries entries, "", zipfile
end
path
end
@ -65,7 +67,7 @@ module Admin
# A helper method to make the recursion work.
def write_entries(entries, path, zipfile)
entries.each do |e|
zipfile_path = path == '' ? e : File.join(path, e)
zipfile_path = path == "" ? e : File.join(path, e)
disk_file_path = File.join(@input_dir, zipfile_path)
if File.directory? disk_file_path

View file

@ -2,4 +2,17 @@
class ApplicationRecord < ActiveRecord::Base
primary_abstract_class
class << self
def translates_attributes(*attributes)
attributes.each do |attribute|
define_method("t_#{attribute}") do
lang = I18n.locale.to_s.split("-").first
send("#{attribute}_#{lang}")
end
end
end
alias_method :translates_attribute, :translates_attributes
end
end

View file

@ -1,11 +1,67 @@
# frozen_string_literal: true
class Check < ApplicationRecord
include RichTextTargetBlank
enum :level, %i[A AA AAA]
belongs_to :principle
has_rich_text :success_criterion_html
has_and_belongs_to_many :links
has_and_belongs_to_many :standards
scope :search, lambda { |term|
joins("INNER JOIN action_text_rich_texts ON action_text_rich_texts.record_id = checks.id AND record_type = 'Check'").where('checks.name LIKE :term OR action_text_rich_texts.body_text LIKE :term', term: "%#{term}%")
}
accepts_nested_attributes_for :links, allow_destroy: true
enum :conformity_level, %i[A AA AAA]
enum :priority, %i[highest high normal low]
has_rich_text :conformity_notice_de
has_rich_text :conformity_notice_en
has_rich_text :quick_criterion_de
has_rich_text :quick_criterion_en
has_rich_text :quick_fail_de
has_rich_text :quick_fail_en
has_rich_text :quick_fix_de
has_rich_text :quick_fix_en
has_rich_text :criterion_de
has_rich_text :criterion_en
has_rich_text :criterion_details_de
has_rich_text :criterion_details_en
has_rich_text :example_de
has_rich_text :example_en
has_rich_text :exemption_details_de
has_rich_text :exemption_details_en
has_rich_text :standard_text_de
has_rich_text :standard_text_en
has_rich_text :test_instructions
has_rich_text :powerpoint_text_de
has_rich_text :powerpoint_text_en
has_rich_text :comment
translates_attributes :name,
:conformity_notice,
:quick_criterion,
:quick_fail,
:quick_fix,
:criterion,
:criterion_details,
:example,
:exemption_details,
:standard_text,
:powerpoint_text
scope(:search, lambda do |term|
# 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
end)
def display_target_disabilities
%i[visual auditory physical cognitive].select { |d| send(:"#{d}?") }.map { |d| I18n.t("disability.#{d}") }.map(&:first).join(", ")
end
def display_applicabilities
%i[applicable_to_app applicable_to_web].select { |a| send(:"#{a}?") }.map { |a| I18n.t("applicability.#{a}") }.map(&:first).join(", ")
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Checklist < ApplicationRecord
has_many :checklist_entries, -> { order(position: :asc) }, dependent: :destroy, inverse_of: :checklist
has_many :checks, through: :checklist_entries

View file

@ -1,12 +1,15 @@
# frozen_string_literal: true
class ChecklistEntry < ApplicationRecord
belongs_to :checklist
belongs_to :check
before_validation :set_position
after_validation :normalize_positions
before_create :update_positions
before_update :update_positions, if: :position_changed?
def set_position
self.position ||= checklist.checklist_entries.maximum(:position).to_i + 1
self.position ||= (checklist.checklist_entries.pluck(:position).max || 0) + 1
end
def normalize_positions
@ -15,4 +18,11 @@ class ChecklistEntry < ApplicationRecord
# entry.update_column(:position, index + 1) if entry.position != index + 1
# end
end
def update_positions
if position_was
checklist.checklist_entries.where("position > ?", position_was).update_all("position = position - 1")
end
checklist.checklist_entries.where(position: position..).update_all("position = position + 1")
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module RichTextTargetBlank
extend ActiveSupport::Concern
@ -11,7 +13,7 @@ module RichTextTargetBlank
rich_text_attribute = send(name)
if rich_text_attribute.present?
doc = Nokogiri::HTML::DocumentFragment.parse(rich_text_attribute.body.to_html)
doc.css('a').each { |a| a['target'] ||= '_blank' }
doc.css("a").each { |a| a["target"] ||= "_blank" }
rich_text_attribute.body = doc.to_html
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Element < ApplicationRecord
attr_accessor :checklist_id
@ -22,8 +24,8 @@ class Element < ApplicationRecord
return nil if possible_levels.empty?
puts possible_levels.inspect
puts min_failed
Rails.logger.debug possible_levels.inspect
Rails.logger.debug min_failed
possible_levels[possible_levels.find_index(min_failed) - 1]
end

View file

@ -1,7 +1,11 @@
require 'net/http'
# frozen_string_literal: true
require "net/http"
class Link < ApplicationRecord
belongs_to :link_category
has_and_belongs_to_many :checks
has_rich_text :description_html
validates :url, :text, presence: true
@ -10,13 +14,21 @@ class Link < ApplicationRecord
before_validation :ensure_absolute_url
def t_text
text
end
def ok?
fail_count == 0
fail_count.zero?
end
def to_s
"#{text} (#{url})"
end
private
USER_AGENT = 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0'
USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0"
def check_url(input = url, add_error = true)
response = begin

View file

@ -1,5 +1,11 @@
# frozen_string_literal: true
class LinkCategory < ApplicationRecord
has_many :links
has_rich_text :description_html
has_rich_text :description
def t_name
name
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
module PdfDocuments
class Base
attr_reader :params
@ -11,7 +13,7 @@ module PdfDocuments
# exta_bold: 'vendor/assets/fonts/Lexend-ExtraBold.ttf',
# italic: 'vendor/assets/fonts/Lexend-Regular.ttf'
# })
@prawn_document.font 'Helvetica', size: 12
@prawn_document.font "Helvetica", size: 12
@params = OpenStruct.new(params)
end
@ -47,7 +49,7 @@ module PdfDocuments
end
def hr
@prawn_document.markup '<hr>'
@prawn_document.markup "<hr>"
end
def markup_options
@ -63,12 +65,12 @@ module PdfDocuments
end
def logo
@prawn_document.image 'app/assets/images/logo-apfelschule.png', width: 150
@prawn_document.image "app/assets/images/logo-apfelschule.png", width: 150
@prawn_document.move_down 30
end
def prepare_rich_text(rich_text)
{ h1: 'h4' }.each do |tag, replacement|
{ h1: "h4" }.each do |tag, replacement|
rich_text = rich_text.to_s.gsub("<#{tag}", "<#{replacement}")
rich_text = rich_text.to_s.gsub("</#{tag}>", "</#{replacement}>")
end

View file

@ -1,19 +1,21 @@
# frozen_string_literal: true
module PdfDocuments
class CustomerReport < Base
private
def generate
logo
@prawn_document.formatted_text_box [{
@prawn_document.formatted_text_box [ {
text: "Dieses Dokument wurd am #{Time.current.strftime('%d %B %Y')} um #{Time.current.strftime('%H:%M:%S')} erstellt.", size: 8, align: :right
}], align: :right
} ], align: :right
heading1 params.report.name
rich_text params.report.comment_html
params.report.elements.each.with_index(1) do |element, element_index|
heading2 "#{element_index} #{element.title}"
formatted_text [{ text: element.path, styles: %i[bold italic underline] }]
formatted_text [ { text: element.path, styles: %i[bold italic underline] } ]
move_down(5)
rich_text element.description_html

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

@ -0,0 +1,3 @@
class Principle < ApplicationRecord
translates_attribute :name
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class Report < ApplicationRecord
has_rich_text :comment_html

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

@ -0,0 +1,5 @@
class Standard < ApplicationRecord
has_and_belongs_to_many :checks
translates_attribute :name
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
class SuccessCriterion < ApplicationRecord
enum :result, %i[passed failed not_applicable]
enum :level, %i[A AA AAA]

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
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

@ -1 +1,3 @@
# frozen_string_literal: true
json.array! @checklist_entries, partial: "checklist_entries/checklist_entry", as: :checklist_entry

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.partial! "checklist_entries/checklist_entry", checklist_entry: @checklist_entry

View file

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

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.array! @checklists, partial: "checklists/checklist", as: :checklist

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.partial! "checklists/checklist", checklist: @checklist

View file

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

View file

@ -0,0 +1,68 @@
div id=dom_id(check)
table.table
tbody
tr
th = Check.human_attribute_name(: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
th = Check.human_attribute_name(:name)
td = check.t_name
tr
th = Standard.model_name.human(count: check.standard_ids.size)
td = check.standards.map(&:t_name).join(", ")
tr
th = Check.human_attribute_name(:target_disabilities)
td = check.display_target_disabilities
tr
th = Check.human_attribute_name(:applicabilities)
td = check.display_applicabilities
tr
th = Check.human_attribute_name(:external_number)
td = check.external_number
tr
th = Check.human_attribute_name(:conformity_level)
td = check.conformity_level
tr
th = Check.human_attribute_name(:conformity_notice_de)
td = check.conformity_notice_de
tr
th = Check.human_attribute_name(:conformity_notice_en)
td = check.conformity_notice_en
tr
th = Check.human_attribute_name(:priority)
td = check.priority
tr
th = Check.human_attribute_name(:quick_criterion_de)
td = check.quick_criterion_de
tr
th = Check.human_attribute_name(:quick_criterion_en)
td = check.quick_criterion_en
tr
th = Check.human_attribute_name(:quick_fail_de)
td = check.quick_fail_de
tr
th = Check.human_attribute_name(:quick_fail_en)
td = check.quick_fail_en
tr
th = Check.human_attribute_name(:quick_fix_de)
td = check.quick_fix_de
tr
th = Check.human_attribute_name(:quick_fix_en)
td = check.quick_fix_en
tr
th = Link.model_name.human(count: check.links.size)
td
.row
.col
- check.links.map(&:link_category).uniq.each do |category|
span = category.name
ul
- check.links.select{ _1.link_category == category }.map { |link| link_to link.text, link.url, target: :_blank }.each do |link|
li = link

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
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 +0,0 @@
<%= bootstrap_form_with(model: check, remote: true) do |form| %>
<%= form.text_field :position %>
<%= form.text_field :name %>
<%= form.rich_text_area :success_criterion_html %>
<%= form.select :level, Check.levels.keys, add_blank: !form.object.level.present? %>
<%= form.submit %>
<% end %>

View file

@ -0,0 +1,53 @@
= bootstrap_form_with(model: check, remote: true) do |form|
h2 Details
= form.collection_select :principle_id, Principle.all.sort_by(&:t_name), :id, :t_name
= form.text_field :number
= multilang_form_field(form, :name)
= form.collection_check_boxes :standard_ids, Standard.all.sort_by(&:t_name), :id, :t_name, include_blank: true
h2 Zugänglichkeit
.row
.col-md-3
= form.check_box :visual, label: t("disability.visual").capitalize
.col-md-3
= form.check_box :auditory, label: t("disability.auditory").capitalize
.col-md-3
= form.check_box :physical, label: t("disability.physical").capitalize
.col-md-3
= form.check_box :cognitive, label: t("disability.cognitive").capitalize
h2 Anwendbarkeit
.row
.col-md-6
= form.check_box :applicable_to_web, label: t("applicability.applicable_to_web").capitalize
.col-md-6
= form.check_box :applicable_to_app, label: t("applicability.applicable_to_app").capitalize
h2 Richtlinie
= form.text_field :external_number
= form.select :conformity_level, Check.conformity_levels.keys, include_blank: true
= multilang_form_field(form, :conformity_notice, as: :rich_text_area)
= form.select :priority, Check.priorities.keys.map{ [t("priority.#{_1}"), _1] }, include_blank: true
h2 Quick Infos
= 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_fix, as: :rich_text_area)
h2 Regular-Kriterium
= multilang_form_field(form, :criterion, as: :rich_text_area)
= multilang_form_field(form, :criterion_details, as: :rich_text_area)
= multilang_form_field(form, :example, as: :rich_text_area)
= multilang_form_field(form, :exemption_details, as: :rich_text_area)
= multilang_form_field(form, :standard_text, as: :rich_text_area)
h2 Intern
= form.rich_text_area :test_instructions
= multilang_form_field(form, :powerpoint_text, as: :rich_text_area)
= form.rich_text_area :comment
h2 Links
- LinkCategory.all.sort_by(&:t_name).each do |c|
h3 = c.t_name
= form.collection_check_boxes(:link_ids, c.links.sort_by(&:t_text), :id, :to_s, hide_label: true)
/ = form.collection_check_boxes :link_ids, Link.all.sort_by(&:text), :id, :to_s
/ = form.rich_text_area :success_criterion_de
= form.submit

View file

@ -15,18 +15,24 @@
<table class="table table-striped">
<thead>
<tr>
<th><%= Check.human_attribute_name(:id) %></th>
<th><%= Check.human_attribute_name(:level) %></th>
<th><%= Check.human_attribute_name(:number) %></th>
<th><%= Check.human_attribute_name(:name) %></th>
<th><%= Check.human_attribute_name(:success_criterion_html) %></th>
<th><%= Check.human_attribute_name(:standards) %></th>
<th><%= t("checks.target_disabilities") %></th>
<th><%= t("checks.applicability") %></th>
<th><%= Check.human_attribute_name(:external_number) %></th>
<th><%= Check.human_attribute_name(:conformity_level) %></th>
</thead>
<tbody>
<% @checks.each do |check| %>
<tr>
<td><%= check.id %></td>
<td><%= check.level %></td>
<td><%= link_to(check.name, url_for(check)) %></td>
<td><%= link_to(truncate(strip_tags(check.success_criterion_html.to_s)), url_for(check)) %></td>
<td><%= check.number %></td>
<td><%= check.t_name %></td>
<td><%= check.standards.map(&:t_name).join(", ") %></td>
<td><%= check.display_target_disabilities %></td>
<td><%= check.t_name %></td>
<td><%= check.t_name %></td>
<td><%= link_to(check.t_name, url_for(check)) %></td>
</tr>
<% end %>
</tbody>

View file

@ -0,0 +1,51 @@
h1
= t("scaffold.pagetitle_index", model: Check.model_name.human(count: 2))
= 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]
.row
.col-md-3
= form.text_field(:s, placeholder: "suchen...", hide_label: true, value: filter_params[:s])
.col
= form.submit name: "", value: "Suchen"
= link_to "Filter löschen", checks_path, class: "btn btn-outline-secondary ms-3" if filter_params[:s]
table.table.table-striped
thead
tr
th ID
th
= Check.human_attribute_name(:number)
th
= Check.human_attribute_name(:name)
th
= Check.human_attribute_name(:standard_ids)
th
= Check.human_attribute_name(:target_disability)
th
= Check.human_attribute_name(:applicability)
th
= Check.human_attribute_name(:external_number)
th
= Check.human_attribute_name(:conformity_level)
tbody
- @checks.each do |check|
tr
td = link_to check.id, check
td
= link_to(check.number, check)
td
= link_to check.t_name&.truncate(64), check
td
= link_to check.standards.map(&:t_name).join(", "), check
td
= link_to check.display_target_disabilities, check
td
= link_to check.display_applicabilities, check
td
= link_to check.external_number, check
td
= link_to check.conformity_level, check
.my-3
== pagy_info(@pagy)
== pagy_bootstrap_nav(@pagy)
.action-row
= link_to t("scaffold.link_new", model: Check.model_name.human), new_check_path

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.array! @checks, partial: "checks/check", as: :check

View file

@ -1,4 +1,4 @@
<h1><%= t("scaffold.pagetitle_show", model: @check.class.model_name.human) %></h1>
<h1><%= @check.t_name %></h1>
<%= render @check %>

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.partial! "checks/check", check: @check

View file

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

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.array! @elements, partial: "elements/element", as: :element

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.partial! "elements/element", element: @element

View file

@ -1,5 +1,5 @@
<!doctype html>
<html <%== cookies[:"modeTheme"] && "data-bs-theme=\"#{cookies[:"modeTheme"]}\"" %> data-controller="set-theme">
<html data-bs-theme="<%= cookies[:"modeTheme"] || "light" %>" data-controller="set-theme">
<head>
<title>a11ydive</title>
<meta name="viewport" content="width=device-width,initial-scale=1">

View file

@ -6,7 +6,7 @@
<p>
<strong>Description:</strong>
<%= link_category.description_html %>
<%= link_category.description %>
</p>
</div>

View file

@ -1,2 +1,4 @@
# frozen_string_literal: true
json.extract! link_category, :id, :name, :description, :rich_text, :created_at, :updated_at
json.url link_category_url(link_category, format: :json)

View file

@ -18,7 +18,7 @@
<td><%= link_to(link_category.name, url_for(link_category)) %></td>
<td><%= link_to(link_category.description, url_for(link_category)) %></td>
<td><%= link_to(truncate(link_category.description.to_plain_text), url_for(link_category)) %></td>
</tr>
<% end %>
</tbody>

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.array! @link_categories, partial: "link_categories/link_category", as: :link_category

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.partial! "link_categories/link_category", link_category: @link_category

View file

@ -1,3 +1,6 @@
json.extract! link, :id, :url, :text, :description, :last_check_at, :fail_count, :link_category_id, :created_at, :updated_at
# frozen_string_literal: true
json.extract! link, :id, :url, :text, :description, :last_check_at, :fail_count, :link_category_id, :created_at,
:updated_at
json.url link_url(link, format: :json)
json.description link.description.to_s

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.array! @links, partial: "links/link", as: :link

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.partial! "links/link", link: @link

View file

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

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.array! @reports, partial: "reports/report", as: :report

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.partial! "reports/report", report: @report

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
wb = xlsx_package.workbook
wb.add_worksheet(name: "Erfolgskriterien") do |sheet|
sheet.add_row SuccessCriterion.column_names
@ -7,4 +9,4 @@ wb.add_worksheet(name: "Erfolgskriterien") do |sheet|
sheet.add_row sc.attributes.values
end
end
end
end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
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 +1,3 @@
# frozen_string_literal: true
json.array! @success_criteria, partial: "success_criteria/success_criterion", as: :success_criterion

View file

@ -1 +1,3 @@
# frozen_string_literal: true
json.partial! "success_criteria/success_criterion", success_criterion: @success_criterion