1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Add enable/disable toggle button for groups in info-outliner

This commit is contained in:
Nick O'Leary 2021-01-28 22:07:19 +00:00
parent 3a0074d96e
commit a50404b141
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -169,7 +169,7 @@ RED.sidebar.info.outliner = (function() {
// evt.stopPropagation(); // evt.stopPropagation();
// RED.view.reveal(n.id); // RED.view.reveal(n.id);
// }) // })
if (n.type !== 'group' && n.type !== 'subflow') { if (n.type !== 'subflow') {
var toggleButton = $('<button type="button" class="red-ui-info-outline-item-control-disable red-ui-button red-ui-button-small"><i class="fa fa-circle-thin"></i><i class="fa fa-ban"></i></button>').appendTo(controls).on("click",function(evt) { var toggleButton = $('<button type="button" class="red-ui-info-outline-item-control-disable red-ui-button red-ui-button-small"><i class="fa fa-circle-thin"></i><i class="fa fa-ban"></i></button>').appendTo(controls).on("click",function(evt) {
evt.preventDefault(); evt.preventDefault();
evt.stopPropagation(); evt.stopPropagation();
@ -179,6 +179,45 @@ RED.sidebar.info.outliner = (function() {
} else { } else {
RED.workspaces.disable(n.id) RED.workspaces.disable(n.id)
} }
} else if (n.type === 'group') {
var groupNodes = RED.group.getNodes(n,true);
var groupHistoryEvent = {
t:'multi',
events:[],
dirty: RED.nodes.dirty()
}
var targetState;
groupNodes.forEach(function(n) {
if (n.type !== 'group') {
if (targetState === undefined) {
targetState = !n.d;
}
if (!!n.d !== targetState) {
var historyEvent = {
t: "edit",
node: n,
changed: n.changed,
changes: {
d: n.d
}
}
if (n.d) {
delete n.d;
} else {
n.d = true;
}
n.dirty = true;
n.changed = true;
RED.events.emit("nodes:change",n);
groupHistoryEvent.events.push(historyEvent);
}
}
if (groupHistoryEvent.events.length > 0) {
RED.history.push(groupHistoryEvent);
RED.nodes.dirty(true)
RED.view.redraw();
}
})
} else { } else {
// TODO: this ought to be a utility function in RED.nodes // TODO: this ought to be a utility function in RED.nodes
var historyEvent = { var historyEvent = {
@ -198,11 +237,15 @@ RED.sidebar.info.outliner = (function() {
n.dirty = true; n.dirty = true;
n.changed = true; n.changed = true;
RED.events.emit("nodes:change",n); RED.events.emit("nodes:change",n);
RED.history.push(historyEvent);
RED.nodes.dirty(true) RED.nodes.dirty(true)
RED.view.redraw(); RED.view.redraw();
} }
}); });
RED.popover.tooltip(toggleButton,function() { RED.popover.tooltip(toggleButton,function() {
if (n.type === "group") {
return RED._("common.label.enable")+" / "+RED._("common.label.disable")
}
return RED._("common.label."+(((n.type==='tab' && n.disabled) || (n.type!=='tab' && n.d))?"enable":"disable")); return RED._("common.label."+(((n.type==='tab' && n.disabled) || (n.type!=='tab' && n.d))?"enable":"disable"));
}); });
} else { } else {