mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-18 03:01:05 +01:00
added Sonia.rest.FormPanel
This commit is contained in:
@@ -92,7 +92,7 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
var editPanel = Ext.getCmp('repositoryEditPanel');
|
||||
editPanel.removeAll();
|
||||
var panel = new Sonia.repository.FormPanel({
|
||||
item: selected.data,
|
||||
item: item,
|
||||
region: 'south',
|
||||
title: 'Repository Form',
|
||||
padding: 5,
|
||||
@@ -121,23 +121,13 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
Ext.reg('repositoryGrid', Sonia.repository.Grid);
|
||||
|
||||
// RepositoryFormPanel
|
||||
Sonia.repository.FormPanel = Ext.extend(Ext.FormPanel,{
|
||||
|
||||
item: null,
|
||||
onUpdate: null,
|
||||
onCreate: null,
|
||||
Sonia.repository.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
update = this.item != null;
|
||||
|
||||
var config = {
|
||||
padding: 5,
|
||||
labelWidth: 100,
|
||||
defaults: {width: 240},
|
||||
autoScroll: true,
|
||||
monitorValid: true,
|
||||
defaultType: 'textfield',
|
||||
items:[
|
||||
{id: 'repositoryName', fieldLabel: 'Name', name: 'name', readOnly: update, allowBlank: false},
|
||||
{
|
||||
@@ -159,38 +149,11 @@ Sonia.repository.FormPanel = Ext.extend(Ext.FormPanel,{
|
||||
|
||||
{fieldLabel: 'Contact', name: 'contact'},
|
||||
{fieldLabel: 'Description', name: 'description', xtype: 'textarea'}
|
||||
],
|
||||
buttonAlign: 'center',
|
||||
buttons: [
|
||||
{text: 'Ok', formBind: true, scope: this, handler: this.submit},
|
||||
{text: 'Cancel', scope: this, handler: this.reset}
|
||||
]
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.repository.FormPanel.superclass.initComponent.apply(this, arguments);
|
||||
|
||||
if ( update ){
|
||||
this.loadData( this.item );
|
||||
}
|
||||
},
|
||||
|
||||
loadData: function(item){
|
||||
this.item = item;
|
||||
var data = {success: true, data: item};
|
||||
this.getForm().loadRecord(data);
|
||||
},
|
||||
|
||||
submit: function(){
|
||||
if ( debug ){
|
||||
console.debug( 'repository form submitted' );
|
||||
}
|
||||
var item = this.getForm().getFieldValues();
|
||||
if ( this.item != null ){
|
||||
this.update(item);
|
||||
} else {
|
||||
this.create(item);
|
||||
}
|
||||
},
|
||||
|
||||
update: function(item){
|
||||
@@ -237,18 +200,6 @@ Sonia.repository.FormPanel = Ext.extend(Ext.FormPanel,{
|
||||
alert( 'failure' );
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
reset: function(){
|
||||
this.getForm().reset();
|
||||
},
|
||||
|
||||
execCallback: function(obj, item){
|
||||
if ( Ext.isFunction( obj ) ){
|
||||
obj(item);
|
||||
} else if ( Ext.isObject( obj )){
|
||||
obj.fn.call( obj.scope, item );
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -59,6 +59,8 @@ Sonia.rest.JsonStore = Ext.extend( Ext.data.JsonStore, {
|
||||
|
||||
});
|
||||
|
||||
// Grid
|
||||
|
||||
Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
urlTemplate: '<a href="{0}" target="_blank">{0}</a>',
|
||||
@@ -107,7 +109,7 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
},
|
||||
|
||||
selectItem: function(item){
|
||||
|
||||
console.debug( item );
|
||||
},
|
||||
|
||||
renderUrl: function(url){
|
||||
@@ -118,5 +120,80 @@ Sonia.rest.Grid = Ext.extend(Ext.grid.GridPanel, {
|
||||
return String.format( this.mailtoTemplate, mail );
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// FormPanel
|
||||
|
||||
Sonia.rest.FormPanel = Ext.extend(Ext.FormPanel,{
|
||||
|
||||
item: null,
|
||||
onUpdate: null,
|
||||
onCreate: null,
|
||||
|
||||
initComponent: function(){
|
||||
var config = {
|
||||
padding: 5,
|
||||
labelWidth: 100,
|
||||
defaults: {width: 240},
|
||||
autoScroll: true,
|
||||
monitorValid: true,
|
||||
defaultType: 'textfield',
|
||||
buttonAlign: 'center',
|
||||
buttons: [
|
||||
{text: 'Ok', formBind: true, scope: this, handler: this.submit},
|
||||
{text: 'Cancel', scope: this, handler: this.reset}
|
||||
]
|
||||
}
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.rest.FormPanel.superclass.initComponent.apply(this, arguments);
|
||||
|
||||
if ( this.item != null ){
|
||||
this.loadData(this.item);
|
||||
}
|
||||
},
|
||||
|
||||
loadData: function(item){
|
||||
this.item = item;
|
||||
var data = {success: true, data: item};
|
||||
this.getForm().loadRecord(data);
|
||||
},
|
||||
|
||||
submit: function(){
|
||||
if ( debug ){
|
||||
console.debug( 'form submitted' );
|
||||
}
|
||||
var item = this.getForm().getFieldValues();
|
||||
if ( this.item != null ){
|
||||
this.update(item);
|
||||
} else {
|
||||
this.create(item);
|
||||
}
|
||||
},
|
||||
|
||||
reset: function(){
|
||||
if ( debug ){
|
||||
console.debug( 'reset form' );
|
||||
}
|
||||
this.getForm().reset();
|
||||
},
|
||||
|
||||
execCallback: function(obj, item){
|
||||
if ( Ext.isFunction( obj ) ){
|
||||
obj(item);
|
||||
} else if ( Ext.isObject( obj )){
|
||||
obj.fn.call( obj.scope, item );
|
||||
}
|
||||
},
|
||||
|
||||
update: function(item){
|
||||
console.debug( 'update item: ' );
|
||||
console.debug( item );
|
||||
},
|
||||
|
||||
create: function(item){
|
||||
console.debug( 'create item: ' );
|
||||
console.debug( item );
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user