Sha256: 3689ec2807d4df9390c4f796d1673f26c60b75e1b352423a7dcd61faedc2cc4b

Contents?: true

Size: 768 Bytes

Versions: 24

Compression:

Stored size: 768 Bytes

Contents

module SirTrevorRails
  module Blocks
    ##
    # Multi-up featured page block
    class FeaturedPagesBlock < SirTrevorRails::Block
      include Displayable

      def page_options(id)
        (items.detect { |x| x[:id] == id }) || {}
      end

      def pages
        @pages ||= parent.exhibit.pages.published.where(slug: item_ids).sort do |a, b|
          ordered_items.index(a.slug) <=> ordered_items.index(b.slug)
        end
      end

      def pages?
        !pages.empty?
      end

      def as_json
        result = super

        result[:data][:item] ||= {}

        result[:data][:item].each_value do |v|
          v['thumbnail_image_url'] = parent.exhibit.pages.find(v['id']).thumbnail_image_url
        end

        result
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
blacklight-spotlight-2.4.1 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.4.0 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.3.3 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.3.2 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.3.1 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.3.0 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.2.1 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.2.0 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.1.0 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.0.2 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.0.1 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.0.0 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.0.0.rc6 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.0.0.rc5 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.0.0.rc4 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.0.0.rc3 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.0.0.rc2 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-2.0.0.rc1 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-1.5.1 app/models/sir_trevor_rails/blocks/featured_pages_block.rb
blacklight-spotlight-1.4.1 app/models/sir_trevor_rails/blocks/featured_pages_block.rb