added ChangesetViewer

This commit is contained in:
Sebastian Sdorra
2011-04-03 12:48:30 +02:00
parent f2b876a2c1
commit a8598ffdc7
2 changed files with 112 additions and 9 deletions

View File

@@ -351,6 +351,24 @@ Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
name: 'public', name: 'public',
xtype: 'checkbox', xtype: 'checkbox',
helpText: this.publicHelpText helpText: this.publicHelpText
},
// TODO remove
{
fieldLabel: 'ChangesetViewer',
text: 'ChangesetViewer',
xtype: 'button',
scope: this,
handler: function(){
var changesetViewer = {
id: 'changesetViewer',
title: this.item.name,
repository: this.item,
xtype: 'repositoryChangesetViewerPanel',
closable: true,
autoScroll: true
}
main.addTab(changesetViewer);
}
} }
] ]
},{ },{
@@ -658,3 +676,83 @@ Sonia.repository.Panel = Ext.extend(Ext.Panel, {
// register xtype // register xtype
Ext.reg('repositoryPanel', Sonia.repository.Panel); Ext.reg('repositoryPanel', Sonia.repository.Panel);
// changeset viewer
Sonia.repository.ChangesetViewerGrid = Ext.extend(Ext.grid.GridPanel, {
repository: null,
/**
* 0 - id
* 1 - date
* 2 - author
* 3 - description
*/
changesetTemplate: '<div><b>{0}</b>: {3}</div><div>{2}</div><div>{1}</div>',
initComponent: function(){
var changesetStore = new Ext.data.JsonStore({
id: 'changesetStore',
url: restUrl + 'repositories/' + this.repository.id + '/changesets.json',
fields: ['id', 'date', 'author', 'description'],
idProperty: 'id',
autoLoad: true,
autoDestroy: true
});
var changesetColModel = new Ext.grid.ColumnModel({
defaults: {
sortable: false
},
columns: [
{id: 'changeset', dataIndex: 'id', header: 'Changeset', renderer: this.renderChangeset, scope: this},
{id: 'date', dataIndex: 'date', header: 'Date', hidden: true},
{id: 'author', dataIndex: 'author', header: 'Author', hidden: true},
{id: 'description', dataIndex: 'description', header: 'Description', hidden: true}
]
});
var config = {
autoExpandColumn: 'changeset',
autoHeight: true,
store: changesetStore,
colModel: changesetColModel
}
Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.repository.ChangesetViewerGrid.superclass.initComponent.apply(this, arguments);
},
renderChangeset: function(value, p, record){
var data = record.data;
return String.format(this.changesetTemplate, data.id, data.date, data.author, data.description);
}
});
// register xtype
Ext.reg('repositoryChangesetViewerGrid', Sonia.repository.ChangesetViewerGrid);
Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
repository: null,
initComponent: function(){
var config = {
items: [{
xtype: 'repositoryChangesetViewerGrid',
repository: this.repository
}]
};
Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.repository.ChangesetViewerPanel.superclass.initComponent.apply(this, arguments);
}
});
// register xtype
Ext.reg('repositoryChangesetViewerPanel', Sonia.repository.ChangesetViewerPanel);

View File

@@ -198,17 +198,22 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
}, },
addTabPanel: function(id, xtype, title){ addTabPanel: function(id, xtype, title){
var tab = this.mainTabPanel.findById( id ); var panel = {
if ( tab == null ){
this.mainTabPanel.add({
id: id, id: id,
xtype: xtype, xtype: xtype,
title: title, title: title,
closable: true, closable: true,
autoScroll: true autoScroll: true
}); };
this.addTab(panel);
},
addTab: function(panel){
var tab = this.mainTabPanel.findById(panel.id);
if ( tab == null ){
this.mainTabPanel.add(panel);
} }
this.mainTabPanel.setActiveTab(id); this.mainTabPanel.setActiveTab(panel.id);
}, },
loadState: function(s){ loadState: function(s){