From 85b1dee6fc535755ec33eda95178e6bc9930678e Mon Sep 17 00:00:00 2001 From: Robin Scholtes Date: Sat, 1 Jun 2024 11:31:34 +1200 Subject: [PATCH] [181] resolve undefined operation name on drag event to recipe list --- src/web/App.mjs | 2 +- src/web/components/c-category-li.mjs | 2 +- src/web/components/c-operation-li.mjs | 12 ++++-------- src/web/components/c-operation-list.mjs | 2 +- src/web/components/c-recipe-li.mjs | 2 +- src/web/stylesheets/components/_operation.css | 2 ++ 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/web/App.mjs b/src/web/App.mjs index 410cac25a..ef341f553 100755 --- a/src/web/App.mjs +++ b/src/web/App.mjs @@ -26,7 +26,7 @@ class App { * @param {CatConf[]} categories - The list of categories and operations to be populated. * @param {Object.} operations - The list of operation configuration objects. * @param {String[]} defaultFavourites - A list of default favourite operations. - * @param {Object} options - Default setting for app options. + * @param {Object} defaultOptions - Default setting for app options. */ constructor(categories, operations, defaultFavourites, defaultOptions) { this.categories = categories; diff --git a/src/web/components/c-category-li.mjs b/src/web/components/c-category-li.mjs index 232e1f382..de8a1fbc9 100644 --- a/src/web/components/c-category-li.mjs +++ b/src/web/components/c-category-li.mjs @@ -106,7 +106,7 @@ export class CCategoryLi extends HTMLElement { a.innerText = this.label; if (this.label === "Favourites") { - const editFavouritesButton = this.buildEditFavouritesButton(a); + const editFavouritesButton = this.buildEditFavouritesButton(); // Note: I'm leaving this here as it was in the code originally, but it's not doing anything and it didn't // do anything before my refactoring. I imagine we may want to fix that at some point though, diff --git a/src/web/components/c-operation-li.mjs b/src/web/components/c-operation-li.mjs index 06ca912e2..64e650520 100644 --- a/src/web/components/c-operation-li.mjs +++ b/src/web/components/c-operation-li.mjs @@ -28,7 +28,7 @@ export class COperationLi extends HTMLElement { this.includeStarIcon = includeStarIcon; this.charIndicesToHighlight = charIndicesToHighlight; - this.config = this.app.operations[name]; + this.config = this.app.operations[this.operationName]; this.isFavourite = this.app.isLocalStorageAvailable() && JSON.parse(localStorage.favourites).indexOf(name) >= 0; @@ -60,14 +60,9 @@ export class COperationLi extends HTMLElement { /** * Handle double click - * - * @param {Event} e */ - handleDoubleClick(e) { - // this span is element holding the operation title - if (e.target === this.querySelector("li") || e.target === this.querySelector("span")) { - this.app.manager.recipe.addOperation(this.operationName); - } + handleDoubleClick() { + this.app.manager.recipe.addOperation(this.operationName); } /** @@ -208,6 +203,7 @@ export class COperationLi extends HTMLElement { li.setAttribute("data-boundary", "viewport"); li.setAttribute("data-content", dataContent); } + return li; } diff --git a/src/web/components/c-operation-list.mjs b/src/web/components/c-operation-list.mjs index 7c00d62c7..3fb884746 100644 --- a/src/web/components/c-operation-list.mjs +++ b/src/web/components/c-operation-list.mjs @@ -160,7 +160,7 @@ export class COperationList extends HTMLElement { }, onEnd: ({item, to, newIndex }) => { if (item.parentNode.id === targetListId && dragOverRecList) { - this.app.manager.recipe.addOperation(item.name, newIndex); + this.app.manager.recipe.addOperation(item.querySelector("li").getAttribute("data-name"), newIndex); item.remove(); } else if (!dragOverRecList && !to.classList.contains("op-list")) { item.remove(); diff --git a/src/web/components/c-recipe-li.mjs b/src/web/components/c-recipe-li.mjs index 2e81f6c74..e2162ac25 100644 --- a/src/web/components/c-recipe-li.mjs +++ b/src/web/components/c-recipe-li.mjs @@ -144,7 +144,7 @@ export class CRecipeLi extends HTMLElement { } if (this.manualBake && this.app.autoBake_) { - this.manager.controls.setAutoBake(false); + this.app.manager.controls.setAutoBake(false); this.app.alert("Auto-Bake is disabled by default when using this operation.", 5000); } diff --git a/src/web/stylesheets/components/_operation.css b/src/web/stylesheets/components/_operation.css index f294ba1bc..c04ea036d 100755 --- a/src/web/stylesheets/components/_operation.css +++ b/src/web/stylesheets/components/_operation.css @@ -56,6 +56,8 @@ li.operation.favourite > .op-icon.star-icon { .op-icon.check-icon { display: none; color: var(--checkmark-color); + position: relative; + margin-right: 5px; } .operation.selected {