added history functions to repositorybrowser

This commit is contained in:
Sebastian Sdorra
2011-08-23 20:17:26 +02:00
parent 68ad2afb35
commit c6991e797c
3 changed files with 47 additions and 2 deletions

View File

@@ -125,7 +125,7 @@ Sonia.repository.ChangesetViewerGrid = Ext.extend(Ext.grid.GridPanel, {
openRepositoryBrowser: function(revision){
main.addTab({
id: 'repositorybrowser-' + this.repository.id + '-' + revision,
id: 'repositorybrowser-' + this.repository.id + ':' + revision,
xtype: 'repositoryBrowser',
repository: this.repository,
revision: revision,

View File

@@ -96,7 +96,7 @@ Sonia.repository.ExtendedInfoPanel = Ext.extend(Sonia.repository.InfoPanel,{
createRepositoryBrowser: function(){
return {
id: 'repositorybrowser-' + this.item.id,
id: 'repositorybrowser-' + this.item.id + ':_',
xtype: 'repositoryBrowser',
repository: this.item,
closable: true

View File

@@ -50,6 +50,12 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
console.debug('create new browser for repository ' + this.repository.name + " and revision " + this.revision);
}
this.historyId = Sonia.History.createToken([
'repositorybrowser',
this.repository.id,
this.revision ? this.revision : '_'
]);
var browserStore = new Sonia.rest.JsonStore({
proxy: new Ext.data.HttpProxy({
url: restUrl + 'repositories/' + this.repository.id + '/browse.json',
@@ -162,6 +168,22 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
length: 0
}));
}
var historyParams = [];
if ( this.revision ){
historyParams.push(this.revision)
} else {
historyParams.push('_');
}
if ( extra.params.path ){
historyParams.push(extra.params.path);
}
var id = Sonia.History.appendWithDepth(historyParams, 2);
if (id){
this.historyId = id;
}
},
onClick: function(e){
@@ -313,3 +335,26 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
// register xtype
Ext.reg('repositoryBrowser', Sonia.repository.RepositoryBrowser);
// register history handler
Sonia.History.register('repositorybrowser', function(params){
if (params){
var id = 'repositorybrowser-' + params[0] + ':';
var revision = params[1];
id += revision;
var path = params[2] ? params[2] : '';
if (debug){
console.debug('load repositorybrowser for ' + id + ', ' + revision + ', ' + path );
}
var tab = Ext.getCmp(id);
if ( tab ){
main.getMainTabPanel().setActiveTab(id);
tab.changeDirectory(path);
}
}
});