update for check for menu item api
This commit is contained in:
@@ -1,22 +1,24 @@
|
|||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
attr_format = []
|
attr_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
item.item_attributes.each do|attr_id|
|
if item.item_attributes.count > 0
|
||||||
menu_attr = MenuItemAttribute.find(attr_id)
|
item.item_attributes.each do|attr_id|
|
||||||
if attr_format.count == 0
|
menu_attr = MenuItemAttribute.find(attr_id)
|
||||||
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
|
if attr_format.count == 0
|
||||||
next
|
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
|
||||||
end
|
next
|
||||||
|
end
|
||||||
|
|
||||||
attr_format.each do |af|
|
attr_format.each do |af|
|
||||||
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
|
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
|
||||||
if menu_attr.attribute_type == af[:type]
|
if menu_attr.attribute_type == af[:type]
|
||||||
af[:values].push(menu_attr.name)
|
af[:values].push(menu_attr.name)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
||||||
|
attr_format.push(new_attr)
|
||||||
|
break
|
||||||
end
|
end
|
||||||
else
|
|
||||||
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
|
||||||
attr_format.push(new_attr)
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -24,22 +26,24 @@ end
|
|||||||
# Format for option json
|
# Format for option json
|
||||||
opt_format = []
|
opt_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
item.item_options.each do|opt|
|
if item.item_options.count > 0
|
||||||
menu_opt = MenuItemOption.find(opt)
|
item.item_options.each do|opt|
|
||||||
if opt_format.count == 0
|
menu_opt = MenuItemOption.find(opt)
|
||||||
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
if opt_format.count == 0
|
||||||
next
|
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
||||||
end
|
next
|
||||||
|
end
|
||||||
|
|
||||||
opt_format.each do |of|
|
opt_format.each do |of|
|
||||||
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
||||||
if menu_opt.option_type == of[:type]
|
if menu_opt.option_type == of[:type]
|
||||||
of[:values].push(menu_opt.name)
|
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
|
||||||
else
|
|
||||||
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
|
||||||
opt_format.push(new_opt)
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user