improvements
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
root = exports ? this
|
||||
data_host = ''
|
||||
root.Qsupplier=
|
||||
move_table_to_active_section: (table_id)->
|
||||
table_container = $('#section-table-'+table_id)
|
||||
@@ -56,7 +57,7 @@ root.Qsupplier=
|
||||
)
|
||||
|
||||
load_active_lists: () ->
|
||||
$.get('/supplier/active_lists.json', (res) ->
|
||||
$.get('/supplier/active_lists.json?section_id='+($('#current_section_selector').val() || ''), (res) ->
|
||||
body = $('#active-lists-table tbody')
|
||||
body.find('tr').remove()
|
||||
foot = $('#active-lists-table tfoot')
|
||||
@@ -84,7 +85,7 @@ root.Qsupplier=
|
||||
icons_td.append('<i class="icon-hand-up"></i>').append(' ') if list.needs_help # or icon-bell
|
||||
icons_td.append('<i class="icon-check"></i>') if list.needs_payment
|
||||
|
||||
row.append($('<td class="numeric"></td>').text(list.table_number))
|
||||
row.append($('<td class="numeric"></td>').append($('<a href="/supplier/lists/'+list._id+'"></a>').text(list.table_number)))
|
||||
row.append($('<td></td>').text(list.section_title))
|
||||
row.append($('<td class="currency"></td>').html(currency(list.total_amount)))
|
||||
td_buttons = $('<td class="actions"></td>')
|
||||
@@ -95,7 +96,7 @@ root.Qsupplier=
|
||||
)
|
||||
|
||||
load_active_orders: () ->
|
||||
$.get('/supplier/active_orders.json', (res) ->
|
||||
$.get('/supplier/active_orders.json?section_id='+($('#current_section_selector').val() || ''), (res) ->
|
||||
body = $('#active-orders-table tbody')
|
||||
body.find('tr').remove()
|
||||
foot = $('#active-orders-table tfoot')
|
||||
@@ -132,3 +133,27 @@ root.Qsupplier=
|
||||
row.append(td_buttons)
|
||||
#foot.append('<tr><td></td><td class="currency"><strong>'+currency(res.total_amount)+'</strong></td></tr>');
|
||||
)
|
||||
load_list: (list_id) ->
|
||||
$.get(data_host + '/supplier/lists/'+list_id+'.json', (res) ->
|
||||
body = $('#list-table tbody')
|
||||
foot = $('#list-table tfoot')
|
||||
Qsupplier.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>')
|
||||
|
||||
@@ -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>')
|
||||
|
||||
@@ -69,5 +69,8 @@ body
|
||||
.order-count-cell
|
||||
white-space: nowrap
|
||||
.page-header
|
||||
.supplier-name
|
||||
float: right
|
||||
margin-right: 8px
|
||||
.table-number
|
||||
float: right
|
||||
|
||||
Reference in New Issue
Block a user