Added support for new task actions. Issue# 55

This commit is contained in:
Martin Edenhofer 2013-04-24 10:34:18 +02:00
parent 7b8d4de2d6
commit c9fedb7558
8 changed files with 101 additions and 13 deletions

View file

@ -11,3 +11,4 @@ App.Config.set( 'User', {
App.Config.set( 'Admin', { prio: 10000, parent: '', name: 'Manage', target: '#admin', role: ['Admin'] }, 'NavBar' ) App.Config.set( 'Admin', { prio: 10000, parent: '', name: 'Manage', target: '#admin', role: ['Admin'] }, 'NavBar' )
App.Config.set( 'Setting', { prio: 20000, parent: '', name: 'Settings', target: '#settings', role: ['Admin'] }, 'NavBar' ) App.Config.set( 'Setting', { prio: 20000, parent: '', name: 'Settings', target: '#settings', role: ['Admin'] }, 'NavBar' )
App.Config.set( 'Misc', { prio: 90000, parent: '', name: 'Tools', target: '#tools' }, 'NavBar' )

View file

@ -63,6 +63,9 @@ class App.TicketCreate extends App.Controller
@navupdate '#' @navupdate '#'
@title @article_attributes['title'] @title @article_attributes['title']
changed: =>
true
release: => release: =>
# @clearInterval( @key, 'ticket_zoom' ) # @clearInterval( @key, 'ticket_zoom' )
@el.remove() @el.remove()
@ -195,7 +198,7 @@ class App.TicketCreate extends App.Controller
userNew: (e) => userNew: (e) =>
e.preventDefault() e.preventDefault()
new UserNew() new UserNew( type: @type )
cancel: -> cancel: ->
@navigate '#' @navigate '#'
@ -332,8 +335,8 @@ class UserNew extends App.ControllerModal
# force to reload object # force to reload object
callbackReload = (user) -> callbackReload = (user) ->
realname = user.displayName() realname = user.displayName()
$('#create_customer_id').val( user.id ) $('#create_' + ui.type + '_customer_id').val( user.id )
$('#create_customer_id_autocompletion').val( realname ) $('#create_' + ui.type + '_customer_id_autocompletion').val( realname )
# start customer info controller # start customer info controller
ui.userInfo( user_id: user.id ) ui.userInfo( user_id: user.id )
@ -360,8 +363,7 @@ App.Config.set( 'ticket_create', TicketCreateRouter, 'Routes' )
App.Config.set( 'ticket_create/:ticket_id/:article_id', TicketCreateRouter, 'Routes' ) App.Config.set( 'ticket_create/:ticket_id/:article_id', TicketCreateRouter, 'Routes' )
App.Config.set( 'ticket_create/:type', TicketCreateRouter, 'Routes' ) App.Config.set( 'ticket_create/:type', TicketCreateRouter, 'Routes' )
App.Config.set( 'New', { prio: 8000, parent: '', name: 'New', target: '#new', role: ['Agent'] }, 'NavBarRight' ) App.Config.set( 'TicketNewCallOutbound', { prio: 8001, name: 'Call Outbound', target: '#ticket_create/call_outbound', role: ['Agent'] }, 'TaskActions' )
App.Config.set( 'TicketNewCallOutbound', { prio: 8001, parent: '#new', name: 'Call Outbound', target: '#ticket_create/call_outbound', role: ['Agent'] }, 'NavBarRight' ) App.Config.set( 'TicketNewCallInbound', { prio: 8002, name: 'Call Inbound', target: '#ticket_create/call_inbound', role: ['Agent'] }, 'TaskActions' )
App.Config.set( 'TicketNewCallInbound', { prio: 8002, parent: '#new', name: 'Call Inbound', target: '#ticket_create/call_inbound', role: ['Agent'] }, 'NavBarRight' ) App.Config.set( 'TicketNewEmail', { prio: 8003, name: 'Email', target: '#ticket_create/email', role: ['Agent'] }, 'TaskActions' )
App.Config.set( 'TicketNewEmail', { prio: 8003, parent: '#new', name: 'Email', target: '#ticket_create/email', role: ['Agent'] }, 'NavBarRight' )

View file

@ -47,7 +47,10 @@ class App.TicketZoom extends App.Controller
activate: => activate: =>
@navupdate '#' @navupdate '#'
@title 'Ticket Zoom ' + @ticket.number if @ticket
@title 'Ticket Zoom ' + @ticket.number
# else
# @title 'Loading...'
release: => release: =>
@clearInterval( @key, 'ticket_zoom' ) @clearInterval( @key, 'ticket_zoom' )
@ -59,7 +62,7 @@ class App.TicketZoom extends App.Controller
# get data # get data
App.Com.ajax( App.Com.ajax(
id: 'ticket_zoom' id: 'ticket_zoom_' + ticket_id
type: 'GET' type: 'GET'
url: 'api/ticket_full/' + ticket_id + '?do_not_log=' + @doNotLog url: 'api/ticket_full/' + ticket_id + '?do_not_log=' + @doNotLog
data: data:
@ -70,6 +73,7 @@ class App.TicketZoom extends App.Controller
return if _.isEqual( @dataLastCall.ticket, data.ticket) return if _.isEqual( @dataLastCall.ticket, data.ticket)
diff = difference( @dataLastCall.ticket, data.ticket ) diff = difference( @dataLastCall.ticket, data.ticket )
console.log('diff', diff) console.log('diff', diff)
App.TaskManager.notify(@task_key)
if $('[name="body"]').val() if $('[name="body"]').val()
App.Event.trigger 'notify', { App.Event.trigger 'notify', {
type: 'success' type: 'success'

View file

@ -193,7 +193,12 @@ class App.Navigation extends App.Controller
sub = @getOrder( dropdown[ item.parent ] ) sub = @getOrder( dropdown[ item.parent ] )
itemLevel1.child = sub itemLevel1.child = sub
nav = @getOrder(level1) # clean up, only show navbar items with existing childrens
clean_list = []
for item in level1
if !item.child || item.child && !_.isEmpty( item.child )
clean_list.push item
nav = @getOrder(clean_list)
return nav return nav
getOrder: (data) -> getOrder: (data) ->

View file

@ -48,7 +48,8 @@ class App.TaskWidget extends App.Controller
item_list.push item item_list.push item
@html App.view('task_widget')( @html App.view('task_widget')(
item_list: item_list item_list: item_list
taskBarActions: @_getTaskActions()
) )
remove: (e) => remove: (e) =>
@ -77,4 +78,30 @@ class App.TaskWidget extends App.Controller
if _.isEmpty( tasks_all ) if _.isEmpty( tasks_all )
@navigate '#' @navigate '#'
_getTaskActions: ->
roles = App.Session.get( 'roles' )
navbar = _.values( @Config.get( 'TaskActions' ) )
level1 = []
for item in navbar
if typeof item.callback is 'function'
data = item.callback() || {}
for key, value of data
item[key] = value
if !item.parent
match = 0
if !item.role
match = 1
if !roles && item.role
match = _.include( item.role, 'Anybody' )
if roles
for role in roles
if !match
match = _.include( item.role, role.name )
if match
level1.push item
level1
App.Config.set( 'task', App.TaskWidget, 'Widgets' ) App.Config.set( 'task', App.TaskWidget, 'Widgets' )

View file

@ -19,6 +19,11 @@ class App.TaskManager
_instance ?= new _Singleton _instance ?= new _Singleton
_instance.remove( key ) _instance.remove( key )
@notify: ( key ) ->
if _instance == undefined
_instance ?= new _Singleton
_instance.notify( key )
@reset: -> @reset: ->
if _instance == undefined if _instance == undefined
_instance ?= new _Singleton _instance ?= new _Singleton
@ -54,6 +59,7 @@ class _Singleton extends App.Controller
$('#content_permanent_' + key ).show() $('#content_permanent_' + key ).show()
$('#content_permanent_' + key ).addClass('active') $('#content_permanent_' + key ).addClass('active')
@tasks[key].worker.activate() @tasks[key].worker.activate()
@tasks[key].notify = false
for task_key, task of @tasks for task_key, task of @tasks
if task_key isnt key if task_key isnt key
task.active = false task.active = false
@ -120,6 +126,9 @@ class _Singleton extends App.Controller
delete @tasks[key] delete @tasks[key]
App.Event.trigger 'ui:rerender' App.Event.trigger 'ui:rerender'
notify: ( key ) =>
@tasks[key].notify = true
reset: => reset: =>
@tasks = {} @tasks = {}
App.Event.trigger 'ui:rerender' App.Event.trigger 'ui:rerender'
@ -133,7 +142,6 @@ class _Singleton extends App.Controller
type_id: task.type_id type_id: task.type_id
params: task.params params: task.params
callback: task.callback callback: task.callback
active: task.active
store.push item store.push item
App.Store.write( 'tasks', store ) App.Store.write( 'tasks', store )

View file

@ -1,5 +1,20 @@
<div class="well taskbar"> <div class="well taskbar">
<% for item in @item_list: %> <% for item in @item_list: %>
<span class="label <% if item.task.active: %>active label-success<% else: %>label-info<% end %>" data-id="<%- item.key %>"><span class="task"><a href="<%- item.data.url %>" title="<%= item.data.title %>"><%- item.data.head %></a></span><a href="#" data-type="close" class="icon-remove-circle" title="<%- @T('close') %>"></a></span> <a href="<%- item.data.url %>" title="<%= item.data.title %>" class="btn btn-mini <% if item.task.active: %>active btn-success<% else if item.task.notify: %>active btn-warning<% else: %>btn-default<% end %>" data-id="<%- item.key %>"><span class="task"><%- item.data.head %></span><span data-type="close" class="icon-remove-circle" title="<%- @T('close') %>"></a>
<% end %>
<% if !_.isEmpty( @taskBarActions ): %>
<div class="taskbar-new">
<div class="btn-group">
<a class="btn btn-small btn-primary dropdown-toggle" data-toggle="dropdown" href="#new">
<%- @T('New') %>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<% for item in @taskBarActions: %>
<li><a href="<%- item.target %>"><%- @T(item.name) %></a></li>
<% end %>
</ul>
</div>
</div>
<% end %> <% end %>
</div> </div>

View file

@ -56,18 +56,44 @@ table th, table td {
} }
.task { .task {
margin: -6px;
padding: 0px 4px;
display: inline-block; display: inline-block;
max-width: 120px; max-width: 120px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
.task > a, .task > a,
.task > a:hover { .task > a:hover {
color: #ffffff; color: #ffffff;
text-decoration: none; text-decoration: none;
} }
.btn-default .task > a,
.btn-default .task > a:hover {
color: #333333;
}
.taskbar .btn-mini {
margin-top: 2px;
}
[data-type="close"] {
margin-left: 5px;
}
.taskbar-new {
float: right;
margin-right: 12px;
}
.taskbar-new .dropdown-menu {
right: -1px;
left: auto;
}
.max-size-scroll { .max-size-scroll {
max-height: 240px; max-height: 240px;
overflow-y: scroll; overflow-y: scroll;