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

Add subflows to context sidebar

This commit is contained in:
Dave Conway-Jones 2019-06-19 09:51:48 +01:00
parent 5a7592a953
commit 7518987083
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
2 changed files with 22 additions and 41 deletions

View File

@ -529,6 +529,7 @@
"refresh": "refresh to load", "refresh": "refresh to load",
"empty": "empty", "empty": "empty",
"node": "Node", "node": "Node",
"subflow": "Subflow",
"flow": "Flow", "flow": "Flow",
"global": "Global", "global": "Global",
"deleteConfirm": "Are you sure you want to delete this item?", "deleteConfirm": "Are you sure you want to delete this item?",

View File

@ -14,28 +14,21 @@
* limitations under the License. * limitations under the License.
**/ **/
RED.sidebar.context = (function() { RED.sidebar.context = (function() {
var content; var content;
var sections; var sections;
var localCache = {}; var localCache = {};
var flowAutoRefresh; var flowAutoRefresh;
var nodeSection; var nodeSection;
// var subflowSection;
var flowSection; var flowSection;
var globalSection; var globalSection;
var currentNode; var currentNode;
var currentFlow; var currentFlow;
function init() { function init() {
content = $("<div>").css({"position":"relative","height":"100%"}); content = $("<div>").css({"position":"relative","height":"100%"});
content.className = "red-ui-sidebar-context" content.className = "red-ui-sidebar-context"
var header = $('<div class="red-ui-sidebar-header"></div>').appendTo(content); var header = $('<div class="red-ui-sidebar-header"></div>').appendTo(content);
var autoUpdate = RED.settings.get("editor.context.refresh",false); var autoUpdate = RED.settings.get("editor.context.refresh",false);
flowAutoRefresh = $('<input type="checkbox">').prop("checked",autoUpdate).appendTo(header).toggleButton({ flowAutoRefresh = $('<input type="checkbox">').prop("checked",autoUpdate).appendTo(header).toggleButton({
baseClass: "red-ui-sidebar-header-button", baseClass: "red-ui-sidebar-header-button",
@ -47,7 +40,6 @@ RED.sidebar.context = (function() {
}); });
var footerToolbar = $('<div></div>'); var footerToolbar = $('<div></div>');
var stackContainer = $("<div>",{class:"red-ui-sidebar-context-stack"}).appendTo(content); var stackContainer = $("<div>",{class:"red-ui-sidebar-context-stack"}).appendTo(content);
sections = RED.stack.create({ sections = RED.stack.create({
container: stackContainer container: stackContainer
@ -55,10 +47,8 @@ RED.sidebar.context = (function() {
nodeSection = sections.add({ nodeSection = sections.add({
title: RED._("sidebar.context.node"), title: RED._("sidebar.context.node"),
collapsible: true, collapsible: true
// onexpand: function() { // onexpand: function() { updateNode(currentNode,true); }
// updateNode(currentNode,true);
// }
}); });
nodeSection.expand(); nodeSection.expand();
nodeSection.content.css({height:"100%"}); nodeSection.content.css({height:"100%"});
@ -75,22 +65,6 @@ RED.sidebar.context = (function() {
}) })
RED.popover.tooltip(bg,RED._("sidebar.context.refrsh")); RED.popover.tooltip(bg,RED._("sidebar.context.refrsh"));
// subflowSection = sections.add({
// title: "Subflow",
// collapsible: true
// });
// subflowSection.expand();
// subflowSection.content.css({height:"100%"});
// bg = $('<div style="float: right"></div>').appendTo(subflowSection.header);
// $('<button class="red-ui-button red-ui-button-small"><i class="fa fa-refresh"></i></button>')
// .appendTo(bg)
// .on("click", function(evt) {
// evt.stopPropagation();
// evt.preventDefault();
// })
// RED.popover.tooltip(bg,RED._("sidebar.context.refrsh"));
// subflowSection.container.hide();
flowSection = sections.add({ flowSection = sections.add({
title: RED._("sidebar.context.flow"), title: RED._("sidebar.context.flow"),
collapsible: true collapsible: true
@ -165,7 +139,6 @@ RED.sidebar.context = (function() {
// } // }
// }); // });
RED.events.on("view:selection-changed", function(event) { RED.events.on("view:selection-changed", function(event) {
var selectedNode = event.nodes && event.nodes.length === 1 && event.nodes[0]; var selectedNode = event.nodes && event.nodes.length === 1 && event.nodes[0];
updateNode(selectedNode); updateNode(selectedNode);
@ -181,24 +154,31 @@ RED.sidebar.context = (function() {
$('<tr class="red-ui-help-info-row red-ui-search-empty blank" colspan="2"><td data-i18n="sidebar.context.refresh"></td></tr>').appendTo(globalSection.table).i18n(); $('<tr class="red-ui-help-info-row red-ui-search-empty blank" colspan="2"><td data-i18n="sidebar.context.refresh"></td></tr>').appendTo(globalSection.table).i18n();
globalSection.timestamp.html("&nbsp;"); globalSection.timestamp.html("&nbsp;");
} }
} }
function updateNode(node,force) { function updateNode(node,force) {
currentNode = node; currentNode = node;
if (currentNode && currentNode.hasOwnProperty("name") && currentNode.name.length > 0 ) { if (node && /^subflow:/.test(node.type)) {
$(nodeSection.title).text(RED._("sidebar.context.node") + ": " + currentNode.name); if (currentNode && currentNode.hasOwnProperty("name") && currentNode.name.length > 0 ) {
$(nodeSection.title).text(RED._("sidebar.context.subflow") + ": " + currentNode.name);
} else {
$(nodeSection.title).text(RED._("sidebar.context.subflow"));
}
} else {
if (currentNode && currentNode.hasOwnProperty("name") && currentNode.name.length > 0 ) {
$(nodeSection.title).text(RED._("sidebar.context.node") + ": " + currentNode.name);
}
else { $(nodeSection.title).text(RED._("sidebar.context.node")); }
} }
else { $(nodeSection.title).text(RED._("sidebar.context.node")); }
if (force) { if (force) {
if (node) { if (node) {
updateEntry(nodeSection,"context/node/"+node.id,node.id); if (/^subflow:/.test(node.type)) {
// if (/^subflow:/.test(node.type)) { //subflowSection.container.show();
// subflowSection.container.show(); updateEntry(nodeSection,"context/flow/"+node.id,node.id);
// updateEntry(subflowSection,"context/flow/"+node.id,node.id); }
// } else { else {
// subflowSection.container.hide(); updateEntry(nodeSection,"context/node/"+node.id,node.id);
// } }
} else { } else {
// subflowSection.container.hide(); // subflowSection.container.hide();
updateEntry(nodeSection) updateEntry(nodeSection)
@ -213,6 +193,7 @@ RED.sidebar.context = (function() {
nodeSection.timestamp.html("&nbsp;"); nodeSection.timestamp.html("&nbsp;");
} }
} }
function updateFlow(flow, force) { function updateFlow(flow, force) {
currentFlow = flow; currentFlow = flow;
$(flowSection.title).text(RED._("sidebar.context.flow") + ": " + currentFlow.label); $(flowSection.title).text(RED._("sidebar.context.flow") + ": " + currentFlow.label);
@ -230,7 +211,6 @@ RED.sidebar.context = (function() {
} }
function refreshEntry(section,baseUrl,id) { function refreshEntry(section,baseUrl,id) {
var contextStores = RED.settings.context.stores; var contextStores = RED.settings.context.stores;
var container = section.table; var container = section.table;