added repository type icons to grid

This commit is contained in:
Sebastian Sdorra
2012-10-27 13:04:30 +02:00
parent 404b47ca30
commit 94d8d9f2bf
8 changed files with 42 additions and 3 deletions

View File

@@ -100,10 +100,12 @@ initCallbacks.push(function(main){
}); });
}); });
// register panel // register panel
registerConfigPanel({ registerConfigPanel({
xtype : 'gitConfigPanel' xtype : 'gitConfigPanel'
}); });
// register type icon
Sonia.repository.typeIcons['git'] = 'resources/images/icons/16x16/git.png';

View File

@@ -241,3 +241,7 @@ registerConfigPanel({
id: 'hgConfigForm', id: 'hgConfigForm',
xtype : 'hgConfigPanel' xtype : 'hgConfigPanel'
}); });
// register type icon
Sonia.repository.typeIcons['hg'] = 'resources/images/icons/16x16/mercurial.png';

View File

@@ -153,3 +153,7 @@ initCallbacks.push(function(main){
registerConfigPanel({ registerConfigPanel({
xtype : 'svnConfigPanel' xtype : 'svnConfigPanel'
}); });
// register type icon
Sonia.repository.typeIcons['svn'] = 'resources/images/icons/16x16/subversion.png';

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

View File

@@ -30,6 +30,9 @@
*/ */
Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, { Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
// templates
typeIconTemplate: '<img src="{0}" alt="{1}" title="{2}">',
colNameText: 'Name', colNameText: 'Name',
colTypeText: 'Type', colTypeText: 'Type',
colContactText: 'Contact', colContactText: 'Contact',
@@ -121,6 +124,11 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
width: 125 width: 125
}, },
columns: [{ columns: [{
id: 'iconType',
dataIndex: 'type',
renderer: this.renderTypeIcon,
width: 20
},{
id: 'name', id: 'name',
header: this.colNameText, header: this.colNameText,
dataIndex: 'name', dataIndex: 'name',
@@ -131,7 +139,8 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
header: this.colTypeText, header: this.colTypeText,
dataIndex: 'type', dataIndex: 'type',
renderer: this.renderRepositoryType, renderer: this.renderRepositoryType,
width: 80 width: 80,
hidden: true
},{ },{
id: 'contact', id: 'contact',
header: this.colContactText, header: this.colContactText,
@@ -220,6 +229,20 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
} }
}, },
renderTypeIcon: function(type){
var result = '';
var icon = Sonia.repository.getTypeIcon(type);
if ( icon ){
var displayName = type;
var t = Sonia.repository.getTypeByName(type);
if (t){
displayName = t.displayName;
}
result = String.format(this.typeIconTemplate, icon, type, displayName);
}
return result;
},
renderRepositoryUrl: function(name, meta, record){ renderRepositoryUrl: function(name, meta, record){
var type = record.get('type'); var type = record.get('type');
return this.renderUrl( return this.renderUrl(

View File

@@ -45,8 +45,14 @@ Ext.ns('Sonia.repository');
Sonia.repository.openListeners = []; Sonia.repository.openListeners = [];
Sonia.repository.typeIcons = [];
// functions // functions
Sonia.repository.getTypeIcon = function(type){
return Sonia.repository.typeIcons[type];
}
Sonia.repository.createContentUrl = function(repository, path, revision){ Sonia.repository.createContentUrl = function(repository, path, revision){
var contentUrl = restUrl + 'repositories/' + repository.id + '/'; var contentUrl = restUrl + 'repositories/' + repository.id + '/';
contentUrl += 'content?path=' + path; contentUrl += 'content?path=' + path;