seperate rails logic for parameters for showing products
This commit is contained in:
@@ -136,9 +136,11 @@ window.Quser=
|
||||
row.append($('<td></td>').text(order_txts.join(', ')))
|
||||
row.append($('<td class="currency"></td>').html(currency(order.total_amount)))
|
||||
foot.append('<tr><td></td><td class="currency"><strong>'+currency(res.total_amount)+'</strong></td></tr>')
|
||||
order_selected_products: (h)->
|
||||
order_selected_products: ()->
|
||||
return if $.isEmptyObject(window.active_products_list)
|
||||
h ||= {}
|
||||
h = {}
|
||||
match = window.document.URL.toString().match('table_id=([0-9a-zA-Z]+)')
|
||||
h['table_id'] = match[1] if match
|
||||
for product_id, info of window.active_products_list
|
||||
h['products['+product_id+']'] = info.number
|
||||
$.post(data_host + '/user/order_selected_products', h, ((res) -> Quser.handle_response(res)), 'json')
|
||||
@@ -170,11 +172,23 @@ window.Quser=
|
||||
table.show()
|
||||
|
||||
load_active_list_products: ->
|
||||
Quser.populate_products_table('/user/list_products.json', true)
|
||||
load_table_products: (table_id, occupied)->
|
||||
Quser.populate_products_table('/user/list_products_for_table.json?table_id='+table_id, !occupied)
|
||||
populate_products_table: (src, include_order_buttons)->
|
||||
Quser.populate_products_table('/user/list_products.json')
|
||||
load_table_products: ->
|
||||
match = window.document.URL.toString().match('table_id=([0-9a-zA-Z]+)')
|
||||
if match
|
||||
table_id = match[1]
|
||||
else
|
||||
redirect_to 'user_root', {message: 'cannot_identify_table'}
|
||||
return
|
||||
Quser.populate_products_table('/user/list_products_for_table.json?table_id='+table_id)
|
||||
populate_products_table: (src)->
|
||||
$.get(data_host + src, (res) ->
|
||||
if res.has_occupied_info
|
||||
include_order_buttons = !res.is_occupied
|
||||
delete(res['has_occupied_info'])
|
||||
delete(res['is_occupied'])
|
||||
else
|
||||
include_order_buttons = true
|
||||
body = $('#products-table tbody')
|
||||
if res.table_number
|
||||
$('.table-number').text(res.table_number)
|
||||
|
||||
Reference in New Issue
Block a user