diff --git a/src/web/Manager.mjs b/src/web/Manager.mjs index f04fd5eb..675ba0f6 100755 --- a/src/web/Manager.mjs +++ b/src/web/Manager.mjs @@ -153,7 +153,6 @@ class Manager { // Recipe this.addDynamicListener(".arg:not(select)", "input", this.recipe.ingChange, this.recipe); this.addDynamicListener(".arg[type=checkbox], .arg[type=radio], select.arg", "change", this.recipe.ingChange, this.recipe); - this.addDynamicListener(".disable-icon", "click", this.recipe.disableClick, this.recipe); this.addDynamicListener(".breakpoint", "click", this.recipe.breakpointClick, this.recipe); this.addDynamicListener("#rec-list .dropdown-menu.toggle-dropdown a", "click", this.recipe.dropdownToggleClick, this.recipe); this.addDynamicListener("textarea.arg", "dragover", this.recipe.textArgDragover, this.recipe); diff --git a/src/web/components/c-recipe-li.mjs b/src/web/components/c-recipe-li.mjs index 18f8981b..835584f0 100644 --- a/src/web/components/c-recipe-li.mjs +++ b/src/web/components/c-recipe-li.mjs @@ -45,12 +45,31 @@ export class CRecipeLi extends HTMLElement { /** * Handle click + * @fires Manager#statechange * @param {Event} e */ - handleClick(e) {} + handleClick(e) { + const disableIcon = this.querySelector("i.disable-icon"); + + if (e.target === disableIcon) { + if (disableIcon.getAttribute("disabled") === "false") { + disableIcon.setAttribute("disabled", "true"); + disableIcon.classList.add("disable-icon-selected"); + this.querySelector("li.operation").classList.add("disabled"); + } else { + disableIcon.setAttribute("disabled", "false"); + disableIcon.classList.remove("disable-icon-selected"); + this.querySelector("li.operation").classList.remove("disabled"); + } + + this.app.progress = 0; + window.dispatchEvent(this.app.manager.statechange); + } + } /** * Handle double click + * * @param {Event} e */ handleDoubleClick(e) { @@ -62,13 +81,13 @@ export class CRecipeLi extends HTMLElement { /** * Remove this operation from the recipe list + * + * @fires Manager#statechange */ removeOperation(){ this.remove(); log.debug("Operation removed from recipe"); window.dispatchEvent(this.app.manager.statechange); - - // @TODO: this func can be moved to c-operation-list this.app.manager.ops.updateListItemsClasses("#rec-list", "selected"); } diff --git a/src/web/waiters/RecipeWaiter.mjs b/src/web/waiters/RecipeWaiter.mjs index a6142d42..99fb6ece 100755 --- a/src/web/waiters/RecipeWaiter.mjs +++ b/src/web/waiters/RecipeWaiter.mjs @@ -161,31 +161,6 @@ class RecipeWaiter { } - /** - * Handler for disable click events. - * Updates the icon status. - * - * @fires Manager#statechange - * @param {Event} e - */ - disableClick(e) { - const icon = e.target; - - if (icon.getAttribute("disabled") === "false") { - icon.setAttribute("disabled", "true"); - icon.classList.add("disable-icon-selected"); - icon.parentNode.parentNode.classList.add("disabled"); - } else { - icon.setAttribute("disabled", "false"); - icon.classList.remove("disable-icon-selected"); - icon.parentNode.parentNode.classList.remove("disabled"); - } - - this.app.progress = 0; - window.dispatchEvent(this.manager.statechange); - } - - /** * Handler for breakpoint click events. * Updates the icon status.