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.40.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.39.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.38.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.37.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.36.2 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.36.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.36.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.35.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.34.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.33.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.33.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.32.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.31.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.30.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.29.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.28.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.27.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.27.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-7.26.1 app/presenters/blacklight/rendering/link_to_facet.rb