From f87698438db8fae6ab82756bd757ac72eaea7dd5 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 7 May 2020 21:48:47 +0100 Subject: [PATCH] [outliner] Handle switching projects properly --- .../@node-red/editor-client/src/js/nodes.js | 1 - .../editor-client/src/js/ui/subflow.js | 6 ++-- .../src/js/ui/tab-info-outliner.js | 32 +++++++------------ 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/packages/node_modules/@node-red/editor-client/src/js/nodes.js b/packages/node_modules/@node-red/editor-client/src/js/nodes.js index 974a69b24..1eac45494 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/nodes.js +++ b/packages/node_modules/@node-red/editor-client/src/js/nodes.js @@ -1524,7 +1524,6 @@ RED.nodes = (function() { groupsByZ = {}; var subflowIds = Object.keys(subflows); - subflows = {}; subflowIds.forEach(function(id) { RED.subflow.removeSubflow(id) }); diff --git a/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js b/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js index b60cbe991..8eda5f5b7 100644 --- a/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js +++ b/packages/node_modules/@node-red/editor-client/src/js/ui/subflow.js @@ -463,15 +463,15 @@ RED.subflow = (function() { var activeSubflow = RED.nodes.subflow(id); RED.nodes.eachNode(function(n) { - if (n.type == "subflow:"+activeSubflow.id) { + if (n.type == "subflow:"+id) { removedNodes.push(n); } - if (n.z == activeSubflow.id) { + if (n.z == id) { removedNodes.push(n); } }); RED.nodes.eachConfig(function(n) { - if (n.z == activeSubflow.id) { + if (n.z == id) { removedNodes.push(n); } }); 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 28ef2f74d..ec06808e7 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 @@ -3,14 +3,13 @@ RED.sidebar.info.outliner = (function() { var treeList; var searchInput; var projectInfo; + var projectInfoLabel; var flowList; var subflowList; var globalConfigNodes; var objects = {}; - var objectBacklog = {}; - function getFlowData() { var flowData = [ { @@ -187,8 +186,11 @@ RED.sidebar.info.outliner = (function() { } function onProjectLoad(activeProject) { + objects = {}; var newFlowData = getFlowData(); - getProjectLabel(activeProject).appendTo(projectInfo); + projectInfoLabel.empty(); + getProjectLabel(activeProject).appendTo(projectInfoLabel); + projectInfo.show(); treeList.treeList('data',newFlowData); } @@ -223,7 +225,8 @@ RED.sidebar.info.outliner = (function() { } }); - projectInfo = $('
').appendTo(container) + projectInfo = $('
').hide().appendTo(container) + projectInfoLabel = $('').appendTo(projectInfo); //
Space Monkey
').appendTo(container) @@ -267,15 +270,13 @@ RED.sidebar.info.outliner = (function() { RED.events.on("view:selection-changed", onSelectionChanged); + RED.events.on("workspace:clear", onWorkspaceClear) - // ["links","nodes","flows","subflows","groups"].forEach(function(t) { - // ["add","remove","change"].forEach(function(v) { - // RED.events.on(t+":"+v, function(n) { console.log(t+":"+v,n)}) - // }) - // }) - // RED.events.on("workspace:clear", function() { console.log("workspace:clear")}) return container; } + function onWorkspaceClear() { + treeList.treeList('data',getFlowData()); + } function onFlowAdd(ws) { objects[ws.id] = { id: ws.id, @@ -390,17 +391,6 @@ RED.sidebar.info.outliner = (function() { function onSelectionChanged(selection) { treeList.treeList('clearSelection'); - // // console.log(selection); - // if (selection.nodes) { - // selection.nodes.forEach(function(n) { - // // console.log("..",n.id); - // treeList.treeList('show',n.id); - // if (objects[n.id].treeList) { - // objects[n.id].treeList.select(true); - // } - // - // }); - // } } return {