better broadcasting for user
This commit is contained in:
+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
|
||||
|
||||
Reference in New Issue
Block a user