]> BookStack Code Mirror - bookstack/blob - resources/js/components/webhook-events.js
Added list shortcuts to markdown editor
[bookstack] / resources / js / components / webhook-events.js
1
2 /**
3  * Webhook Events
4  * Manages dynamic selection control in the webhook form interface.
5  * @extends {Component}
6  */
7 class WebhookEvents {
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 }
31
32 export default WebhookEvents;