Use real macros, users and groups in batch action.
This commit is contained in:
parent
d0da1af974
commit
b1c6768114
5 changed files with 221 additions and 105 deletions
|
@ -24,57 +24,6 @@ class App.TicketOverview extends App.Controller
|
||||||
@batchSupport = @permissionCheck('ticket.agent')
|
@batchSupport = @permissionCheck('ticket.agent')
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
return if !@batchSupport
|
|
||||||
users = [
|
|
||||||
App.User.find(2),
|
|
||||||
App.User.find(2),
|
|
||||||
App.User.find(2),
|
|
||||||
]
|
|
||||||
groups = App.Group.all()
|
|
||||||
|
|
||||||
@batchAssign.html $(App.view('ticket_overview/batch_overlay_user_group')(
|
|
||||||
users: users
|
|
||||||
groups: groups
|
|
||||||
))
|
|
||||||
macros = [
|
|
||||||
{
|
|
||||||
name: 'Close Beispiel für eine besonders'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Close Beispiel für eine besonders'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Close Beispiel für eine besonders'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Close Beispiel für eine besonders'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Close Beispiel für eine besonders'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Close Beispiel für eine besonders'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Close Beispiel für eine besonders'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Close & Tag as Spam'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Close & Reply we\'re on Holidays'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Escalate to 2nd level'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: '1st Close'
|
|
||||||
},
|
|
||||||
]
|
|
||||||
@batchMacro.html $(App.view('ticket_overview/batch_overlay_macro')(
|
|
||||||
macros: macros
|
|
||||||
))
|
|
||||||
|
|
||||||
startDragItem: (event) =>
|
startDragItem: (event) =>
|
||||||
return if !@batchSupport
|
return if !@batchSupport
|
||||||
@grabbedItem = $(event.currentTarget)
|
@grabbedItem = $(event.currentTarget)
|
||||||
|
@ -126,6 +75,8 @@ class App.TicketOverview extends App.Controller
|
||||||
if(additionalItemsClones.length)
|
if(additionalItemsClones.length)
|
||||||
@batchDragger.find('.js-batch-dragger-count').text(@draggedItems.length)
|
@batchDragger.find('.js-batch-dragger-count').text(@draggedItems.length)
|
||||||
|
|
||||||
|
@renderOptions()
|
||||||
|
|
||||||
$('#app').append @batchDragger
|
$('#app').append @batchDragger
|
||||||
|
|
||||||
@draggedItems.each (i, item) ->
|
@draggedItems.each (i, item) ->
|
||||||
|
@ -219,6 +170,61 @@ class App.TicketOverview extends App.Controller
|
||||||
performBatchAction: (items, action, id) ->
|
performBatchAction: (items, action, id) ->
|
||||||
console.log "perform action #{action} with id #{id} on #{items.length} checked items"
|
console.log "perform action #{action} with id #{id} on #{items.length} checked items"
|
||||||
|
|
||||||
|
if action is 'macro'
|
||||||
|
@batchCount = items.length
|
||||||
|
@batchCountIndex = 0
|
||||||
|
macro = App.Macro.find(id)
|
||||||
|
for item in items
|
||||||
|
#console.log "perform action #{action} with id #{id} on ", $(item).val()
|
||||||
|
ticket = App.Ticket.find($(item).val())
|
||||||
|
App.Ticket.macro(
|
||||||
|
macro: macro.perform
|
||||||
|
ticket: ticket
|
||||||
|
)
|
||||||
|
ticket.save(
|
||||||
|
done: (r) =>
|
||||||
|
@batchCountIndex++
|
||||||
|
|
||||||
|
# refresh view after all tickets are proceeded
|
||||||
|
if @batchCountIndex == @batchCount
|
||||||
|
App.Event.trigger('overview:fetch')
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
if action is 'user_assign'
|
||||||
|
@batchCount = items.length
|
||||||
|
@batchCountIndex = 0
|
||||||
|
for item in items
|
||||||
|
#console.log "perform action #{action} with id #{id} on ", $(item).val()
|
||||||
|
ticket = App.Ticket.find($(item).val())
|
||||||
|
ticket.owner_id = id
|
||||||
|
ticket.save(
|
||||||
|
done: (r) =>
|
||||||
|
@batchCountIndex++
|
||||||
|
|
||||||
|
# refresh view after all tickets are proceeded
|
||||||
|
if @batchCountIndex == @batchCount
|
||||||
|
App.Event.trigger('overview:fetch')
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
if action is 'group_assign'
|
||||||
|
@batchCount = items.length
|
||||||
|
@batchCountIndex = 0
|
||||||
|
for item in items
|
||||||
|
#console.log "perform action #{action} with id #{id} on ", $(item).val()
|
||||||
|
ticket = App.Ticket.find($(item).val())
|
||||||
|
ticket.group_id = id
|
||||||
|
ticket.save(
|
||||||
|
done: (r) =>
|
||||||
|
@batchCountIndex++
|
||||||
|
|
||||||
|
# refresh view after all tickets are proceeded
|
||||||
|
if @batchCountIndex == @batchCount
|
||||||
|
App.Event.trigger('overview:fetch')
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
showBatchOverlay: ->
|
showBatchOverlay: ->
|
||||||
@batchOverlay.show()
|
@batchOverlay.show()
|
||||||
@batchOverlayBackdrop.velocity { opacity: [1, 0] }, { duration: 500 }
|
@batchOverlayBackdrop.velocity { opacity: [1, 0] }, { duration: 500 }
|
||||||
|
@ -463,6 +469,84 @@ class App.TicketOverview extends App.Controller
|
||||||
App.OverviewListCollection.fetch(@view)
|
App.OverviewListCollection.fetch(@view)
|
||||||
@delay(update, 2800, 'overview:fetch')
|
@delay(update, 2800, 'overview:fetch')
|
||||||
|
|
||||||
|
renderOptions: =>
|
||||||
|
macros = App.Macro.all()
|
||||||
|
groups = App.Group.all()
|
||||||
|
users = []
|
||||||
|
items = @el.find('[name="bulk"]:checked')
|
||||||
|
|
||||||
|
# find all possible owners for selected tickets
|
||||||
|
possibleUsers = {}
|
||||||
|
possibleUserGroups = {}
|
||||||
|
for item in items
|
||||||
|
#console.log "selected items with id ", $(item).val()
|
||||||
|
ticket = App.Ticket.find($(item).val())
|
||||||
|
if !possibleUserGroups[ticket.group_id.toString()]
|
||||||
|
group = App.Group.find(ticket.group_id)
|
||||||
|
for user_id in group.user_ids
|
||||||
|
if !possibleUserGroups[ticket.group_id.toString()]
|
||||||
|
possibleUsers[user_id.toString()] = true
|
||||||
|
else
|
||||||
|
hit = false
|
||||||
|
for user_id, exists of possibleUsers
|
||||||
|
if possibleUsers[user_id.toString()]
|
||||||
|
hit = true
|
||||||
|
if !hit
|
||||||
|
delete possibleUsers[user_id.toString()]
|
||||||
|
possibleUserGroups[ticket.group_id.toString()] = true
|
||||||
|
for user_id, _exists of possibleUsers
|
||||||
|
user = App.User.find(user_id)
|
||||||
|
users.push user
|
||||||
|
###
|
||||||
|
users = [
|
||||||
|
App.User.find(2),
|
||||||
|
App.User.find(2),
|
||||||
|
App.User.find(2),
|
||||||
|
]
|
||||||
|
macros = [
|
||||||
|
{
|
||||||
|
name: 'Close Beispiel für eine besonders'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Close Beispiel für eine besonders'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Close Beispiel für eine besonders'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Close Beispiel für eine besonders'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Close Beispiel für eine besonders'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Close Beispiel für eine besonders'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Close Beispiel für eine besonders'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Close & Tag as Spam'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Close & Reply we\'re on Holidays'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Escalate to 2nd level'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '1st Close'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
###
|
||||||
|
@batchAssign.html $(App.view('ticket_overview/batch_overlay_user_group')(
|
||||||
|
users: users
|
||||||
|
groups: groups
|
||||||
|
))
|
||||||
|
@batchMacro.html $(App.view('ticket_overview/batch_overlay_macro')(
|
||||||
|
macros: macros
|
||||||
|
))
|
||||||
|
|
||||||
active: (state) =>
|
active: (state) =>
|
||||||
return @shown if state is undefined
|
return @shown if state is undefined
|
||||||
@shown = state
|
@shown = state
|
||||||
|
|
|
@ -672,31 +672,19 @@ class App.TicketZoom extends App.Controller
|
||||||
for key, value of ticketParams
|
for key, value of ticketParams
|
||||||
ticket[key] = value
|
ticket[key] = value
|
||||||
|
|
||||||
# apply macro
|
App.Ticket.macro(
|
||||||
for key, content of macro
|
macro: macro
|
||||||
attributes = key.split('.')
|
ticket: ticket
|
||||||
if attributes[0] is 'ticket'
|
callback:
|
||||||
|
tagAdd: (tag) =>
|
||||||
# apply tag changes
|
return if !@sidebar
|
||||||
if attributes[1] is 'tags'
|
return if !@sidebar.tagWidget
|
||||||
if @sidebar && @sidebar.tagWidget
|
|
||||||
tags = content.value.split(',')
|
|
||||||
for tag in tags
|
|
||||||
if content.operator is 'remove'
|
|
||||||
@sidebar.tagWidget.remove(tag)
|
|
||||||
else
|
|
||||||
@sidebar.tagWidget.add(tag)
|
@sidebar.tagWidget.add(tag)
|
||||||
|
tagRemove: (tag) =>
|
||||||
# apply user changes
|
return if !@sidebar
|
||||||
else if attributes[1] is 'owner_id'
|
return if !@sidebar.tagWidget
|
||||||
if content.pre_condition is 'current_user.id'
|
@sidebar.tagWidget.remove(tag)
|
||||||
ticket[attributes[1]] = App.Session.get('id')
|
)
|
||||||
else
|
|
||||||
ticket[attributes[1]] = content.value
|
|
||||||
|
|
||||||
# apply direct value changes
|
|
||||||
else
|
|
||||||
ticket[attributes[1]] = content.value
|
|
||||||
|
|
||||||
# set defaults
|
# set defaults
|
||||||
if !@permissionCheck('ticket.customer')
|
if !@permissionCheck('ticket.customer')
|
||||||
|
|
|
@ -32,15 +32,10 @@ class App.WidgetTag extends App.Controller
|
||||||
|
|
||||||
fetch: =>
|
fetch: =>
|
||||||
@pendingRefresh = false
|
@pendingRefresh = false
|
||||||
@ajax(
|
App[@object_type].tagGet(
|
||||||
id: @key
|
@object.id,
|
||||||
type: 'GET'
|
@key,
|
||||||
url: "#{@apiPath}/tags"
|
(data) =>
|
||||||
data:
|
|
||||||
object: @object_type
|
|
||||||
o_id: @object.id
|
|
||||||
processData: true
|
|
||||||
success: (data, status, xhr) =>
|
|
||||||
@localTags = data.tags
|
@localTags = data.tags
|
||||||
@render()
|
@render()
|
||||||
)
|
)
|
||||||
|
@ -104,16 +99,7 @@ class App.WidgetTag extends App.Controller
|
||||||
return if App.Config.get('tag_new') is false && !@possibleTags[item]
|
return if App.Config.get('tag_new') is false && !@possibleTags[item]
|
||||||
@localTags.push item
|
@localTags.push item
|
||||||
@render()
|
@render()
|
||||||
|
App[@object_type].tagAdd(@object.id, item)
|
||||||
@ajax(
|
|
||||||
type: 'GET'
|
|
||||||
url: "#{@apiPath}/tags/add"
|
|
||||||
data:
|
|
||||||
object: @object_type
|
|
||||||
o_id: @object.id
|
|
||||||
item: item
|
|
||||||
processData: true,
|
|
||||||
)
|
|
||||||
|
|
||||||
onRemoveTag: (e) =>
|
onRemoveTag: (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
@ -124,16 +110,7 @@ class App.WidgetTag extends App.Controller
|
||||||
remove: (item) =>
|
remove: (item) =>
|
||||||
@localTags = _.filter(@localTags, (tagItem) -> return tagItem if tagItem isnt item)
|
@localTags = _.filter(@localTags, (tagItem) -> return tagItem if tagItem isnt item)
|
||||||
@render()
|
@render()
|
||||||
|
App[@object_type].tagRemove(@object.id, item)
|
||||||
@ajax(
|
|
||||||
type: 'GET'
|
|
||||||
url: "#{@apiPath}/tags/remove"
|
|
||||||
data:
|
|
||||||
object: @object_type
|
|
||||||
o_id: @object.id
|
|
||||||
item: item
|
|
||||||
processData: true
|
|
||||||
)
|
|
||||||
|
|
||||||
searchTag: (e) ->
|
searchTag: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
|
@ -737,3 +737,38 @@ class App.Model extends Spine.Model
|
||||||
|
|
||||||
@findNative: (id) ->
|
@findNative: (id) ->
|
||||||
@irecords[id] or notFound?(id)
|
@irecords[id] or notFound?(id)
|
||||||
|
|
||||||
|
@tagGet: (id, key, callback) ->
|
||||||
|
App.Ajax.request(
|
||||||
|
id: key
|
||||||
|
type: 'GET'
|
||||||
|
url: "#{@apiPath}/tags"
|
||||||
|
data:
|
||||||
|
object: @.className
|
||||||
|
o_id: id
|
||||||
|
processData: true
|
||||||
|
success: (data, status, xhr) ->
|
||||||
|
callback(data)
|
||||||
|
)
|
||||||
|
|
||||||
|
@tagAdd: (id, item) ->
|
||||||
|
App.Ajax.request(
|
||||||
|
type: 'GET'
|
||||||
|
url: "#{@apiPath}/tags/add"
|
||||||
|
data:
|
||||||
|
object: @.className
|
||||||
|
o_id: id
|
||||||
|
item: item
|
||||||
|
processData: true
|
||||||
|
)
|
||||||
|
|
||||||
|
@tagRemove: (id, item) ->
|
||||||
|
App.Ajax.request(
|
||||||
|
type: 'GET'
|
||||||
|
url: "#{@apiPath}/tags/remove"
|
||||||
|
data:
|
||||||
|
object: @.className
|
||||||
|
o_id: id
|
||||||
|
item: item
|
||||||
|
processData: true
|
||||||
|
)
|
||||||
|
|
|
@ -92,3 +92,35 @@ class App.Ticket extends App.Model
|
||||||
else if item.type is 'escalation_warning'
|
else if item.type is 'escalation_warning'
|
||||||
return App.i18n.translateContent('Ticket |%s| will escalate soon!', item.title)
|
return App.i18n.translateContent('Ticket |%s| will escalate soon!', item.title)
|
||||||
return "Unknow action for (#{@objectDisplayName()}/#{item.type}), extend activityMessage() of model."
|
return "Unknow action for (#{@objectDisplayName()}/#{item.type}), extend activityMessage() of model."
|
||||||
|
|
||||||
|
# apply macro
|
||||||
|
@macro: (params) ->
|
||||||
|
for key, content of params.macro
|
||||||
|
attributes = key.split('.')
|
||||||
|
if attributes[0] is 'ticket'
|
||||||
|
|
||||||
|
# apply tag changes
|
||||||
|
if attributes[1] is 'tags'
|
||||||
|
tags = content.value.split(',')
|
||||||
|
for tag in tags
|
||||||
|
if content.operator is 'remove'
|
||||||
|
if params.callback && params.callback.tagRemove
|
||||||
|
params.callback.tagRemove(tag)
|
||||||
|
else
|
||||||
|
@tagRemove(params.ticket.id, tag)
|
||||||
|
else
|
||||||
|
if params.callback && params.callback.tagAdd
|
||||||
|
params.callback.tagAdd(tag)
|
||||||
|
else
|
||||||
|
@tagAdd(params.ticket.id, tag)
|
||||||
|
|
||||||
|
# apply user changes
|
||||||
|
else if attributes[1] is 'owner_id'
|
||||||
|
if content.pre_condition is 'current_user.id'
|
||||||
|
params.ticket[attributes[1]] = App.Session.get('id')
|
||||||
|
else
|
||||||
|
params.ticket[attributes[1]] = content.value
|
||||||
|
|
||||||
|
# apply direct value changes
|
||||||
|
else
|
||||||
|
params.ticket[attributes[1]] = content.value
|
||||||
|
|
Loading…
Reference in a new issue