From 842cd1ecf0e1ee95763f76a3147c42070fc2f282 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Thu, 11 Jun 2020 09:57:43 +0900 Subject: [PATCH 1/2] fix empty placeholder not shown on remove from group --- .../@node-red/editor-client/src/js/ui/tab-info-outliner.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 f285f77aa..abfac4ed0 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 @@ -384,8 +384,13 @@ RED.sidebar.info.outliner = (function() { } else { existingObject.element.find(".red-ui-info-outline-item-label").html(" "); } - if (parent !== existingObject.parent.id) { + var oldParent = existingObject.parent; + var oldParentID = oldParent.id; + if (parent !== oldParentID) { existingObject.treeList.remove(true); + if (oldParent.children.length === 0) { + objects[oldParentID].treeList.addChild(getEmptyItem(oldParentID)); + } if (parent === "__global__") { globalConfigNodes.treeList.addChild(existingObject); } else { From 4f3cb3103e0a5f10b747f3f1a9d4867446cebea4 Mon Sep 17 00:00:00 2001 From: Hiroyasu Nishiyama Date: Thu, 11 Jun 2020 22:18:31 +0900 Subject: [PATCH 2/2] make treelist of subflow/config nodes initialy has empty placeholder --- .../src/js/ui/tab-info-outliner.js | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) 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 abfac4ed0..07f893b03 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 @@ -20,6 +20,7 @@ RED.sidebar.info.outliner = (function() { children: [] }, { + id: "__subflow__", label: RED._("menu.label.subflows"), children: [] }, @@ -272,6 +273,9 @@ RED.sidebar.info.outliner = (function() { } }) + subflowList.treeList.addChild(getEmptyItem("__subflow__")); + globalConfigNodes.treeList.addChild(getEmptyItem("__global__")); + RED.events.on("projects:load", onProjectLoad) RED.events.on("flows:add", onFlowAdd) @@ -358,6 +362,10 @@ RED.sidebar.info.outliner = (function() { } else { objects[sf.id].children.push(getEmptyItem(sf.id)); } + if (empties["__subflow__"]) { + empties["__subflow__"].treeList.remove(); + delete empties["__subflow__"]; + } subflowList.treeList.addChild(objects[sf.id]) updateSearch(); } @@ -384,13 +392,8 @@ RED.sidebar.info.outliner = (function() { } else { existingObject.element.find(".red-ui-info-outline-item-label").html(" "); } - var oldParent = existingObject.parent; - var oldParentID = oldParent.id; - if (parent !== oldParentID) { + if (parent !== existingObject.parent.id) { existingObject.treeList.remove(true); - if (oldParent.children.length === 0) { - objects[oldParentID].treeList.addChild(getEmptyItem(oldParentID)); - } if (parent === "__global__") { globalConfigNodes.treeList.addChild(existingObject); } else { @@ -443,8 +446,8 @@ RED.sidebar.info.outliner = (function() { delete missingParents[n.id] } } - var parent = n.g||n.z; - if (parent) { + var parent = n.g||n.z||"__global__"; + if (parent !== "__global__") { if (objects[parent]) { if (empties[parent]) { empties[parent].treeList.remove(); @@ -460,8 +463,12 @@ RED.sidebar.info.outliner = (function() { missingParents[parent].push(objects[n.id]) } } else { + if (empties[parent]) { + empties[parent].treeList.remove(); + delete empties[parent]; + } // No parent - add to Global flow list - globalConfigNodes.treeList.addChild(objects[n.id]) + globalConfigNodes.treeList.addChild(objects[n.id]); } objects[n.id].element.toggleClass("red-ui-info-outline-item-disabled", !!n.d) updateSearch();