Refactorings and gui improvements
This commit is contained in:
parent
c965e03e5a
commit
d1294c2fc4
46 changed files with 358 additions and 128020 deletions
|
|
@ -65,4 +65,74 @@
|
|||
|
||||
.highlight-when-nonempty:not([value=""]) {
|
||||
@extend .border-primary
|
||||
}
|
||||
|
||||
@mixin details-icon($color) {
|
||||
background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="rgb(#{$color})" class="bi bi-chevron-right" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708"/></svg>');
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.page_nav nav ul {
|
||||
padding-left: 0;
|
||||
list-style-type: none;
|
||||
line-height: 2rem;
|
||||
|
||||
a {
|
||||
color: var(--bs-text);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
ul {
|
||||
// padding-left: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
summary,
|
||||
summary a {
|
||||
font-size: 1rem;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
summary {
|
||||
display: flex;
|
||||
line-height: 2rem;
|
||||
}
|
||||
|
||||
summary::before {
|
||||
@include details-icon(to-rgb(map-get($theme-colors, "dark")));
|
||||
content: '';
|
||||
float: inline-end;
|
||||
width: 0.7rem;
|
||||
height: 1rem;
|
||||
margin-top: 0.5rem;
|
||||
margin-right: 6px;
|
||||
// background: url('chevron-right.svg');
|
||||
// background-size: cover;
|
||||
margin-left: 0;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
@include color-mode(dark) {
|
||||
summary::before {
|
||||
@include details-icon(to-rgb(map-get($theme-colors, "light")));
|
||||
// content: '';
|
||||
// float: inline-end;
|
||||
// width: 0.7rem;
|
||||
// height: 1rem;
|
||||
// margin-top: 0.5rem;
|
||||
// margin-right: 6px;
|
||||
// // background: url('chevron-right.svg');
|
||||
// // background-size: cover;
|
||||
// margin-left: 0;
|
||||
// transition: 0.2s;
|
||||
}
|
||||
}
|
||||
|
||||
details[open]>summary::before {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
|
@ -7,7 +7,7 @@ class ChecksController < ApplicationController
|
|||
|
||||
# GET /checks or /checks.json
|
||||
def index
|
||||
@pagy, @checks = pagy(Check.filter_by(filter_params).order(:external_number))
|
||||
@pagy, @checks = pagy(Check.filter_by(filter_params).order(:external_number_1, :external_number_2, :external_number_3))
|
||||
end
|
||||
|
||||
# GET /checks/1 or /checks/1.json
|
||||
|
|
@ -69,7 +69,7 @@ class ChecksController < ApplicationController
|
|||
end
|
||||
|
||||
def filter_params
|
||||
@filter_params ||= params.permit(filter: [ :s, priority: [], conformity_level: [], standard_ids: [], principle_id: [], target_disabilities: []])[:filter] || {}
|
||||
@filter_params ||= params.permit(filter: [ :s, priority: [], conformity_level: [], standard_ids: [], principle_id: [], target_disabilities: [] ])[:filter] || {}
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -58,7 +58,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 page_elements_url(@element.page), notice: "Element was successfully destroyed.", status: :see_other
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class PagesController < ApplicationController
|
|||
# DELETE /pages/1
|
||||
def destroy
|
||||
@page.destroy!
|
||||
redirect_to pages_url, notice: "Page was successfully destroyed.", status: :see_other
|
||||
redirect_to report_pages_url(@page.report), notice: "Page was successfully destroyed.", status: :see_other
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -60,7 +60,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 element_success_criteria_url(@success_criterion.element), notice: "Erfolgskriterium was successfully destroyed.", status: :see_other
|
||||
end
|
||||
format.turbo_stream
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,4 +24,8 @@ module ApplicationHelper
|
|||
|
||||
yield(value)
|
||||
end
|
||||
|
||||
def current_page_displayed(page)
|
||||
@current_page&.id == page.id ? "open" : nil
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,18 +7,21 @@ export default class extends Controller {
|
|||
static targets = ["cancel"]
|
||||
|
||||
initialState = null
|
||||
isSubmitted = false
|
||||
|
||||
connect() {
|
||||
console.log("connect unsaved-changes")
|
||||
this.initialState = this.formState()
|
||||
console.log(this.cancelTargets)
|
||||
|
||||
console.log("usaved-changes connect ", this.cancelTargets)
|
||||
|
||||
window.addEventListener("beforeunload", (event) => this.leavingPage(event))
|
||||
document.addEventListener('turbo:before-visit', (e) => this.leavingPage(e))
|
||||
this.element.addEventListener("submit", (_) => this.initialState = null)
|
||||
this.cancelTargets.forEach(element => {
|
||||
console.log(element)
|
||||
element.addEventListener("onclick", (_) => this.initialState = null)
|
||||
});
|
||||
this.element.addEventListener("submit", (_) => this.isSubmitted = true)
|
||||
// this.cancelTargets.forEach(element => {
|
||||
// console.log(element)
|
||||
// element.addEventListener("onclick", (_) => this.reset())
|
||||
// });
|
||||
}
|
||||
|
||||
formState() {
|
||||
|
|
@ -27,21 +30,23 @@ export default class extends Controller {
|
|||
.sort(x => x[0]))
|
||||
}
|
||||
|
||||
reset() {
|
||||
console.log("reset")
|
||||
this.initialState = this.formState()
|
||||
}
|
||||
|
||||
hasChanged() {
|
||||
console.log("hasChanged result", this.initialState != this.formState())
|
||||
return this.formState() != this.initialState
|
||||
}
|
||||
|
||||
leavingPage(event) {
|
||||
console.log(event.type)
|
||||
if (this.initialState == null || this.initialState == this.formState()) {
|
||||
if (this.isSubmitted || !this.hasChanged()) {
|
||||
return
|
||||
}
|
||||
if (event.type == "turbo:before-visit") {
|
||||
if (!window.confirm(LEAVE_ALERT)) {
|
||||
event.preventDefault()
|
||||
} else {
|
||||
this.initialState = null
|
||||
}
|
||||
} else {
|
||||
this.initialState = null
|
||||
event.returnValue = LEAVE_ALERT;
|
||||
return event.returnValue;
|
||||
if (!window.confirm(LEAVE_ALERT)) {
|
||||
event.preventDefault()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ class Check < ApplicationRecord
|
|||
relation = relation.joins(:standards).where(standards: { id: value })
|
||||
when "target_disabilities"
|
||||
cond = String.new
|
||||
value.intersection(%w(auditory visual physical cognitive)).each_with_index do |v, i|
|
||||
value.intersection(%w[auditory visual physical cognitive]).each_with_index do |v, i|
|
||||
if i == 0
|
||||
cond << "checks.#{v} = 1"
|
||||
else
|
||||
|
|
@ -112,10 +112,10 @@ class Check < ApplicationRecord
|
|||
end
|
||||
|
||||
def display_applicabilities
|
||||
%i[applicable_to_analogue
|
||||
applicable_to_app
|
||||
applicable_to_document
|
||||
applicable_to_non_web
|
||||
%i[applicable_to_analogue
|
||||
applicable_to_app
|
||||
applicable_to_document
|
||||
applicable_to_non_web
|
||||
applicable_to_web].select { |a| send(:"#{a}?") }
|
||||
.map { |a| I18n.t("applicability.#{a}") }
|
||||
.sort_by(&:downcase)
|
||||
|
|
@ -123,6 +123,10 @@ class Check < ApplicationRecord
|
|||
end
|
||||
|
||||
def display_label
|
||||
[external_number, name_de].compact_blank.join(" ")
|
||||
[ external_number, name_de ].compact_blank.join(" ")
|
||||
end
|
||||
|
||||
def external_number
|
||||
[ external_number_1, external_number_2, external_number_3 ].compact_blank.join(".")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ class ChecklistEntry < ApplicationRecord
|
|||
belongs_to :check
|
||||
|
||||
before_validation :set_position
|
||||
before_create :update_positions
|
||||
before_update :update_positions, if: :position_changed?
|
||||
|
||||
def set_position
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ class Element < ApplicationRecord
|
|||
def level
|
||||
return nil
|
||||
return nil unless success_criteria.all(&:result)
|
||||
|
||||
element
|
||||
min_failed = success_criteria.select(&:failed?).map(&:level).min
|
||||
possible_levels = success_criteria.select(&:passed?).map(&:level).uniq
|
||||
|
||||
|
|
@ -37,4 +37,8 @@ class Element < ApplicationRecord
|
|||
Rails.logger.debug("element: position #{position}")
|
||||
self.position ||= (page.elements.pluck(:position).max || 0) + 1
|
||||
end
|
||||
|
||||
def number
|
||||
"#{page.position}.#{position}"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<%= link_to "Abbrechen", checklist_entry.persisted? ? checklist_entry : checklist_entry.checklist, class: "btn btn-outline-secondary float-end", data: { turbo_frame: "checklist_entries" } %>
|
||||
<%= form.submit class: "btn btn-secondary float-end me-2" %>
|
||||
<%= form.hidden_field :checklist_id %>
|
||||
<%= form.collection_select :check_id, Check.all.order(:external_number), :id, :display_label %>
|
||||
<%= form.collection_select :check_id, Check.all.order(:external_number_1, :external_number_2, :external_number_3), :id, :display_label %>
|
||||
<%# form.number_field :position %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<%= bootstrap_form_with(model: checklist, data: { controller: "unsaved-changes" }) do |form| %>
|
||||
<%= form.text_field :name %>
|
||||
<%= form.rich_text_area :description_html, rows: 12 %>
|
||||
<%= form.submit %>
|
||||
<% end %>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
= bootstrap_form_with(model: checklist, data: { controller: "unsaved-changes" }) do |form|
|
||||
= form.text_field :name
|
||||
= form.rich_text_area :description_html, rows: 12
|
||||
= form.collection_check_boxes :check_ids, Check.all.order(:external_number), :id, :display_label
|
||||
= form.collection_check_boxes :check_ids, Check.all.order(:external_number_1, :external_number_2, :external_number_3), :id, :display_label
|
||||
= form.submit
|
||||
|
|
|
|||
|
|
@ -18,8 +18,17 @@
|
|||
.col-md-2
|
||||
= form.check_box d, label: t("applicability.#{d}").capitalize
|
||||
|
||||
h2 Richtlinie
|
||||
= form.text_field :external_number
|
||||
h2 Erfolgskriterium
|
||||
.d-flex.justify-content-start
|
||||
div style="width:60px"
|
||||
= form.number_field :external_number_1, hide_label: true
|
||||
div.px-1.mt-3 style="" = "."
|
||||
div style="width:60px"
|
||||
= form.number_field :external_number_2, hide_label: true
|
||||
div.px-1.mt-3 style="" = "."
|
||||
div style="width:60px"
|
||||
= form.number_field :external_number_3, hide_label: true
|
||||
|
||||
= form.text_field :external_url
|
||||
= form.select :conformity_level, Check.conformity_levels.keys, include_blank: true
|
||||
= multilang_form_field(form, :conformity_notice, as: :rich_text_area)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
<div id="<%= dom_id element %>" class="mb-5">
|
||||
<a id="<%= dom_id(element, :scroll) %>"></a>
|
||||
<%= turbo_frame_tag dom_id(element, :frame) do %>
|
||||
<div class="d-flex">
|
||||
<h2 class="h4">
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
<%= link_to "#{tag.i(class: "bi bi-plus-lg")} Neue Checkliste".html_safe, new_from_checklist_element_success_criteria_path(element), class: "btn btn-primary" %>
|
||||
<%= link_to "#{tag.i(class: "bi bi-plus-lg")} Checkliste".html_safe, new_from_checklist_element_success_criteria_path(element), class: "btn btn-primary" %>
|
||||
|
||||
<%= link_to "#{tag.i(class: "bi bi-plus-lg")} Neues Erfolgskriterium".html_safe, new_element_success_criterion_path(element), class: "btn btn-primary" %>
|
||||
<%= link_to "#{tag.i(class: "bi bi-plus-lg")} Erfolgskriterium".html_safe, new_element_success_criterion_path(element), class: "btn btn-secondary" %>
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
<%= turbo_stream.update "new_element_frame", partial: "pages/new_element_button", locals: { page: @element.page } %>
|
||||
<%= turbo_stream.append "element_list", @element %>
|
||||
5
app/views/elements/create.turbo_stream.slim
Normal file
5
app/views/elements/create.turbo_stream.slim
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
= turbo_stream.update "new_element_frame", partial: "pages/new_element_button", locals: { page: @element.page }
|
||||
= turbo_stream.append "element_list", @element
|
||||
= turbo_stream.append dom_id(@element.page, :page_nav_elements) do
|
||||
i.bi.bi-boxes.me-1
|
||||
= link_to("#{@element.number} #{@element.title}", "##{dom_id(@element)}", data: { "turbo": false })
|
||||
|
|
@ -5,33 +5,24 @@
|
|||
<tr>
|
||||
<th><%= Element.human_attribute_name(:id) %></th>
|
||||
|
||||
<th><%= Element.human_attribute_name(:report_id) %></th>
|
||||
|
||||
<th><%= Element.human_attribute_name(:path) %></th>
|
||||
<th><%= Element.human_attribute_name(:page_id) %></th>
|
||||
|
||||
<th><%= Element.human_attribute_name(:title) %></th>
|
||||
|
||||
<th><%= Element.human_attribute_name(:description_html) %></th>
|
||||
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @elements.each do |element| %>
|
||||
<tr>
|
||||
<td><%= link_to(element.id, url_for(element)) %></td>
|
||||
|
||||
<td><%= link_to(element.report_id, url_for(element)) %></td>
|
||||
|
||||
<td><%= link_to(element.path, url_for(element)) %></td>
|
||||
<td><%= link_to(element.page_id, url_for(element)) %></td>
|
||||
|
||||
<td><%= link_to(element.title, url_for(element)) %></td>
|
||||
|
||||
<td><%= link_to(truncate(element.description_html&.to_plain_text), url_for(element)) %></td>
|
||||
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="action-row">
|
||||
<%= link_to t("scaffold.link_new", model: Element.model_name.human), new_element_path %>
|
||||
<%= link_to t("scaffold.link_new", model: Element.model_name.human), new_page_element_path(@page) %>
|
||||
</div>
|
||||
30
app/views/layouts/_application.html.erb
Normal file
30
app/views/layouts/_application.html.erb
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<!doctype html>
|
||||
<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">
|
||||
|
||||
<%= csrf_meta_tags %>
|
||||
<%= csp_meta_tag %>
|
||||
|
||||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
|
||||
<%= javascript_include_tag "application", "data-turbo-track": "reload", type: "module" %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= render partial: "layouts/navigation" %>
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<%= render partial: "layouts/sidebar" %>
|
||||
<main class="col ps-md-2 pt-2 <%= "border-start" if sidebar? %>">
|
||||
<div class="container-fluid">
|
||||
<div id="main-content" data-controller="rich-text-link-targets">
|
||||
<%= yield %>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="container-fluid mt-auto border-top"><%= Rails.configuration.build_version && "Version: #{Rails.configuration.build_version}" %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -13,8 +13,7 @@ html data-bs-theme="#{cookies[:"modeTheme"] || "light"}" data-controller="set-th
|
|||
.row
|
||||
= render partial: "layouts/sidebar"
|
||||
main.col.ps-md-2.pt-2
|
||||
.container-fluid
|
||||
#main-content[data-controller="rich-text-link-targets"]
|
||||
= yield
|
||||
#main-content[data-controller="rich-text-link-targets"]
|
||||
= yield
|
||||
footer.container-fluid.mt-auto.border-top
|
||||
= Rails.configuration.build_version && "Version: #{Rails.configuration.build_version}"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
= bootstrap_form_with(model: [:report, page], data: { "turbo-frame": :nav }) do |form|
|
||||
= bootstrap_form_with(model: page.persisted? ? page : [:report, page], data: { "turbo-frame": :_top }) do |form|
|
||||
= form.text_field :path
|
||||
= form.text_field :url
|
||||
= form.submit
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
= bootstrap_form_with(model: page) do |form|
|
||||
= form.text_area :notes, rows: [(page.notes&.count("\n") || 0) + 1, 10].max, placeholder: "Hier kannst du Notizen speichern. \n\nJeder Pfad hat seine eigenen Notizen.", hide_label: true
|
||||
= form.submit "Speichern"
|
||||
.mt-5
|
||||
= bootstrap_form_with(model: page) do |form|
|
||||
= form.text_area :notes, rows: [(page.notes&.count("\n") || 0) + 1, 10].max, placeholder: "Hier kannst du Notizen speichern. \n\nJeder Pfad hat seine eigenen Notizen.", hide_label: true
|
||||
= form.submit "Speichern"
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<div id="<%= dom_id page %>" class="mb-3">
|
||||
<h2>
|
||||
<i class="bi bi-file"></i>
|
||||
<i class="bi bi-file-earmark-check"></i>
|
||||
<%= page.position %> <%= page.path %></h2>
|
||||
<p>url: <%= page.url %></p>
|
||||
<div id="element_list">
|
||||
|
|
|
|||
|
|
@ -1,8 +1,11 @@
|
|||
h1
|
||||
= t("scaffold.pagetitle_show", model: @page.class.model_name.human)
|
||||
|
||||
= render @page
|
||||
|
||||
= turbo_frame_tag(dom_id(@page, :notes)) do
|
||||
= render partial: "pages/notes", locals: { page: @page }
|
||||
|
||||
.action-row
|
||||
= link_to t("scaffold.link_edit", model: @page.model_name.human), edit_page_path(@page)
|
||||
= link_to t("scaffold.link_index", model: @page.model_name.human(count: 2)), report_pages_path(@page.report)
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<%= link_to "#{tag.i(class: "bi bi-plus-lg")} Neuer Pfad".html_safe, new_report_page_path(report), class: "btn btn-primary mb-3" %>
|
||||
<%= link_to "#{tag.i(class: "bi bi-plus-lg")}".html_safe, new_report_page_path(report), class: "btn btn-primary" %>
|
||||
|
|
|
|||
26
app/views/reports/_page_nav.html.slim
Normal file
26
app/views/reports/_page_nav.html.slim
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
div id=dom_id(report, :page_nav)
|
||||
- if report.pages.any?
|
||||
details open=true
|
||||
summary Struktur
|
||||
nav
|
||||
ul
|
||||
- report.pages.each do |page|
|
||||
- is_current = current_page == page
|
||||
li
|
||||
details open=current_page_displayed(page) class=""
|
||||
summary
|
||||
i.bi.me-1 class="bi-file-earmark-check#{is_current ? "-fill" : "" }"
|
||||
- if is_current
|
||||
=< "#{page.position} #{page.path}"
|
||||
- else
|
||||
=< link_to("#{page.position} #{page.path}", report_path(report, page_id: page.id), class: "#{is_current ? " active text-decoration-underline" : nil }", data: { "turbo-frame": :_top })
|
||||
ul id=dom_id(page, :page_nav_elements)
|
||||
- page.elements.each do |element|
|
||||
li
|
||||
i.bi.bi-boxes.me-1
|
||||
- if current_page == page
|
||||
=< link_to("#{element.number} #{element.title}", "##{dom_id(element)}", data: { "turbo": false })
|
||||
- else
|
||||
=< link_to("#{element.number} #{element.title}", report_path(report, page_id: page.id, anchor: dom_id(element)), data: { "turbo": false })
|
||||
= turbo_frame_tag "new_page_frame" do
|
||||
= render partial: "reports/new_page_button", locals: { report: report }
|
||||
|
|
@ -1,33 +1,27 @@
|
|||
small.float-end
|
||||
| Erstellt am
|
||||
= l(@report.created_at, format: :short)
|
||||
| , zuletzt bearbeitet am
|
||||
= l(@report.updated_at, format: :short)
|
||||
div
|
||||
small.float-end
|
||||
| Erstellt am
|
||||
= l(@report.created_at, format: :short)
|
||||
| , zuletzt bearbeitet am
|
||||
= l(@report.updated_at, format: :short)
|
||||
h1
|
||||
i.bi.bi-journal-text.me-2
|
||||
= @report.name
|
||||
- if @report.comment
|
||||
.smb-4.lead.mb-3
|
||||
= @report.comment
|
||||
= turbo_frame_tag "nav" do
|
||||
.row
|
||||
.col-lg-3.col-md-6.col-sm-12
|
||||
nav.nav.nav-pills.flex-column.mb-3#page_list
|
||||
- @report.pages.each do |page|
|
||||
/= link_to(report_path(@report, page_id: page.id), class: "nav-link#{@current_page&.id == page.id ? " active" : nil }", data: { "turbo-action": :advance }) do
|
||||
i.bi.bi-file
|
||||
=< "#{page.position} #{page.path}"
|
||||
= link_to(page.path, report_path(@report, page_id: page.id), class: "nav-link#{@current_page&.id == page.id ? " active" : nil }", data: { "turbo-action": :advance })
|
||||
= turbo_frame_tag "new_page_frame" do
|
||||
= render partial: "reports/new_page_button", locals: { report: @report }
|
||||
.row
|
||||
.col-lg-3.col-md-6.col-sm-12
|
||||
.page_nav.sticky-top
|
||||
= render partial: "reports/page_nav", locals: { report: @report, current_page: @current_page }
|
||||
- if @current_page
|
||||
= turbo_frame_tag(dom_id(@current_page, :notes)) do
|
||||
= render partial: "pages/notes", locals: { page: @current_page }
|
||||
.col-lg-9.col-md-6.col-sm-12
|
||||
- if @current_page
|
||||
= render @current_page
|
||||
- else
|
||||
'Gehen Sie weiter, hier gibt es nichts zu sehen.
|
||||
.col-lg-9.col-md-6.col-sm-12
|
||||
- if @current_page
|
||||
= render @current_page
|
||||
- else
|
||||
'Gehen Sie weiter, hier gibt es nichts zu sehen.
|
||||
.action-row
|
||||
= link_to report_path(@report, format: :pdf), class: "btn btn-secondary", target: "_blank" do
|
||||
i.bi.bi-filetype-pdf
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
<div class="collapse show" id="collapseSuccessCriterion_<%= success_criterion.id %>">
|
||||
<div class="card-body">
|
||||
<%= bootstrap_form_with(model: success_criterion.persisted? ? success_criterion : [:element, success_criterion]) do |form| %>
|
||||
<%= bootstrap_form_with(model: success_criterion.persisted? ? success_criterion : [:element, success_criterion], data: { controller: "unsaved-changes" }) do |form| %>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="btn-group" role="group" aria-label="Resultat">
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ h1
|
|||
= turbo_frame_tag dom_id(@success_criterion.element, "new_success_criterion_frame") do
|
||||
.border.border-info.p-3
|
||||
= bootstrap_form_with(model: @success_criterion.persisted? ? @success_criterion : [:element, @success_criterion]) do |form|
|
||||
= form.collection_select :check_id, Check.all.order(:external_number), :id, :display_label
|
||||
= form.collection_select :check_id, Check.all.order(:external_number_1, :external_number_2, :external_number_3), :id, :display_label
|
||||
= form.submit class: "btn btn-warning"
|
||||
= link_to "Abbrechen", @success_criterion.persisted? ? @success_criterion : @success_criterion.element, class: "btn btn-outline-secondary"
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,15 @@ de-CH:
|
|||
name: Bezeichnung
|
||||
comment: Projektbeschreibung
|
||||
page:
|
||||
path: Name
|
||||
url: Url
|
||||
notes: Notizen
|
||||
success_criterion:
|
||||
test_comment: Testkommentar
|
||||
quick_criterion: Quick Kriterium
|
||||
quick_fail: Quick Fail
|
||||
quick_fix: Quick Fix
|
||||
title: Titel
|
||||
models:
|
||||
account:
|
||||
one: Konto
|
||||
|
|
@ -108,3 +116,6 @@ de-CH:
|
|||
principle:
|
||||
one: Prinzip (WCAG)
|
||||
other: Prinzipien (WCAG)
|
||||
page:
|
||||
one: Pfad
|
||||
other: Pfade
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
class AddExternalNumbersFieldToChecks < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
reversible do |dir|
|
||||
dir.down do
|
||||
add_column :checks, :external_number, :integer
|
||||
execute <<~SQL
|
||||
UPDATE checks SET
|
||||
external_number = printf('%d.%d.%d', external_number_1, external_number_2, external_number_3)
|
||||
SQL
|
||||
remove_column :checks, :external_number_1, :integer
|
||||
remove_column :checks, :external_number_2, :integer
|
||||
remove_column :checks, :external_number_3, :integer
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
add_column :checks, :external_number_1, :integer
|
||||
add_column :checks, :external_number_2, :integer
|
||||
add_column :checks, :external_number_3, :integer
|
||||
execute <<~SQL
|
||||
UPDATE checks SET
|
||||
external_number_1 = CAST(SUBSTRING(external_number, 1, INSTR(external_number, '.') - 1) AS integer),
|
||||
external_number_2 = CAST(SUBSTRING(SUBSTRING(external_number, INSTR(external_number, '.') + 1), 1, INSTR(SUBSTRING(external_number, INSTR(external_number, '.') + 1), '.') - 1) AS integer),
|
||||
external_number_3 = CAST(SUBSTRING(SUBSTRING(external_number, INSTR(external_number, '.') + 1), INSTR(SUBSTRING(external_number, INSTR(external_number, '.') + 1), '.') + 1) AS integer)
|
||||
SQL
|
||||
remove_column :checks, :external_number
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
6
db/schema.rb
generated
6
db/schema.rb
generated
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2024_11_01_015725) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2024_11_01_125547) do
|
||||
create_table "account_remember_keys", force: :cascade do |t|
|
||||
t.string "key", null: false
|
||||
t.datetime "deadline", null: false
|
||||
|
|
@ -95,7 +95,6 @@ ActiveRecord::Schema[7.2].define(version: 2024_11_01_015725) do
|
|||
t.boolean "applicable_to_web", default: false, null: false
|
||||
t.boolean "applicable_to_app", default: false, null: false
|
||||
t.integer "principle_id"
|
||||
t.string "external_number"
|
||||
t.integer "conformity_level"
|
||||
t.integer "priority"
|
||||
t.boolean "manual_test", default: true, null: false
|
||||
|
|
@ -104,6 +103,9 @@ ActiveRecord::Schema[7.2].define(version: 2024_11_01_015725) do
|
|||
t.boolean "applicable_to_analogue", default: false, null: false
|
||||
t.boolean "applicable_to_document", default: false, null: false
|
||||
t.boolean "applicable_to_non_web", default: false, null: false
|
||||
t.integer "external_number_1"
|
||||
t.integer "external_number_2"
|
||||
t.integer "external_number_3"
|
||||
t.index ["number"], name: "index_checks_on_number", unique: true
|
||||
t.index ["principle_id"], name: "index_checks_on_principle_id"
|
||||
end
|
||||
|
|
|
|||
42626
public/404.html
42626
public/404.html
File diff suppressed because one or more lines are too long
42624
public/422.html
42624
public/422.html
File diff suppressed because one or more lines are too long
42624
public/500.html
42624
public/500.html
File diff suppressed because one or more lines are too long
|
|
@ -25,20 +25,19 @@ class ElementsControllerTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
test "should get index" do
|
||||
get elements_url
|
||||
get page_elements_url(@element.page)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_element_url
|
||||
get new_page_element_url(@element.page)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create element" do
|
||||
assert_difference("Element.count") do
|
||||
post elements_url,
|
||||
params: { element: { description_html: @element.description_html, path: @element.path, report_id: @element.report_id,
|
||||
title: @element.title, checklist_id: @checklist.id } }
|
||||
post page_elements_url(@element.page),
|
||||
params: { element: { description: @element.description, title: @element.title, checklist_id: @checklist.id } }
|
||||
end
|
||||
|
||||
assert_redirected_to report_url(Element.last.report)
|
||||
|
|
@ -56,7 +55,7 @@ class ElementsControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
test "should update element" do
|
||||
patch element_url(@element),
|
||||
params: { element: { description_html: @element.description_html, path: @element.path, report_id: @element.report_id,
|
||||
params: { element: { description: @element.description, page_id: @element.page_id,
|
||||
title: @element.title } }
|
||||
assert_redirected_to element_url(@element)
|
||||
end
|
||||
|
|
@ -66,6 +65,6 @@ class ElementsControllerTest < ActionDispatch::IntegrationTest
|
|||
delete element_url(@element)
|
||||
end
|
||||
|
||||
assert_redirected_to elements_url
|
||||
assert_redirected_to page_elements_url(@element.page)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,26 +1,42 @@
|
|||
require "test_helper"
|
||||
|
||||
class PagesControllerTest < ActionDispatch::IntegrationTest
|
||||
def login(email, password)
|
||||
post "/login", params: { email: email, password: password }
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
def logout
|
||||
post "/logout"
|
||||
assert_redirected_to "/"
|
||||
end
|
||||
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
setup do
|
||||
Account.create(email: "test@example.com", password: "password")
|
||||
@page = pages(:one)
|
||||
login("test@example.com", "password")
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get pages_url
|
||||
get report_pages_url(@page.report)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_page_url
|
||||
get new_report_page_url(@page.report)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create page" do
|
||||
assert_difference("Page.count") do
|
||||
post pages_url, params: { page: { path: @page.path, position: @page.position, report_id: @page.report_id, url: @page.url } }
|
||||
post report_pages_url(@page.report), params: { page: { path: @page.path, position: @page.position + 1, url: @page.url } }
|
||||
end
|
||||
|
||||
assert_redirected_to page_url(Page.last)
|
||||
assert_redirected_to report_url(Page.last.report, page_id: Page.last)
|
||||
end
|
||||
|
||||
test "should show page" do
|
||||
|
|
@ -40,9 +56,10 @@ class PagesControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
test "should destroy page" do
|
||||
assert_difference("Page.count", -1) do
|
||||
Rails.logger.level = :debug
|
||||
delete page_url(@page)
|
||||
end
|
||||
|
||||
assert_redirected_to pages_url
|
||||
assert_redirected_to report_pages_url(@page.report)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -24,20 +24,19 @@ class SuccessCriteriaControllerTest < ActionDispatch::IntegrationTest
|
|||
end
|
||||
|
||||
test "should get index" do
|
||||
get success_criteria_url
|
||||
get element_success_criteria_url(@success_criterion.element)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get new_success_criterion_url
|
||||
get new_element_success_criterion_url(@success_criterion.element)
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create success_criterion" do
|
||||
assert_difference("SuccessCriterion.count") do
|
||||
post success_criteria_url,
|
||||
params: { success_criterion: { comment: @success_criterion.comment,
|
||||
description_html: @success_criterion.description_html, element_id: @success_criterion.element_id, level: @success_criterion.level, result: @success_criterion.result, title: @success_criterion.title } }
|
||||
post element_success_criteria_url(@success_criterion.element),
|
||||
params: { success_criterion: { check_id: @success_criterion.check_id } }
|
||||
end
|
||||
|
||||
assert_redirected_to success_criterion_url(SuccessCriterion.last)
|
||||
|
|
@ -55,8 +54,7 @@ class SuccessCriteriaControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
test "should update success_criterion" do
|
||||
patch success_criterion_url(@success_criterion),
|
||||
params: { success_criterion: { comment: @success_criterion.comment,
|
||||
description_html: @success_criterion.description_html, element_id: @success_criterion.element_id, level: @success_criterion.level, result: @success_criterion.result, title: @success_criterion.title } }
|
||||
params: { success_criterion: { test_comment: @success_criterion.test_comment, level: @success_criterion.level, result: @success_criterion.result, title: @success_criterion.title } }
|
||||
assert_redirected_to success_criterion_url(@success_criterion)
|
||||
end
|
||||
|
||||
|
|
@ -65,6 +63,6 @@ class SuccessCriteriaControllerTest < ActionDispatch::IntegrationTest
|
|||
delete success_criterion_url(@success_criterion)
|
||||
end
|
||||
|
||||
assert_redirected_to success_criteria_url
|
||||
assert_redirected_to element_success_criteria_url(@success_criterion.element)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
9
test/fixtures/checks.yml
vendored
9
test/fixtures/checks.yml
vendored
|
|
@ -2,18 +2,21 @@
|
|||
|
||||
one:
|
||||
position: MyString
|
||||
name: MyString
|
||||
name_de: MyString
|
||||
level: 1
|
||||
number: 1
|
||||
principle: one
|
||||
|
||||
two:
|
||||
position: MyString
|
||||
name: MyString
|
||||
name_de: MyString
|
||||
level: 1
|
||||
number: 2
|
||||
principle: one
|
||||
|
||||
deletable:
|
||||
position: MyString
|
||||
name: MyString
|
||||
name_de: MyString
|
||||
level: 1
|
||||
number: 3
|
||||
principle: one
|
||||
|
|
|
|||
10
test/fixtures/elements.yml
vendored
10
test/fixtures/elements.yml
vendored
|
|
@ -1,13 +1,11 @@
|
|||
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
report: one
|
||||
path: MyString
|
||||
page: one
|
||||
title: MyString
|
||||
# description: MyText
|
||||
position: 1
|
||||
|
||||
two:
|
||||
report: two
|
||||
path: MyString
|
||||
page: two
|
||||
title: MyString
|
||||
# description: MyText
|
||||
position: 2
|
||||
|
|
|
|||
4
test/fixtures/success_criteria.yml
vendored
4
test/fixtures/success_criteria.yml
vendored
|
|
@ -5,9 +5,13 @@ one:
|
|||
title: MyString
|
||||
level: 1
|
||||
result: 1
|
||||
position: 1
|
||||
check: one
|
||||
|
||||
two:
|
||||
element: two
|
||||
title: MyString
|
||||
level: 1
|
||||
result: 1
|
||||
position: 2
|
||||
check: two
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ class ElementsTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit elements_url
|
||||
visit page_elements_url(@element.page)
|
||||
assert_selector "h1", text: "Elemente"
|
||||
end
|
||||
|
||||
test "should create element" do
|
||||
skip
|
||||
visit elements_url
|
||||
visit page_elements_url(@element.page)
|
||||
click_on "Element hinzufügen"
|
||||
|
||||
assert_difference("Element.count", 1) do
|
||||
|
|
@ -35,9 +35,6 @@ class ElementsTest < ApplicationSystemTestCase
|
|||
test "should update Element" do
|
||||
visit element_url(@element)
|
||||
click_on "Element bearbeiten", match: :first
|
||||
|
||||
fill_in_rich_text_area "Details", with: @element.description_html
|
||||
fill_in "Pfad", with: @element.path
|
||||
fill_in "Beschreibung", with: @element.title
|
||||
click_on "Element aktualisieren"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,45 +3,43 @@ require "application_system_test_case"
|
|||
class PagesTest < ApplicationSystemTestCase
|
||||
setup do
|
||||
@page = pages(:one)
|
||||
login_test
|
||||
end
|
||||
|
||||
teardown do
|
||||
logout
|
||||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit pages_url
|
||||
assert_selector "h1", text: "Pages"
|
||||
visit report_pages_url(@page.report)
|
||||
assert_selector "h1", text: "Pfade"
|
||||
end
|
||||
|
||||
test "should create page" do
|
||||
visit pages_url
|
||||
click_on "New page"
|
||||
visit report_pages_url(@page.report)
|
||||
click_on "Pfad hinzufügen"
|
||||
|
||||
fill_in "Path", with: @page.path
|
||||
fill_in "Position", with: @page.position
|
||||
fill_in "Report", with: @page.report_id
|
||||
fill_in "Name", with: @page.path
|
||||
fill_in "Url", with: @page.url
|
||||
click_on "Create Page"
|
||||
click_on "Pfad erstellen"
|
||||
|
||||
assert_text "Page was successfully created"
|
||||
click_on "Back"
|
||||
assert_text "Prüfbericht bearbeiten"
|
||||
end
|
||||
|
||||
test "should update Page" do
|
||||
visit page_url(@page)
|
||||
click_on "Edit this page", match: :first
|
||||
click_on "Pfad bearbeiten", match: :first
|
||||
|
||||
fill_in "Path", with: @page.path
|
||||
fill_in "Position", with: @page.position
|
||||
fill_in "Report", with: @page.report_id
|
||||
fill_in "Name", with: @page.path
|
||||
fill_in "Url", with: @page.url
|
||||
click_on "Update Page"
|
||||
|
||||
assert_text "Page was successfully updated"
|
||||
click_on "Back"
|
||||
click_on "Pfad aktualisieren"
|
||||
end
|
||||
|
||||
test "should destroy Page" do
|
||||
visit page_url(@page)
|
||||
click_on "Destroy this page", match: :first
|
||||
click_on "Pfad löschen", match: :first
|
||||
|
||||
assert_text "Page was successfully destroyed"
|
||||
assert_text "Pfad hinzufügen"
|
||||
assert(Page.exists?(@page.id) == false)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class ReportsTest < ApplicationSystemTestCase
|
|||
test "should destroy Report" do
|
||||
visit report_url(@report)
|
||||
click_on "Prüfbericht löschen", match: :first
|
||||
assert_text("Report was successfully destroyed")
|
||||
assert_text("Prüfberichte")
|
||||
assert(Report.exists?(@report.id) == false)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,21 +8,27 @@ class SuccessCriteriaTest < ApplicationSystemTestCase
|
|||
end
|
||||
|
||||
setup do
|
||||
@check = checks(:one)
|
||||
@check.update!(name_de: "Testcheck")
|
||||
@success_criterion = success_criteria(:one)
|
||||
@success_criterion.check = @check
|
||||
@success_criterion.save!
|
||||
login_test
|
||||
end
|
||||
|
||||
test "visiting the index" do
|
||||
visit success_criteria_url
|
||||
visit element_success_criteria_url(@success_criterion.element)
|
||||
assert_selector "h1", text: "Erfolgskriterien"
|
||||
end
|
||||
|
||||
test "should create Erfolgskriterium" do
|
||||
visit success_criteria_url
|
||||
visit element_success_criteria_url(@success_criterion.element)
|
||||
click_on "Erfolgskriterium hinzufügen"
|
||||
|
||||
fill_in_rich_text_area "Testkommentar", with: @success_criterion.comment
|
||||
fill_in_rich_text_area "Richtlinie", with: @success_criterion.description_html
|
||||
select @check.name_de, from: "Check"
|
||||
|
||||
# fill_in_rich_text_area "Testkommentar", with: @success_criterion.test_comment
|
||||
# fill_in_rich_text_area "Quick Kriterium", with: @success_criterion.quick_criterion
|
||||
# fill_in 'Element', with: @success_criterion.element_id
|
||||
# fill_in 'Level', with: @success_criterion.level
|
||||
# fill_in 'Result', with: @success_criterion.result
|
||||
|
|
@ -34,8 +40,8 @@ class SuccessCriteriaTest < ApplicationSystemTestCase
|
|||
visit success_criterion_url(@success_criterion)
|
||||
click_on "Erfolgskriterium bearbeiten", match: :first
|
||||
|
||||
fill_in_rich_text_area "Testkommentar", with: @success_criterion.comment
|
||||
fill_in_rich_text_area "Richtlinie", with: @success_criterion.description_html
|
||||
fill_in_rich_text_area "Testkommentar", with: @success_criterion.test_comment
|
||||
fill_in_rich_text_area "Quick Kriterium", with: @success_criterion.quick_criterion
|
||||
find("label", text: "Bestanden", visible: true).click
|
||||
fill_in "Titel", with: "new"
|
||||
click_on "Erfolgskriterium aktualisieren"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue