mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-08 07:21:02 -04:00
[#181] correctly handle checkmarks after favourites updates and resetting, update addSelectedClass to put selected on all operations with target data name ( as sometimes there will be 2 of the same rather than 1, in the case of a favourited operation ). Make updates to pass the op-title around based by the data-name attr instead of innerText
This commit is contained in:
parent
8d693a7d0e
commit
bc93969d4b
5 changed files with 18 additions and 6 deletions
|
@ -46,6 +46,7 @@ class HTMLOperation {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
toStubHtml(removeIcon) {
|
toStubHtml(removeIcon) {
|
||||||
|
console.log("toStubHtml ==>",this.name);
|
||||||
let html = `<li data-name="${this.name}" class="operation"`;
|
let html = `<li data-name="${this.name}" class="operation"`;
|
||||||
|
|
||||||
if (this.description) {
|
if (this.description) {
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
- test drag and drop etc. Regular mobile events / UX
|
- test drag and drop etc. Regular mobile events / UX
|
||||||
- view-heights not correct due to variable taskbar on mobile devices
|
- view-heights not correct due to variable taskbar on mobile devices
|
||||||
|
|
||||||
|
- see if i can use OpWaiter > getSelectedOp for getting selected ops. Although I dont see 'selected-op' on any op?
|
||||||
|
|
||||||
### Desktop UI:
|
### Desktop UI:
|
||||||
### General UI:
|
### General UI:
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {fuzzyMatch, calcMatchRanges} from "../../core/lib/FuzzyMatch.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waiter to handle events related to the operations.
|
* Waiter to handle events related to the operations.
|
||||||
|
* Waiter to handle events related to the operations
|
||||||
*/
|
*/
|
||||||
class OperationsWaiter {
|
class OperationsWaiter {
|
||||||
|
|
||||||
|
@ -54,7 +55,7 @@ class OperationsWaiter {
|
||||||
if (ops.length) {
|
if (ops.length) {
|
||||||
selected = this.getSelectedOp(ops);
|
selected = this.getSelectedOp(ops);
|
||||||
if (selected > -1) {
|
if (selected > -1) {
|
||||||
this.manager.recipe.addOperation(ops[selected].innerHTML);
|
this.manager.recipe.addOperation(ops[selected].getAttribute("data-name"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,6 +351,7 @@ class OperationsWaiter {
|
||||||
*/
|
*/
|
||||||
resetFavouritesClick() {
|
resetFavouritesClick() {
|
||||||
this.app.resetFavourites();
|
this.app.resetFavourites();
|
||||||
|
this.manager.recipe.updateSelectedOperations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ class RecipeWaiter {
|
||||||
filter: ".arg",
|
filter: ".arg",
|
||||||
preventOnFilter: false,
|
preventOnFilter: false,
|
||||||
setData: function(dataTransfer, dragEl) {
|
setData: function(dataTransfer, dragEl) {
|
||||||
dataTransfer.setData("Text", dragEl.querySelector(".op-title").textContent);
|
dataTransfer.setData("Text", dragEl.getAttribute("data-name"));
|
||||||
},
|
},
|
||||||
onEnd: function(evt) {
|
onEnd: function(evt) {
|
||||||
if (this.removeIntent) {
|
if (this.removeIntent) {
|
||||||
|
@ -97,7 +97,7 @@ class RecipeWaiter {
|
||||||
draggable: draggable ? ".operation" : null,
|
draggable: draggable ? ".operation" : null,
|
||||||
sort: false,
|
sort: false,
|
||||||
setData: function(dataTransfer, dragEl) {
|
setData: function(dataTransfer, dragEl) {
|
||||||
dataTransfer.setData("Text", dragEl.textContent);
|
dataTransfer.setData("Text", dragEl.getAttribute("data-name"));
|
||||||
},
|
},
|
||||||
onStart: function(evt) {
|
onStart: function(evt) {
|
||||||
// Removes popover element and event bindings from the dragged operation but not the
|
// Removes popover element and event bindings from the dragged operation but not the
|
||||||
|
@ -147,6 +147,7 @@ class RecipeWaiter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log("opSortEnd ==>", evt.item);
|
||||||
this.buildRecipeOperation(evt.item);
|
this.buildRecipeOperation(evt.item);
|
||||||
evt.item.dispatchEvent(this.manager.operationadd);
|
evt.item.dispatchEvent(this.manager.operationadd);
|
||||||
}
|
}
|
||||||
|
@ -327,7 +328,7 @@ class RecipeWaiter {
|
||||||
}
|
}
|
||||||
|
|
||||||
item = {
|
item = {
|
||||||
op: operations[i].querySelector(".op-title").textContent,
|
op: operations[i].getAttribute("data-name"),
|
||||||
args: ingredients
|
args: ingredients
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -371,6 +372,7 @@ class RecipeWaiter {
|
||||||
* @param {element} el - The operation stub element from the operations pane
|
* @param {element} el - The operation stub element from the operations pane
|
||||||
*/
|
*/
|
||||||
buildRecipeOperation(el) {
|
buildRecipeOperation(el) {
|
||||||
|
console.log("buildRecipeOperation ==>", el);
|
||||||
const opName = el.textContent;
|
const opName = el.textContent;
|
||||||
const op = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager);
|
const op = new HTMLOperation(opName, this.app.operations[opName], this.app, this.manager);
|
||||||
el.innerHTML = op.toFullHtml();
|
el.innerHTML = op.toFullHtml();
|
||||||
|
@ -396,6 +398,7 @@ class RecipeWaiter {
|
||||||
* @returns {element}
|
* @returns {element}
|
||||||
*/
|
*/
|
||||||
addOperation(name) {
|
addOperation(name) {
|
||||||
|
console.log("addOperation ==>", name);
|
||||||
const item = document.createElement("li");
|
const item = document.createElement("li");
|
||||||
item.setAttribute("data-name", name);
|
item.setAttribute("data-name", name);
|
||||||
|
|
||||||
|
@ -638,9 +641,13 @@ class RecipeWaiter {
|
||||||
*/
|
*/
|
||||||
addSelectedClass(opDataName){
|
addSelectedClass(opDataName){
|
||||||
const list = document.querySelectorAll(".operation");
|
const list = document.querySelectorAll(".operation");
|
||||||
const item = Array.from(list).find((item) => item.getAttribute("data-name") === opDataName );
|
const item = Array.from(list).filter((item) => item.getAttribute("data-name") === opDataName );
|
||||||
|
|
||||||
item.classList.add("selected");
|
// when an item is listed in favourites, there are 2 of
|
||||||
|
// them and both need the 'selected' class ( checkmark )
|
||||||
|
item.forEach((op) => {
|
||||||
|
op.classList.add("selected");
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,6 +27,7 @@ class WindowWaiter {
|
||||||
* continuous resetting).
|
* continuous resetting).
|
||||||
*/
|
*/
|
||||||
windowResize() {
|
windowResize() {
|
||||||
|
// @TODO: maybe a debounce is desireable although genrally people won't be resizing like crazy
|
||||||
if ( window.innerWidth >= this.app.breakpoint ) {
|
if ( window.innerWidth >= this.app.breakpoint ) {
|
||||||
this.app.setDesktopUI(false);
|
this.app.setDesktopUI(false);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue