From d1925bdf7d54096eeb4ace5b044b1ab347898365 Mon Sep 17 00:00:00 2001 From: Cory Chaplin Date: Wed, 16 Jul 2014 22:59:08 +0200 Subject: [PATCH] Add tab fallback for removed panels that have not been expressly closed --- client/src/views/application.js | 14 ++++++++++++++ client/src/views/tabs.js | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/client/src/views/application.js b/client/src/views/application.js index dd68619..624a081 100644 --- a/client/src/views/application.js +++ b/client/src/views/application.js @@ -390,5 +390,19 @@ _kiwi.view.Application = Backbone.View.extend({ } } }); + + this.model.panels.on('remove', function(panel) { + // If closing the active panel, switch to the last-accessed panel + if (panel_access[0] === panel.cid) { + panel_access.shift(); + + //Get the last-accessed panel model now that we removed the closed one + var model = _.find(_kiwi.app.panels('applets').concat(_kiwi.app.panels('connections')), {cid: panel_access[0]}); + + if (model) { + model.view.show(); + } + } + }); } }); diff --git a/client/src/views/tabs.js b/client/src/views/tabs.js index 0af7973..20881a2 100644 --- a/client/src/views/tabs.js +++ b/client/src/views/tabs.js @@ -87,9 +87,10 @@ _kiwi.view.Tabs = Backbone.View.extend({ var connection = _kiwi.app.connections.active_connection; panel.tab.remove(); - delete panel.tab; + _kiwi.app.panels.trigger('remove', this); + _kiwi.app.view.doLayout(); }, -- 2.25.1