Sha256: 55852ec6ad205e2bc264d1b449189c60a45bd5cbaae5911f056e169f3c4fb5e3

Contents?: true

Size: 1019 Bytes

Versions: 3

Compression:

Stored size: 1019 Bytes

Contents

module Workarea
  decorate Storefront::ContentBlocksController, with: :product_grid_content do
    decorated do
      layout :check_grid_preview, only: [:show, :draft]
    end

    def show
      super

      if @block.area.inquiry.in_grid?
        get_product_for_grid_preview
      end
    end

    def draft
      draft = Content::BlockDraft.find(params[:id])

      @content = draft.content
      @block = Storefront::ContentBlockViewModel.wrap(
        draft.to_block,
        view_model_options
      )

      if @block.area.inquiry.in_grid?
        get_product_for_grid_preview
      end

      render :show
    end

    private

      def check_grid_preview
        if @block.area.inquiry.in_grid?
          "workarea/storefront/in_grid_content_preview"
        else
          "workarea/storefront/empty"
        end
      end

      def get_product_for_grid_preview
        product = Workarea::Catalog::Product.sample
        @product = Workarea::Storefront::ProductViewModel.wrap(product)
      end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-product_grid_content-1.4.0 app/controllers/workarea/storefront/content_blocks_controller.decorator
workarea-product_grid_content-1.3.1 app/controllers/workarea/storefront/content_blocks_controller.decorator
workarea-product_grid_content-1.3.0 app/controllers/workarea/storefront/content_blocks_controller.decorator