Sha256: 5c29d2fad6ab8edac3cbcb633b5ab1322d0a86a24c27b751e66063e4216bcda3

Contents?: true

Size: 895 Bytes

Versions: 53

Compression:

Stored size: 895 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)
        Deprecation.silence(Blacklight::SearchState) do
          context.search_state.reset.add_facet_params(field, v)
        end
      end
    end
  end
end

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
blacklight-7.26.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.25.3 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.25.2 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.25.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.25.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.24.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.23.0.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.23.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.22.2 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.22.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.22.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.21.2 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.21.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.21.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.20.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.20.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.19.2 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.19.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.19.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.18.1 app/presenters/blacklight/rendering/link_to_facet.rb