Improved changing customers.

This commit is contained in:
Martin Edenhofer 2014-04-03 00:35:56 +02:00
parent 17ca8d375a
commit 6be0e97a48
5 changed files with 29 additions and 26 deletions

View file

@ -9,7 +9,7 @@ class App.TicketMerge extends App.ControllerModal
@ajax(
id: 'ticket_merge_list'
type: 'GET'
url: @apiPath + '/ticket_merge_list/' + @ticket_id
url: @apiPath + '/ticket_merge_list/' + @ticket.id
processData: true,
success: (data, status, xhr) =>
@ -28,7 +28,7 @@ class App.TicketMerge extends App.ControllerModal
list = []
for ticket_id in @ticket_ids_by_customer
if ticket_id isnt @ticket_id
if ticket_id isnt @ticket.id
ticketItem = App.Ticket.retrieve( ticket_id )
list.push ticketItem
new App.ControllerTable(
@ -55,7 +55,7 @@ class App.TicketMerge extends App.ControllerModal
list = []
for ticket_id in @ticket_ids_recent_viewed
if ticket_id isnt @ticket_id
if ticket_id isnt @ticket.id
ticketItem = App.Ticket.retrieve( ticket_id )
list.push ticketItem
new App.ControllerTable(
@ -105,7 +105,7 @@ class App.TicketMerge extends App.ControllerModal
@ajax(
id: 'ticket_merge',
type: 'GET',
url: @apiPath + '/ticket_merge/' + @ticket_id + '/' + params['master_ticket_number'],
url: @apiPath + '/ticket_merge/' + @ticket.id + '/' + params['master_ticket_number'],
data: {
# view: @view
}

View file

@ -25,19 +25,17 @@ class App.TicketCustomer extends App.ControllerModal
params = @formParam(e.target)
# update ticket
ticket = App.Ticket.find(@ticket_id)
ticket.updateAttributes(
customer_id: params['customer_id']
)
@customer_id = params['customer_id']
callback = =>
# close modal
@modalHide()
# reload zoom view
@ui.render()
# update ticket
@ticket.updateAttributes(
customer_id: @customer_id
)
# load user if not already exists
App.User.retrieve( params['customer_id'], callback )
App.User.retrieve( @customer_id, callback )

View file

@ -9,7 +9,7 @@ class App.TicketHistory extends App.GenericHistory
@ajax(
id: 'ticket_history',
type: 'GET',
url: @apiPath + '/ticket_history/' + @ticket_id,
url: @apiPath + '/ticket_history/' + @ticket.id,
success: (data, status, xhr) =>
# load assets

View file

@ -28,8 +28,8 @@ class App.TicketZoom extends App.Controller
update = =>
if data.id.toString() is @ticket_id.toString()
ticket = App.Ticket.find( @ticket_id )
@log 'notice', 'TRY', data.updated_at, ticket.updated_at
if data.updated_at isnt ticket.updated_at
@log 'notice', 'TRY', Date(data.updated_at), Date(ticket.updated_at)
if Date(data.updated_at) isnt Date(ticket.updated_at)
@fetch( @ticket_id, false )
@delay( update, 1800, 'ticket-zoom-' + @ticket_id )
)
@ -282,15 +282,17 @@ class TicketInfo extends App.ControllerDrox
class Widgets extends App.Controller
constructor: ->
super
@render()
render: ->
@subscribeId = @ticket.subscribe(@render)
@render(@ticket)
render: (ticket) =>
@html App.view('ticket_zoom/widgets')()
# show ticket info
new TicketInfo(
ticket: @ticket
ticket: ticket
el: @el.find('.ticket_info')
)
@ -298,8 +300,8 @@ class Widgets extends App.Controller
if !@isRole('Customer')
new App.WidgetUser(
el: @el.find('.customer_info')
user_id: @ticket.customer_id
ticket: @ticket
user_id: ticket.customer_id
ticket: ticket
)
# start link info controller
@ -307,9 +309,12 @@ class Widgets extends App.Controller
new App.WidgetLink(
el: @el.find('.link_info')
object_type: 'Ticket'
object: @ticket
object: ticket
)
release: =>
App.Ticket.unsubscribe( @subscribeId )
class Edit extends App.Controller
events:
'click .submit': 'update'
@ -802,15 +807,15 @@ class ActionRow extends App.Controller
history_dialog: (e) ->
e.preventDefault()
new App.TicketHistory( ticket_id: @ticket.id )
new App.TicketHistory( ticket: @ticket )
merge_dialog: (e) ->
e.preventDefault()
new App.TicketMerge( ticket_id: @ticket.id, task_key: @ui.task_key )
new App.TicketMerge( ticket: @ticket, task_key: @ui.task_key )
customer_dialog: (e) ->
e.preventDefault()
new App.TicketCustomer( ticket_id: @ticket.id, ui: @ui )
new App.TicketCustomer( ticket: @ticket )
class TicketZoomRouter extends App.ControllerPermanent
constructor: (params) ->

View file

@ -92,11 +92,11 @@ class ActionRow extends App.Controller
merge_dialog: (e) ->
e.preventDefault()
new App.TicketMerge( ticket_id: @ticket.id, task_key: @ui.task_key )
new App.TicketMerge( ticket: @ticket, task_key: @ui.task_key )
customer_dialog: (e) ->
e.preventDefault()
new App.TicketCustomer( ticket_id: @ticket.id, ui: @ui )
new App.TicketCustomer( ticket: @ticket, ui: @ui )
class Router extends App.ControllerPermanent