mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 10:16:16 +01:00
added basic history methods for changesetviewer
This commit is contained in:
@@ -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
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -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 parts = token.split('|');
|
||||
this.add(parts[0] + '|' + item);
|
||||
var tokenSuffix = '';
|
||||
if (Ext.isArray(item)){
|
||||
for (var i=0; i<item.length; i++){
|
||||
tokenSuffix += item[i];
|
||||
if ( (i+1)<item.length ){
|
||||
tokenSuffix += '|';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tokenSuffix = item;
|
||||
}
|
||||
|
||||
var parts = token.split('|');
|
||||
var newToken = '';
|
||||
for (var j=0; j<depth; j++){
|
||||
newToken += parts[j] + '|';
|
||||
}
|
||||
newToken += tokenSuffix;
|
||||
this.add(newToken);
|
||||
token = newToken;
|
||||
}
|
||||
return token;
|
||||
},
|
||||
|
||||
register: function(id, fn, scope){
|
||||
@@ -68,7 +94,7 @@ Sonia.History = {
|
||||
console.debug('handle history event for ' + id + ' with "' + params + '"');
|
||||
}
|
||||
if (Ext.isFunction(el) ){
|
||||
el();
|
||||
el(params);
|
||||
} else {
|
||||
el.fn.call(el.scope, params);
|
||||
}
|
||||
|
||||
@@ -502,7 +502,10 @@ Ext.onReady(function(){
|
||||
listeners: {
|
||||
tabchange: function(tabPanel, tab){
|
||||
if ( Ext.isDefined(tab) ){
|
||||
Sonia.History.add(tab.id, true);
|
||||
var id = tab.historyId ? tab.historyId : tab.id;
|
||||
if (id){
|
||||
Sonia.History.add(id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user