User foundation setup

This commit is contained in:
2014-03-26 13:17:34 +01:00
parent 6c2427e082
commit 4e75c72097
87 changed files with 861 additions and 120 deletions
@@ -3,14 +3,9 @@ root.Qsupplier=
watch_events: ->
faye = new Faye.Client(event_host)
faye.subscribe "/supplier/"+supplier_id, (e)=>
console.log(e)
if(e.event == 'new_order')
Qsupplier.App.Order.pushByAttriburtes(e.data.order) if Qsupplier.App
# old stuff
body = $('#active-orders-table tbody')
order = new Order(e.data.order)
if body.length
body.append @mustache('#active-order-template', order)
$('.section-table-list-'+order.list_id()).addClass('active_order')
else if(e.event == 'list_needs_help')
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.markNeedsHelp()
@@ -29,18 +24,6 @@ root.Qsupplier=
list.markIsPaid()
else if e.event == 'list_update'
Qsupplier.App.List.updateOrAdd(e.data.list) if Qsupplier.App
# old stuff
list = new List(e.data.list)
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())
if table.length
table.addClass('section-table-list-'+list.id())
table.addClass('occupied')
table.addClass('needs_help') if list.needs_help()
table.addClass('needs_payment') if list.needs_payment()
table.addClass('active_order') if list.has_active_orders()
else if e.event == 'list_closed'
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
list.markClosed()
@@ -68,26 +51,24 @@ root.Qsupplier=
Qsupplier.App && Qsupplier.App.List.updateOrAdd(e.data.list)
# old stuff
list = new List(e.data.list)
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())
order_rows.find('.table_number').text(list.table_number()).addClass('changed')
order_rows.find('.section_title').text(e.data.section_title)
# Move properties from table in section tables view
window.last_data = e.data
from_table = $('#section-table-'+e.data.from_table_id)
to_table = $('#section-table-'+list.table_id())
if to_table.length
to_table.addClass('section-table-list-'+list.id())
to_table.addClass('occupied')
to_table.addClass('needs_help') if list.needs_help()
to_table.addClass('needs_payment') if list.needs_payment()
to_table.addClass('active_order') if list.has_active_orders()
from_table.removeClass('occupied needs_help needs_payment active_order section-table-list-'+list.id())
#list = new List(e.data.list)
#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())
#order_rows.find('.table_number').text(list.table_number()).addClass('changed')
#order_rows.find('.section_title').text(e.data.section_title)
## Move properties from table in section tables view
#window.last_data = e.data
#from_table = $('#section-table-'+e.data.from_table_id)
#to_table = $('#section-table-'+list.table_id())
#if to_table.length
#to_table.addClass('section-table-list-'+list.id())
#to_table.addClass('occupied')
#to_table.addClass('needs_help') if list.needs_help()
#to_table.addClass('needs_payment') if list.needs_payment()
#to_table.addClass('active_order') if list.has_active_orders()
#from_table.removeClass('occupied needs_help needs_payment active_order section-table-list-'+list.id())
console.log(e)
false
move_table_to_active_section: (table_id)->