mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Merge pull request #2844 from node-red/disable-groups
Add enable/disable toggle button for groups in info-outliner
This commit is contained in:
commit
9c1ce5543d
@ -152,7 +152,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();
|
||||||
@ -162,6 +162,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 = {
|
||||||
@ -181,11 +220,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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user