Sebastian Sdorra avatar Sebastian Sdorra committed d3d0e90

improve hg config

Comments (0)

Files changed (2)

plugins/scm-hg-plugin/src/main/resources/sonia/scm/hg.config.js

     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();
+      }
+    });
+  }
+
 });

scm-webapp/src/main/webapp/resources/js/sonia.config.js

 
   title: 'Config Form',
   items: null,
+  onSubmit: null,
+  getValues: null,
+  onCancel: null,
 
   initComponent: function(){
 
         },
         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);
+    }
   }
 
 });
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.