Better speccing and cleanup in between commit
This commit is contained in:
@@ -72,7 +72,15 @@ root.Qsupplier=
|
|||||||
else if e.event == 'orders_placed_count'
|
else if e.event == 'orders_placed_count'
|
||||||
$('.supplier-orders-placed-count-number').text e.data.count
|
$('.supplier-orders-placed-count-number').text e.data.count
|
||||||
else if e.event == 'list_changed_table'
|
else if e.event == 'list_changed_table'
|
||||||
App && App.List.updateOrAdd(e.data.list)
|
# App && App.List.updateOrAdd(e.data.list)
|
||||||
|
# App.store().update 'list', e.data.list
|
||||||
|
#TODO: waiting for single source of truth
|
||||||
|
if list = App.List.findCached(e.data.list.id)
|
||||||
|
list.get('table').set('active_list', null)
|
||||||
|
App.store().findById('table', e.data.list.table_id).then (new_table)->
|
||||||
|
list.set('table', new_table)
|
||||||
|
new_table.set('active_list', list) # making reverse association
|
||||||
|
|
||||||
else if e.event == 'order_cancelled'
|
else if e.event == 'order_cancelled'
|
||||||
if App and order = App.Order.findCached(e.data.id)
|
if App and order = App.Order.findCached(e.data.id)
|
||||||
order.markCancelled()
|
order.markCancelled()
|
||||||
|
|||||||
@@ -6,6 +6,5 @@
|
|||||||
#= require_directory ./modifications
|
#= require_directory ./modifications
|
||||||
#= require ./app
|
#= require ./app
|
||||||
#= require_directory ./modules
|
#= require_directory ./modules
|
||||||
#= require user/quser
|
|
||||||
#= require_tree .
|
#= require_tree .
|
||||||
@EmberENV = {FEATURES: {'query-params-new': true}}
|
@EmberENV = {FEATURES: {'query-params-new': true}}
|
||||||
|
|||||||
@@ -1,413 +0,0 @@
|
|||||||
#authentication_string = QMobile.authentication_string()
|
|
||||||
#authentication_object = $.parseJSON(QMobile.authentication_object())
|
|
||||||
class Quser
|
|
||||||
format_date: (utc) ->
|
|
||||||
formatted = ''
|
|
||||||
formatted += utc.substr(0,10)
|
|
||||||
formatted += ' '
|
|
||||||
formatted += utc.substr(11, 5)
|
|
||||||
formatted
|
|
||||||
watch_events: ->
|
|
||||||
return if window.redirecting
|
|
||||||
faye = new Faye.Client(event_host)
|
|
||||||
user_id = Qstorage.getItem('user_id')
|
|
||||||
unless user_id
|
|
||||||
@reset_user()
|
|
||||||
redirect_to 'obtain_token'
|
|
||||||
return false
|
|
||||||
faye.subscribe "/user/"+user_id, (e)=>
|
|
||||||
if(e.event == 'list_closed')
|
|
||||||
#redirect_to 'user_root', {list_closed: 'true'}
|
|
||||||
redirect_to 'history_list', {list_id: e.data.id, list_closed: true}
|
|
||||||
else if(e.event == 'list_helped')
|
|
||||||
window.active_list.needs_help = false
|
|
||||||
@list_needs_help_default_action()
|
|
||||||
else if(e.event == 'order_being_processed')
|
|
||||||
$('.order-row-'+e.data.id).addClass('active')
|
|
||||||
else if(e.event == 'order_being_delivered')
|
|
||||||
$('.order-row-'+e.data.id).addClass('delivered')
|
|
||||||
else if(e.event == 'list_changed_table')
|
|
||||||
list = new List(e.data.list)
|
|
||||||
$('.table-number').text(list.table_number())
|
|
||||||
else if(e.event == 'list_needs_help')
|
|
||||||
window.active_list.needs_help = true
|
|
||||||
@list_needs_help_default_action()
|
|
||||||
else if(e.event == 'list_needs_payment')
|
|
||||||
window.active_list.needs_payment = true
|
|
||||||
@list_needs_payment_default_action()
|
|
||||||
else if(e.event == 'user_join_request')
|
|
||||||
@show_join_request(e.data)
|
|
||||||
else if(e.event == 'join_request_approved')
|
|
||||||
redirect_to 'list_products', message: 'join_request_approved'
|
|
||||||
else if(e.event == 'join_request_rejected')
|
|
||||||
redirect_to 'user_root', message: 'join_request_rejected'
|
|
||||||
else if(e.event == 'new_order')
|
|
||||||
$('#active-list-table tbody').append @mustache('#active-list-order-template', new Order(e.data.order))
|
|
||||||
$('.list-total-amount').html(currency(e.data.total_amount))
|
|
||||||
else if(e.event == 'orders_in_process_count')
|
|
||||||
$('.supplier-orders-in-process-count').text(e.data.count || 0)
|
|
||||||
else if(e.event == 'orders_placed_count')
|
|
||||||
$('.supplier-orders-placed-count').text(e.data.count || 0)
|
|
||||||
console.log(e)
|
|
||||||
false
|
|
||||||
ensure_json: (res)->
|
|
||||||
if typeof(res) == 'string' then JSON.parse(res) else res
|
|
||||||
reset_user: ->
|
|
||||||
Qstorage.removeItem('auth_token')
|
|
||||||
Qstorage.removeItem('user_id')
|
|
||||||
authenticate_user: ->
|
|
||||||
email = $('#user-email')
|
|
||||||
password = $('#user-password')
|
|
||||||
return unless email.length && password.length
|
|
||||||
return email.focus() unless email.val() && email.val().length > 0
|
|
||||||
return password.focus() unless password.val() && password.val().length > 0
|
|
||||||
$.post(data_host + '/user/obtain_token.json', {"user[email]": email.val(), "user[password]": password.val()}, (res)=>
|
|
||||||
res = @ensure_json(res)
|
|
||||||
if res.auth_token
|
|
||||||
Qstorage.setItem('auth_token', res.auth_token)
|
|
||||||
Qstorage.setItem('user_id', res.user_id)
|
|
||||||
redirect_to 'user_root'
|
|
||||||
else
|
|
||||||
$('.user-alert').html(t('obtain_token.invalid_combination')).show()
|
|
||||||
)
|
|
||||||
|
|
||||||
false
|
|
||||||
ensure_token: (callback)->
|
|
||||||
unless Qstorage.getItem('auth_token') && typeof(Qstorage.getItem('auth_token')) == 'string' && Qstorage.getItem('auth_token').length > 0
|
|
||||||
return redirect_to('obtain_token')
|
|
||||||
@authentication_string = 'auth_token='+Qstorage.getItem('auth_token')
|
|
||||||
@authentication_object = {auth_token: Qstorage.getItem('auth_token')}
|
|
||||||
callback.call() if callback
|
|
||||||
home_loader: ->
|
|
||||||
@ensure_token =>
|
|
||||||
$.getJSON(data_host + '/user/list_info.json', @authentication_object, (res) => @handle_active_list_default_actions(res))
|
|
||||||
handle_active_list: (callback) ->
|
|
||||||
@ensure_token =>
|
|
||||||
$.getJSON(data_host + '/user/list_info.json', @authentication_object, (res) =>
|
|
||||||
if(res.ok == false && res.status && res.status == 401)
|
|
||||||
redirect_to('obtain_token')
|
|
||||||
else if !res.list_active
|
|
||||||
redirect_to 'user_root', {list_closed: 'true'}
|
|
||||||
return
|
|
||||||
window.active_list = res
|
|
||||||
callback.call() if callback
|
|
||||||
@handle_active_list_default_actions(res)
|
|
||||||
)
|
|
||||||
handle_active_list_default_actions: (response)->
|
|
||||||
response ||= {}
|
|
||||||
if(response.ok == false && response.status && response.status == 401)
|
|
||||||
redirect_to('obtain_token')
|
|
||||||
return
|
|
||||||
|
|
||||||
$('.table-number').text(response.table_number) if response.table_number
|
|
||||||
$('.supplier-name').text(response.supplier_name) if response.supplier_name
|
|
||||||
$('.supplier-orders-placed-count').text(response.supplier_orders_placed_count || 0)
|
|
||||||
$('.supplier-orders-in-process-count').text(response.supplier_orders_in_process_count || 0)
|
|
||||||
|
|
||||||
|
|
||||||
if response.not_present || response.list_active == false then $('.home-link').removeClass('active') else $('.home-link').addClass('active')
|
|
||||||
|
|
||||||
@list_needs_payment_default_action(response)
|
|
||||||
@list_needs_help_default_action(response)
|
|
||||||
# join_request_active is to ensure that there are no more modals loaded when one is still active
|
|
||||||
# console.log('join_request_active=' + window.join_request_active)
|
|
||||||
@handle_join_requests(response)
|
|
||||||
handle_join_requests: (response)->
|
|
||||||
if !window.join_request_active && response.join_requests && response.join_requests.length
|
|
||||||
window.join_request_active = true
|
|
||||||
for join_request in response.join_requests
|
|
||||||
@show_join_request(join_request)
|
|
||||||
show_join_request: (join_request)->
|
|
||||||
$(@mustache('#join-request-template',
|
|
||||||
title: t('join_request.title')
|
|
||||||
message: t('join_request.body', {email: join_request.user_email})
|
|
||||||
reject: t('join_request.reject')
|
|
||||||
approve: t('join_request.approve')
|
|
||||||
requester_id: join_request.user_id
|
|
||||||
)).modal()
|
|
||||||
false
|
|
||||||
approve_join_request: (user_id)->
|
|
||||||
@ensure_token =>
|
|
||||||
$.post(data_host + '/user/approve_join_request', $.extend({user_id: user_id}, @authentication_object), -> window.join_request_active = false)
|
|
||||||
reject_join_request: (user_id)->
|
|
||||||
@ensure_token =>
|
|
||||||
$.post(data_host + '/user/reject_join_request', $.extend({user_id: user_id}, @authentication_object), -> window.join_request_active = false)
|
|
||||||
list_needs_help: ->
|
|
||||||
return unless window.active_list && !window.active_list.needs_help
|
|
||||||
@ensure_token =>
|
|
||||||
$.post(data_host + '/user/needs_help.json', @authentication_object, (res) => window.active_list = @ensure_json(res); @list_needs_help_default_action())
|
|
||||||
list_needs_help_default_action: (response)=>
|
|
||||||
response ||= window.active_list
|
|
||||||
window.active_list = response
|
|
||||||
needs_help_container = $('#list-needs-help-button')
|
|
||||||
if needs_help_container.length
|
|
||||||
if response.needs_help
|
|
||||||
needs_help_container.data('needs-help', true)
|
|
||||||
needs_help_container.addClass('active')
|
|
||||||
else
|
|
||||||
needs_help_container.data('needs-help', false)
|
|
||||||
needs_help_container.removeClass('active')
|
|
||||||
unless needs_help_container.data('click-initialized')
|
|
||||||
needs_help_container.click( ->
|
|
||||||
if $(this).data('needs-help')
|
|
||||||
Qwaiter.alert(t('list_needs_help.help_is_on_its_way'))
|
|
||||||
else
|
|
||||||
Qwaiter.confirm(
|
|
||||||
title: t('list_needs_help.title')
|
|
||||||
content: t('list_needs_help.content')
|
|
||||||
ok: 'Quser.list_needs_help()'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
needs_help_container.data('click-initialized', true)
|
|
||||||
list_needs_payment: ->
|
|
||||||
return unless window.active_list && !window.active_list.needs_payment
|
|
||||||
@ensure_token =>
|
|
||||||
$.post(data_host + '/user/list_needs_payment.json', @authentication_object, (res) => window.active_list = @ensure_json(res); @list_needs_payment_default_action())
|
|
||||||
list_needs_payment_default_action: (response)->
|
|
||||||
response ||= window.active_list
|
|
||||||
window.active_list = response
|
|
||||||
needs_payment_container = $('#list-needs-payment-button')
|
|
||||||
if needs_payment_container.length
|
|
||||||
if response.needs_payment
|
|
||||||
needs_payment_container.data('needs-payment', true)
|
|
||||||
needs_payment_container.addClass('active')
|
|
||||||
else
|
|
||||||
needs_payment_container.data('needs-payment', false)
|
|
||||||
needs_payment_container.removeClass('active')
|
|
||||||
unless needs_payment_container.data('click-initialized')
|
|
||||||
needs_payment_container.click( ->
|
|
||||||
if $(this).data('needs-payment')
|
|
||||||
Qwaiter.alert(t('list_needs_payment.payment_already_requested'))
|
|
||||||
else
|
|
||||||
Qwaiter.confirm(
|
|
||||||
title: t('list_needs_payment.title')
|
|
||||||
content: t('list_needs_payment.content')
|
|
||||||
ok: 'Quser.list_needs_payment()'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
needs_payment_container.data('click-initialized', true)
|
|
||||||
load_active_list: () ->
|
|
||||||
@ensure_token =>
|
|
||||||
$.getJSON(data_host + '/user/active_list.json?'+@authentication_string, (res) =>
|
|
||||||
if(res.ok == false && res.status && res.status == 401)
|
|
||||||
redirect_to('obtain_token')
|
|
||||||
window.active_list = res if res._id
|
|
||||||
unless res.list_active
|
|
||||||
redirect_to 'history_list', {list_id: window.active_list._id, list_closed: true}
|
|
||||||
return
|
|
||||||
@handle_active_list_default_actions(res)
|
|
||||||
body = $('#active-list-table tbody')
|
|
||||||
foot = $('#active-list-table tfoot')
|
|
||||||
@build_list_table(body, foot, res)
|
|
||||||
)
|
|
||||||
load_history_list: () ->
|
|
||||||
return unless list_id = Qstorage.list_id
|
|
||||||
@ensure_token =>
|
|
||||||
$.getJSON(data_host + '/user/history_list.json?list_id='+list_id+'&'+ @authentication_string, (res) =>
|
|
||||||
body = $('#history-list-table tbody')
|
|
||||||
foot = $('#history-list-table tfoot')
|
|
||||||
@build_list_table(body, foot, res)
|
|
||||||
$('.list-created-at').text(@format_date(res.created_at))
|
|
||||||
$('.list-closed-at').text(@format_date(res.closed_at))
|
|
||||||
$('.supplier-name').text(res.supplier_name)
|
|
||||||
)
|
|
||||||
load_list_history: ->
|
|
||||||
@ensure_token =>
|
|
||||||
page = Qstorage.getItem('page') || 1
|
|
||||||
page = parseInt(page)
|
|
||||||
$.getJSON(data_host + '/user/list_history.json?'+@authentication_string+'&page='+page, (res) =>
|
|
||||||
@paginate(res, @load_list_history)
|
|
||||||
container = $('#list-history-container').html('')
|
|
||||||
return unless res.lists
|
|
||||||
for list in res.lists
|
|
||||||
container.append @mustache('#list-history-template', new List(list) )
|
|
||||||
)
|
|
||||||
paginate: (wrapper, callback) ->
|
|
||||||
container = $('nav.pagination')
|
|
||||||
container.html('')
|
|
||||||
return unless wrapper.num_pages
|
|
||||||
list = $('<ul></ul>').appendTo(container)
|
|
||||||
if wrapper.num_pages && wrapper.num_pages > 1
|
|
||||||
for i in [1..wrapper.num_pages]
|
|
||||||
li = $('<li class="page"></li>')
|
|
||||||
link = $('<a href="#"></a>')
|
|
||||||
link.text(i)
|
|
||||||
if wrapper.current_page && wrapper.current_page == i
|
|
||||||
li.addClass('active')
|
|
||||||
else
|
|
||||||
callback = ((i)->
|
|
||||||
->
|
|
||||||
Qstorage.page = i
|
|
||||||
window.Quser.load_list_history()
|
|
||||||
)(i)
|
|
||||||
link.click(callback)
|
|
||||||
li.append(link)
|
|
||||||
list.append(li)
|
|
||||||
mustache: (selector, locals)->
|
|
||||||
locs = $.extend(locals,
|
|
||||||
currency: ->
|
|
||||||
(val)->
|
|
||||||
currency(Mustache.render(val, this))
|
|
||||||
)
|
|
||||||
Mustache.to_html($(selector).html(), locs)
|
|
||||||
build_list_table: (body, foot, res) ->
|
|
||||||
body.find('tr').remove()
|
|
||||||
return unless res.orders
|
|
||||||
m_obj = res
|
|
||||||
body.append @mustache('#active-list-order-template', new Order(order)) for order in m_obj.orders
|
|
||||||
$('.list-total-amount').html(currency(m_obj.total_amount))
|
|
||||||
|
|
||||||
order_selected_products: ()->
|
|
||||||
@ensure_token =>
|
|
||||||
return if $.isEmptyObject(window.active_products_list)
|
|
||||||
h = {}
|
|
||||||
h['table_id'] = Qstorage.getItem('table_id') if Qstorage.getItem('table_id')
|
|
||||||
for product_id, number of window.active_products_list
|
|
||||||
h['products['+product_id+']'] = number
|
|
||||||
$.post(data_host + '/user/order_selected_products.json', $.extend(h, @authentication_object), ((res) => @handle_response(res)), 'json')
|
|
||||||
handle_response: (res) ->
|
|
||||||
if(typeof(res) == 'string')
|
|
||||||
return unless res.length
|
|
||||||
if res[0] == '{'
|
|
||||||
res = JSON.parse(res)
|
|
||||||
else
|
|
||||||
eval(res)
|
|
||||||
return
|
|
||||||
|
|
||||||
if res['message'] && !res['ok']
|
|
||||||
redirect_to res.location || 'user_root', $.extend({message: res['message']}, res.location_params)
|
|
||||||
else if res.ok
|
|
||||||
redirect_to res.location || 'list_products', $.extend({message: res['message']}, res.location_params)
|
|
||||||
build_product_list: ->
|
|
||||||
total = 0.0
|
|
||||||
h = {products: []}
|
|
||||||
for product_id, number of window.active_products_list
|
|
||||||
product = window.products[product_id]
|
|
||||||
product.number = number
|
|
||||||
product.product_total = product.price * number
|
|
||||||
h.products.push product
|
|
||||||
total += product.price * number
|
|
||||||
h.total = total
|
|
||||||
$('#active-order-container').html @mustache('#active-order-template', h)
|
|
||||||
Qupdate('#active-order-container')
|
|
||||||
|
|
||||||
load_active_list_products: ->
|
|
||||||
@populate_products_table('/user/list_products.json')
|
|
||||||
load_table_products: ->
|
|
||||||
@ensure_token =>
|
|
||||||
return redirect_to 'user_root', {message: 'cannot_identify_table'} unless Qstorage.table_id
|
|
||||||
@populate_products_table('/user/list_products_for_table.json', {table_id: Qstorage.table_id})
|
|
||||||
populate_products_table: (src, data)->
|
|
||||||
data ||= {}
|
|
||||||
$.getJSON(data_host + src, $.extend(@authentication_object, data), (res) =>
|
|
||||||
include_order_buttons = res.my_list || !res.table_occupied
|
|
||||||
|
|
||||||
$('.table-number').text(res.table_number) if res.table_number
|
|
||||||
$('.supplier-name').text(res.supplier_name) if res.supplier_name
|
|
||||||
|
|
||||||
window.products = {}
|
|
||||||
body = $('#products-table tbody')
|
|
||||||
body.find('tr').remove()
|
|
||||||
script_id = if include_order_buttons then '#products-category-for-order-template' else '#products-category-template'
|
|
||||||
#for category, products of res
|
|
||||||
for category in res.categories
|
|
||||||
body.append @mustache(script_id,
|
|
||||||
category: category.name,
|
|
||||||
products: category.products,
|
|
||||||
include_order_buttons: include_order_buttons
|
|
||||||
)
|
|
||||||
for product in category.products
|
|
||||||
window.products[product._id] = product
|
|
||||||
)
|
|
||||||
increment_products_counter: (product_id)->
|
|
||||||
product_count_holder = $('#order-product-count-'+product_id)
|
|
||||||
count = parseInt(product_count_holder.text())
|
|
||||||
product_count_holder.text(count + 1)
|
|
||||||
false
|
|
||||||
lower_products_counter: (product_id)->
|
|
||||||
product_count_holder = $('#order-product-count-'+product_id)
|
|
||||||
count = parseInt(product_count_holder.text())
|
|
||||||
product_count_holder.text(count - 1)
|
|
||||||
false
|
|
||||||
add_product_to_order: (product_id, context) ->
|
|
||||||
product_count_holder = $('#order-product-count-'+product_id)
|
|
||||||
count = parseInt(product_count_holder.text())
|
|
||||||
count ||= 1
|
|
||||||
product_count_holder.text(1)
|
|
||||||
window.active_products_list ||= {}
|
|
||||||
window.active_products_list[product_id] ||= 0
|
|
||||||
window.active_products_list[product_id] += count
|
|
||||||
delete(window.active_products_list[product_id]) if window.active_products_list[product_id] < 1
|
|
||||||
@build_product_list()
|
|
||||||
false
|
|
||||||
actions_for_table: (table)->
|
|
||||||
table = @ensure_json(table)
|
|
||||||
Qstorage.setItem('table_id', table.table_id)
|
|
||||||
@ensure_token =>
|
|
||||||
$.getJSON(data_host + '/user/table_info.json?'+@authentication_string+'&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'}
|
|
||||||
else if res.current_table_id == table.table_id
|
|
||||||
#nothing has changed, show product list
|
|
||||||
redirect_to 'list_products'
|
|
||||||
else if res.current_table_id != table.table_id
|
|
||||||
if res.occupied
|
|
||||||
redirect_to 'user_root', {message: 'table_is_occupied'}
|
|
||||||
else if res.reserved
|
|
||||||
redirect_to 'user_root', {message: 'table_is_reserved'}
|
|
||||||
else if table.closed
|
|
||||||
redirect_to 'user_root', {message: 'table_is_closed'}
|
|
||||||
else if res.supplier_closed
|
|
||||||
redirect_to 'user_root', {message: 'supplier_is_closed'}
|
|
||||||
else
|
|
||||||
## Offer to move table
|
|
||||||
Qwaiter.confirm(
|
|
||||||
ok: =>
|
|
||||||
$.post(data_host + '/user/move_table.json', $.extend({table_id: table.table_id}, @authentication_object), (res2)->
|
|
||||||
if res2.occupied
|
|
||||||
redirect_to 'user_root', {message: 'move_table.cannot_move_to_occupied_tabe'}
|
|
||||||
else
|
|
||||||
redirect_to 'list_products', {message: 'move_table.moved_to_another_table'}
|
|
||||||
)
|
|
||||||
cancel: ->
|
|
||||||
redirect_to 'list_products'
|
|
||||||
title: t('move_table.confirmation_title')
|
|
||||||
content: t('move_table.confirmation_body')
|
|
||||||
)
|
|
||||||
else
|
|
||||||
if res.occupied
|
|
||||||
redirect_to 'join_occupied_table', {table_id: table.table_id}
|
|
||||||
else if res.supplier_closed
|
|
||||||
redirect_to 'user_root', {message: 'supplier_is_closed'}
|
|
||||||
else
|
|
||||||
#$.post(data_host + '/user/create_list.json', {table_id: table.table_id}, (res)-> Quser.handle_response(res))
|
|
||||||
redirect_to 'list_products_for_table', {table_id: table.table_id}
|
|
||||||
, 'json')
|
|
||||||
show_table_products: ->
|
|
||||||
unless table_id = Qstorage.table_id
|
|
||||||
redirect_to 'user_root', {message: 'cannot_identify_table'}
|
|
||||||
return
|
|
||||||
redirect_to 'list_products_for_table', table_id: table_id
|
|
||||||
join_occupied_table: () ->
|
|
||||||
unless table_id = Qstorage.table_id
|
|
||||||
redirect_to 'user_root', {message: 'cannot_identify_table'}
|
|
||||||
return
|
|
||||||
$('.form-actions').remove()
|
|
||||||
cont = $('#join-occupied-table-progress-container')
|
|
||||||
cont.html('')
|
|
||||||
cont.append $($('<img />').attr('src', "#{$asset_path}spinner.gif"))
|
|
||||||
cont.append $($('<p data-t="join_request.requestor.waiting_for_confirmation">').html(t('join_request.requestor.waiting_for_confirmation')))
|
|
||||||
@ensure_token =>
|
|
||||||
$.post(data_host + '/user/join_occupied_table.json', $.extend({table_id: table_id}, @authentication_object))
|
|
||||||
#setInterval('Quser.check_if_can_join_occupied_table("'+table_id+'")', 7500)
|
|
||||||
add_product: (product_id, count) ->
|
|
||||||
count ||= 1
|
|
||||||
window.active_products_list ||= {}
|
|
||||||
window.active_products_list[product_id] ||= 0
|
|
||||||
window.active_products_list[product_id] += count
|
|
||||||
@build_product_list()
|
|
||||||
clear_selected_products: ->
|
|
||||||
window.active_products_list = {}
|
|
||||||
$('#active-order-table').hide()
|
|
||||||
@Quser = new Quser
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
<tr class="list-row-{{id}}">
|
|
||||||
<td class="list-status">
|
|
||||||
<span id="list-needs-help-indicator-{{id}}" class="list-needs-help-indicator {{^needs_help}}hide{{/needs_help}}">?</span>
|
|
||||||
<span id="list-needs-payment-indicator-{{id}}" class="list-needs-payment-indicator {{^needs_payment}}hide{{/needs_payment}}">€</span>
|
|
||||||
</td>
|
|
||||||
<td class="numeric table_number">{{table_number}}</td>
|
|
||||||
<td class="section_title">{{section_title}}</td>
|
|
||||||
<td class="currency total_list_amount">{{currency total_amount}}</td>
|
|
||||||
<td class="actions">
|
|
||||||
<button id="list-is-helped-button-{{id}}" class="btn btn-info {{^needs_help}}hide{{/needs_help}}" onclick="Qsupplier.mark_list_as_helped('{{id}}')" data-t="list.is_helped_button"></button>
|
|
||||||
<button class="btn btn-warning" onclick="Qsupplier.close_list('{{id}}')" data-t="list.close_list"></button>
|
|
||||||
<a href="/supplier/lists/{{id}}" class="btn"><span class="icon-list"> </span></a>
|
|
||||||
</td>
|
|
||||||
<tr>
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<tr class="order-row-{{id}} of-list-{{list_id}} {{state}}">
|
|
||||||
<td>{{display}}</td>
|
|
||||||
<td class="numeric table_number">{{table_number}}</td>
|
|
||||||
<td class="section_title">{{section_title}}</td>
|
|
||||||
<td class="currency">{{currency total_amount}}</td>
|
|
||||||
<td class="actions">
|
|
||||||
<button id="order-in-process-button-{{id}}" class="btn btn-success {{^can_process}}hide{{/can_process}}" onclick="Qsupplier.mark_order_in_process('{{id}}')" data-t="order.being_processed"></button>
|
|
||||||
<button class="btn btn-inverse" onclick="Qsupplier.mark_order_delivered('{{id}}')" data-t="order.being_served"></button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<div class="modal hide fade" role="dialog" aria-hidden="true">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
||||||
<h3>{{title}}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<p>{{message}}</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true">{{close}}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<tr class="order-row-{{id}} {{state}}">
|
|
||||||
<td>{{display}}</td>
|
|
||||||
<td class="currency">{{#currency}}{{total_amount}}{{/currency}}</td>
|
|
||||||
</tr>
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<tr class="order-row-{{id}} {{state}}">
|
|
||||||
<td>{{display}}</td>
|
|
||||||
<td class="currency">{{#currency}}{{total_amount}}{{/currency}}</td>
|
|
||||||
</tr>
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
<table id="active-order-table" class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th data-t="models.product"></th>
|
|
||||||
<th>#</th>
|
|
||||||
<th class="currency" data-t="basket.total"></th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
{{#products}}
|
|
||||||
<tr>
|
|
||||||
<td>{{name}}</td>
|
|
||||||
<td>{{number}}</td>
|
|
||||||
<td class="currency">
|
|
||||||
{{#currency}}{{product_total}}{{/currency}}
|
|
||||||
<a class="product-order-remove-button" href=""><span class="fa fa-times fa-large"></span></a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{/products}}
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
Totaal
|
|
||||||
</td>
|
|
||||||
<td class="currency"><strong id="active-order-total">{{#currency}}{{total}}{{/currency}}</strong></td>
|
|
||||||
<tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<button class="btn btn btn-warning hide" onClick="Quser.clear_selected_products()" data-t="selected_products.clear"></button>
|
|
||||||
</td>
|
|
||||||
<td></td>
|
|
||||||
<td style="text-align: right">
|
|
||||||
<button class="order-selected-products" onClick="Quser.order_selected_products()" data-t="selected_products.order"></button>
|
|
||||||
</td>
|
|
||||||
<tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<div class="modal hide fade" role="dialog" aria-hidden="true">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
||||||
<h3>{{title}}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<p>{{message}}</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<a href="#" class="btn" data-dismiss="modal" aria-hidden="true">{{close}}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
<div class="modal hide fade" role="dialog" aria-hidden="true">
|
|
||||||
<div class="modal-header">
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
|
||||||
<h3>{{title}}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<p>{{message}}</p>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<a href="#" class="btn reject-join-request-button" onclick="Quser.reject_join_request('{{requester_id}}')" data-dismiss="modal" aria-hidden="true">{{reject}}</a>
|
|
||||||
<a href="#" class="btn btn-primary approve-join-request-button" onclick="Quser.approve_join_request('{{requester_id}}')" data-dismiss="modal" aria-hidden="true">{{approve}}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
<li>
|
|
||||||
<a href="#" onclick="redirect_to('history_list', {list_id: '{{id}}'})">{{display}}</a>
|
|
||||||
</li>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<tr><td colspan="2"><h4>{{category}}</h4></td></tr>
|
|
||||||
{{#products}}
|
|
||||||
<tr>
|
|
||||||
<td>{{name}}</td>
|
|
||||||
<td>{{#currency}}{{price}}{{/currency}}</td>
|
|
||||||
</tr>
|
|
||||||
{{/products}}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
<tr><td colspan="3"><h4>{{category}}</h4></td></tr>
|
|
||||||
{{#products}}
|
|
||||||
<tr>
|
|
||||||
<td>{{name}}</td>
|
|
||||||
<td class="order-count-cell">
|
|
||||||
<span class="btn btn-mini hide" onclick="Quser.lower_products_counter('{{_id}}')">-</span>
|
|
||||||
<span id="order-product-count-{{_id}}" class="order-product-count">1</span>
|
|
||||||
<span class="btn btn-mini hide" onclick="Quser.increment_products_counter('{{_id}}')">+</span>
|
|
||||||
</td>
|
|
||||||
<td style="text-align: right">
|
|
||||||
{{#currency}}{{price}}{{/currency}}
|
|
||||||
<button class="btn order-product-button order-product-{{_id}}" onclick="Quser.add_product_to_order('{{_id}}', this)">Add</button>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
{{/products}}
|
|
||||||
@@ -45,7 +45,6 @@ html lang="en"
|
|||||||
.row
|
.row
|
||||||
.span12
|
.span12
|
||||||
#ember-app-container
|
#ember-app-container
|
||||||
script#alert-template[type="text/html"]= mustache_template 'supplier/alert'
|
|
||||||
= yield :footer
|
= yield :footer
|
||||||
javascript:
|
javascript:
|
||||||
jQuery(function(){#{onload_javascript}});
|
jQuery(function(){#{onload_javascript}});
|
||||||
|
|||||||
@@ -59,3 +59,4 @@ Qwaiter::Application.configure do
|
|||||||
# Raises helpful error messages.
|
# Raises helpful error messages.
|
||||||
config.assets.raise_runtime_errors = true
|
config.assets.raise_runtime_errors = true
|
||||||
end
|
end
|
||||||
|
STDOUT.sync = true
|
||||||
|
|||||||
+4
-1
@@ -73,10 +73,13 @@ Feature: Supplier main board
|
|||||||
Then I should be redirected to the supplier section view
|
Then I should be redirected to the supplier section view
|
||||||
|
|
||||||
@javascript
|
@javascript
|
||||||
Scenario: Update table number if table chanes
|
Scenario: Update table number and section if table changes
|
||||||
Given there is an active list and order
|
Given there is an active list and order
|
||||||
And I am signed in as supplier
|
And I am signed in as supplier
|
||||||
|
# wait until page is fully loaded
|
||||||
|
And I wait 2 seconds
|
||||||
When the active list changes to another table in another section
|
When the active list changes to another table in another section
|
||||||
|
And I wait 1 second
|
||||||
Then the supplier main board table number should be updated to the new table number
|
Then the supplier main board table number should be updated to the new table number
|
||||||
And the supplier main board section name should be updated to the new section
|
And the supplier main board section name should be updated to the new section
|
||||||
|
|
||||||
@@ -1,13 +1,11 @@
|
|||||||
step "the user scans a table QR code" do
|
step "the user scans a table QR code" do
|
||||||
step 'there is a table'
|
step 'there is a table'
|
||||||
#page.execute_script "Quser.actions_for_table({table_id: '#{@table.id}'})"
|
|
||||||
page.execute_script "App.__container__.lookup('route:application').transitionTo('table','#{@table.id}')"
|
page.execute_script "App.__container__.lookup('route:application').transitionTo('table','#{@table.id}')"
|
||||||
end
|
end
|
||||||
|
|
||||||
step "another user scans the QR code on the table" do
|
step "another user scans the QR code on the table" do
|
||||||
step 'there is another signed in user user'
|
step 'there is another signed in user user'
|
||||||
visit user_root_path
|
visit user_root_path
|
||||||
#page.execute_script "Quser.actions_for_table({table_id: '#{@table.id}'})"
|
|
||||||
page.execute_script "App.__container__.lookup('route:application').transitionTo('table','#{@table.id}')"
|
page.execute_script "App.__container__.lookup('route:application').transitionTo('table','#{@table.id}')"
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -38,4 +36,3 @@ end
|
|||||||
step "the other user clicks the join table button" do
|
step "the other user clicks the join table button" do
|
||||||
find('.join-table-button').click
|
find('.join-table-button').click
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user