end of day commit for users and suppliers authenticated handling

This commit is contained in:
2012-08-25 15:55:56 +02:00
parent b7c57d41ce
commit e56badcbf8
29 changed files with 435 additions and 582 deletions
+16 -13
View File
@@ -58,9 +58,9 @@ root.Qrammer =
eval(res)
return
window.location = '/' if res['message'] && !res['ok']
window.location = '/view_active_list' if res['ok']
load_active_orders: (supplier_id) ->
$.get('/suppliers/'+supplier_id+'/active_orders.json', (res) ->
window.location = '/user/active_list' if res['ok']
load_active_orders: () ->
$.get('/supplier/active_orders.json', (res) ->
body = $('#active-orders-table tbody')
body.find('tr').remove()
foot = $('#active-orders-table tfoot')
@@ -74,7 +74,7 @@ root.Qrammer =
process_callback = ( (ord) ->
->
my_btn = $(this)
$.post('/orders/'+ord.id+'/is_being_processed', {}, (res)-> my_btn.remove())
$.post('/supplier/mark_order_in_process', {order_id: ord.id}, (res)-> my_btn.remove())
)(order)
process_btn.click(process_callback)
@@ -82,7 +82,7 @@ root.Qrammer =
delivered_callback = ( (ord, r) ->
->
my_btn = $(this)
$.post('/orders/'+ord.id+'/is_delivered', {}, (res)-> r.slideUp('slow'))
$.post('/supplier/order_is_delivered', {order_id: ord.id}, (res)-> r.slideUp('slow'))
)(order, row)
delivered_btn.click(delivered_callback)
for product in order.products
@@ -98,7 +98,7 @@ root.Qrammer =
)
handle_active_user_list: (callback) ->
$.get('/user_list_info.json', (res) ->
$.get('/user/list_info.json', (res) ->
if !res.list_active
window.location = '/phone_home?list_closed=true'
return
@@ -118,7 +118,7 @@ root.Qrammer =
needs_help_container.html($('<button class="btn btn-info">I have a question</button>').click(Qrammer.list_needs_help)) #TODO TEXT
list_needs_help: ->
return unless window.active_list && !window.active_list.needs_help
$.post('/active_user_list_needs_help.json', (res) -> window.active_list = res; Qrammer.list_needs_help_default_action())
$.post('/user/needs_help.json', (res) -> window.active_list = res; Qrammer.list_needs_help_default_action())
list_needs_payment_default_action: ->
needs_payment_container = $('#list-needs-payment-button')
if needs_payment_container.length
@@ -128,10 +128,10 @@ root.Qrammer =
needs_payment_container.html($('<button class="btn btn-warning">Check please</button>').click(Qrammer.list_needs_payment)) #TODO TEXT
list_needs_payment: ->
return unless window.active_list && !window.active_list.needs_payment
$.post('/active_user_list_needs_payment.json', (res) -> window.active_list = res; Qrammer.list_needs_payment_default_action())
$.post('/user/list_needs_payment.json', (res) -> window.active_list = res; Qrammer.list_needs_payment_default_action())
load_active_lists: (supplier_id) ->
$.get('/suppliers/'+supplier_id+'/active_lists.json', (res) ->
load_active_lists: () ->
$.get('/supplier/active_lists.json', (res) ->
body = $('#active-lists-table tbody')
body.find('tr').remove()
foot = $('#active-lists-table tfoot')
@@ -142,7 +142,7 @@ root.Qrammer =
close_callback = ( (lst, r) ->
->
my_btn = $(this)
$.post('/lists/'+lst._id+'/is_closed', {}, (res)-> r.slideUp('slow'))
$.post('/supplier/close_list', {list_id: list._id}, (res)-> r.slideUp('slow'))
)(list, row)
close_btn.click(close_callback)
@@ -150,7 +150,7 @@ root.Qrammer =
needs_help_callback = ( (lst, r) ->
->
my_btn = $(this)
$.post('/lists/'+lst._id+'/is_helped', {}, (res)-> my_btn.remove() )
$.post('/supplier/mark_list_as_helped', {list_id: list._id}, (res)-> my_btn.remove() )
)(list, row)
needs_help_btn.click(needs_help_callback)
@@ -168,8 +168,11 @@ root.Qrammer =
#foot.append('<tr><td></td><td class="currency"><strong>'+Qrammer.currency(res.total_amount)+'</strong></td></tr>');
)
active_user_list: (list_id) ->
$.get('/lists/'+list_id+'/current.json', (res) ->
$.get('/user/active_list.json', (res) ->
window.active_list = res
unless res.list_active
window.location = '/user/list_history/'+res._id + '?list_closed=true'
return
Qrammer.handle_active_user_list_default_actions()
body = $('#active-list-table tbody')
foot = $('#active-list-table tfoot')