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

View file

@ -182,7 +182,10 @@ class TicketsController < ApplicationController
# GET /api/v1/ticket_merge_list/1 # GET /api/v1/ticket_merge_list/1
def ticket_merge_list 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( ticket_list = Ticket.where(
:customer_id => ticket.customer_id, :customer_id => ticket.customer_id,
:ticket_state_id => Ticket::State.by_category( 'open' ) :ticket_state_id => Ticket::State.by_category( 'open' )
@ -191,19 +194,29 @@ class TicketsController < ApplicationController
.order('created_at DESC') .order('created_at DESC')
.limit(6) .limit(6)
# get related users # get related assets
assets = {} ticket_ids_by_customer = []
ticket_list.each {|ticket| ticket_list.each {|ticket|
ticket = Ticket.lookup( :id => ticket.id ) ticket_ids_by_customer.push ticket.id
assets = ticket.assets(assets) 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 # return result
render :json => { render :json => {
:customer => assets, :assets => assets,
:recent => recent_viewed :ticket_ids_by_customer => ticket_ids_by_customer,
:ticket_ids_recent_viewed => ticket_ids_recent_viewed,
} }
end end