From 60652d2095624c3a28ccc3ae9c09bc369bbce1d7 Mon Sep 17 00:00:00 2001 From: Nicholas O'Leary Date: Wed, 30 Oct 2013 19:25:22 +0000 Subject: [PATCH] Update workspace delete button state properly --- public/red/ui/tabs.js | 3 +++ public/red/ui/view.js | 24 +++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/public/red/ui/tabs.js b/public/red/ui/tabs.js index c2a41ab47..e08cc5f3f 100644 --- a/public/red/ui/tabs.js +++ b/public/red/ui/tabs.js @@ -87,6 +87,9 @@ RED.tabs = function() { activateTab(tab.find("a")); } li.remove(); + if (options.onremove) { + options.onremove(id); + } }, activateTab: activateTab, diff --git a/public/red/ui/view.js b/public/red/ui/view.js index 9f9a430cb..9c1c8fb91 100644 --- a/public/red/ui/view.js +++ b/public/red/ui/view.js @@ -85,6 +85,19 @@ RED.view = function() { }); $('#workspace-menu-list').append(menuli); + + if (workspace_tabs.count() == 1) { + $('#btn-workspace-delete').parent().addClass("disabled"); + } else { + $('#btn-workspace-delete').parent().removeClass("disabled"); + } + }, + onremove: function(tab) { + if (workspace_tabs.count() == 1) { + $('#btn-workspace-delete').parent().addClass("disabled"); + } else { + $('#btn-workspace-delete').parent().removeClass("disabled"); + } } }); @@ -100,7 +113,6 @@ RED.view = function() { RED.nodes.addWorkspace(ws); workspace_tabs.addTab(ws); workspace_tabs.activateTab(tabId); - RED.history.push({t:'add',workspaces:[ws],dirty:dirty}); RED.view.dirty(true); } @@ -1144,20 +1156,10 @@ RED.view = function() { addWorkspace: function(ws) { workspace_tabs.addTab(ws); workspace_tabs.resize(); - if (workspace_tabs.count() == 1) { - $('#btn-workspace-delete').parent().addClass("disabled"); - } else { - $('#btn-workspace-delete').parent().removeClass("disabled"); - } }, removeWorkspace: function(ws) { workspace_tabs.removeTab(ws.id); $('#workspace-menu-list a[href="#'+ws.id+'"]').parent().remove(); - if (workspace_tabs.count() == 1) { - $('#btn-workspace-delete').parent().addClass("disabled"); - } else { - $('#btn-workspace-delete').parent().removeClass("disabled"); - } }, getWorkspace: function() { return activeWorkspace;