From 3af1d102a5ec36659adcb52579ee406c63e1fb53 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 18 Sep 2014 08:13:06 +0200 Subject: [PATCH] Improve error handling. --- .../app/controllers/widget/template.js.coffee | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/controllers/widget/template.js.coffee b/app/assets/javascripts/app/controllers/widget/template.js.coffee index dd7e89f33..df9370f15 100644 --- a/app/assets/javascripts/app/controllers/widget/template.js.coffee +++ b/app/assets/javascripts/app/controllers/widget/template.js.coffee @@ -54,6 +54,10 @@ class App.WidgetTemplate extends App.Controller # get params params = @formParam(e.target) + + # check if template is selected + return if !params['template_id'] + template = App.Template.find( params['template_id'] ) if confirm('Sure?') @template_id = false @@ -65,7 +69,12 @@ class App.WidgetTemplate extends App.Controller # get params params = @formParam(e.target) + # check if template is selected + return if !params['template_id'] + + # remember template (to select it after rerender) @template_id = params['template_id'] + template = App.Template.find( params['template_id'] ) App.Event.trigger 'ticket_create_rerender', template.attributes() @@ -98,7 +107,7 @@ class App.WidgetTemplate extends App.Controller ui = @ template.save( done: -> - ui.template_id = @.id + ui.template_id = @id fail: => @log 'error', 'save failed!'