Make section table view work request and event based
This commit is contained in:
@@ -29,6 +29,10 @@ class Section
|
||||
@active_lists = List.active_for_section(self.id)
|
||||
end
|
||||
|
||||
def active_orders
|
||||
@active_orders ||= Order.active_for_supplier_and_section(supplier_id, id)
|
||||
end
|
||||
|
||||
|
||||
def width
|
||||
self.path.last.try(:first).to_f - self.path.first.try(:first).to_f
|
||||
@@ -66,9 +70,11 @@ class Section
|
||||
h[:tables] = []
|
||||
for table in tables
|
||||
ht = table.as_json
|
||||
table_list = active_lists.find{|l| l.table_id == table.id}
|
||||
ht[:occupied] = occupied_tables.include?(table)
|
||||
ht[:needs_help] = ht[:occupied] ? active_lists.find{|l| l.table_id == table.id}.try(:needs_help).present? : false
|
||||
ht[:needs_payment] = ht[:occupied] ? active_lists.find{|l| l.table_id == table.id}.try(:needs_payment).present? : false
|
||||
ht[:needs_help] = ht[:occupied] && table_list ? table_list.needs_help? : false
|
||||
ht[:needs_payment] = ht[:occupied] && table_list ? table_list.needs_payment? : false
|
||||
ht[:active_order] = ht[:occupied] && table_list ? active_orders.any?{|o| o.list_id == table_list.id } : false
|
||||
h[:tables] << ht
|
||||
end
|
||||
@for_tables_as_json = h
|
||||
|
||||
Reference in New Issue
Block a user