diff --git a/src/web/Manager.mjs b/src/web/Manager.mjs index 166f0ac5..7c4e30c9 100755 --- a/src/web/Manager.mjs +++ b/src/web/Manager.mjs @@ -154,7 +154,6 @@ 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 6110582c..8e97cd03 100644 --- a/src/web/components/c-recipe-li.mjs +++ b/src/web/components/c-recipe-li.mjs @@ -24,6 +24,9 @@ export class CRecipeLi extends HTMLElement { this.name = name; this.args = []; + this.flowControl = this.app.operations[this.name].flowControl; + this.manualBake = this.app.operations[this.name].manualBake; + for (let i = 0; i < args.length; i++) { const ing = new HTMLIngredient(args[i], this.app, this.app.manager); this.args.push(ing); @@ -132,10 +135,15 @@ export class CRecipeLi extends HTMLElement { const clearfixDiv = document.createElement("div"); - if (this.app.operations[this.name].flowControl) { + if (this.flowControl) { li.classList.add("flow-control-op"); } + if (this.manualBake && this.app.autoBake_) { + this.manager.controls.setAutoBake(false); + this.app.alert("Auto-Bake is disabled by default when using this operation.", 5000); + } + li.appendChild(icons); li.appendChild(clearfixDiv); diff --git a/src/web/waiters/OperationsWaiter.mjs b/src/web/waiters/OperationsWaiter.mjs index dfb359a2..8bd1bf1b 100755 --- a/src/web/waiters/OperationsWaiter.mjs +++ b/src/web/waiters/OperationsWaiter.mjs @@ -280,7 +280,6 @@ 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 c9615ad6..ed824395 100755 --- a/src/web/waiters/RecipeWaiter.mjs +++ b/src/web/waiters/RecipeWaiter.mjs @@ -234,25 +234,6 @@ class RecipeWaiter { } - /** - * Given an operation stub element, this function converts it into a full recipe element with - * arguments. - * - * @param {string} name - The operation stub element from the operations pane - */ - buildRecipeOperation(name) { - const op = new CRecipeLi(this.app, name, this.app.operations[name].args); - - // Disable auto-bake if this is a manual op - if (op.manualBake && this.app.autoBake_) { - this.manager.controls.setAutoBake(false); - this.app.alert("Auto-Bake is disabled by default when using this operation.", 5000); - } - - return op; - } - - /** * Adds the specified operation to the recipe * @@ -261,7 +242,8 @@ class RecipeWaiter { * @param {string} name - The name of the operation to add */ addOperation(name) { - const item = this.buildRecipeOperation(name); + const item = new CRecipeLi(this.app, name, this.app.operations[name].args); + document.getElementById("rec-list").appendChild(item); $(item).find("[data-toggle='tooltip']").tooltip(); @@ -285,7 +267,9 @@ 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"); } @@ -335,7 +319,6 @@ class RecipeWaiter { opAdd(e) { console.log(e); log.debug(`'${e.target.querySelector("li").getAttribute("data-name")}' added to recipe`); - console.log(e.target.querySelector("li").getAttribute("data-name")); this.triggerArgEvents(e.target); window.dispatchEvent(this.manager.statechange); }