feat: exclusion groups for additional services

This commit is contained in:
Björn Fromme
2026-08-04 10:24:29 +02:00
parent c31d086356
commit 331c88c38e
11 changed files with 457 additions and 17 deletions
@@ -0,0 +1,33 @@
import { Controller } from '@hotwired/stimulus'
/**
* Unchecks conflicting additional services as soon as one is selected, so the user sees the
* result immediately instead of waiting for the debounced htmx refresh. The server resolves
* the same conflicts again and stays the source of truth.
*/
export default class extends Controller {
static targets = [ 'input' ]
select(event) {
const input = event.target
if (!input.checked) {
return
}
const group = input.dataset.exclusionGroup
if (!group) {
return
}
const exclusive = '1' === input.dataset.exclusive
this.inputTargets
.filter(other => other !== input)
.filter(other => other.dataset.exclusionGroup === group)
.filter(other => exclusive || '1' === other.dataset.exclusive)
.forEach(other => { other.checked = false })
}
}