move towards mobile deployable app
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
data_host = ''
|
||||
data_host = window.data_host
|
||||
root_url = window.root_url
|
||||
window.Quser=
|
||||
format_date: (utc) ->
|
||||
formatted = ''
|
||||
formatted += utc.substr(0,10)
|
||||
formatted += ' '
|
||||
formatted += utc.substr(11, 5)
|
||||
formatted
|
||||
home_loader: ->
|
||||
$.getJSON(data_host + '/user/list_info.json', (res) -> Quser.handle_active_list_default_actions(res))
|
||||
handle_active_list: (callback) ->
|
||||
$.get(data_host + '/user/list_info.json', (res) ->
|
||||
$.getJSON(data_host + '/user/list_info.json', (res) ->
|
||||
if !res.list_active
|
||||
redirect_to 'user_root', {list_closed: 'true'}
|
||||
return
|
||||
@@ -15,6 +24,10 @@ window.Quser=
|
||||
$('.table-number').text(response.table_number)
|
||||
if response.supplier_name
|
||||
$('.supplier-name').text(response.supplier_name)
|
||||
if response.not_present
|
||||
$('.home-link').hide()
|
||||
else
|
||||
$('.home-link').show()
|
||||
Quser.list_needs_payment_default_action(response)
|
||||
Quser.list_needs_help_default_action(response)
|
||||
# join_request_active is to ensure that there are no more modals loaded when one is still active
|
||||
@@ -98,10 +111,10 @@ window.Quser=
|
||||
return unless window.active_list && !window.active_list.needs_payment
|
||||
$.post(data_host + '/user/list_needs_payment.json', (res) -> window.active_list = res; Quser.list_needs_payment_default_action(res))
|
||||
load_active_list: () ->
|
||||
$.get(data_host + '/user/active_list.json', (res) ->
|
||||
$.getJSON(data_host + '/user/active_list.json', (res) ->
|
||||
window.active_list = res
|
||||
unless res.list_active
|
||||
window.location = '/user/list_history/'+res._id + '.html?list_closed=true'
|
||||
window.location = root_url + '/user/list_history/'+res._id + '.html?list_closed=true'
|
||||
return
|
||||
Quser.handle_active_list_default_actions(res)
|
||||
body = $('#active-list-table tbody')
|
||||
@@ -109,15 +122,17 @@ window.Quser=
|
||||
Quser.build_list_table(body, foot, res)
|
||||
)
|
||||
load_history_list: () ->
|
||||
match = window.document.URL.toString().match('([0-9a-zA-Z]+)(\\?|$)')
|
||||
match = window.document.URL.toString().match('([0-9a-zA-Z]+)(.html)?(\\?|$)')
|
||||
if match
|
||||
list_id = match[1]
|
||||
else
|
||||
return
|
||||
$.get(data_host + '/user/list_history/'+list_id+'.json', (res) ->
|
||||
$.getJSON(data_host + '/user/list_history/'+list_id+'.json', (res) ->
|
||||
body = $('#history-list-table tbody')
|
||||
foot = $('#history-list-table tfoot')
|
||||
Quser.build_list_table(body, foot, res)
|
||||
$('.list-created-at').text(Quser.format_date(res.created_at))
|
||||
$('.supplier-name').text(res.supplier_name)
|
||||
)
|
||||
load_list_history: ->
|
||||
match = window.document.URL.toString().match('page=([0-9]+)')
|
||||
@@ -125,7 +140,7 @@ window.Quser=
|
||||
page = match[1]
|
||||
else
|
||||
page = 1
|
||||
$.get(data_host + '/user/list_history.json?page='+page, (res) ->
|
||||
$.getJSON(data_host + '/user/list_history.json?page='+page, (res) ->
|
||||
Quser.paginate(res, '/user/list_history.html')
|
||||
container = $('#list-history-container')
|
||||
for list in res.lists
|
||||
@@ -134,9 +149,7 @@ window.Quser=
|
||||
link.attr('href', '/user/list_history/'+list._id + '.html')
|
||||
txt = list.supplier_name
|
||||
txt += ' - '
|
||||
txt += list.created_at.substr(0,10)
|
||||
txt += ' '
|
||||
txt += list.created_at.substr(11, 5)
|
||||
txt += Quser.format_date(list.created_at)
|
||||
link.text(txt)
|
||||
)
|
||||
paginate: (wrapper, src) ->
|
||||
@@ -222,7 +235,7 @@ window.Quser=
|
||||
return
|
||||
Quser.populate_products_table('/user/list_products_for_table.json?table_id='+table_id)
|
||||
populate_products_table: (src)->
|
||||
$.get(data_host + src, (res) ->
|
||||
$.getJSON(data_host + src, (res) ->
|
||||
if res.has_occupied_info
|
||||
include_order_buttons = !res.is_occupied
|
||||
delete(res['has_occupied_info'])
|
||||
@@ -272,7 +285,7 @@ window.Quser=
|
||||
)
|
||||
actions_for_table: (table)->
|
||||
table = JSON.parse(table) if typeof(table) == 'string'
|
||||
$.get(data_host + '/user/table_info.json?table_id='+table.table_id, (res)->
|
||||
$.getJSON(data_host + '/user/table_info.json?table_id='+table.table_id, (res)->
|
||||
if res.current_table_id
|
||||
if res.other_supplier
|
||||
redirect_to 'user_root', {message: 'table_is_from_other_supplier'}
|
||||
|
||||
Reference in New Issue
Block a user