Sha256: 3b611d4e6abdb3085368ceef89531d82fd4d02b8eabcb3ae92ce5702634124b2

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

module Spree
  module Admin
    class BannerBoxesController < ResourceController
      
      def index
        respond_with(@collection)
      end
      
      def show
        redirect_to( :action => :edit )
      end
      
      def update
        @banner_box.enhance_settings
        super
      end

      def clone
        @new = @banner_box.duplicate

        if @new.save
          flash.notice = I18n.t('notice_messages.banner_box_cloned')
        else
          flash.notice = I18n.t('notice_messages.banner_box_not_cloned')
        end

        respond_with(@new) { |format| format.html { redirect_to edit_admin_banner_box_url(@new) } }
      end
      
      protected

      def find_resource
        Spree::BannerBox.find(params[:id])
      end
      
      def location_after_save
         admin_banner_boxes_url
      end
      
      def collection
        return @collection if @collection.present?
        params[:q] ||= {}

        params[:q][:s] ||= 'category, position asc'
        @collection = super

        @q = @collection.ransack(params[:q])
        @collection = @q.result.
            page(params[:page]).
            per(params[:per_page] || Spree::Config[:admin_products_per_page])
        @collection
      end

      def model_class
        Spree::BannerBox
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_zaez_banner-3.0.4 app/controllers/spree/admin/banner_boxes_controller.rb
spree_zaez_banner-3.0.3 app/controllers/spree/admin/banner_boxes_controller.rb