Add tab fallback for removed panels that have not been expressly closed
authorCory Chaplin <cory.chaplin@laposte.net>
Wed, 16 Jul 2014 20:59:08 +0000 (22:59 +0200)
committerCory Chaplin <cory.chaplin@laposte.net>
Wed, 16 Jul 2014 20:59:08 +0000 (22:59 +0200)
client/src/views/application.js
client/src/views/tabs.js

index dd686190610a3b3fa0ce639243cbc5824b8bd9c5..624a08107fed0c36948bc0d0598037318bc441a1 100644 (file)
@@ -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();
+                }
+            }
+        });
     }
 });
index 0af7973a883618f62d9425f3501c60fa08bb579a..20881a250eed2ffc5457390ebfa32236187c3899 100644 (file)
@@ -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();
     },