From 51afed404126b2408546dd8949d8d3fc78e2893e Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 14 Jan 2016 15:22:00 +0000 Subject: [PATCH] Ensure config list refreshes properly on tab delete --- editor/js/ui/tab-config.js | 20 +++++++++++--------- editor/js/ui/workspaces.js | 1 + 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/editor/js/ui/tab-config.js b/editor/js/ui/tab-config.js index 279b5b491..6877179ee 100644 --- a/editor/js/ui/tab-config.js +++ b/editor/js/ui/tab-config.js @@ -187,24 +187,26 @@ RED.sidebar.config = (function() { getOrCreateCategory("global",globalCategories); RED.nodes.eachWorkspace(function(ws) { - validList[ws.id] = true; + validList[ws.id.replace(/\./g,"-")] = true; getOrCreateCategory(ws.id,flowCategories,ws.label); }) RED.nodes.eachSubflow(function(sf) { - validList[sf.id] = true; + validList[sf.id.replace(/\./g,"-")] = true; getOrCreateCategory(sf.id,subflowCategories,sf.name); }) - // $(".workspace-config-node-category").each(function() { - // if (!validList[$(this).attr('id').substring("workspace-config-node-category-".length)]) { - // $(this).remove(); - // } - // }) + $(".workspace-config-node-category").each(function() { + var id = $(this).attr('id').substring("workspace-config-node-category-".length); + if (!validList[id]) { + $(this).remove(); + delete categories[id]; + } + }) var globalConfigNodes = []; var configList = {}; RED.nodes.eachConfig(function(cn) { if (cn.z) {//} == RED.workspaces.active()) { - configList[cn.z] = configList[cn.z]||[]; - configList[cn.z].push(cn); + configList[cn.z.replace(/\./g,"-")] = configList[cn.z.replace(/\./g,"-")]||[]; + configList[cn.z.replace(/\./g,"-")].push(cn); } else if (!cn.z) { globalConfigNodes.push(cn); } diff --git a/editor/js/ui/workspaces.js b/editor/js/ui/workspaces.js index acb9d17ce..d643ee695 100644 --- a/editor/js/ui/workspaces.js +++ b/editor/js/ui/workspaces.js @@ -54,6 +54,7 @@ RED.workspaces = (function() { historyEvent.workspaces = [ws]; RED.history.push(historyEvent); RED.nodes.dirty(true); + RED.sidebar.config.refresh(); } else { $( "#node-dialog-delete-workspace" ).dialog('option','workspace',ws); $( "#node-dialog-delete-workspace-content" ).text(RED._("workspace.delete",{label:ws.label}));