Sha256: 573418fc6d60efde3f34ad5647e52d3cc84cf33e5a8234808da40ac4b80fab71

Contents?: true

Size: 825 Bytes

Versions: 21

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  module Rendering
    class LinkToFacet < AbstractStep
      extend Deprecation
      def render
        return next_step(values) unless config.link_to_facet

        next_step(render_link)
      end

      private

      # This allows the link to wrap an itemprop
      def render_link
        values.map { |v| link(link_field, v) }
      end

      def link_field
        return config.key if config.link_to_facet == true

        config.link_to_facet
      end

      def link(field, v)
        context.link_to v, search_path(field, v)
      end

      def search_path(field, v)
        context.search_action_path(facet_params(field, v))
      end

      def facet_params(field, v)
        context.search_state.reset.add_facet_params(field, v)
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
blacklight-7.12.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.12.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.11.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.10.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.9.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.8.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.8.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.7.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.6.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.5.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.5.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.4.2 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.4.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.4.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.3.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.2.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.1.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.1.0.alpha app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.0.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.0.0 app/presenters/blacklight/rendering/link_to_facet.rb