Fixes for event stream and section view actions

This commit is contained in:
2014-07-28 15:13:18 +02:00
parent 2c4c51fe77
commit 48e1850200
17 changed files with 76 additions and 40 deletions
@@ -2,7 +2,7 @@ root = exports ? this
root.Qsupplier=
watch_events: ->
faye = new Faye.Client(event_host)
faye.subscribe "/supplier/"+supplier_id, (e)=>
faye.subscribe "/supplier/#{supplier_id}", (e)=>
console.log "Event: #{e.event}"
console.log e.data
if(e.event == 'new_order')
@@ -14,14 +14,17 @@ root.Qsupplier=
# 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') isnt list
table.set 'active_list', list
, 200
else if(e.event == 'list_needs_help')
if Qsupplier.App and list = Qsupplier.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')
# $('#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)
list.markNeedsPayment()
@@ -34,7 +37,6 @@ root.Qsupplier=
else if e.event == 'list_update'
if Qsupplier.App
list = Qsupplier.App.List.updateOrAdd(e.data.list)
debugger
else if e.event == 'list_closed'
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.markClosed()
@@ -48,10 +50,10 @@ root.Qsupplier=
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.markHelped()
list_id = e.data.id
$('#list-needs-help-indicator-'+list_id).addClass('hide')
$('#list-is-helped-button-'+list_id).addClass('hide')
$('.section-table-list-'+list_id).removeClass('needs_help')
# list_id = e.data.id
# $('#list-needs-help-indicator-'+list_id).addClass('hide')
# $('#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)
order.markActive()