table management fixes

This commit is contained in:
2013-01-12 13:34:00 +01:00
parent f6b28f84f0
commit b02951aaec
17 changed files with 164 additions and 76 deletions
@@ -134,10 +134,8 @@ root.Qsupplier=
Qsupplier.build_list_table(body, foot, res)
)
build_list_table: (body, foot, res) ->
if !res.orders && !res.orders.length
alert('No orders in list')
return
body.html('')
return unless res.orders
for order in res.orders
body.append @mustache('#list-order-template', new Order(order))
foot.find('.list-total').html(currency(res.total_amount))
@@ -160,10 +158,11 @@ root.Qsupplier=
by_row_count = parseInt($('#arrange-tables-by-row-count').val())
by_column_count = parseInt($('#arrange-tables-by-column-count').val())
if(option == "by_row")
return alert('Please fill in a positive number representing the number of tables per row') unless by_row_count && by_row_count > 0
return @alert(t('section.arrange_tables.by_row_no_row_count')) unless by_row_count && by_row_count > 0
if(option == "by_column")
return alert('Please fill in a positive number representing the number of tables per column') unless by_column_count && by_column_count > 0
$.post('/supplier/sections/'+current_section_id+'/arrange_tables', {option: option, row_count: by_row_count, column_count: by_column_count}, -> window.location.reload())
return @alert(t('section.arrange_tables.by_column_no_column_count')) unless by_column_count && by_column_count > 0
$.post '/supplier/sections/'+current_section_id+'/arrange_tables', {option: option, row_count: by_row_count, column_count: by_column_count}, (response)=>
if response.ok then window.location.reload() else @alert(t(response.message))
false
mustache: (selector, locals)->
locs = $.extend(locals,
@@ -172,3 +171,4 @@ root.Qsupplier=
currency(Mustache.render(val, this))
)
Mustache.to_html($(selector).html(), locs)
alert: Qwaiter.alert