Sha256: 7b2061cccb206093f2949e1260c36768725df1ea081da9096561d93198329266

Contents?: true

Size: 942 Bytes

Versions: 9

Compression:

Stored size: 942 Bytes

Contents

module SirTrevorRails
  module Blocks
    ##
    # Multi-up browse block
    class BrowseBlock < SirTrevorRails::Block
      include Displayable

      attr_reader :solr_helper

      def with_solr_helper(solr_helper)
        @solr_helper = solr_helper
      end

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

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

      def searches?
        !searches.empty?
      end

      def display_item_counts?
        send(:'display-item-counts') == 'true'
      end

      def as_json
        result = super

        result[:data][:item].each do |_k, v|
          v['thumbnail_image_url'] = parent.exhibit.searches.find(v['id']).thumbnail_image_url
        end

        result
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
blacklight-spotlight-1.0.0 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-1.0.0.alpha2 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-1.0.0.alpha1 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-0.34.1 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-0.34.0 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-0.33.3 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-0.33.2 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-0.33.1 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-0.33.0 app/models/sir_trevor_rails/blocks/browse_block.rb