better broadcasting for user
This commit is contained in:
@@ -30,6 +30,15 @@ root.Qsupplier=
|
||||
$('#order-in-process-button-'+e.data.id).hide()
|
||||
else if e.event == 'order_being_delivered'
|
||||
$('#order-row-'+e.data.id).remove()
|
||||
else if e.event == 'list_changed_table'
|
||||
list_row = $('#list-row-'+e.data.list_id)
|
||||
list_row.find('.table_number').text(e.data.table.number).addClass('changed')
|
||||
list_row.find('.section_title').text(e.data.section_title)
|
||||
order_rows = $('.of-list-'+e.data.list_id)
|
||||
order_rows.find('.table_number').text(e.data.table.number).addClass('changed')
|
||||
order_rows.find('.section_title').text(e.data.section_title)
|
||||
|
||||
|
||||
console.log(e)
|
||||
false
|
||||
move_table_to_active_section: (table_id)->
|
||||
|
||||
@@ -52,7 +52,7 @@ var $translations = {
|
||||
content: 'Request a waiter to your table'
|
||||
},
|
||||
list_needs_payment: {
|
||||
payment_already_requested: 'You already asked for the check',
|
||||
payment_already_requested: 'You already asked for the bill',
|
||||
title: 'Ask for the check',
|
||||
content: 'Do you want to pay?'
|
||||
},
|
||||
|
||||
@@ -22,6 +22,16 @@ class Quser
|
||||
$('#order-row-'+e.data.id).addClass('active')
|
||||
if(e.event == 'order_being_delivered')
|
||||
$('#order-row-'+e.data.id).addClass('delivered')
|
||||
if(e.event == 'list_changed_table')
|
||||
$('.table-number').text(e.data.table.number)
|
||||
if(e.event == 'list_needs_help')
|
||||
window.active_list.needs_help = true
|
||||
@list_needs_help_default_action()
|
||||
if(e.event == 'list_needs_payment')
|
||||
window.active_list.needs_payment = true
|
||||
@list_needs_payment_default_action()
|
||||
|
||||
console.log(e)
|
||||
false
|
||||
home_loader: ->
|
||||
$.getJSON(data_host + '/user/list_info.json?' + authentication_string, (res) => @handle_active_list_default_actions(res))
|
||||
|
||||
@@ -213,9 +213,7 @@ class UserController < ApplicationController
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: {list_active: false} and return unless list.present?
|
||||
list.needs_help = true
|
||||
list.save
|
||||
broadcast_supplier(list.supplier_id, 'list_needs_help', id: list.id)
|
||||
list.needs_help!
|
||||
render json: list.as_json.merge(list_active: list.active?)
|
||||
end
|
||||
end
|
||||
@@ -299,7 +297,7 @@ class UserController < ApplicationController
|
||||
if @table.occupied?
|
||||
render json: {occupied: true}
|
||||
else
|
||||
list.move_to_table @table
|
||||
list.move_to_table! @table
|
||||
render json: {occupied: false}
|
||||
end
|
||||
end
|
||||
|
||||
+23
-7
@@ -126,6 +126,29 @@ class List
|
||||
end
|
||||
end
|
||||
|
||||
def move_to_table! to_table
|
||||
UserTableMove.create list: self, from_table_id: table_id, to_table: to_table
|
||||
self.table = to_table
|
||||
self.section_id = to_table.section_id
|
||||
if save
|
||||
for user_id in user_ids
|
||||
broadcast_user user_id, 'list_changed_table', list_id: id, table: to_table, section_title: to_table.section.try(:title)
|
||||
end
|
||||
broadcast_supplier supplier_id, 'list_changed_table', list_id: id, table: to_table, section_title: to_table.section.try(:title)
|
||||
end
|
||||
end
|
||||
|
||||
def needs_help!
|
||||
self.needs_help = true
|
||||
if save
|
||||
for user_id in user_ids
|
||||
broadcast_user user_id, 'list_needs_help', id: id
|
||||
end
|
||||
broadcast_supplier(supplier_id, 'list_needs_help', id: id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def set_price
|
||||
list_total = 0.0
|
||||
for order in orders
|
||||
@@ -162,13 +185,6 @@ class List
|
||||
order
|
||||
end
|
||||
|
||||
def move_to_table to_table
|
||||
UserTableMove.create list: self, from_table_id: table_id, to_table: to_table
|
||||
self.table = to_table
|
||||
self.section_id = to_table.section_id
|
||||
save
|
||||
end
|
||||
|
||||
def as_json(*args)
|
||||
super.merge(table_number: table_number)
|
||||
end
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
<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"><a href="/supplier/lists/{{id}}">{{table_number}}</a></td>
|
||||
<td>{{section_title}}</td>
|
||||
<td class="currency">{{#currency}}{{total_amount}}{{/currency}}</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}}{{/currency}}</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}}')">Question answered!</button>
|
||||
<button class="btn btn-warning" onclick="Qsupplier.close_list('{{id}}')">Close!</button>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<tr id="order-row-{{id}}" class="of-list-{{list_id}}">
|
||||
<td>{{display}}</td>
|
||||
<td class="numeric">{{table_number}}</td>
|
||||
<td>{{section_title}}</td>
|
||||
<td class="numeric table_number">{{table_number}}</td>
|
||||
<td class="section_title">{{section_title}}</td>
|
||||
<td class="currency">{{#currency}}{{total_amount}}{{/currency}}</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}}')">In process!</button>
|
||||
|
||||
Reference in New Issue
Block a user