wip: continue implementation

This commit is contained in:
Björn Fromme
2024-12-02 17:38:56 +01:00
parent 84ab6446ea
commit 6f989d4c7a
24 changed files with 444 additions and 237 deletions
+2 -1
View File
@@ -7,4 +7,5 @@ htmx.config.includeIndicatorStyles = false
htmx.config.historyEnabled = false
htmx.config.historyCacheSize = 0
htmx.config.allowScriptTags = false
htmx.config.withCredentials = true
htmx.config.withCredentials = true
htmx.config.selfRequestsOnly = false
@@ -1,5 +0,0 @@
import { Controller} from '@hotwired/stimulus'
export default class extends Controller {
static targets = ['field']
}
+29
View File
@@ -0,0 +1,29 @@
import { Controller} from '@hotwired/stimulus'
export default class extends Controller {
static targets = ['field']
static values = { availabilities: Object }
toggle(event) {
let field = event.target
let id = field.value
let availabilities = this.availabilitiesValue
if (field.checked) {
availabilities[id].available--
} else {
availabilities[id].available++
}
field.disabled = 0 >= availabilities[id].available
field.classList.toggle('cursor-not-allowed', field.disabled)
this.availabilitiesValue = availabilities
}
availabilitiesValueChanged(availabilities) {
this.fieldTargets.forEach((field) => {
let id = field.value
if (false === field.checked && 0 >= availabilities[id].available) {
field.disabled = true
}
})
}
}
+18
View File
@@ -0,0 +1,18 @@
import { Controller } from '@hotwired/stimulus'
import Toastify from 'toastify-js'
export default class extends Controller {
static values = { text: String, class: String }
connect() {
Toastify({
duration: 5000,
text: this.textValue,
gravity: 'top',
position: 'right',
className: this.classValue,
close: true,
}).showToast()
}
}
+36
View File
@@ -0,0 +1,36 @@
import { Controller } from '@hotwired/stimulus'
import tippy from 'tippy.js'
export default class extends Controller {
static targets = ['trigger', 'template']
static values = { content: String, placement: String }
connect() {
let options, element
let placement = this.placementValue ? this.placementValue : 'top'
if (this.hasTemplateTarget) {
options = {
content: this.templateTarget.innerHTML,
placement,
touch: true,
trigger: 'click',
allowHTML: true,
interactive: true,
}
} else {
options = {
content: this.contentValue,
placement,
touch: false,
allowHTML: true,
interactive: true,
}
}
if (this.hasTriggerTarget) {
element = this.triggerTarget
} else {
element = this.element
}
tippy(element, options)
}
}
+2 -2
View File
@@ -1,5 +1,5 @@
@import "components/forms.css";
@import "components/button.css";
@import "components/menu.css";
/*@import "components/toast.css";*/
/*@import "components/tooltip.css";*/
@import "components/toast.css";
@import "components/tooltip.css";