Refactor Qsupplier.App to App
This commit is contained in:
@@ -6,11 +6,11 @@ root.Qsupplier=
|
||||
console.log "Event: #{e.event}"
|
||||
console.log e.data
|
||||
if(e.event == 'new_order')
|
||||
if Qsupplier.App
|
||||
Qsupplier.App.store().pushPayload(e.data)
|
||||
if App
|
||||
App.store().pushPayload(e.data)
|
||||
# Fix for ember pushPayload bug not creating the proper relations/triggers
|
||||
setTimeout ->
|
||||
if order = Qsupplier.App.store().all('order').findProperty('id', e.data.order.id)
|
||||
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
|
||||
@@ -20,35 +20,35 @@ root.Qsupplier=
|
||||
table.set 'active_list', list if table_list isnt list
|
||||
, 200
|
||||
else if(e.event == 'list_needs_help')
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
if App and list = App.List.findCached(e.data.id)
|
||||
list.markNeedsHelp()
|
||||
# old stuff
|
||||
# $('#list-needs-help-indicator-'+e.data.id).removeClass('hide')
|
||||
# $('#list-is-helped-button-'+e.data.id).removeClass('hide')
|
||||
# $('.section-table-list-'+e.data.id).addClass('needs_help')
|
||||
else if(e.event == 'list_needs_payment')
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
if App and list = App.List.findCached(e.data.id)
|
||||
list.markNeedsPayment()
|
||||
# old stuff
|
||||
$('#list-needs-payment-indicator-'+e.data.id).removeClass('hide')
|
||||
$('.section-table-list-'+e.data.id).addClass('needs_payment')
|
||||
else if(e.event == 'list_is_paid')
|
||||
if list = Qsupplier.App.List.findCached(e.data.id)
|
||||
if list = App.List.findCached(e.data.id)
|
||||
list.markIsPaid()
|
||||
else if e.event == 'list_update'
|
||||
if Qsupplier.App
|
||||
list = Qsupplier.App.List.updateOrAdd(e.data.list)
|
||||
if App
|
||||
list = App.List.updateOrAdd(e.data.list)
|
||||
else if e.event == 'list_closed'
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
if App and list = App.List.findCached(e.data.id)
|
||||
list.markClosed()
|
||||
$('.list-row-'+e.data.id).remove()
|
||||
$('.of-list-'+e.data.id).remove()
|
||||
table_list_class = 'section-table-list-'+e.data.id
|
||||
$('.'+table_list_class).removeClass('occupied needs_help needs_payment active_order').removeClass(table_list_class)
|
||||
else if e.event == 'order_closed'
|
||||
order.markClosed() if Qsupplier.App and order = Qsupplier.App.Order.findCached(e.data.id)
|
||||
order.markClosed() if App and order = App.Order.findCached(e.data.id)
|
||||
else if e.event == 'list_helped'
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
if App and list = App.List.findCached(e.data.id)
|
||||
list.markHelped()
|
||||
|
||||
# list_id = e.data.id
|
||||
@@ -56,12 +56,12 @@ root.Qsupplier=
|
||||
# $('#list-is-helped-button-'+list_id).addClass('hide')
|
||||
# $('.section-table-list-'+list_id).removeClass('needs_help')
|
||||
else if e.event == 'order_being_processed'
|
||||
if Qsupplier.App and order = Qsupplier.App.Order.findCached(e.data.id)
|
||||
if App and order = App.Order.findCached(e.data.id)
|
||||
order.markActive()
|
||||
# $('#order-in-process-button-'+e.data.id).hide()
|
||||
# $('.order-row-'+e.data.id).removeClass('placed').addClass('active')
|
||||
else if e.event == 'order_being_delivered'
|
||||
if Qsupplier.App and order = Qsupplier.App.Order.findCached(e.data.id)
|
||||
if App and order = App.Order.findCached(e.data.id)
|
||||
order.markDelivered()
|
||||
# $('.order-row-'+e.data.id).remove()
|
||||
# $('.section-table-list-'+e.data.list_id).removeClass('active_order')
|
||||
@@ -70,9 +70,9 @@ root.Qsupplier=
|
||||
else if e.event == 'orders_placed_count'
|
||||
$('.supplier-orders-placed-count-number').text e.data.count
|
||||
else if e.event == 'list_changed_table'
|
||||
Qsupplier.App && Qsupplier.App.List.updateOrAdd(e.data.list)
|
||||
App && App.List.updateOrAdd(e.data.list)
|
||||
else if e.event == 'order_cancelled'
|
||||
if Qsupplier.App and order = Qsupplier.App.Order.findCached(e.data.id)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user