fix menu attributes error
This commit is contained in:
@@ -31,15 +31,13 @@ json.is_sub_item item.is_sub_item
|
|||||||
json.unit item.unit
|
json.unit item.unit
|
||||||
|
|
||||||
# Item Sets of Menu Item
|
# Item Sets of Menu Item
|
||||||
json.item_sets item.item_sets.includes(:menu_item_instances) do |its|
|
json.item_sets item.item_sets do |its|
|
||||||
json.id its.id
|
json.id its.id
|
||||||
json.name its.name
|
json.name its.name
|
||||||
json.alt_name its.alt_name
|
json.alt_name its.alt_name
|
||||||
json.min_selectable_qty its.min_selectable_qty
|
json.min_selectable_qty its.min_selectable_qty
|
||||||
json.max_selectable_qty its.max_selectable_qty
|
json.max_selectable_qty its.max_selectable_qty
|
||||||
json.instances its.menu_item_instances do |i|
|
json.instances its.menu_item_instances.map { |i| {id: i.id} }
|
||||||
json.id i.id
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
json.attributes attr_format
|
json.attributes attr_format
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ json.valid_time_to menu.valid_time_to.strftime("%H:%M")
|
|||||||
if (menu.menu_categories)
|
if (menu.menu_categories)
|
||||||
order_by = Lookup.find_by_lookup_type("order_by")
|
order_by = Lookup.find_by_lookup_type("order_by")
|
||||||
# if !order_by.nil? && order_by.value == "name"
|
# if !order_by.nil? && order_by.value == "name"
|
||||||
# categories = MenuCategory.unscoped.where("menu_id ='#{menu.id}'").order("name asc")
|
# categories = MenuCategory.unscope(:order).where("menu_id ='#{menu.id}'").order("name asc")
|
||||||
# else
|
# else
|
||||||
# categories = menu.menu_categories
|
# categories = menu.menu_categories
|
||||||
# end
|
# end
|
||||||
@@ -41,21 +41,21 @@ if (menu.menu_categories)
|
|||||||
attr_format = []
|
attr_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
if item.item_attributes.count > 0
|
if item.item_attributes.count > 0
|
||||||
item_attributes = @item_attributes.select{ |x| item.item_attributes.include?(x.id.to_s) }
|
item_attributes = item.item_attributes.map(&:to_s)
|
||||||
attr_format = item_attributes.group_by {|att| att.attribute_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
attr_format = @item_attributes.select { |x| item_attributes.include?(x.id.to_s) }.group_by {|att| att.attribute_type.strip }.map { |type, values| {type: type, values: values.map { |x| x.name.strip } } }
|
||||||
end
|
end
|
||||||
|
|
||||||
# Format for option json
|
# Format for option json
|
||||||
opt_format = []
|
opt_format = []
|
||||||
# Format for attributes json
|
# Format for attributes json
|
||||||
if item.item_options.count > 0
|
if item.item_options.count > 0
|
||||||
item_options = @item_options.select{ |x| item.item_options.include?(x.id.to_s) }
|
item_options = item.item_options.map(&:to_s)
|
||||||
opt_format = item_options.group_by {|opt| opt.option_type }.map { |type, values| {type: type, values: values.map(&:name)} }
|
opt_format = @item_options.select { |x| item_options.include?(x.id.to_s) }.group_by {|opt| opt.option_type.strip }.map { |type, values| {type: type, values: values.map { |x| x.name.strip } } }
|
||||||
end
|
end
|
||||||
|
|
||||||
#Menu Item Information
|
#Menu Item Information
|
||||||
json.id item.id
|
json.id item.id
|
||||||
json.code item.item_code
|
json.code item.item_code
|
||||||
json.name item.name
|
json.name item.name
|
||||||
json.alt_name item.alt_name
|
json.alt_name item.alt_name
|
||||||
json.image item.image_path.url
|
json.image item.image_path.url
|
||||||
@@ -69,15 +69,14 @@ if (menu.menu_categories)
|
|||||||
json.unit item.unit
|
json.unit item.unit
|
||||||
|
|
||||||
# Item Sets of Menu Item
|
# Item Sets of Menu Item
|
||||||
json.item_sets item.item_sets.map { |its|
|
json.item_sets item.item_sets do |its|
|
||||||
{ id: its.id,
|
json.id its.id
|
||||||
name: its.name,
|
json.name its.name
|
||||||
alt_name: its.alt_name,
|
json.alt_name its.alt_name
|
||||||
min_selectable_qty: its.min_selectable_qty,
|
json.min_selectable_qty its.min_selectable_qty
|
||||||
max_selectable_qty: its.max_selectable_qty,
|
json.max_selectable_qty its.max_selectable_qty
|
||||||
instances: its.menu_item_instances.map { |i| {id: i.id} }
|
json.instances its.menu_item_instances.map { |i| {id: i.id} }
|
||||||
}
|
end
|
||||||
}
|
|
||||||
|
|
||||||
json.attributes attr_format
|
json.attributes attr_format
|
||||||
json.options opt_format
|
json.options opt_format
|
||||||
@@ -85,7 +84,8 @@ if (menu.menu_categories)
|
|||||||
json.instances item.menu_item_instances do |is|
|
json.instances item.menu_item_instances do |is|
|
||||||
if is.is_available
|
if is.is_available
|
||||||
# Convert id to name for attributes
|
# Convert id to name for attributes
|
||||||
instance_attr = @item_attributes.select{ |x| item.item_attributes.include?(x.id) }.pluck(:name)
|
item_attributes = is.item_attributes.map(&:to_s)
|
||||||
|
instance_attr = @item_attributes.select{ |x| item_attributes.include?(x.id.to_s) }.pluck(:name)
|
||||||
|
|
||||||
json.id is.id
|
json.id is.id
|
||||||
json.code is.item_instance_code
|
json.code is.item_instance_code
|
||||||
|
|||||||
Reference in New Issue
Block a user