Everything is green
This commit is contained in:
@@ -6,27 +6,33 @@ root.Qsupplier=
|
||||
<% if Rails.env.test? %>
|
||||
window.faye_log ||= []
|
||||
faye_message = {}
|
||||
faye_message[e.event] = e.data
|
||||
faye_message[e.event] = JSON.parse(JSON.stringify(e.data))
|
||||
faye_log.push faye_message
|
||||
<% elsif Rails.env.development? %>
|
||||
console.log "Event: #{e.event}"
|
||||
console.log e.data
|
||||
<% end %>
|
||||
if(e.event == 'new_order')
|
||||
if App
|
||||
App.store().pushPayload(e.data)
|
||||
# Fix for ember pushPayload bug not creating the proper relations/triggers
|
||||
setTimeout ->
|
||||
if order = App.store().all('order').findProperty('id', e.data.order.id)
|
||||
# console.log "Ugly ember fix for adding order #{e.data.order.id} as relation to its list"
|
||||
list = order.get('list')
|
||||
list.get('orders').addRecord order
|
||||
if table = list.get('table')
|
||||
if table.get('active_list')
|
||||
table.get('active_list').then (table_list)->
|
||||
table.set 'active_list', list if table_list isnt list
|
||||
, 200
|
||||
else if(e.event == 'list_needs_help')
|
||||
if e.data
|
||||
if e.data.supplier_orders_placed_count == 0 or e.data.supplier_orders_placed_count
|
||||
$('.supplier-orders-placed-count-number').text(e.data.supplier_orders_placed_count)
|
||||
if e.data.supplier_orders_in_process_count == 0 or e.data.supplier_orders_in_process_count
|
||||
$('.supplier-orders-in-process-count-number').text(e.data.supplier_orders_in_process_count)
|
||||
|
||||
# if(e.event == 'new_order')
|
||||
# if App
|
||||
# App.store().pushPayload(e.data)
|
||||
# # Fix for ember pushPayload bug not creating the proper relations/triggers
|
||||
# setTimeout ->
|
||||
# if order = App.store().all('order').findProperty('id', e.data.order.id)
|
||||
# # console.log "Ugly ember fix for adding order #{e.data.order.id} as relation to its list"
|
||||
# list = order.get('list')
|
||||
# list.get('orders').addRecord order
|
||||
# if table = list.get('table')
|
||||
# if table.get('active_list')
|
||||
# table.get('active_list').then (table_list)->
|
||||
# table.set 'active_list', list if table_list isnt list
|
||||
# , 200
|
||||
if(e.event == 'list_needs_help')
|
||||
if App and list = App.List.findCached(e.data.id)
|
||||
list.markNeedsHelp()
|
||||
# old stuff
|
||||
@@ -43,8 +49,12 @@ root.Qsupplier=
|
||||
if list = App.List.findCached(e.data.id)
|
||||
list.markIsPaid()
|
||||
else if e.event == 'list_update'
|
||||
if App
|
||||
list = App.List.updateOrAdd(e.data.list)
|
||||
App.store().pushPayload('list', e.data)
|
||||
App.store().findById('list', e.data.list.id).then (list)->
|
||||
list.get('table').then (table)->table.set('active_list', list)
|
||||
|
||||
# if App
|
||||
# list = App.List.updateOrAdd(e.data.list)
|
||||
else if e.event == 'list_closed'
|
||||
if App and list = App.List.findCached(e.data.id)
|
||||
list.markClosed()
|
||||
@@ -89,8 +99,6 @@ root.Qsupplier=
|
||||
else if e.event == 'order_cancelled'
|
||||
if App and order = App.Order.findCached(e.data.id)
|
||||
order.markCancelled()
|
||||
$('.supplier-orders-placed-count-number').text(e.data.orders_placed_count) if e.data.orders_placed_count == 0 or e.data.orders_placed_count
|
||||
$('.supplier-orders-in-process-count-number').text(e.data.orders_in_process_count) if e.data.orders_in_process_count == 0 or e.data.orders_in_process_count
|
||||
|
||||
|
||||
# old stuff
|
||||
|
||||
Reference in New Issue
Block a user