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