diff --git a/plugins/scm-hg-plugin/src/main/resources/sonia/scm/hg.config.js b/plugins/scm-hg-plugin/src/main/resources/sonia/scm/hg.config.js index 6f2d9bdf89..c6f85324b4 100644 --- a/plugins/scm-hg-plugin/src/main/resources/sonia/scm/hg.config.js +++ b/plugins/scm-hg-plugin/src/main/resources/sonia/scm/hg.config.js @@ -20,5 +20,39 @@ registerConfigPanel({ name: 'baseUrl', fieldLabel: 'Base URL', allowBlank : false - }] + }], + + onSubmit: function(values){ + Ext.Ajax.request({ + url: restUrl + 'config/repositories/hg.json', + method: 'POST', + jsonData: values, + scope: this, + success: function(response){ + alert( 'success' ); + }, + failure: function(){ + alert( 'failure' ); + } + }); + }, + + onLoad: function(){ + //this.getEl().mask(); + Ext.Ajax.request({ + url: restUrl + 'config/repositories/hg.json', + method: 'GET', + scope: this, + success: function(response){ + var obj = Ext.decode(response.responseText); + this.load(obj); + //this.getEl().unmask(); + }, + failure: function(){ + alert( 'failure' ); + //this.getEl().unmask(); + } + }); + } + }); diff --git a/scm-webapp/src/main/webapp/resources/js/sonia.config.js b/scm-webapp/src/main/webapp/resources/js/sonia.config.js index 9767334e7c..818a07eead 100644 --- a/scm-webapp/src/main/webapp/resources/js/sonia.config.js +++ b/scm-webapp/src/main/webapp/resources/js/sonia.config.js @@ -33,6 +33,9 @@ Sonia.config.ConfigForm = Ext.extend(Ext.form.FormPanel, { title: 'Config Form', items: null, + onSubmit: null, + getValues: null, + onCancel: null, initComponent: function(){ @@ -61,15 +64,41 @@ Sonia.config.ConfigForm = Ext.extend(Ext.form.FormPanel, { }, items: this.items, buttons: [{ - text: 'Save' + text: 'Save', + scope: this, + handler: this.submitForm },{ - text: 'Cancel' + text: 'Cancel', + scope: this, + handler: this.cancel }] }] }; Ext.apply(this, Ext.apply(this.initialConfig, config)); Sonia.config.ConfigForm.superclass.initComponent.apply(this, arguments); + + if ( this.onLoad != null && Ext.isFunction( this.onLoad ) ){ + this.onLoad(); + } + }, + + load: function(values){ + this.getForm().loadRecord({success: true, data: values}); + }, + + submitForm: function(){ + var form = this.getForm(); + if ( this.onSubmit != null && Ext.isFunction( this.onSubmit ) ){ + this.onSubmit( form.getValues() ); + } + }, + + cancel: function(){ + var form = this.getForm(); + if ( this.onCancel != null && Ext.isFunction( this.onCancel ) ){ + this.onCancel(form); + } } });