From a20c6e438ac86e11936257e1777bed2cc58a7226 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 16 Feb 2016 20:00:27 +0100 Subject: [PATCH] Added support to show error message of object was not able to create. --- .../_application_controller_generic.coffee | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee index 5d344dafb..63df1d627 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.coffee @@ -6,13 +6,13 @@ class App.ControllerGenericNew extends App.ControllerModal content: => @head = @pageData.object - controller = new App.ControllerForm( + @controller = new App.ControllerForm( model: App[ @genericObject ] params: @item screen: @screen || 'edit' autofocus: true ) - controller.form + @controller.form onSubmit: (e) -> params = @formParam(e.target) @@ -39,9 +39,10 @@ class App.ControllerGenericNew extends App.ControllerModal ui.callback(item) ui.close() - fail: -> - ui.log 'errors' - ui.close() + fail: (settings, details) -> + ui.log 'errors', details + ui.formEnable(e) + ui.controller.showAlert(details.error_human || details.error || 'Unable to create object!') ) class App.ControllerGenericEdit extends App.ControllerModal @@ -54,13 +55,13 @@ class App.ControllerGenericEdit extends App.ControllerModal @item = App[ @genericObject ].find( @id ) @head = @pageData.object - controller = new App.ControllerForm( + @controller = new App.ControllerForm( model: App[ @genericObject ] params: @item screen: @screen || 'edit' autofocus: true ) - controller.form + @controller.form onSubmit: (e) -> params = @formParam(e.target) @@ -85,9 +86,10 @@ class App.ControllerGenericEdit extends App.ControllerModal ui.callback(item) ui.close() - fail: -> + fail: (settings, details) -> ui.log 'errors' - ui.close() + ui.formEnable(e) + ui.controller.showAlert(details.error_human || details.error || 'Unable to update object!') ) class App.ControllerGenericIndex extends App.Controller