/hippo/src/main/webapp/js/form/NewExperimentForm.js

http://hdbc.googlecode.com/ · JavaScript · 63 lines · 57 code · 6 blank · 0 comment · 0 complexity · ad0404f4bdbcd7cb05042cb7dc255473 MD5 · raw file

  1. Ext.namespace('Hippo.form');
  2. Hippo.form.NewExperimentForm = Ext.extend(Ext.form.FormPanel, {
  3. submitHandler: function(e, t) {
  4. this.getForm().submit({
  5. url: 'console/experiments'
  6. ,method: 'post'
  7. ,timeout: 5000
  8. ,success: this.onSubmitSuccess.createDelegate(this)
  9. ,failure: this.onSubmitFail
  10. });
  11. }
  12. ,onSubmitSuccess: function(frm, action) {
  13. var jsonRsp = Ext.util.JSON.decode(action.response.responseText);
  14. Ext.getCmp('viewport').fireEvent("on_newExperimentSaved", jsonRsp, this.ownerCt);
  15. }
  16. ,onSubmitFail: function(frm, act) {
  17. Ext.Msg.alert('Failure', act.response.statusText);
  18. }
  19. ,initComponent : function() {
  20. Ext.apply(this, {
  21. id: 'newexpmntform'
  22. ,bodyStyle: 'padding: 5px 5px 5px 5px'
  23. ,frame: true
  24. ,method: 'post'
  25. ,buttons: [{id: 'create' ,text: 'create' ,xtype: 'button'
  26. ,listeners: {
  27. 'click': {
  28. fn: this.submitHandler
  29. ,scope: this
  30. }
  31. }
  32. }
  33. ,{
  34. id: 'cancel'
  35. ,text: 'cancel'
  36. ,xtype: 'button'
  37. ,listeners: {
  38. 'click': {
  39. fn: function(e, t) {
  40. this.ownerCt.ownerCt.ownerCt.destroy();
  41. }
  42. }
  43. }
  44. }]
  45. ,defaults: {
  46. allowBlank: false
  47. ,width: 325
  48. }
  49. ,items: [
  50. {id: 'title', name: 'title', fieldLabel: 'title', maxLength: 64, xtype: 'textfield'}
  51. ,{id: 'purpose', name: 'purpose', fieldLabel: 'purpose', maxLength: 128, xtype: 'textarea'}
  52. ]
  53. });
  54. Hippo.form.NewExperimentForm.superclass.initComponent.apply(this, arguments);
  55. }
  56. });
  57. Ext.reg('form.NewExperimentForm', Hippo.form.NewExperimentForm);