From c110e5a59fe316f1e4a4d759c1e1a5055d3bd6bf Mon Sep 17 00:00:00 2001 From: Robin Scholtes Date: Tue, 15 Aug 2023 13:02:33 +1200 Subject: [PATCH] fix 'clear all --- src/web/Manager.mjs | 1 + src/web/components/c-recipe-li.mjs | 4 ++++ src/web/waiters/OperationsWaiter.mjs | 1 + src/web/waiters/RecipeWaiter.mjs | 6 ++---- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/web/Manager.mjs b/src/web/Manager.mjs index 7c4e30c9..166f0ac5 100755 --- a/src/web/Manager.mjs +++ b/src/web/Manager.mjs @@ -154,6 +154,7 @@ class Manager { 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("#rec-list .dropdown-menu.toggle-dropdown a", "click", this.recipe.dropdownToggleClick, this.recipe); + this.addDynamicListener("#rec-list", "operationremove", this.recipe.clearRecipe.bind(this.recipe)); this.addDynamicListener("textarea.arg", "dragover", this.recipe.textArgDragover, this.recipe); this.addDynamicListener("textarea.arg", "dragleave", this.recipe.textArgDragLeave, this.recipe); this.addDynamicListener("textarea.arg", "drop", this.recipe.textArgDrop, this.recipe); diff --git a/src/web/components/c-recipe-li.mjs b/src/web/components/c-recipe-li.mjs index 78c69bf5..6110582c 100644 --- a/src/web/components/c-recipe-li.mjs +++ b/src/web/components/c-recipe-li.mjs @@ -132,6 +132,10 @@ export class CRecipeLi extends HTMLElement { const clearfixDiv = document.createElement("div"); + if (this.app.operations[this.name].flowControl) { + li.classList.add("flow-control-op"); + } + li.appendChild(icons); li.appendChild(clearfixDiv); diff --git a/src/web/waiters/OperationsWaiter.mjs b/src/web/waiters/OperationsWaiter.mjs index 8bd1bf1b..dfb359a2 100755 --- a/src/web/waiters/OperationsWaiter.mjs +++ b/src/web/waiters/OperationsWaiter.mjs @@ -280,6 +280,7 @@ class OperationsWaiter { * @param {string} className - the className to update */ updateListItemsClasses(srcListSelector, className) { + console.log("li update"); const listItems = document.querySelectorAll(`${srcListSelector} li`); const ops = document.querySelectorAll("c-operation-li > li.operation"); diff --git a/src/web/waiters/RecipeWaiter.mjs b/src/web/waiters/RecipeWaiter.mjs index a062b01d..c9615ad6 100755 --- a/src/web/waiters/RecipeWaiter.mjs +++ b/src/web/waiters/RecipeWaiter.mjs @@ -243,10 +243,6 @@ class RecipeWaiter { buildRecipeOperation(name) { const op = new CRecipeLi(this.app, name, this.app.operations[name].args); - if (this.app.operations[name].flowControl) { - op.classList.add("flow-control-op"); - } - // Disable auto-bake if this is a manual op if (op.manualBake && this.app.autoBake_) { this.manager.controls.setAutoBake(false); @@ -289,6 +285,8 @@ class RecipeWaiter { recList.removeChild(recList.firstChild); } recList.dispatchEvent(this.manager.operationremove); + window.dispatchEvent(this.app.manager.statechange); + this.app.manager.ops.updateListItemsClasses("#rec-list", "selected"); }