import { Controller } from '@hotwired/stimulus'; /* * Shows and hides the parts of the booking form that only apply in some states: the time fields * when "ganzer Tag" is off, the recurrence fields when a repetition is picked, and the weekday * boxes only for a weekly rule. * * Purely client-side, so it is Stimulus rather than an htmx form refresh -- there is nothing the * server needs to decide here. The server still validates every one of these rules, because a * hidden field is not an absent one. */ export default class extends Controller { static targets = ['times', 'repeat', 'weekdays']; toggleTimes(event) { this.timesTarget.classList.toggle('hidden', event.target.checked); } toggleRepeat(event) { const rule = event.target.value; this.repeatTarget.classList.toggle('hidden', rule === ''); this.weekdaysTarget.classList.toggle('hidden', rule !== 'weekly'); } }