Cosmetics
Some checks failed
/ Run tests (push) Successful in 1m52s
/ Run system tests (push) Failing after 2m3s
/ Build, push and deploy image (push) Successful in 1m45s

This commit is contained in:
david 2024-11-11 05:00:51 +01:00
parent ee5dbcf33e
commit e569bcb246
21 changed files with 54 additions and 65 deletions

View file

@ -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

View file

@ -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;

View file

@ -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');
}

View file

@ -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")
})
}

View file

@ -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)
}
}

View file

@ -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";

View file

@ -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)
}
}

View file

@ -6,7 +6,6 @@ export default class extends Controller {
COOKIE_NAME = "modeTheme"
connect() {
console.log("connect switcher", this.init())
}
init() {

View file

@ -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
}