class Settings::MenuItemAttributesController < ApplicationController
  load_and_authorize_resource except: [:create]
  before_action :set_settings_menu_item_attribute, only: [:show, :edit, :update, :destroy]

  # GET /settings/menu_item_attributes
  # GET /settings/menu_item_attributes.json
  def index
    @settings_menu_item_attributes = MenuItemAttribute.all
  end

  # GET /settings/menu_item_attributes/1
  # GET /settings/menu_item_attributes/1.json
  def show
  end

  # GET /settings/menu_item_attributes/new
  def new
    @settings_menu_item_attribute = MenuItemAttribute.new
  end

  # GET /settings/menu_item_attributes/1/edit
  def edit
  end

  # POST /settings/menu_item_attributes
  # POST /settings/menu_item_attributes.json
  def create
    @settings_menu_item_attribute = MenuItemAttribute.new(settings_menu_item_attribute_params)

    respond_to do |format|
      if @settings_menu_item_attribute.save
        format.html { redirect_to settings_menu_item_attributes_path, notice: 'Menu item attribute was successfully created.' }
        format.json { render :show, status: :created, location: @settings_menu_item_attribute }
      else
        format.html { render :new }
        format.json { render json: @settings_menu_item_attribute.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /settings/menu_item_attributes/1
  # PATCH/PUT /settings/menu_item_attributes/1.json
  def update
    respond_to do |format|
      if @settings_menu_item_attribute.update(settings_menu_item_attribute_params)
        format.html { redirect_to settings_menu_item_attribute_path(@settings_menu_item_attribute), notice: 'Menu item attribute was successfully updated.' }
        format.json { render :show, status: :ok, location: @settings_menu_item_attribute }
      else
        format.html { render :edit }
        format.json { render json: @settings_menu_item_attribute.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /settings/menu_item_attributes/1
  # DELETE /settings/menu_item_attributes/1.json
  def destroy
    @settings_menu_item_attribute.destroy
    respond_to do |format|
      format.html { redirect_to settings_menu_item_attributes_path, notice: 'Menu item attribute was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_settings_menu_item_attribute
      @settings_menu_item_attribute = MenuItemAttribute.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def settings_menu_item_attribute_params
      params.require(:menu_item_attribute).permit(:attribute_type, :name, :value)
    end
end
