diff --git a/app/assets/javascripts/user/application.js.erb b/app/assets/javascripts/user/application.js.erb
index 55ed9706..2be7040a 100644
--- a/app/assets/javascripts/user/application.js.erb
+++ b/app/assets/javascripts/user/application.js.erb
@@ -64,7 +64,8 @@ var $translations = {
title: 'Join request',
body: '%{email} wants to join the table',
reject: 'Reject',
- approve: 'Approve'
+ approve: 'Approve',
+ waiting_for_confirmation: 'Waiting for approval of the person on this table...'
},
move_table: {
cannot_move_to_occupied_table: 'You cannot move to an occupied table',
@@ -98,7 +99,8 @@ var $translations = {
title: 'Lijst deling',
body: '%{email} wil ook op jouw lijst bestellen',
reject: 'Afwijzen',
- approve: 'Toestaan'
+ approve: 'Toestaan',
+ waiting_for_confirmation: 'Wachten op toestemming van huidige gebruikers om hier te kunnen bestellen...'
},
move_table: {
cannot_move_to_occupied_table: 'Je kan niet verhuizen naar een tafel die reeds gebruikt wordt.',
diff --git a/app/assets/javascripts/user/quser.js.coffee b/app/assets/javascripts/user/quser.js.coffee
index 3481f67b..ef8e3b2a 100644
--- a/app/assets/javascripts/user/quser.js.coffee
+++ b/app/assets/javascripts/user/quser.js.coffee
@@ -36,6 +36,9 @@ class Quser
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))
console.log(e)
false
home_loader: ->
@@ -226,13 +229,12 @@ class Quser
Mustache.to_html($(selector).html(), locs)
build_list_table: (body, foot, res) ->
body.find('tr').remove()
- foot.find('tr').remove()
if !res.orders && !res.orders.length
Qwaiter.alert('No orders in list')
return
m_obj = res
body.append @mustache('#active-list-order-template', new Order(order)) for order in m_obj.orders
- foot.append @mustache('#active-list-orders-footer-template', m_obj)
+ $('.list-total-amount').html(currency(m_obj.total_amount))
order_selected_products: ()->
return if $.isEmptyObject(window.active_products_list)
@@ -370,8 +372,8 @@ class Quser
$('.form-actions').remove()
cont = $('#join-occupied-table-progress-container')
cont.html('')
- cont.append $('
')
- cont.append $('
Waiting for approval of the person on this table
') + cont.append $($('').html(t('join_request.waiting_for_confirmation'))) $.post(data_host + '/user/join_occupied_table', $.extend({table_id: table_id}, authentication_object)) #setInterval('Quser.check_if_can_join_occupied_table("'+table_id+'")', 7500) add_product: (product_id, count) -> diff --git a/app/models/list.rb b/app/models/list.rb index 2fa43d5f..21118092 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -236,6 +236,11 @@ class List product = loaded_products.find{|p| p.id == product_id} # to get the price ProductOrder.create order: order, product_id: product_id, amount: number, price: product.price if number > 0 end + set_price + save + for user_id in user_ids + broadcast_user user_id, 'new_order', order: order.with_products_as_json, total_amount: price + end broadcast_supplier supplier.id, 'new_order', order.with_products_as_json broadcast_supplier supplier.id, 'list_update', with_info_as_json order diff --git a/app/templates/user/_active_list_orders_footer.mustache b/app/templates/user/_active_list_orders_footer.mustache deleted file mode 100644 index 403b0f47..00000000 --- a/app/templates/user/_active_list_orders_footer.mustache +++ /dev/null @@ -1 +0,0 @@ -