diff --git a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.changesetviewerpanel.js b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.changesetviewerpanel.js index 0ae6af099f..ab47b1bf99 100644 --- a/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.changesetviewerpanel.js +++ b/scm-webapp/src/main/webapp/resources/js/repository/sonia.repository.changesetviewerpanel.js @@ -33,9 +33,13 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, { repository: null, + start: 0, + limit: -1, pageSize: 20, + historyId: null, initComponent: function(){ + this.historyId = 'changesetviewer|' + this.repository.id; var changesetStore = new Sonia.rest.JsonStore({ id: 'changesetStore', @@ -50,8 +54,14 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, { autoLoad: true, autoDestroy: true, baseParams: { - start: 0, - limit: this.pageSize + start: this.start, + limit: this.limit > 0 ? this.limit : this.pageSize + }, + listeners: { + load: { + fn: this.updateHistory, + scope: this + } } }); @@ -72,9 +82,47 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, { Ext.apply(this, Ext.apply(this.initialConfig, config)); Sonia.repository.ChangesetViewerPanel.superclass.initComponent.apply(this, arguments); + }, + + updateHistory: function(store, records, options){ + var id = Sonia.History.appendWithDepth([options.params.start, options.params.limit], 2); + if (id){ + this.historyId = id; + } } }); // register xtype Ext.reg('repositoryChangesetViewerPanel', Sonia.repository.ChangesetViewerPanel); + +// register history handler +Sonia.History.register('changesetviewer', function(params){ + + if (params){ + + Ext.Ajax.request({ + url: restUrl + 'repositories/' + params[0] + '.json', + method: 'GET', + scope: this, + success: function(response){ + var item = Ext.decode(response.responseText); + main.addTab({ + id: item.id + '-changesetViewer', + xtype: 'repositoryChangesetViewerPanel', + repository: item, + start: parseInt(params[1]), + limit: parseInt(params[2]), + closable: true + }) + }, + failure: function(result){ + main.handleFailure( + result.status + ); + } + }); + + } + +}); diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.history.js b/scm-webapp/src/main/webapp/resources/js/sonia.history.js index 6a817f8542..17407d09e7 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.history.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.history.js @@ -37,16 +37,42 @@ Sonia.History = { recentlyAdded: [], add: function(token){ + if ( debug ){ + console.debug('add history element ' + token); + } this.recentlyAdded.push(token); Ext.History.add(token, true); }, append: function(item){ + return this.appendWithDepth(item, 1); + }, + + appendWithDepth: function(item, depth){ var token = Ext.History.getToken(); if ( token ){ + var tokenSuffix = ''; + if (Ext.isArray(item)){ + for (var i=0; i