From 039cdb8f38b6f2bde1e22f65267f488979385db9 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 14 Oct 2012 15:45:31 +0200 Subject: [PATCH] Improved form handling of generic objects. --- .../_application_controller_form.js.coffee | 2 ++ .../_application_controller_generic.js.coffee | 17 ++++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee index f309f537d..92d4ec952 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_form.js.coffee @@ -574,12 +574,14 @@ class App.ControllerForm extends App.Controller @disable: (form) -> console.log 'disable...', $(form.target).parent() + $(form.target).parent().find('button').attr('disabled', true) $(form.target).parent().find('[type="submit"]').attr('disabled', true) $(form.target).parent().find('[type="reset"]').attr('disabled', true) @enable: (form) -> console.log 'enable...', $(form).parent() + $(form).parent().find('button').attr('disabled', false) $(form).parent().find('[type="submit"]').attr('disabled', false) $(form).parent().find('[type="reset"]').attr('disabled', false) diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index 6db077fd4..834f1769a 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -27,16 +27,10 @@ class App.ControllerGenericNew extends App.ControllerModal @log 'submit' e.preventDefault() params = @formParam(e.target) - ### - for num in [1..199] - user = new User - params.login = 'login_c' + num - user.updateAttributes(params) - return false - ### + object = new @genericObject object.load(params) - + # validate errors = object.validate() if errors @@ -44,6 +38,9 @@ class App.ControllerGenericNew extends App.ControllerModal @formValidate( form: e.target, errors: errors ) return false + # disable form + @formDisable(e) + # save object object.save( success: => @@ -97,7 +94,9 @@ class App.ControllerGenericEdit extends App.ControllerModal @formValidate( form: e.target, errors: errors ) return false - @log 'save....' + # disable form + @formDisable(e) + # save object @item.save( success: =>