Sha256: de3189514d769e303fc820b51d3a6e3b68cd4b8e1945c572ffa1f87917086031

Contents?: true

Size: 912 Bytes

Versions: 5

Compression:

Stored size: 912 Bytes

Contents

module SirTrevorRails
  module Blocks
    ##
    # Multi-up browse block
    class BrowseBlock < SirTrevorRails::Block
      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|
          order.index(a.slug) <=> order.index(b.slug)
        end
      end

      def searches?
        !searches.empty?
      end

      def item_ids
        items.map { |v| v[:id] }
      end

      def items
        item.values.select { |x| x[:display] == 'true' }
      end

      def order
        items.sort_by { |x| x[:weight] }.map { |x| x[:id] }
      end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-spotlight-0.17.1 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-0.17.0 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-0.16.0 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-0.15.0 app/models/sir_trevor_rails/blocks/browse_block.rb
blacklight-spotlight-0.14.2 app/models/sir_trevor_rails/blocks/browse_block.rb