mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 18:26: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, {
|
Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
|
||||||
|
|
||||||
repository: null,
|
repository: null,
|
||||||
|
start: 0,
|
||||||
|
limit: -1,
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
|
historyId: null,
|
||||||
|
|
||||||
initComponent: function(){
|
initComponent: function(){
|
||||||
|
this.historyId = 'changesetviewer|' + this.repository.id;
|
||||||
|
|
||||||
var changesetStore = new Sonia.rest.JsonStore({
|
var changesetStore = new Sonia.rest.JsonStore({
|
||||||
id: 'changesetStore',
|
id: 'changesetStore',
|
||||||
@@ -50,8 +54,14 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
|
|||||||
autoLoad: true,
|
autoLoad: true,
|
||||||
autoDestroy: true,
|
autoDestroy: true,
|
||||||
baseParams: {
|
baseParams: {
|
||||||
start: 0,
|
start: this.start,
|
||||||
limit: this.pageSize
|
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));
|
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||||
Sonia.repository.ChangesetViewerPanel.superclass.initComponent.apply(this, arguments);
|
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
|
// register xtype
|
||||||
Ext.reg('repositoryChangesetViewerPanel', Sonia.repository.ChangesetViewerPanel);
|
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: [],
|
recentlyAdded: [],
|
||||||
|
|
||||||
add: function(token){
|
add: function(token){
|
||||||
|
if ( debug ){
|
||||||
|
console.debug('add history element ' + token);
|
||||||
|
}
|
||||||
this.recentlyAdded.push(token);
|
this.recentlyAdded.push(token);
|
||||||
Ext.History.add(token, true);
|
Ext.History.add(token, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
append: function(item){
|
append: function(item){
|
||||||
|
return this.appendWithDepth(item, 1);
|
||||||
|
},
|
||||||
|
|
||||||
|
appendWithDepth: function(item, depth){
|
||||||
var token = Ext.History.getToken();
|
var token = Ext.History.getToken();
|
||||||
if ( token ){
|
if ( token ){
|
||||||
|
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 parts = token.split('|');
|
||||||
this.add(parts[0] + '|' + item);
|
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){
|
register: function(id, fn, scope){
|
||||||
@@ -68,7 +94,7 @@ Sonia.History = {
|
|||||||
console.debug('handle history event for ' + id + ' with "' + params + '"');
|
console.debug('handle history event for ' + id + ' with "' + params + '"');
|
||||||
}
|
}
|
||||||
if (Ext.isFunction(el) ){
|
if (Ext.isFunction(el) ){
|
||||||
el();
|
el(params);
|
||||||
} else {
|
} else {
|
||||||
el.fn.call(el.scope, params);
|
el.fn.call(el.scope, params);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -502,7 +502,10 @@ Ext.onReady(function(){
|
|||||||
listeners: {
|
listeners: {
|
||||||
tabchange: function(tabPanel, tab){
|
tabchange: function(tabPanel, tab){
|
||||||
if ( Ext.isDefined(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