Sha256: 27fd6a10835716b232827a20a1fdfe1806cdb062f58aaa43051d4d9e3b4b5e4c

Contents?: true

Size: 887 Bytes

Versions: 1

Compression:

Stored size: 887 Bytes

Contents

module SirTrevorRails::Blocks
  class BrowseBlock < SirTrevorRails::Block

    attr_reader :solr_helper
  
    def with_solr_helper solr_helper
      @solr_helper = solr_helper
    end

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

    def searches
      ids = items.map { |v| v[:id] }
      @searches ||= parent.exhibit.searches.published.where(slug: ids).sort { |a,b| order.index(a.id) <=> order.index(b.id) }
    end

    def searches?
      !searches.empty?
    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
    
    def item_count category
      solr_helper.get_search_results(category.query_params).first["response"]["numFound"]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-spotlight-0.4.1 app/models/sir_trevor_rails/blocks/browse_block.rb