23 lines
881 B
JavaScript
23 lines
881 B
JavaScript
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, and the recurrence fields when a repetition is picked. The weekday a
|
|
* series runs on is derived from its start date, so there is nothing to toggle for it.
|
|
*
|
|
* 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'];
|
|
|
|
toggleTimes(event) {
|
|
this.timesTarget.classList.toggle('hidden', event.target.checked);
|
|
}
|
|
|
|
toggleRepeat(event) {
|
|
this.repeatTarget.classList.toggle('hidden', event.target.value === '');
|
|
}
|
|
}
|