Fix active order display in supplier side
This commit is contained in:
+13
-4
@@ -168,10 +168,15 @@ class List
|
||||
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), from_table_id: from_table
|
||||
# Update the section of an order
|
||||
orders.each do |order|
|
||||
order.section_id = self.section_id
|
||||
order.save
|
||||
end
|
||||
broadcast_supplier supplier_id, 'list_changed_table', list_id: id, table: to_table, section_title: to_table.section.try(:title), from_table_id: from_table
|
||||
for user_id in user_ids
|
||||
broadcast_user user_id, 'list_changed_table', list: as_json, section_title: to_table.section.try(:title), from_table_id: from_table
|
||||
end
|
||||
broadcast_supplier supplier_id, 'list_changed_table', list: as_json, section_title: to_table.section.try(:title), from_table_id: from_table
|
||||
end
|
||||
end
|
||||
|
||||
@@ -272,7 +277,7 @@ class List
|
||||
end
|
||||
|
||||
def as_json(*args)
|
||||
super.merge(table_number: table_number)
|
||||
super.merge(table_number: table_number, has_active_orders: has_active_orders? )
|
||||
end
|
||||
|
||||
def with_orders_as_json
|
||||
@@ -305,6 +310,10 @@ class List
|
||||
@with_orders_and_join_requests_as_json = with_orders_as_json.merge(join_requests_as_json)
|
||||
end
|
||||
|
||||
def has_active_orders?
|
||||
Order.count_active_for_supplier_and_list(supplier_id, id) > 0
|
||||
end
|
||||
|
||||
# Return a join requests object in the form of:
|
||||
# {join_request: [{user_id: '1saf3...', user_email: 'info@qwaiter.com'}, [....]]}
|
||||
def join_requests_as_json
|
||||
|
||||
Reference in New Issue
Block a user