Added org support for sidebar.

This commit is contained in:
Martin Edenhofer 2014-09-20 09:38:15 +02:00
parent 0eb7680f3b
commit 6f37a85f8b
3 changed files with 53 additions and 16 deletions

View file

@ -278,6 +278,7 @@ class App.TicketCreate extends App.Controller
new Sidebar(
el: @sidebar
params: @formDefault
textModule: @textModule
)
$('#tags').tokenfield()
@ -292,6 +293,7 @@ class App.TicketCreate extends App.Controller
new Sidebar(
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
)
@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

View file

@ -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

View file

@ -1,7 +1,7 @@
<div class="dropdown js-recipientDropdown">
<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">
</div>