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",
"empty": "empty",
"node": "Node",
"subflow": "Subflow",
"flow": "Flow",
"global": "Global",
"deleteConfirm": "Are you sure you want to delete this item?",

View File

@ -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 = $("<div>").css({"position":"relative","height":"100%"});
content.className = "red-ui-sidebar-context"
var header = $('<div class="red-ui-sidebar-header"></div>').appendTo(content);
var autoUpdate = RED.settings.get("editor.context.refresh",false);
flowAutoRefresh = $('<input type="checkbox">').prop("checked",autoUpdate).appendTo(header).toggleButton({
baseClass: "red-ui-sidebar-header-button",
@ -47,7 +40,6 @@ RED.sidebar.context = (function() {
});
var footerToolbar = $('<div></div>');
var stackContainer = $("<div>",{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 = $('<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({
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() {
$('<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;");
}
}
function updateNode(node,force) {
currentNode = node;
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")); }
}
if (force) {
if (node) {
updateEntry(nodeSection,"context/node/"+node.id,node.id);
// if (/^subflow:/.test(node.type)) {
if (/^subflow:/.test(node.type)) {
//subflowSection.container.show();
// updateEntry(subflowSection,"context/flow/"+node.id,node.id);
// } else {
// subflowSection.container.hide();
// }
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("&nbsp;");
}
}
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;