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

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