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 canEdit = !RED.workspaces.isLocked()
|
||||
const canRemoveFromGroup = hasSelection && !!selection.nodes[0].g
|
||||
const isAllGroups = hasSelection && selection.nodes.filter(n => n.type !== 'group').length === 0
|
||||
const hasGroup = hasSelection && selection.nodes.filter(n => n.type === 'group').length > 0
|
||||
const hasDisabledNode = hasSelection && selection.nodes.filter(e => e.d).length > 0;
|
||||
const hasEnabledNode = hasSelection && selection.nodes.filter(e => !e.d).length > 0;
|
||||
const hasUnlabeledNode = hasSelection && selection.nodes.filter(e => e.l === false).length > 0;
|
||||
const hasLabeledNode = hasSelection && selection.nodes.filter(e => e.l || e.l === undefined).length > 0;
|
||||
let hasGroup, isAllGroups = true, hasDisabledNode, hasEnabledNode, hasLabeledNode, hasUnlabeledNode;
|
||||
if (hasSelection) {
|
||||
selection.nodes.forEach(n => {
|
||||
if (n.type === 'group') {
|
||||
hasGroup = true;
|
||||
} 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()
|
||||
|
||||
let addX = options.x - offset.left + $("#red-ui-workspace-chart").scrollLeft()
|
||||
|
Loading…
x
Reference in New Issue
Block a user