move to evented mustache system
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
//= require twitter/bootstrap/bootstrap-typeahead
|
||||
//= require twitter/bootstrap/bootstrap-affix
|
||||
//= require qwaiter
|
||||
//= require supplier/order
|
||||
//= require mustache
|
||||
//= require_directory .
|
||||
//= require_self
|
||||
|
||||
@@ -11,11 +11,19 @@ class Quser
|
||||
formatted
|
||||
watch_events: ->
|
||||
faye = new Faye.Client('http://localhost:9292/faye')
|
||||
faye.subscribe "/user/"+QMobile.user_id(), (e)->
|
||||
debugger
|
||||
faye.subscribe "/user/"+QMobile.user_id(), (e)=>
|
||||
if(e.event == 'list_closed')
|
||||
redirect_to 'user_root', {list_closed: 'true'}
|
||||
console.log(data)
|
||||
#redirect_to 'user_root', {list_closed: 'true'}
|
||||
redirect_to 'history_list', {list_id: e.data.id, list_closed: true}
|
||||
if(e.event == 'list_helped')
|
||||
window.active_list.needs_help = false
|
||||
@list_needs_help_default_action()
|
||||
if(e.event == 'order_being_processed')
|
||||
$('#order-row-'+e.data.id).addClass('active')
|
||||
if(e.event == 'order_being_delivered')
|
||||
$('#order-row-'+e.data.id).addClass('delivered')
|
||||
console.log(e)
|
||||
false
|
||||
home_loader: ->
|
||||
$.getJSON(data_host + '/user/list_info.json?' + authentication_string, (res) => @handle_active_list_default_actions(res))
|
||||
handle_active_list: (callback) ->
|
||||
@@ -34,14 +42,12 @@ class Quser
|
||||
if(response.ok == false && response.status && response.status == 401)
|
||||
direct_to_site('obtain_user_token')
|
||||
return
|
||||
if response.table_number
|
||||
$('.table-number').text(response.table_number)
|
||||
if response.supplier_name
|
||||
$('.supplier-name').text(response.supplier_name)
|
||||
if response.not_present
|
||||
$('.home-link').hide()
|
||||
else
|
||||
$('.home-link').show()
|
||||
|
||||
$('.table-number').text(response.table_number) if response.table_number
|
||||
$('.supplier-name').text(response.supplier_name) if response.supplier_name
|
||||
|
||||
if response.not_present || response.list_active == false then $('.home-link').hide() else $('.home-link').show()
|
||||
|
||||
@list_needs_payment_default_action(response)
|
||||
@list_needs_help_default_action(response)
|
||||
# join_request_active is to ensure that there are no more modals loaded when one is still active
|
||||
@@ -126,9 +132,9 @@ class Quser
|
||||
$.post(data_host + '/user/list_needs_payment.json', authentication_object, (res) => window.active_list = res; window.Quser.list_needs_payment_default_action(res))
|
||||
load_active_list: () ->
|
||||
$.getJSON(data_host + '/user/active_list.json?'+authentication_string, (res) =>
|
||||
window.active_list = res
|
||||
window.active_list = res if res._id
|
||||
unless res.list_active
|
||||
redirect_to 'history_list', {list_id: res._id, list_closed: true}
|
||||
redirect_to 'history_list', {list_id: window.active_list._id, list_closed: true}
|
||||
return
|
||||
@handle_active_list_default_actions(res)
|
||||
body = $('#active-list-table tbody')
|
||||
@@ -146,6 +152,7 @@ class Quser
|
||||
foot = $('#history-list-table tfoot')
|
||||
@build_list_table(body, foot, res)
|
||||
$('.list-created-at').text(@format_date(res.created_at))
|
||||
$('.list-closed-at').text(@format_date(res.closed_at))
|
||||
$('.supplier-name').text(res.supplier_name)
|
||||
)
|
||||
load_list_history: ->
|
||||
@@ -196,12 +203,7 @@ class Quser
|
||||
alert('No orders in list')
|
||||
return
|
||||
m_obj = res
|
||||
for order in m_obj.orders
|
||||
order_txts = []
|
||||
for product in order.products
|
||||
order_txts.push(product.name + ' (' + product['number'] + ')')
|
||||
order.products_display = order_txts.join(', ')
|
||||
body.append @mustache('#active-list-orders-template', m_obj)
|
||||
body.append @mustache('#active-list-order-template', new Order(order)) for order in m_obj.orders
|
||||
foot.append @mustache('#active-list-orders-footer-template', m_obj)
|
||||
|
||||
order_selected_products: ()->
|
||||
@@ -211,7 +213,6 @@ class Quser
|
||||
h['table_id'] = match[1] if match
|
||||
for product_id, number of window.active_products_list
|
||||
h['products['+product_id+']'] = number
|
||||
debugger
|
||||
$.post(data_host + '/user/order_selected_products', $.extend(h, authentication_object), ((res) => @handle_response(res)), 'json')
|
||||
handle_response: (res) ->
|
||||
if(typeof(res) == 'string')
|
||||
|
||||
Reference in New Issue
Block a user