fix member sync and menu json
This commit is contained in:
@@ -22,23 +22,59 @@ item.item_attributes.each do|attr_id|
|
||||
param_count -= 1
|
||||
end
|
||||
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
param_count = item.item_options.count
|
||||
# Format for attributes json
|
||||
item.item_options.each do|opt|
|
||||
menu_opt = MenuItemOption.find(opt)
|
||||
if opt_format.count == 0
|
||||
opt_format.push({ type: menu_opt.option_type, value: [] })
|
||||
end
|
||||
|
||||
opt_format.each do |af|
|
||||
if menu_opt.option_type == af[:type]
|
||||
af[:value].push(menu_opt.value)
|
||||
else
|
||||
new_attr = {type: menu_opt.option_type, value: [ menu_opt.value ] }
|
||||
opt_format.push(new_attr)
|
||||
end
|
||||
|
||||
break if opt_format.count > param_count
|
||||
end
|
||||
|
||||
param_count -= 1
|
||||
end
|
||||
|
||||
#Menu Item Information
|
||||
json.id item.id
|
||||
json.item_code item.item_code
|
||||
json.code item.item_code
|
||||
json.name item.name
|
||||
json.alt_name item.alt_name
|
||||
json.image item.image_path.url
|
||||
json.description item.description
|
||||
json.Information item.information
|
||||
json.information item.information
|
||||
json.type item.type
|
||||
json.account_id item.account_id
|
||||
json.min_qty item.min_qty
|
||||
json.is_available item.is_available
|
||||
json.is_sub_item item.is_sub_item
|
||||
json.unit item.unit
|
||||
json.item_sets item.item_sets
|
||||
|
||||
# Item Sets of Menu Item
|
||||
json.item_sets item.item_sets do |its|
|
||||
json.id its.id
|
||||
json.name its.name
|
||||
json.alt_name its.alt_name
|
||||
json.min_selectable_qty its.min_selectable_qty
|
||||
json.max_selectable_qty its.max_selectable_qty
|
||||
json.instances its.menu_item_instances do |i|
|
||||
json.id i.id
|
||||
end
|
||||
end
|
||||
|
||||
json.attributes attr_format
|
||||
json.options item.item_options
|
||||
json.options opt_format
|
||||
# json.min_selectable_item item.min_selectable_item
|
||||
# json.max_selectable_item item.max_selectable_item
|
||||
|
||||
@@ -52,6 +88,7 @@ json.options item.item_options
|
||||
# json.item_attributes = item_instance.item_attributes
|
||||
|
||||
json.instances item.menu_item_instances do |is|
|
||||
json.id is.id
|
||||
json.code is.item_instance_code
|
||||
json.name is.item_instance_name
|
||||
json.price is.price
|
||||
@@ -59,8 +96,8 @@ json.options item.item_options
|
||||
json.is_default is.is_default
|
||||
json.is_on_promotion is.is_on_promotion
|
||||
json.promotion_price is.promotion_price
|
||||
json.item_attributes is.item_attributes
|
||||
json.item_sets is.item_sets
|
||||
json.values is.item_attributes
|
||||
# json.item_sets is.item_sets
|
||||
end
|
||||
|
||||
#Child Menu items
|
||||
|
||||
Reference in New Issue
Block a user