Cosmetics
This commit is contained in:
parent
ee5dbcf33e
commit
e569bcb246
21 changed files with 54 additions and 65 deletions
|
|
@ -130,7 +130,7 @@ class ReportsController < ApplicationController
|
|||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def report_params
|
||||
params.require(:report).permit(:name, :comment)
|
||||
params.require(:report).permit(:name, :comment, :url)
|
||||
end
|
||||
|
||||
def filename(report, extension: "html")
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import * as bootstrap from 'bootstrap'
|
|||
// Connects to data-controller="bs-scrollspy"
|
||||
export default class extends Controller {
|
||||
connect() {
|
||||
// console.log(this.element)
|
||||
const target = this.element.getAttribute("data-bs-scrollspy-target")
|
||||
const scrollSpy = new bootstrap.ScrollSpy(this.element, {
|
||||
target: target
|
||||
|
|
|
|||
|
|
@ -5,13 +5,10 @@ export default class extends Controller {
|
|||
static targets = ["input", "button"]
|
||||
|
||||
connect() {
|
||||
console.log("connect", this.inputTarget, this.buttonTarget)
|
||||
this.inputTarget.addEventListener("input", e => this.onUrlInputChange(e))
|
||||
}
|
||||
|
||||
onUrlInputChange(event) {
|
||||
console.log("connect", this.inputTarget, this.buttonTarget)
|
||||
console.log(event, this.buttonTarget)
|
||||
this.buttonTarget.href = this.inputTarget.value;
|
||||
this.buttonTarget.innerHTML = this.inputTarget.value;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -2,20 +2,19 @@ import { Controller } from "@hotwired/stimulus"
|
|||
|
||||
// Connects to data-controller="collapse-chevron-toggler"
|
||||
export default class extends Controller {
|
||||
static targets = [ "icon" ];
|
||||
static targets = ["icon"];
|
||||
collapsible = null;
|
||||
|
||||
connect() {
|
||||
this.collapsible = window.document.getElementById(this.element.getAttribute('href').substring(1));
|
||||
this.setIcon();
|
||||
|
||||
|
||||
this.collapsible.addEventListener('hide.bs.collapse', e => this.toggle())
|
||||
this.collapsible.addEventListener('show.bs.collapse', e => this.toggle())
|
||||
}
|
||||
|
||||
setIcon(reverted = false) {
|
||||
console.log('setIcon', this.collapsible)
|
||||
if(this.collapsible.classList.contains('show')) {
|
||||
if (this.collapsible.classList.contains('show')) {
|
||||
this.iconTarget.classList.remove('bi-chevron-down')
|
||||
this.iconTarget.classList.add('bi-chevron-up')
|
||||
} else {
|
||||
|
|
@ -25,7 +24,6 @@ export default class extends Controller {
|
|||
}
|
||||
|
||||
toggle() {
|
||||
console.log('toggle', this.collapsible)
|
||||
this.iconTarget.classList.toggle('bi-chevron-down');
|
||||
this.iconTarget.classList.toggle('bi-chevron-up');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,17 +6,20 @@ export default class extends Controller {
|
|||
}
|
||||
|
||||
openAll(e) {
|
||||
console.log(e)
|
||||
console.log("open all")
|
||||
e.preventDefault();
|
||||
this.element.querySelectorAll("details").forEach(el => {
|
||||
const id = this.element.dataset["targetId"]
|
||||
const el = document.getElementById(id)
|
||||
el.querySelectorAll("details").forEach(el => {
|
||||
el.setAttribute("open", "")
|
||||
})
|
||||
}
|
||||
|
||||
closeAll(e) {
|
||||
console.log(e)
|
||||
e.preventDefault();
|
||||
this.element.querySelectorAll("details").forEach(el => {
|
||||
const id = this.element.dataset["targetId"]
|
||||
const el = document.getElementById(id)
|
||||
el.querySelectorAll("details").forEach(el => {
|
||||
el.removeAttribute("open")
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,17 +5,16 @@ import { install } from '@github/hotkey'
|
|||
export default class extends Controller {
|
||||
connect() {
|
||||
// Install all the hotkeys on the page
|
||||
console.log("hotkey connect", this.element)
|
||||
this.element.addEventListener("turbo:load", this.handleTurboLoad)
|
||||
for (const el of this.element.parentNode.querySelectorAll('[data-hotkey]')) {
|
||||
console.log(el)
|
||||
console.log(el.dataset)
|
||||
install(el)
|
||||
}
|
||||
}
|
||||
|
||||
handleTurboLoad(event) {
|
||||
for (const el of event.getTarget().querySelectorAll('[data-hotkey]')) {
|
||||
console.log(el)
|
||||
console.log(el.dataset)
|
||||
install(el)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,7 @@ export default class extends Controller {
|
|||
|
||||
connect() {
|
||||
const cookieValue = Cookie.get(this.COOKIE_NAME);
|
||||
console.log("cookieValue", cookieValue);
|
||||
if(cookieValue) {
|
||||
if (cookieValue) {
|
||||
return true;
|
||||
}
|
||||
const darkMode = window.matchMedia("(prefers-color-scheme:dark)").matches ? "dark" : "light";
|
||||
|
|
|
|||
|
|
@ -8,10 +8,8 @@ export default class extends Controller {
|
|||
connect() {
|
||||
this.element.style.cursor = "grab"
|
||||
|
||||
console.log("dataset", this.element.dataset)
|
||||
if (this.element.dataset["linkedElementId"]) {
|
||||
this.linkedElement = document.getElementById(this.element.dataset["linkedElementId"])
|
||||
console.log("Has a linked element", this.linkedElement)
|
||||
}
|
||||
|
||||
new Sortable(this.element, {
|
||||
|
|
@ -29,7 +27,6 @@ export default class extends Controller {
|
|||
let body = {}
|
||||
body[formName] = {}
|
||||
body[formName][positionAttribute] = position
|
||||
console.log("event", event, "url", url)
|
||||
// Expect backend to update list items via turbo if necessary
|
||||
put(url, {
|
||||
body: JSON.stringify(body),
|
||||
|
|
@ -38,16 +35,13 @@ export default class extends Controller {
|
|||
"Accept": "text/vnd.turbo-stream.html, text/html, application/xhtml+xml"
|
||||
}
|
||||
})
|
||||
console.log(linkedElement)
|
||||
if (linkedElement) {
|
||||
console.log("move linked", linkedElement)
|
||||
let children = linkedElement.children
|
||||
let child = children[event.oldIndex]
|
||||
let newAfter = children[event.newIndex]
|
||||
if (event.oldIndex < event.newIndex) {
|
||||
newAfter = children[event.newIndex + 1]
|
||||
}
|
||||
console.log("move ", child, "before", newAfter)
|
||||
child.parentNode.insertBefore(child, newAfter)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ export default class extends Controller {
|
|||
COOKIE_NAME = "modeTheme"
|
||||
|
||||
connect() {
|
||||
console.log("connect switcher", this.init())
|
||||
}
|
||||
|
||||
init() {
|
||||
|
|
|
|||
|
|
@ -10,18 +10,11 @@ export default class extends Controller {
|
|||
isSubmitted = false
|
||||
|
||||
connect() {
|
||||
console.log("connect unsaved-changes")
|
||||
this.initialState = this.formState()
|
||||
|
||||
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.isSubmitted = true)
|
||||
// this.cancelTargets.forEach(element => {
|
||||
// console.log(element)
|
||||
// element.addEventListener("onclick", (_) => this.reset())
|
||||
// });
|
||||
}
|
||||
|
||||
formState() {
|
||||
|
|
@ -31,17 +24,14 @@ export default class extends Controller {
|
|||
}
|
||||
|
||||
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.isSubmitted || !this.hasChanged()) {
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class Element < ApplicationRecord
|
|||
has_rich_text :description
|
||||
|
||||
belongs_to :page, touch: true
|
||||
has_many :success_criteria, dependent: :destroy
|
||||
has_many :success_criteria, -> { order(:position) }, dependent: :destroy
|
||||
|
||||
delegate :report, to: :page
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ class Page < ApplicationRecord
|
|||
before_validation :set_position
|
||||
before_update :update_positions, if: :position_changed?
|
||||
|
||||
def full_url
|
||||
return nil if report.url.blank? && url.blank?
|
||||
|
||||
[ "https:/", report.url&.sub(/.*:\/\//, ""), url&.sub(/^\//, "") ].compact_blank.join("/")
|
||||
end
|
||||
|
||||
private
|
||||
def set_position
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
<i class="bi bi-pencil">
|
||||
</i>
|
||||
<% end %>
|
||||
<%= button_to(element_path(element), method: :delete, class: "btn btn-link text-danger", data: { turbo_confirm: "Bist du sicher?"}) do %>
|
||||
<i class="bi bi-trash"></i>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if element.description %>
|
||||
<div class="mb-3">
|
||||
|
|
@ -20,9 +23,7 @@
|
|||
</div>
|
||||
<% end %>
|
||||
<p class="actions">
|
||||
<%= button_to(element_path(element), method: :delete, class: "btn btn-outline-danger", data: { turbo_confirm: "Bist du sicher?"}) do %>
|
||||
<i class="bi bi-trash"></i>
|
||||
<% end %>
|
||||
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
li id=dom_id(element, :page_nav_row) data={ "sortable-url": element_path(element), "form-name": "element", "position-attribute": "position" }
|
||||
- if current_page
|
||||
=< link_to("##{dom_id(element)}", data: { "turbo": false }) do
|
||||
i.bi.bi-boxes.me-1
|
||||
i.bi.bi-boxes.me-2
|
||||
span id=dom_id(element, :page_nav_title)
|
||||
= "#{element.number} #{element.title}"
|
||||
- else
|
||||
=< link_to(report_path(element.report, page_id: element.page.id, anchor: dom_id(element)), data: { "turbo": false }) do
|
||||
i.bi.bi-boxes.me-1
|
||||
i.bi.bi-boxes.me-2
|
||||
span id=dom_id(element, :page_nav_title)
|
||||
=< "#{element.number} #{element.title}"
|
||||
|
|
@ -19,7 +19,7 @@ dl
|
|||
dd Springe zum Anfang des Contents (Skip-Link, kann auf allen Seiten verwendet werden)
|
||||
dt a
|
||||
dd Alle auf
|
||||
dt z
|
||||
dt s
|
||||
dd Alle zu
|
||||
dt b
|
||||
dd Baum
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
<div id="<%= dom_id page %>" class="mb-3" data-bs-scrollspy-target="#<%= dom_id(page.report, :page_nav_spy) %>" data-controller="bs-scrollspy">
|
||||
<div class="text-end">
|
||||
<a href="#" data-action="click->details-list#closeAll" data-controller="hotkey" data-hotkey="z">Alle zu [z]</a>
|
||||
<a href="#" data-action="click->details-list#openAll" data-controller="hotkey" data-hotkey="a">Alle auf [a]</a>
|
||||
</div>
|
||||
<div id="element_list" data-controller="details-list">
|
||||
<div id="element_list">
|
||||
<% page.elements.each do |element| %>
|
||||
<%= render element %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<%= bootstrap_form_with(model: report) do |form| %>
|
||||
<%= form.text_field :name %>
|
||||
<%= form.text_field :url %>
|
||||
<%= form.rich_text_area :comment %>
|
||||
<%= form.submit %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -17,9 +17,13 @@ h1
|
|||
=< @current_page.path
|
||||
p
|
||||
'URL:
|
||||
= @current_page.url
|
||||
= safe_display(@current_page.full_url) { link_to(_1, _1, target: :_blank) }
|
||||
p.actions
|
||||
= button_to("Pfad \"#{@current_page.path}\" löschen", page_path(@current_page), method: :delete, class: "btn btn-outline-danger", form: {data: { turbo_confirm: "Bist du sicher?" }})
|
||||
.d-flex.justify-content-end data-controller="details-list" data-target-id="element_list"
|
||||
.btn-group.me-3
|
||||
= link_to("Alle zu [s]", "#", data: { action: "click->details-list#closeAll", controller: :hotkey, hotkey: "s" }, class: "btn btn-outline-secondary")
|
||||
= link_to("Alle auf [a]", "#", data: { action: "click->details-list#openAll", controller: :hotkey, hotkey: "a" }, class: "btn btn-outline-secondary")
|
||||
= button_to(tag.i(class: "bi bi-trash"), page_path(@current_page), method: :delete, class: "btn btn-outline-danger", form: {data: { turbo_confirm: "Bist du sicher?" }})
|
||||
.row
|
||||
.col-lg-3.col-md-4.col-sm-12
|
||||
.page_nav.sticky-top
|
||||
|
|
|
|||
|
|
@ -2,20 +2,18 @@
|
|||
= turbo_frame_tag(dom_id(success_criterion, :frame)) do
|
||||
.row
|
||||
.col
|
||||
.position-relative
|
||||
.position-absolute.top-0.end-0.fw-bold
|
||||
= button_to(tag.i(class: "bi bi-trash"), success_criterion, method: :delete, class: "btn btn-outline-danger", data: { turbo_confirm: "Bist du sicher?"})
|
||||
= success_criterion_edit_button(success_criterion, false)
|
||||
.my-3.btn-group[role="group" aria-label="Resultat"]
|
||||
= bootstrap_form_with(model: success_criterion, data: { controller: "autosubmit" }) do |form|
|
||||
= form.radio_button_without_bootstrap :result, :passed, class: "btn-check", autocomplete: "off", id: dom_id(success_criterion, :result_passed)
|
||||
label.btn.btn-outline-success for=dom_id(success_criterion, :result_passed) Bestanden
|
||||
= form.radio_button_without_bootstrap :result, :failed, class: "btn-check", autocomplete: "off", id: dom_id(success_criterion, :result_failed)
|
||||
label.btn.btn-outline-danger for=dom_id(success_criterion, :result_failed) Durchgefallen
|
||||
= form.radio_button_without_bootstrap :result, :not_applicable, class: "btn-check", autocomplete: "off", id: dom_id(success_criterion, :result_not_applicable)
|
||||
label.btn.btn-outline-secondary for=dom_id(success_criterion, :result_not_applicable) Nicht anwendbar
|
||||
/= form.radio_button_without_bootstrap :result, nil, class: "btn-check", autocomplete: "off", id: dom_id(success_criterion, :result_not_applicable)
|
||||
/label.btn.btn-outline-secondary for=dom_id(success_criterion, :nil) Reset
|
||||
.my-3.btn-group[role="group" aria-label="Resultat"]
|
||||
= bootstrap_form_with(model: success_criterion, data: { controller: "autosubmit" }) do |form|
|
||||
= form.radio_button_without_bootstrap :result, :passed, class: "btn-check", autocomplete: "off", id: dom_id(success_criterion, :result_passed)
|
||||
label.btn.btn-outline-success for=dom_id(success_criterion, :result_passed) Bestanden
|
||||
= form.radio_button_without_bootstrap :result, :failed, class: "btn-check", autocomplete: "off", id: dom_id(success_criterion, :result_failed)
|
||||
label.btn.btn-outline-danger for=dom_id(success_criterion, :result_failed) Durchgefallen
|
||||
= form.radio_button_without_bootstrap :result, :not_applicable, class: "btn-check", autocomplete: "off", id: dom_id(success_criterion, :result_not_applicable)
|
||||
label.btn.btn-outline-secondary for=dom_id(success_criterion, :result_not_applicable) Nicht anwendbar
|
||||
/= form.radio_button_without_bootstrap :result, nil, class: "btn-check", autocomplete: "off", id: dom_id(success_criterion, :result_not_applicable)
|
||||
/label.btn.btn-outline-secondary for=dom_id(success_criterion, :nil) Reset
|
||||
= button_to(tag.i(class: "bi bi-trash"), success_criterion, method: :delete, class: "btn btn-link text-danger", data: { turbo_confirm: "Bist du sicher?"})
|
||||
= success_criterion_edit_button(success_criterion, false)
|
||||
.row
|
||||
.col
|
||||
- if success_criterion.test_comment?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue