#828 focus same repository as was selected previously

This commit is contained in:
Sebastian Sdorra
2016-05-25 10:28:46 +02:00
parent 71b742388c
commit e079481e51
2 changed files with 34 additions and 3 deletions

View File

@@ -482,8 +482,34 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
listener.call(listener.scope, item, panels);
}
});
// get the xtype of the currently opened tab
// search for the tab with the same xtype and activate it
// see issue https://goo.gl/3RGnA3
var activeTab = 0;
var activeXtype = this.getActiveTabXtype();
if (activeXtype){
for (var i=0; i<panels.length; i++){
if (panels[i].xtype === activeXtype){
activeTab = i;
break;
}
}
}
Sonia.repository.setEditPanel(panels);
Sonia.repository.setEditPanel(panels, activeTab);
},
getActiveTabXtype: function(){
var type = null;
var rep = Ext.getCmp('repositoryEditPanel');
if (rep){
var at = rep.getActiveTab();
if (at && at.xtype){
type = at.xtype;
}
}
return type;
},
renderRepositoryType: function(repositoryType){

View File

@@ -74,13 +74,18 @@ Sonia.repository.isOwner = function(repository){
return admin || repository.permissions;
};
Sonia.repository.setEditPanel = function(panels){
Sonia.repository.setEditPanel = function(panels, activeTab){
var editPanel = Ext.getCmp('repositoryEditPanel');
editPanel.removeAll();
Ext.each(panels, function(panel){
editPanel.add(panel);
});
editPanel.setActiveTab(0);
if (!activeTab){
activeTab = 0;
}
editPanel.setActiveTab(activeTab);
editPanel.doLayout();
};