Browse Source

Added org support for sidebar.

Martin Edenhofer 10 years ago
parent
commit
6f37a85f8b

+ 52 - 16
app/assets/javascripts/app/controllers/agent_ticket_create.js.coffee

@@ -276,8 +276,9 @@ class App.TicketCreate extends App.Controller
     )
     )
 
 
     new Sidebar(
     new Sidebar(
-      el:     @sidebar
-      params: @formDefault
+      el:         @sidebar
+      params:     @formDefault
+      textModule: @textModule
     )
     )
 
 
     $('#tags').tokenfield()
     $('#tags').tokenfield()
@@ -290,8 +291,9 @@ class App.TicketCreate extends App.Controller
     params = App.ControllerForm.params( $(e.target).closest('form') )
     params = App.ControllerForm.params( $(e.target).closest('form') )
 
 
     new Sidebar(
     new Sidebar(
-      el:     @sidebar
-      params: params
+      el:         @sidebar
+      params:     params
+      textModule: @textModule
     )
     )
 
 
   cancel: (e) ->
   cancel: (e) ->
@@ -414,26 +416,31 @@ class App.TicketCreate extends App.Controller
 class Sidebar extends App.Controller
 class Sidebar extends App.Controller
   constructor: ->
   constructor: ->
     super
     super
+
+    # load user
+    if @params['customer_id']
+      App.User.full( @params['customer_id'], @render )
+      return
+
+    # render ui
     @render()
     @render()
 
 
-  render: ->
+  render: (user) =>
 
 
     items = []
     items = []
-    if @params['customer_id']
+    if user
 
 
       showCustomer = (el) =>
       showCustomer = (el) =>
         # update text module UI
         # update text module UI
-        callback = (user) =>
-          if @textModule
-            @textModule.reload(
-              ticket:
-                customer: user
-            )
-
-        @userInfo(
-          user_id:  @params.customer_id
+        if @textModule
+          @textModule.reload(
+            ticket:
+              customer: user
+          )
+
+        new App.WidgetUser(
           el:       el
           el:       el
-          callback: callback
+          user_id:  user.id
         )
         )
 
 
       editCustomer = (e, el) =>
       editCustomer = (e, el) =>
@@ -460,6 +467,35 @@ class Sidebar extends App.Controller
         callback: showCustomer
         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) =>
     showTemplates = (el) =>
 
 
       # show template UI
       # show template UI

+ 1 - 0
app/assets/javascripts/app/lib/app_post/user_organization_autocompletion.js.coffee

@@ -28,6 +28,7 @@ class App.UserOrganizationAutocompletion extends App.Controller
   setUser: ->
   setUser: ->
     userId = @el.find('[name="' + @attribute.name + '"]').val()
     userId = @el.find('[name="' + @attribute.name + '"]').val()
     return if !userId
     return if !userId
+    return if !App.User.exists(userId)
     user = App.User.find(userId)
     user = App.User.find(userId)
     name = user.displayName()
     name = user.displayName()
     if user.email
     if user.email

+ 1 - 1
app/assets/javascripts/app/views/generic/user_search/input.jst.eco

@@ -1,7 +1,7 @@
 <div class="dropdown js-recipientDropdown">
 <div class="dropdown js-recipientDropdown">
 
 
   <div class="dropdown-toggle u-positionOrigin" data-toggle="dropdown">
   <div class="dropdown-toggle u-positionOrigin" data-toggle="dropdown">
-    <input type="hidden" name="<%- @attribute.name %>">
+    <input type="hidden" name="<%- @attribute.name %>" value="<%= @attribute.value %>">
     <input name="<%- @attribute.name %>_completion" class="ui-autocomplete-input form-control" autocapitalize="off" placeholder="<%- @attribute.placeholder %>" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
     <input name="<%- @attribute.name %>_completion" class="ui-autocomplete-input form-control" autocapitalize="off" placeholder="<%- @attribute.placeholder %>" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
   </div>
   </div>