diff --git a/src/web/components/c-operation-li.mjs b/src/web/components/c-operation-li.mjs index 8e29b081..f6e12610 100644 --- a/src/web/components/c-operation-li.mjs +++ b/src/web/components/c-operation-li.mjs @@ -298,7 +298,7 @@ export class COperationLi extends HTMLElement { const parser = new DOMParser(); opName = parser.parseFromString(opName, "text/html"); - span.append( ...opName.body.children ); + span.append(...opName.body.children); } else { span.innerText = this.name; } diff --git a/src/web/components/c-operation-list.mjs b/src/web/components/c-operation-list.mjs index 839e5e1b..7c00d62c 100644 --- a/src/web/components/c-operation-list.mjs +++ b/src/web/components/c-operation-list.mjs @@ -158,9 +158,9 @@ export class COperationList extends HTMLElement { .off(".popover") .removeData("bs.popover"); }, - onEnd: ({item, to}) => { + onEnd: ({item, to, newIndex }) => { if (item.parentNode.id === targetListId && dragOverRecList) { - this.app.manager.recipe.addOperation(item.name); + this.app.manager.recipe.addOperation(item.name, newIndex); item.remove(); } else if (!dragOverRecList && !to.classList.contains("op-list")) { item.remove(); diff --git a/src/web/waiters/RecipeWaiter.mjs b/src/web/waiters/RecipeWaiter.mjs index 65408c63..e43dbbc6 100755 --- a/src/web/waiters/RecipeWaiter.mjs +++ b/src/web/waiters/RecipeWaiter.mjs @@ -240,11 +240,18 @@ class RecipeWaiter { * @fires Manager#operationadd * @fires Manager#statechange * @param {string} name - The name of the operation to add + * @param {number} index - The index where the operation should be displayed */ - addOperation(name) { + addOperation(name, index = undefined) { const item = new CRecipeLi(this.app, name, this.app.operations[name].args); - document.getElementById("rec-list").appendChild(item); + const recipeList = document.getElementById("rec-list"); + + if (index !== undefined) { + recipeList.insertBefore(item, recipeList.children[index + 1]); + } else { + recipeList.appendChild(item); + } $(item).find("[data-toggle='tooltip']").tooltip();