Moved ticket merge to new assets feature.

This commit is contained in:
Martin Edenhofer 2013-08-19 10:21:52 +02:00
parent d6b498a20a
commit 4115f1691d
2 changed files with 32 additions and 21 deletions

View file

@ -16,25 +16,23 @@ class App.TicketMerge extends App.ControllerModal
processData: true,
success: (data, status, xhr) =>
if data.customer
App.Collection.load( type: 'Ticket', data: data.customer.tickets )
App.Collection.load( type: 'User', data: data.customer.users )
# load collections
App.Event.trigger 'loadAssets', data.assets
if data.recent
App.Collection.load( type: 'Ticket', data: data.recent.tickets )
App.Collection.load( type: 'User', data: data.recent.users )
@ticket_ids_by_customer = data.ticket_ids_by_customer
@ticket_ids_recent_viewed = data.ticket_ids_recent_viewed
@render( data )
@render()
)
render: (data) ->
render: ->
@html App.view('agent_ticket_merge')()
list = []
for t in data.customer.tickets
if t.id isnt @ticket_id
ticketItem = App.Ticket.retrieve( t.id )
for ticket_id in @ticket_ids_by_customer
if ticket_id isnt @ticket_id
ticketItem = App.Ticket.retrieve( ticket_id )
list.push ticketItem
new App.ControllerTable(
el: @el.find('#ticket-merge-customer-tickets'),
@ -59,9 +57,9 @@ class App.TicketMerge extends App.ControllerModal
)
list = []
for t in data.recent.tickets
if t.id isnt @ticket_id
ticketItem = App.Ticket.retrieve( t.id )
for ticket_id in @ticket_ids_recent_viewed
if ticket_id isnt @ticket_id
ticketItem = App.Ticket.retrieve( ticket_id )
list.push ticketItem
new App.ControllerTable(
el: @el.find('#ticket-merge-recent-tickets'),

View file

@ -182,7 +182,10 @@ class TicketsController < ApplicationController
# GET /api/v1/ticket_merge_list/1
def ticket_merge_list
ticket = Ticket.find( params[:ticket_id] )
ticket = Ticket.find( params[:ticket_id] )
assets = ticket.assets({})
# open tickets by customer
ticket_list = Ticket.where(
:customer_id => ticket.customer_id,
:ticket_state_id => Ticket::State.by_category( 'open' )
@ -191,19 +194,29 @@ class TicketsController < ApplicationController
.order('created_at DESC')
.limit(6)
# get related users
assets = {}
# get related assets
ticket_ids_by_customer = []
ticket_list.each {|ticket|
ticket = Ticket.lookup( :id => ticket.id )
ticket_ids_by_customer.push ticket.id
assets = ticket.assets(assets)
}
recent_viewed = RecentView.list_fulldata( current_user, 8 )
ticket_ids_recent_viewed = []
ticket_recent_view = RecentView.list( current_user, 8 )
ticket_recent_view.each {|item|
if item['recent_view_object'] == 'Ticket'
ticket_ids_recent_viewed.push item['o_id']
ticket = Ticket.find( item['o_id'] )
assets = ticket.assets(assets)
end
}
# return result
render :json => {
:customer => assets,
:recent => recent_viewed
:assets => assets,
:ticket_ids_by_customer => ticket_ids_by_customer,
:ticket_ids_recent_viewed => ticket_ids_recent_viewed,
}
end