Improved userTicketPopups feature.
This commit is contained in:
parent
f023a34d76
commit
8db7b51c32
1 changed files with 55 additions and 40 deletions
|
@ -385,23 +385,12 @@ class App.Controller extends Spine.Controller
|
|||
)
|
||||
)
|
||||
|
||||
userTicketPopups: (data) ->
|
||||
userTicketPopups: (params) ->
|
||||
|
||||
# remove old popovers
|
||||
$('.popover').remove()
|
||||
|
||||
# get data
|
||||
tickets = {}
|
||||
App.Ajax.request(
|
||||
type: 'GET',
|
||||
url: @Config.get('api_path') + '/ticket_customer',
|
||||
data: {
|
||||
customer_id: data.user_id,
|
||||
}
|
||||
processData: true,
|
||||
success: (data, status, xhr) =>
|
||||
tickets = data.tickets
|
||||
)
|
||||
show = (data, tickets) =>
|
||||
|
||||
if !data.position
|
||||
data.position = 'left'
|
||||
|
@ -431,6 +420,32 @@ class App.Controller extends Spine.Controller
|
|||
)
|
||||
)
|
||||
|
||||
fetch = (params) =>
|
||||
@ajax(
|
||||
type: 'GET',
|
||||
url: @Config.get('api_path') + '/ticket_customer',
|
||||
data: {
|
||||
customer_id: params.user_id,
|
||||
}
|
||||
processData: true,
|
||||
success: (data, status, xhr) =>
|
||||
App.Store.write( "user-ticket-popover::#{params.user_id}", data.tickets )
|
||||
show( params, data.tickets )
|
||||
)
|
||||
|
||||
# get data
|
||||
tickets = App.Store.get( "user-ticket-popover::#{params.user_id}" )
|
||||
if tickets
|
||||
show( params, tickets )
|
||||
@delay(
|
||||
=>
|
||||
fetch(params)
|
||||
1000
|
||||
'fetch'
|
||||
)
|
||||
else
|
||||
fetch(params)
|
||||
|
||||
ws_send: (data) ->
|
||||
App.Event.trigger( 'ws:send', JSON.stringify(data) )
|
||||
|
||||
|
|
Loading…
Reference in a new issue