diff --git a/src/lib/components/MaintenancePopup.js b/src/lib/components/MaintenancePopup.js index 3f17a03..ae906f6 100644 --- a/src/lib/components/MaintenancePopup.js +++ b/src/lib/components/MaintenancePopup.js @@ -51,6 +51,7 @@ export class MaintenancePopup extends BaseComponent { this.#mediaBoxTools = mediaBoxTools; MaintenancePopup.#watchActiveProfile(this.#onActiveProfileChanged.bind(this)); + this.#tagsListElement.addEventListener('click', this.#handleTagClick.bind(this)); } /** @@ -90,6 +91,33 @@ export class MaintenancePopup extends BaseComponent { }); } + /** + * Detect and process clicks made directly to the tags. + * @param {MouseEvent} event + */ + #handleTagClick(event) { + /** @type {HTMLElement} */ + let tagElement = event.target; + + if (!tagElement.classList.contains('tag')) { + tagElement = tagElement.closest('.tag'); + } + + if (!tagElement) { + return; + } + + if (tagElement.classList.contains('is-present')) { + tagElement.classList.toggle('is-removed'); + } + + if (tagElement.classList.contains('is-missing')) { + tagElement.classList.toggle('is-added'); + } + + // TODO: Execute the submission on timeout or after user moved the mouse away from the popup. + } + /** * @return {boolean} */