mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
merge code for checking menu activation
This commit is contained in:
parent
07556592c1
commit
a15adc43af
@ -176,10 +176,27 @@ RED.group = (function() {
|
|||||||
function init() {
|
function init() {
|
||||||
|
|
||||||
RED.events.on("view:selection-changed",function(selection) {
|
RED.events.on("view:selection-changed",function(selection) {
|
||||||
RED.menu.setDisabled("menu-item-group-group",!!!selection.nodes);
|
var activateGroup = !!selection.nodes;
|
||||||
RED.menu.setDisabled("menu-item-group-ungroup",!!!selection.nodes || selection.nodes.filter(function(n) { return n.type==='group'}).length === 0);
|
var activateUngroup = false;
|
||||||
RED.menu.setDisabled("menu-item-group-merge", !!!selection.nodes || (selection.nodes.length <= 1) || selection.nodes.filter(function(n) { return n.type==='group'}).length === 0);
|
var activateMerge = false;
|
||||||
RED.menu.setDisabled("menu-item-group-remove",!!!selection.nodes || selection.nodes.filter(function(n) { return !!n.g }).length === 0);
|
var activateRemove = false;
|
||||||
|
if (activateGroup) {
|
||||||
|
selection.nodes.forEach(function (n) {
|
||||||
|
if (n.type === "group") {
|
||||||
|
activateUngroup = true;
|
||||||
|
}
|
||||||
|
if (!!n.g) {
|
||||||
|
activateRemove = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (activateUngroup) {
|
||||||
|
activateMerge = (selection.nodes.length > 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RED.menu.setDisabled("menu-item-group-group", !activateGroup);
|
||||||
|
RED.menu.setDisabled("menu-item-group-ungroup", !activateUngroup);
|
||||||
|
RED.menu.setDisabled("menu-item-group-merge", !activateMerge);
|
||||||
|
RED.menu.setDisabled("menu-item-group-remove", !activateRemove);
|
||||||
});
|
});
|
||||||
|
|
||||||
RED.actions.add("core:group-selection", function() { groupSelection() })
|
RED.actions.add("core:group-selection", function() { groupSelection() })
|
||||||
|
Loading…
Reference in New Issue
Block a user