Added support for new task actions. Issue# 55
This commit is contained in:
parent
7b8d4de2d6
commit
c9fedb7558
8 changed files with 101 additions and 13 deletions
|
@ -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( 'Setting', { prio: 20000, parent: '', name: 'Settings', target: '#settings', role: ['Admin'] }, 'NavBar' )
|
||||
App.Config.set( 'Misc', { prio: 90000, parent: '', name: 'Tools', target: '#tools' }, 'NavBar' )
|
||||
|
|
|
@ -63,6 +63,9 @@ class App.TicketCreate extends App.Controller
|
|||
@navupdate '#'
|
||||
@title @article_attributes['title']
|
||||
|
||||
changed: =>
|
||||
true
|
||||
|
||||
release: =>
|
||||
# @clearInterval( @key, 'ticket_zoom' )
|
||||
@el.remove()
|
||||
|
@ -195,7 +198,7 @@ class App.TicketCreate extends App.Controller
|
|||
|
||||
userNew: (e) =>
|
||||
e.preventDefault()
|
||||
new UserNew()
|
||||
new UserNew( type: @type )
|
||||
|
||||
cancel: ->
|
||||
@navigate '#'
|
||||
|
@ -332,8 +335,8 @@ class UserNew extends App.ControllerModal
|
|||
# force to reload object
|
||||
callbackReload = (user) ->
|
||||
realname = user.displayName()
|
||||
$('#create_customer_id').val( user.id )
|
||||
$('#create_customer_id_autocompletion').val( realname )
|
||||
$('#create_' + ui.type + '_customer_id').val( user.id )
|
||||
$('#create_' + ui.type + '_customer_id_autocompletion').val( realname )
|
||||
|
||||
# start customer info controller
|
||||
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/:type', TicketCreateRouter, 'Routes' )
|
||||
|
||||
App.Config.set( 'New', { prio: 8000, parent: '', name: 'New', target: '#new', role: ['Agent'] }, 'NavBarRight' )
|
||||
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, parent: '#new', name: 'Call Inbound', target: '#ticket_create/call_inbound', role: ['Agent'] }, 'NavBarRight' )
|
||||
App.Config.set( 'TicketNewEmail', { prio: 8003, parent: '#new', name: 'Email', target: '#ticket_create/email', role: ['Agent'] }, 'NavBarRight' )
|
||||
App.Config.set( 'TicketNewCallOutbound', { prio: 8001, name: 'Call Outbound', target: '#ticket_create/call_outbound', role: ['Agent'] }, 'TaskActions' )
|
||||
App.Config.set( 'TicketNewCallInbound', { prio: 8002, name: 'Call Inbound', target: '#ticket_create/call_inbound', role: ['Agent'] }, 'TaskActions' )
|
||||
App.Config.set( 'TicketNewEmail', { prio: 8003, name: 'Email', target: '#ticket_create/email', role: ['Agent'] }, 'TaskActions' )
|
||||
|
||||
|
|
|
@ -47,7 +47,10 @@ class App.TicketZoom extends App.Controller
|
|||
|
||||
activate: =>
|
||||
@navupdate '#'
|
||||
@title 'Ticket Zoom ' + @ticket.number
|
||||
if @ticket
|
||||
@title 'Ticket Zoom ' + @ticket.number
|
||||
# else
|
||||
# @title 'Loading...'
|
||||
|
||||
release: =>
|
||||
@clearInterval( @key, 'ticket_zoom' )
|
||||
|
@ -59,7 +62,7 @@ class App.TicketZoom extends App.Controller
|
|||
|
||||
# get data
|
||||
App.Com.ajax(
|
||||
id: 'ticket_zoom'
|
||||
id: 'ticket_zoom_' + ticket_id
|
||||
type: 'GET'
|
||||
url: 'api/ticket_full/' + ticket_id + '?do_not_log=' + @doNotLog
|
||||
data:
|
||||
|
@ -70,6 +73,7 @@ class App.TicketZoom extends App.Controller
|
|||
return if _.isEqual( @dataLastCall.ticket, data.ticket)
|
||||
diff = difference( @dataLastCall.ticket, data.ticket )
|
||||
console.log('diff', diff)
|
||||
App.TaskManager.notify(@task_key)
|
||||
if $('[name="body"]').val()
|
||||
App.Event.trigger 'notify', {
|
||||
type: 'success'
|
||||
|
|
|
@ -193,7 +193,12 @@ class App.Navigation extends App.Controller
|
|||
sub = @getOrder( dropdown[ item.parent ] )
|
||||
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
|
||||
|
||||
getOrder: (data) ->
|
||||
|
|
|
@ -48,7 +48,8 @@ class App.TaskWidget extends App.Controller
|
|||
item_list.push item
|
||||
|
||||
@html App.view('task_widget')(
|
||||
item_list: item_list
|
||||
item_list: item_list
|
||||
taskBarActions: @_getTaskActions()
|
||||
)
|
||||
|
||||
remove: (e) =>
|
||||
|
@ -77,4 +78,30 @@ class App.TaskWidget extends App.Controller
|
|||
if _.isEmpty( tasks_all )
|
||||
@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' )
|
||||
|
|
|
@ -19,6 +19,11 @@ class App.TaskManager
|
|||
_instance ?= new _Singleton
|
||||
_instance.remove( key )
|
||||
|
||||
@notify: ( key ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _Singleton
|
||||
_instance.notify( key )
|
||||
|
||||
@reset: ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _Singleton
|
||||
|
@ -54,6 +59,7 @@ class _Singleton extends App.Controller
|
|||
$('#content_permanent_' + key ).show()
|
||||
$('#content_permanent_' + key ).addClass('active')
|
||||
@tasks[key].worker.activate()
|
||||
@tasks[key].notify = false
|
||||
for task_key, task of @tasks
|
||||
if task_key isnt key
|
||||
task.active = false
|
||||
|
@ -120,6 +126,9 @@ class _Singleton extends App.Controller
|
|||
delete @tasks[key]
|
||||
App.Event.trigger 'ui:rerender'
|
||||
|
||||
notify: ( key ) =>
|
||||
@tasks[key].notify = true
|
||||
|
||||
reset: =>
|
||||
@tasks = {}
|
||||
App.Event.trigger 'ui:rerender'
|
||||
|
@ -133,7 +142,6 @@ class _Singleton extends App.Controller
|
|||
type_id: task.type_id
|
||||
params: task.params
|
||||
callback: task.callback
|
||||
active: task.active
|
||||
store.push item
|
||||
App.Store.write( 'tasks', store )
|
||||
|
||||
|
|
|
@ -1,5 +1,20 @@
|
|||
<div class="well taskbar">
|
||||
<% 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 %>
|
||||
</div>
|
||||
|
|
|
@ -56,18 +56,44 @@ table th, table td {
|
|||
}
|
||||
|
||||
.task {
|
||||
margin: -6px;
|
||||
padding: 0px 4px;
|
||||
display: inline-block;
|
||||
max-width: 120px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.task > a,
|
||||
.task > a:hover {
|
||||
color: #ffffff;
|
||||
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-height: 240px;
|
||||
overflow-y: scroll;
|
||||
|
|
Loading…
Reference in a new issue