]> BookStack Code Mirror - bookstack/blob - resources/js/components/webhook-events.js
Comments: Fixed display, added archive list support for editor toolbox
[bookstack] / resources / js / components / webhook-events.js
1 /**
2  * Webhook Events
3  * Manages dynamic selection control in the webhook form interface.
4  */
5 import {Component} from './component';
6
7 export class WebhookEvents extends Component {
8
9     setup() {
10         this.checkboxes = this.$el.querySelectorAll('input[type="checkbox"]');
11         this.allCheckbox = this.$el.querySelector('input[type="checkbox"][value="all"]');
12
13         this.$el.addEventListener('change', event => {
14             if (event.target.checked && event.target === this.allCheckbox) {
15                 this.deselectIndividualEvents();
16             } else if (event.target.checked) {
17                 this.allCheckbox.checked = false;
18             }
19         });
20     }
21
22     deselectIndividualEvents() {
23         for (const checkbox of this.checkboxes) {
24             if (checkbox !== this.allCheckbox) {
25                 checkbox.checked = false;
26             }
27         }
28     }
29
30 }