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

[outliner] Handle switching projects properly

This commit is contained in:
Nick O'Leary 2020-05-07 21:48:47 +01:00
parent 4af1cf1d1f
commit f87698438d
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
3 changed files with 14 additions and 25 deletions

View File

@ -1524,7 +1524,6 @@ RED.nodes = (function() {
groupsByZ = {};
var subflowIds = Object.keys(subflows);
subflows = {};
subflowIds.forEach(function(id) {
RED.subflow.removeSubflow(id)
});

View File

@ -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);
}
});

View File

@ -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 = $('<div class="red-ui-treeList-label red-ui-info-outline-project"><span class="red-ui-treeList-icon"><i class="fa fa-archive"></i></span></div>').appendTo(container)
projectInfo = $('<div class="red-ui-treeList-label red-ui-info-outline-project"><span class="red-ui-treeList-icon"><i class="fa fa-archive"></i></span></div>').hide().appendTo(container)
projectInfoLabel = $('<span>').appendTo(projectInfo);
// <div class="red-ui-info-outline-item red-ui-info-outline-item-flow" style=";"><div class="red-ui-search-result-description red-ui-info-outline-item-label">Space Monkey</div><div class="red-ui-info-outline-item-controls"><button class="red-ui-button red-ui-button-small" style="position:absolute;right:5px;"><i class="fa fa-ellipsis-h"></i></button></div></div></div>').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 {