From d2390521aa5cb472625a4e48eb06b8d4df539365 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 11 Oct 2012 13:00:06 +0200 Subject: [PATCH] Added required and callback also for new objects. --- .../_application_controller_generic.js.coffee | 3 +++ .../app/controllers/agent_ticket_create.js.coffee | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) 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 9aea3189d..6db077fd4 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -17,6 +17,7 @@ class App.ControllerGenericNew extends App.ControllerModal el: @el.find('#object_new'), model: @genericObject, params: @item, + required: @required, autofocus: true, ) @@ -46,6 +47,8 @@ class App.ControllerGenericNew extends App.ControllerModal # save object object.save( success: => + if @callback + @callback(@item) @modalHide() error: => @log 'errors' diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee index 230e7687d..952380f99 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -263,13 +263,13 @@ class UserNew extends App.ControllerModal ui = @ user.save( success: -> - ui.modalHide() - realname = @.firstname + ' ' + @.lastname - $('#create_customer_id').val(@.id) - $('#create_customer_id_autocompletion').val(realname) - + realname = @displayName() + $('#create_customer_id').val( @id ) + $('#create_customer_id_autocompletion').val( realname ) + # start customer info controller - ui.userInfo( user_id: @.id ) + ui.userInfo( user_id: @id ) + ui.modalHide() error: -> ui.modalHide() )