From a50404b141a0bf31862f05c1b0a4137fd7ecb6ee Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 28 Jan 2021 22:07:19 +0000 Subject: [PATCH] Add enable/disable toggle button for groups in info-outliner --- .../src/js/ui/tab-info-outliner.js | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info-outliner.js b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info-outliner.js index f0c6e631a..2b11007ee 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info-outliner.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-info-outliner.js @@ -169,7 +169,7 @@ RED.sidebar.info.outliner = (function() { // evt.stopPropagation(); // RED.view.reveal(n.id); // }) - if (n.type !== 'group' && n.type !== 'subflow') { + if (n.type !== 'subflow') { var toggleButton = $('').appendTo(controls).on("click",function(evt) { evt.preventDefault(); evt.stopPropagation(); @@ -179,6 +179,45 @@ RED.sidebar.info.outliner = (function() { } else { 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 { // TODO: this ought to be a utility function in RED.nodes var historyEvent = { @@ -198,11 +237,15 @@ RED.sidebar.info.outliner = (function() { n.dirty = true; n.changed = true; RED.events.emit("nodes:change",n); + RED.history.push(historyEvent); RED.nodes.dirty(true) RED.view.redraw(); } }); 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")); }); } else {