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

@ -276,8 +276,9 @@ class App.TicketCreate extends App.Controller
) )
new Sidebar( new Sidebar(
el: @sidebar el: @sidebar
params: @formDefault 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 el: @sidebar
params: params 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
if @textModule @textModule.reload(
@textModule.reload( ticket:
ticket: customer: user
customer: user )
)
@userInfo( new App.WidgetUser(
user_id: @params.customer_id
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

View file

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

View file

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