From 6f37a85f8b2f6568aa12d3bb1ef1450a78bc541f Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 20 Sep 2014 09:38:15 +0200 Subject: [PATCH] Added org support for sidebar. --- .../controllers/agent_ticket_create.js.coffee | 66 ++++++++++++++----- ...user_organization_autocompletion.js.coffee | 1 + .../views/generic/user_search/input.jst.eco | 2 +- 3 files changed, 53 insertions(+), 16 deletions(-) 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 20516b27e..a499093a7 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee @@ -276,8 +276,9 @@ class App.TicketCreate extends App.Controller ) new Sidebar( - el: @sidebar - params: @formDefault + el: @sidebar + params: @formDefault + textModule: @textModule ) $('#tags').tokenfield() @@ -290,8 +291,9 @@ class App.TicketCreate extends App.Controller params = App.ControllerForm.params( $(e.target).closest('form') ) new Sidebar( - el: @sidebar - params: params + el: @sidebar + params: params + textModule: @textModule ) cancel: (e) -> @@ -414,26 +416,31 @@ class App.TicketCreate extends App.Controller class Sidebar extends App.Controller constructor: -> super + + # load user + if @params['customer_id'] + App.User.full( @params['customer_id'], @render ) + return + + # render ui @render() - render: -> + render: (user) => items = [] - if @params['customer_id'] + if user showCustomer = (el) => # update text module UI - callback = (user) => - if @textModule - @textModule.reload( - ticket: - customer: user - ) + if @textModule + @textModule.reload( + ticket: + customer: user + ) - @userInfo( - user_id: @params.customer_id + new App.WidgetUser( el: el - callback: callback + user_id: user.id ) editCustomer = (e, el) => @@ -460,6 +467,35 @@ class Sidebar extends App.Controller callback: showCustomer } + if user.organization_id + editOrganization = (e, el) => + new App.ControllerGenericEdit( + id: user.organization_id + genericObject: 'Organization' + pageData: + title: 'Organizations' + object: 'Organization' + objects: 'Organizations' + ) + showOrganization = (el) => + new App.WidgetOrganization( + el: el + organization_id: user.organization_id + ) + items.push { + head: 'Organization' + name: 'organization' + icon: 'group' + actions: [ + { + name: 'Edit Organization' + class: 'glyphicon glyphicon-edit' + callback: editOrganization + }, + ] + callback: showOrganization + } + showTemplates = (el) => # show template UI diff --git a/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.js.coffee b/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.js.coffee index 308f29d7c..9bf26fc6f 100644 --- a/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.js.coffee @@ -28,6 +28,7 @@ class App.UserOrganizationAutocompletion extends App.Controller setUser: -> userId = @el.find('[name="' + @attribute.name + '"]').val() return if !userId + return if !App.User.exists(userId) user = App.User.find(userId) name = user.displayName() if user.email diff --git a/app/assets/javascripts/app/views/generic/user_search/input.jst.eco b/app/assets/javascripts/app/views/generic/user_search/input.jst.eco index ba7f90465..498291aac 100644 --- a/app/assets/javascripts/app/views/generic/user_search/input.jst.eco +++ b/app/assets/javascripts/app/views/generic/user_search/input.jst.eco @@ -1,7 +1,7 @@