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

[outliner] handle items being added out-of-order

Closes #2573
This commit is contained in:
Nick O'Leary 2020-05-20 12:36:26 +01:00
parent 0832be5970
commit 7d67e6a276
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9

View File

@ -9,6 +9,7 @@ RED.sidebar.info.outliner = (function() {
var globalConfigNodes;
var objects = {};
var missingParents = {};
function getFlowData() {
var flowData = [
@ -288,11 +289,17 @@ RED.sidebar.info.outliner = (function() {
objects[ws.id] = {
id: ws.id,
element: getFlowLabel(ws),
children:[getEmptyItem(ws.id)],
children:[],
deferBuild: true,
icon: "red-ui-icons red-ui-icons-flow",
gutter: getGutter(ws)
}
if (missingParents[ws.id]) {
objects[ws.id].children = missingParents[ws.id];
delete missingParents[ws.id]
} else {
objects[ws.id].children.push(getEmptyItem(ws.id));
}
flowList.treeList.addChild(objects[ws.id])
objects[ws.id].element.toggleClass("red-ui-info-outline-item-disabled", !!ws.disabled)
objects[ws.id].treeList.container.toggleClass("red-ui-info-outline-item-disabled", !!ws.disabled)
@ -327,10 +334,16 @@ RED.sidebar.info.outliner = (function() {
objects[sf.id] = {
id: sf.id,
element: getNodeLabel(sf),
children:[getEmptyItem(sf.id)],
children:[],
deferBuild: true,
gutter: getGutter(sf)
}
if (missingParents[sf.id]) {
objects[sf.id].children = missingParents[sf.id];
delete missingParents[sf.id]
} else {
objects[sf.id].children.push(getEmptyItem(sf.id));
}
subflowList.treeList.addChild(objects[sf.id])
}
function onSubflowChange(sf) {
@ -397,6 +410,10 @@ RED.sidebar.info.outliner = (function() {
if (n.type === "group") {
objects[n.id].children = [];
objects[n.id].deferBuild = true;
if (missingParents[n.id]) {
objects[n.id].children = missingParents[n.id];
delete missingParents[n.id]
}
}
var parent = n.g||n.z;
if (parent) {
@ -405,10 +422,14 @@ RED.sidebar.info.outliner = (function() {
empties[parent].treeList.remove();
delete empties[parent];
}
objects[parent].treeList.addChild(objects[n.id])
if (objects[parent].treeList) {
objects[parent].treeList.addChild(objects[n.id]);
} else {
objects[parent].children.push(objects[n.id])
}
} else {
// The parent hasn't been added yet
console.log("missing",parent)
missingParents[parent] = missingParents[parent]||[];
missingParents[parent].push(objects[n.id])
}
} else {
// No parent - add to Global flow list