eslint, rec-list dragging indices

This commit is contained in:
Robin Scholtes 2023-08-16 17:29:26 +12:00
parent d07502d2e1
commit c9f40928fb
3 changed files with 12 additions and 5 deletions

View file

@ -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;
}

View file

@ -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();

View file

@ -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();