mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 01:15:44 +01:00
added sonia.rest.Grid
This commit is contained in:
@@ -46,24 +46,10 @@ Ext.ns('Sonia.repository');
|
||||
|
||||
|
||||
// RepositoryGrid
|
||||
Sonia.repository.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
urlTemplate: '<a href="{0}" target="_blank">{0}</a>',
|
||||
mailtoTemplate: '<a href="mailto: {0}">{0}</a>',
|
||||
Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
var selectionModel = new Ext.grid.RowSelectionModel({
|
||||
singleSelect: true
|
||||
});
|
||||
|
||||
selectionModel.on({
|
||||
selectionchange: {
|
||||
scope: this,
|
||||
fn: this.selectionChanged
|
||||
}
|
||||
});
|
||||
|
||||
var repositoryStore = new Sonia.rest.JsonStore({
|
||||
url: restUrl + 'repositories.json',
|
||||
root: 'repositories',
|
||||
@@ -90,35 +76,18 @@ Sonia.repository.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
});
|
||||
|
||||
var config = {
|
||||
loadMask: true,
|
||||
autoExpandColumn: 'description',
|
||||
store: repositoryStore,
|
||||
colModel: repositoryColModel,
|
||||
sm: selectionModel
|
||||
colModel: repositoryColModel
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.repository.Grid.superclass.initComponent.apply(this, arguments);
|
||||
|
||||
// load data
|
||||
if ( debug ){
|
||||
console.debug( 'load repository list' );
|
||||
}
|
||||
repositoryStore.load();
|
||||
},
|
||||
|
||||
reload: function(){
|
||||
selectItem: function(item){
|
||||
if ( debug ){
|
||||
console.debug('reload store');
|
||||
}
|
||||
this.store.load();
|
||||
},
|
||||
|
||||
selectionChanged: function(sm){
|
||||
var selected = sm.getSelected();
|
||||
if ( selected ){
|
||||
if ( debug ){
|
||||
console.debug( selected.data.name + ' selected' );
|
||||
console.debug( item.name + ' selected' );
|
||||
}
|
||||
var editPanel = Ext.getCmp('repositoryEditPanel');
|
||||
editPanel.removeAll();
|
||||
@@ -138,24 +107,14 @@ Sonia.repository.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
});
|
||||
editPanel.add(panel);
|
||||
editPanel.doLayout();
|
||||
}
|
||||
},
|
||||
|
||||
renderRepositoryType: function(repositoryType){
|
||||
return repositoryTypeStore.queryBy(function(rec){
|
||||
return rec.data.name == repositoryType;
|
||||
}).itemAt(0).data.displayName;
|
||||
},
|
||||
|
||||
renderUrl: function(url){
|
||||
return String.format( this.urlTemplate, url );
|
||||
},
|
||||
|
||||
renderMailto: function(mail){
|
||||
return String.format( this.mailtoTemplate, mail );
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
// register xtype
|
||||
|
||||
@@ -58,3 +58,65 @@ Sonia.rest.JsonStore = Ext.extend( Ext.data.JsonStore, {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
urlTemplate: '<a href="{0}" target="_blank">{0}</a>',
|
||||
mailtoTemplate: '<a href="mailto: {0}">{0}</a>',
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
var selectionModel = new Ext.grid.RowSelectionModel({
|
||||
singleSelect: true
|
||||
});
|
||||
|
||||
selectionModel.on({
|
||||
selectionchange: {
|
||||
scope: this,
|
||||
fn: this.selectionChanged
|
||||
}
|
||||
});
|
||||
|
||||
var config = {
|
||||
loadMask: true,
|
||||
sm: selectionModel
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.rest.Grid.superclass.initComponent.apply(this, arguments);
|
||||
|
||||
// load store
|
||||
if ( debug ){
|
||||
console.debug( 'load store' );
|
||||
}
|
||||
this.store.load();
|
||||
},
|
||||
|
||||
reload: function(){
|
||||
if ( debug ){
|
||||
console.debug('reload store');
|
||||
}
|
||||
this.store.load();
|
||||
},
|
||||
|
||||
selectionChanged: function(sm){
|
||||
var selected = sm.getSelected();
|
||||
if ( selected ){
|
||||
this.selectItem( selected.data );
|
||||
}
|
||||
},
|
||||
|
||||
selectItem: function(item){
|
||||
|
||||
},
|
||||
|
||||
renderUrl: function(url){
|
||||
return String.format( this.urlTemplate, url );
|
||||
},
|
||||
|
||||
renderMailto: function(mail){
|
||||
return String.format( this.mailtoTemplate, mail );
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
@@ -33,23 +33,10 @@
|
||||
Ext.ns('Sonia.user');
|
||||
|
||||
// UserGrid
|
||||
Sonia.user.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
mailtoTemplate: '<a href="mailto: {0}">{0}</a>',
|
||||
Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
var selectionModel = new Ext.grid.RowSelectionModel({
|
||||
singleSelect: true
|
||||
});
|
||||
|
||||
selectionModel.on({
|
||||
selectionchange: {
|
||||
scope: this,
|
||||
fn: this.selectionChanged
|
||||
}
|
||||
});
|
||||
|
||||
var userStore = new Sonia.rest.JsonStore({
|
||||
url: restUrl + 'users.json',
|
||||
root: 'users',
|
||||
@@ -74,40 +61,16 @@ Sonia.user.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
});
|
||||
|
||||
var config = {
|
||||
loadMask: true,
|
||||
store: userStore,
|
||||
colModel: userColModel,
|
||||
sm: selectionModel
|
||||
colModel: userColModel
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.user.Grid.superclass.initComponent.apply(this, arguments);
|
||||
|
||||
// load data
|
||||
if ( debug ){
|
||||
console.debug( 'load user list' );
|
||||
}
|
||||
userStore.load();
|
||||
},
|
||||
|
||||
reload: function(){
|
||||
if ( debug ){
|
||||
console.debug('reload store');
|
||||
}
|
||||
this.store.load();
|
||||
},
|
||||
|
||||
selectionChanged: function(sm){
|
||||
var selected = sm.getSelected();
|
||||
if ( selected ){
|
||||
if ( debug ){
|
||||
console.debug( selected.data.name + ' selected' );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
renderMailto: function(mail){
|
||||
return String.format( this.mailtoTemplate, mail );
|
||||
selectItem: function(item){
|
||||
console.debug( item );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user