fix menu item json format
This commit is contained in:
@@ -1,49 +1,47 @@
|
|||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
attr_format = []
|
attr_format = []
|
||||||
param_count = item.item_attributes.count
|
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
item.item_attributes.each do|attr_id|
|
item.item_attributes.each do|attr_id|
|
||||||
menu_attr = MenuItemAttribute.find(attr_id)
|
menu_attr = MenuItemAttribute.find(attr_id)
|
||||||
if attr_format.count == 0
|
if attr_format.count == 0
|
||||||
attr_format.push({ type: menu_attr.attribute_type, values: [] })
|
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
|
||||||
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_format.each do |af|
|
attr_format.each do |af|
|
||||||
if menu_attr.attribute_type == af[:type]
|
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
|
||||||
af[:values].push(menu_attr.name)
|
if menu_attr.attribute_type == af[:type]
|
||||||
|
af[:values].push(menu_attr.name)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
|
||||||
attr_format.push(new_attr)
|
attr_format.push(new_attr)
|
||||||
end
|
break
|
||||||
|
end
|
||||||
break if attr_format.count > param_count
|
|
||||||
end
|
end
|
||||||
|
|
||||||
param_count -= 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Format for option json
|
# Format for option json
|
||||||
opt_format = []
|
opt_format = []
|
||||||
param_count = item.item_options.count
|
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
item.item_options.each do|opt|
|
item.item_options.each do|opt|
|
||||||
menu_opt = MenuItemOption.find(opt)
|
menu_opt = MenuItemOption.find(opt)
|
||||||
if opt_format.count == 0
|
if opt_format.count == 0
|
||||||
opt_format.push({ type: menu_opt.option_type, values: [] })
|
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
|
||||||
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
opt_format.each do |af|
|
opt_format.each do |of|
|
||||||
if menu_opt.option_type == af[:type]
|
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
|
||||||
af[:values].push(menu_opt.name)
|
if menu_opt.option_type == of[:type]
|
||||||
|
of[:values].push(menu_opt.name)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
new_attr = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
|
||||||
opt_format.push(new_attr)
|
opt_format.push(new_opt)
|
||||||
|
break
|
||||||
end
|
end
|
||||||
|
end
|
||||||
break if opt_format.count > param_count
|
|
||||||
end
|
|
||||||
|
|
||||||
param_count -= 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
#Menu Item Information
|
#Menu Item Information
|
||||||
|
|||||||
Reference in New Issue
Block a user