Sha256: 0c3099e0889aa77d371daba8e2141bafeb086c7e3a82b9962bfb14b9158b7b8b

Contents?: true

Size: 719 Bytes

Versions: 39

Compression:

Stored size: 719 Bytes

Contents

module SirTrevorRails
  module Blocks
    ##
    # Embed search results (from a browse category) into the page
    class SearchResultsBlock < SirTrevorRails::Block
      def query_params
        if search
          search.query_params
        else
          {}
        end
      end

      def search
        searches.first
      end

      def searches
        @searches ||= parent.exhibit.searches.published.where(slug: item_ids).sort { |a, b| order.index(a.id) <=> order.index(b.id) }
      end

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

      def searches?
        !searches.empty?
      end

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

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
blacklight-spotlight-0.25.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.24.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.23.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.22.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.21.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.20.3 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.20.2 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.20.1 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.20.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.19.2 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.19.1 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.19.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.18.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.17.1 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.17.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.16.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.15.0 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.14.2 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.14.1 app/models/sir_trevor_rails/blocks/search_results_block.rb
blacklight-spotlight-0.14.0 app/models/sir_trevor_rails/blocks/search_results_block.rb