improvements

This commit is contained in:
2012-09-06 14:49:22 +02:00
parent 27d7fd304e
commit 161da7a82d
18 changed files with 209 additions and 81 deletions
+30 -17
View File
@@ -12,6 +12,8 @@ window.Quser=
response ||= {}
if response.table_number
$('.table-number').text(response.table_number)
if response.supplier_name
$('.supplier-name').text(response.supplier_name)
Quser.list_needs_payment_default_action()
Quser.list_needs_help_default_action()
# join_request_active is to ensure that there are no more modals loaded when one is still active
@@ -72,24 +74,32 @@ window.Quser=
Quser.handle_active_list_default_actions(res)
body = $('#active-list-table tbody')
foot = $('#active-list-table tfoot')
body.find('tr').remove()
foot.find('tr').remove()
if !res.orders && !res.orders.length
alert('No orders in list')
return
for order in res.orders
order_txts = []
row = $('<tr></tr>').appendTo(body)
row.addClass(order.state)
#if(order.state == 'placed') row.addClass('info');
#if(order.state == 'delivered') row.addClass('success');
row.addClass('error') if order.state == 'cancelled'
for product in order.products
order_txts.push(product.name + ' (' + product['number'] + ')')
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>')
Quser.build_list_table(body, foot, res)
)
load_history_list: (list_id) ->
$.get('/user/list_history/'+list_id+'.json', (res) ->
body = $('#history-list-table tbody')
foot = $('#history-list-table tfoot')
Quser.build_list_table(body, foot, res)
)
build_list_table: (body, foot, res) ->
body.find('tr').remove()
foot.find('tr').remove()
if !res.orders && !res.orders.length
alert('No orders in list')
return
for order in res.orders
order_txts = []
row = $('<tr></tr>').appendTo(body)
row.addClass(order.state)
#if(order.state == 'placed') row.addClass('info');
#if(order.state == 'delivered') row.addClass('success');
row.addClass('error') if order.state == 'cancelled'
for product in order.products
order_txts.push(product.name + ' (' + product['number'] + ')')
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)->
return if $.isEmptyObject(window.active_products_list)
h ||= {}
@@ -133,6 +143,9 @@ window.Quser=
if res.table_number
$('.table-number').text(res.table_number)
delete(res['table_number'])
if res.supplier_name
$('.supplier-name').text(res.supplier_name)
delete(res['supplier_name'])
body.find('tr').remove()
for category, products of res
body.append('<tr><td colspan="4"><h4>'+category+'<h4></td></tr>')