mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Use single forEach
instead of multiple filter
This commit is contained in:
parent
aaed9882b8
commit
84ed88c8dd
@ -30,12 +30,26 @@ RED.contextMenu = (function () {
|
|||||||
const isGroup = hasSelection && selection.nodes.length === 1 && selection.nodes[0].type === 'group'
|
const isGroup = hasSelection && selection.nodes.length === 1 && selection.nodes[0].type === 'group'
|
||||||
const canEdit = !RED.workspaces.isLocked()
|
const canEdit = !RED.workspaces.isLocked()
|
||||||
const canRemoveFromGroup = hasSelection && !!selection.nodes[0].g
|
const canRemoveFromGroup = hasSelection && !!selection.nodes[0].g
|
||||||
const isAllGroups = hasSelection && selection.nodes.filter(n => n.type !== 'group').length === 0
|
let hasGroup, isAllGroups = true, hasDisabledNode, hasEnabledNode, hasLabeledNode, hasUnlabeledNode;
|
||||||
const hasGroup = hasSelection && selection.nodes.filter(n => n.type === 'group').length > 0
|
if (hasSelection) {
|
||||||
const hasDisabledNode = hasSelection && selection.nodes.filter(e => e.d).length > 0;
|
selection.nodes.forEach(n => {
|
||||||
const hasEnabledNode = hasSelection && selection.nodes.filter(e => !e.d).length > 0;
|
if (n.type === 'group') {
|
||||||
const hasUnlabeledNode = hasSelection && selection.nodes.filter(e => e.l === false).length > 0;
|
hasGroup = true;
|
||||||
const hasLabeledNode = hasSelection && selection.nodes.filter(e => e.l || e.l === undefined).length > 0;
|
} else {
|
||||||
|
isAllGroups = false;
|
||||||
|
}
|
||||||
|
if (n.d) {
|
||||||
|
hasDisabledNode = true;
|
||||||
|
} else {
|
||||||
|
hasEnabledNode = true;
|
||||||
|
}
|
||||||
|
if (n.l === undefined || n.l) {
|
||||||
|
hasLabeledNode = true;
|
||||||
|
} else {
|
||||||
|
hasUnlabeledNode = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
const offset = $("#red-ui-workspace-chart").offset()
|
const offset = $("#red-ui-workspace-chart").offset()
|
||||||
|
|
||||||
let addX = options.x - offset.left + $("#red-ui-workspace-chart").scrollLeft()
|
let addX = options.x - offset.left + $("#red-ui-workspace-chart").scrollLeft()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user