From 75189870835e1d592297e4ed157ba00261119987 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 19 Jun 2019 09:51:48 +0100 Subject: [PATCH] Add subflows to context sidebar --- .../editor-client/locales/en-US/editor.json | 1 + .../editor-client/src/js/ui/tab-context.js | 62 +++++++------------ 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json index 9a53a870c..fe80b706c 100755 --- a/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json +++ b/packages/node_modules/@node-red/editor-client/locales/en-US/editor.json @@ -529,6 +529,7 @@ "refresh": "refresh to load", "empty": "empty", "node": "Node", + "subflow": "Subflow", "flow": "Flow", "global": "Global", "deleteConfirm": "Are you sure you want to delete this item?", diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-context.js b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-context.js index c023034dd..838a951ca 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/tab-context.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/tab-context.js @@ -14,28 +14,21 @@ * limitations under the License. **/ RED.sidebar.context = (function() { - var content; var sections; - var localCache = {}; - var flowAutoRefresh; var nodeSection; - // var subflowSection; var flowSection; var globalSection; - var currentNode; var currentFlow; function init() { - content = $("
").css({"position":"relative","height":"100%"}); content.className = "red-ui-sidebar-context" var header = $('
').appendTo(content); - var autoUpdate = RED.settings.get("editor.context.refresh",false); flowAutoRefresh = $('').prop("checked",autoUpdate).appendTo(header).toggleButton({ baseClass: "red-ui-sidebar-header-button", @@ -47,7 +40,6 @@ RED.sidebar.context = (function() { }); var footerToolbar = $('
'); - var stackContainer = $("
",{class:"red-ui-sidebar-context-stack"}).appendTo(content); sections = RED.stack.create({ container: stackContainer @@ -55,10 +47,8 @@ RED.sidebar.context = (function() { nodeSection = sections.add({ title: RED._("sidebar.context.node"), - collapsible: true, - // onexpand: function() { - // updateNode(currentNode,true); - // } + collapsible: true + // onexpand: function() { updateNode(currentNode,true); } }); nodeSection.expand(); nodeSection.content.css({height:"100%"}); @@ -75,22 +65,6 @@ RED.sidebar.context = (function() { }) RED.popover.tooltip(bg,RED._("sidebar.context.refrsh")); - // subflowSection = sections.add({ - // title: "Subflow", - // collapsible: true - // }); - // subflowSection.expand(); - // subflowSection.content.css({height:"100%"}); - // bg = $('
').appendTo(subflowSection.header); - // $('') - // .appendTo(bg) - // .on("click", function(evt) { - // evt.stopPropagation(); - // evt.preventDefault(); - // }) - // RED.popover.tooltip(bg,RED._("sidebar.context.refrsh")); - // subflowSection.container.hide(); - flowSection = sections.add({ title: RED._("sidebar.context.flow"), collapsible: true @@ -165,7 +139,6 @@ RED.sidebar.context = (function() { // } // }); - RED.events.on("view:selection-changed", function(event) { var selectedNode = event.nodes && event.nodes.length === 1 && event.nodes[0]; updateNode(selectedNode); @@ -181,24 +154,31 @@ RED.sidebar.context = (function() { $('').appendTo(globalSection.table).i18n(); globalSection.timestamp.html(" "); } - } function updateNode(node,force) { currentNode = node; - if (currentNode && currentNode.hasOwnProperty("name") && currentNode.name.length > 0 ) { - $(nodeSection.title).text(RED._("sidebar.context.node") + ": " + currentNode.name); + if (node && /^subflow:/.test(node.type)) { + 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 (node) { - updateEntry(nodeSection,"context/node/"+node.id,node.id); - // if (/^subflow:/.test(node.type)) { - // subflowSection.container.show(); - // updateEntry(subflowSection,"context/flow/"+node.id,node.id); - // } else { - // subflowSection.container.hide(); - // } + if (/^subflow:/.test(node.type)) { + //subflowSection.container.show(); + updateEntry(nodeSection,"context/flow/"+node.id,node.id); + } + else { + updateEntry(nodeSection,"context/node/"+node.id,node.id); + } } else { // subflowSection.container.hide(); updateEntry(nodeSection) @@ -213,6 +193,7 @@ RED.sidebar.context = (function() { nodeSection.timestamp.html(" "); } } + function updateFlow(flow, force) { currentFlow = flow; $(flowSection.title).text(RED._("sidebar.context.flow") + ": " + currentFlow.label); @@ -230,7 +211,6 @@ RED.sidebar.context = (function() { } function refreshEntry(section,baseUrl,id) { - var contextStores = RED.settings.context.stores; var container = section.table;