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

class Admin::MailContentsController < ApplicationController
	before_action :auth_admin

	layout "admin"


	before_action :find_mail_contents


	def index 
    
  end

	def show
		@mail_content = MailContent.find(params[:id])
    render :layout => false
	end

	def edit
		@mail_content = MailContent.find(params[:id])
	end


	

	def update
		@mail_content = MailContent.find(params[:id])


		
	
		
		
		respond_to do |format|
			if @mail_content.update_attributes(params.require(:mail_content).permit!)
				

			
				flash[:notice] = "Le menu à été modifié avec succès."
				
				if @reorder
					format.js { 
						
						render :action => "update" }
				else
					format.js { 
					   @mail_content = MailContent.find(@mail_content.id)
						render :action => "update_row" }
				end
      end
			
		end
    
    
    
    

	end

	protected
	
	def find_mail_contents    
    
    @mail_contents = MailContent.all #.order("key ASC")
		

	
  end
  
end