Qwaiter supplier on Ember 1.0

This commit is contained in:
2013-09-30 17:49:22 +02:00
parent 6d7647c2c5
commit 8ea2e79dc2
44 changed files with 378 additions and 156 deletions
@@ -4,7 +4,7 @@ root.Qsupplier=
faye = new Faye.Client(event_host)
faye.subscribe "/supplier/"+supplier_id, (e)=>
if(e.event == 'new_order')
Qsupplier.App.Order.create(e.data.order)
Qsupplier.App.Order.pushByAttriburtes(e.data.order) if Qsupplier.App
# old stuff
body = $('#active-orders-table tbody')
order = new Order(e.data.order)
@@ -12,14 +12,14 @@ root.Qsupplier=
body.append @mustache('#active-order-template', order)
$('.section-table-list-'+order.list_id()).addClass('active_order')
else if(e.event == 'list_needs_help')
if list = Qsupplier.App.List.findCached(e.data.id)
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.set('needs_help', true)
# 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 list = Qsupplier.App.List.findCached(e.data.id)
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.set('needs_payment', true)
# old stuff
$('#list-needs-payment-indicator-'+e.data.id).removeClass('hide')
@@ -28,10 +28,10 @@ root.Qsupplier=
if list = Qsupplier.App.List.findCached(e.data.id)
list.set('needs_payment', false)
else if e.event == 'list_update'
Qsupplier.App.List.updateOrCreate(e.data.list)
Qsupplier.App.List.updateOrAdd(e.data.list) if Qsupplier.App
# old stuff
list = new List(e.data.list)
row = $('#list-row-'+list.id())
row = $('#active-lists-table .list-row-'+list.id())
content = @mustache('#active-list-template', list)
if row.length then row.replaceWith(content) else $('#active-lists-table tbody').append(content)
table = $('#section-table-'+list.table_id())
@@ -42,15 +42,14 @@ root.Qsupplier=
table.addClass('needs_payment') if list.needs_payment()
table.addClass('active_order') if list.has_active_orders()
else if e.event == 'list_closed'
if list = Qsupplier.App.List.findCached(e.data.id)
list.set('table', null)
list.set('state', 'closed')
$('#list-row-'+e.data.id).remove()
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.close()
$('.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 == 'list_helped'
if list = Qsupplier.App.List.findCached(e.data.id)
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.set('needs_help', false)
list_id = e.data.id
$('#list-needs-help-indicator-'+list_id).addClass('hide')
@@ -58,13 +57,13 @@ root.Qsupplier=
$('.section-table-list-'+list_id).removeClass('needs_help')
else if e.event == 'order_being_processed'
$('#order-in-process-button-'+e.data.id).hide()
$('#order-row-'+e.data.id).removeClass('placed').addClass('active')
$('.order-row-'+e.data.id).removeClass('placed').addClass('active')
else if e.event == 'order_being_delivered'
$('#order-row-'+e.data.id).remove()
$('.order-row-'+e.data.id).remove()
$('.section-table-list-'+e.data.list_id).removeClass('active_order')
else if e.event == 'list_changed_table'
list = new List(e.data.list)
list_row = $('#list-row-'+list.id())
list_row = $('.list-row-'+list.id())
list_row.find('.table_number').text(list.table_number()).addClass('changed')
list_row.find('.section_title').text(e.data.section_title)
order_rows = $('.of-list-'+list.id())