Merge branch 'addorder' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
@@ -1,4 +1,28 @@
|
||||
if(@id)
|
||||
menu_item = MenuItem.find(@id.menu_item_id)
|
||||
# Format for option json
|
||||
opt_format = []
|
||||
# Format for attributes json
|
||||
menu_item.item_options.each do|opt|
|
||||
menu_opt = MenuItemOption.find(opt)
|
||||
if opt_format.count == 0
|
||||
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
||||
next
|
||||
end
|
||||
|
||||
opt_format.each do |of|
|
||||
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
||||
if menu_opt.option_type == of[:type]
|
||||
of[:values].push(menu_opt.name)
|
||||
end
|
||||
else
|
||||
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
||||
opt_format.push(new_opt)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
json.success true
|
||||
json.id @id.id
|
||||
json.name @id.item_instance_name
|
||||
@@ -8,6 +32,8 @@ if(@id)
|
||||
json.attributes @id.item_attributes
|
||||
json.price @id.price
|
||||
json.is_default @id.is_default
|
||||
|
||||
json.options opt_format
|
||||
else
|
||||
json.success false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user