# -*- encoding : utf-8 -*-

class Admin::BigMenusController < ApplicationController
	
	

	layout "admin"

	def index
    @big_menus = BigMenu.order(:position).all
		
	end
  
  def reorder
    @big_menu = BigMenu.find(params[:id])
		i = 0
		params[:big_menu_item].each do |big_menu_item_id|
			i += 1
			big_menu_item = BigMenuItem.find(big_menu_item_id)
			big_menu_item.position = i
      big_menu_item.big_menu_id = @big_menu.id
			big_menu_item.save
		end
    render :inline => "true"
  end



	def edit
		@big_menu = BigMenu.find(params[:id])
		render :layout => false
	end


	

	def update
		@big_menu = BigMenu.find(params[:id])

		if @big_menu.update_attributes(params.require(:big_menu).permit!)
			flash[:notice] = "L'événement à été modifié avec succès."
		else
			render :action => "edit" 
			
		end

	end
end
