update menu_sync
This commit is contained in:
@@ -37,6 +37,34 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
# end
|
||||
@settings_menu_item.created_by = current_login_employee.name
|
||||
|
||||
# Remove "" default first
|
||||
params[:simple_menu_item][:item_attributes].delete_at(0)
|
||||
params[:simple_menu_item][:item_options].delete_at(0)
|
||||
|
||||
# attr_format = []
|
||||
# param_count = params[:simple_menu_item][:item_attributes].count
|
||||
# # Format for attributes json
|
||||
# params[:simple_menu_item][:item_attributes].each do|attr_id|
|
||||
# menu_attr = MenuItemAttribute.find(attr_id)
|
||||
# if attr_format.count == 0
|
||||
# attr_format.push({ type: menu_attr.attribute_type, value: [] })
|
||||
# end
|
||||
|
||||
# attr_format.each do |af|
|
||||
# if menu_attr.attribute_type == af[:type]
|
||||
# af[:value].push(menu_attr.value)
|
||||
# else
|
||||
# new_attr = {type: menu_attr.attribute_type, value: [ menu_attr.value ] }
|
||||
# attr_format.push(new_attr)
|
||||
# end
|
||||
|
||||
# break if attr_format.count > param_count
|
||||
# end
|
||||
|
||||
# param_count -= 1
|
||||
# end
|
||||
# @settings_menu_item.item_attributes = attr_format
|
||||
|
||||
# Bind for Item Sets
|
||||
if params[:simple_menu_item][:item_sets].count > 1
|
||||
params[:simple_menu_item][:item_sets].delete_at(0)
|
||||
@@ -47,14 +75,11 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
@settings_menu_item.item_sets = sets
|
||||
end
|
||||
end
|
||||
|
||||
# Remove "" default first
|
||||
params[:simple_menu_item][:item_attributes].delete_at(0)
|
||||
params[:simple_menu_item][:item_options].delete_at(0)
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item.save
|
||||
menu_item = MenuItem.find(@settings_menu_item.id)
|
||||
menu_item.update_attributes(item_attributes: params[:simple_menu_item][:item_attributes], item_options: params[:simple_menu_item][:item_options])
|
||||
menu_item.update_attributes(item_options: params[:simple_menu_item][:item_options])
|
||||
|
||||
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_menu_item }
|
||||
@@ -129,6 +154,6 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_item_params
|
||||
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by)
|
||||
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user