menu and menu item categories
This commit is contained in:
20
app/views/api/restaurant/menu/_menu.json.jbuilder
Normal file
20
app/views/api/restaurant/menu/_menu.json.jbuilder
Normal file
@@ -0,0 +1,20 @@
|
||||
json.id menu.id
|
||||
json.name menu.name
|
||||
json.is_active menu.is_active
|
||||
json.valid_time_from menu.valid_time_from.strftime("%H:%M")
|
||||
json.valid_time_to menu.valid_time_to.strftime("%H:%M")
|
||||
|
||||
if (menu.menu_categories)
|
||||
json.menu_categories menu.menu_categories do |category|
|
||||
json.id category.id
|
||||
json.name category.name
|
||||
json.alt_name category.alt_name
|
||||
|
||||
if category.menu_items
|
||||
json.menu_items category.menu_items do |item|
|
||||
json.partial! 'api/restaurant/menu/menu_item', item: item
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
40
app/views/api/restaurant/menu/_menu_item.json.jbuilder
Normal file
40
app/views/api/restaurant/menu/_menu_item.json.jbuilder
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
#Menu Item Information
|
||||
json.item_code item.item_code
|
||||
json.name item.name
|
||||
json.alt_name item.alt_name
|
||||
json.type item.type
|
||||
json.min_qty item.min_qty
|
||||
json.min_selectable_item item.min_selectable_item
|
||||
json.max_selectable_item item.max_selectable_item
|
||||
|
||||
#Item instance
|
||||
if item.menu_item_instances.count == 1 then
|
||||
|
||||
item_instance = item.menu_item_instances[0]
|
||||
json.price = item_instance.price
|
||||
json.is_available = item_instance.is_available
|
||||
json.is_on_promotion = item_instance.is_on_promotion
|
||||
json.promotion_price = item_instance.promotion_price
|
||||
json.item_attributes = item_instance.item_attributes
|
||||
|
||||
elsif item.menu_item_instances.count > 1 then
|
||||
|
||||
json.item_instances item.menu_item_instances do |is|
|
||||
json.item_instance_item_code = is.item_instance_code
|
||||
json.item_instance_name = is.item_instance_name
|
||||
json.price = is.price
|
||||
json.is_available = is.is_available
|
||||
json.is_on_promotion = is.is_on_promotion
|
||||
json.promotion_price = is.promotion_price
|
||||
json.item_attributes = is.item_attributes
|
||||
end
|
||||
|
||||
end
|
||||
#Child Menu items
|
||||
if (item.children) then
|
||||
json.set_items item.children.each do |item|
|
||||
json.partial! 'api/restaurant/menu/menu_item', item: item
|
||||
end
|
||||
|
||||
end
|
||||
12
app/views/api/restaurant/menu/index.json.jbuilder
Normal file
12
app/views/api/restaurant/menu/index.json.jbuilder
Normal file
@@ -0,0 +1,12 @@
|
||||
json.array! @menus do |menu|
|
||||
json.id menu.id
|
||||
json.name menu.name
|
||||
json.valid_days menu.valid_days
|
||||
json.valid_time_from menu.valid_time_from.strftime("%H:%M")
|
||||
json.valid_time_to menu.valid_time_to.strftime("%H:%M")
|
||||
if (@current_menu)
|
||||
json.current_menu do
|
||||
json.partial! 'api/restaurant/menu/menu', menu: @current_menu
|
||||
end
|
||||
end
|
||||
end
|
||||
3
app/views/api/restaurant/menu/show.json.jbuilder
Normal file
3
app/views/api/restaurant/menu/show.json.jbuilder
Normal file
@@ -0,0 +1,3 @@
|
||||
if (@menu)
|
||||
json.partial! 'api/restaurant/menu/menu', menu: @menu
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
json.array! @menu_attributes do |attribute|
|
||||
json.type attribute.attribute_type
|
||||
json.name attribute.name
|
||||
json.value attribute.value
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
json.array! @menu_options do |option|
|
||||
json.name option.name
|
||||
json.value option.value
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
if @status == true
|
||||
json.status :success
|
||||
json.id @order.id
|
||||
json.order_items do
|
||||
json.array! @order.order_items, :item_code, :item_name, :qty, :options, :variants, :remarks
|
||||
end
|
||||
else
|
||||
json.status :error
|
||||
if @error_messages
|
||||
json.error_messages @error_messages
|
||||
else
|
||||
json.error_messages @order.errors
|
||||
end
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
if @status == true
|
||||
json.status :success
|
||||
json.id @order.id
|
||||
else
|
||||
json.status :error
|
||||
json.error_messages @order.error_messages
|
||||
end
|
||||
42
app/views/api/restaurant/zones/index.json.jbuilder
Normal file
42
app/views/api/restaurant/zones/index.json.jbuilder
Normal file
@@ -0,0 +1,42 @@
|
||||
if @zones
|
||||
json.array! @zones do |zone|
|
||||
json.id zone.id
|
||||
json.name zone.name
|
||||
#List all tables
|
||||
json.tables zone.tables do |table|
|
||||
json.id table.id
|
||||
json.name table.name
|
||||
json.status table.status
|
||||
json.zone_id table.zone_id #Add this zone_id to keep data structure consistance
|
||||
json.current_booking table.get_current_booking
|
||||
end
|
||||
|
||||
json.rooms zone.rooms do |room|
|
||||
json.id room.id
|
||||
json.name room.name
|
||||
json.status room.status
|
||||
json.zone_id room.zone_id #Add this zone_id to keep data structure consistance
|
||||
json.current_booking room.get_current_booking
|
||||
|
||||
end
|
||||
end
|
||||
else #list all tables and rooms with out zones
|
||||
json.tables @all_tables do |table|
|
||||
json.id table.id
|
||||
json.name table.name
|
||||
json.status table.status
|
||||
json.zone_id table.zone_id #Add this zone_id to keep data structure consistance
|
||||
json.current_booking table.get_current_booking
|
||||
|
||||
end
|
||||
|
||||
json.rooms @all_rooms do |room|
|
||||
json.id room.id
|
||||
json.name room.name
|
||||
json.status room.status
|
||||
json.zone_id room.zone_id #Add this zone_id to keep data structure consistance
|
||||
json.current_booking room.get_current_booking
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user