Sha256: ad3f1ae20a8fc243350b17593dc5df47a27bb3f075205e7836f98f4d167d5cc1

Contents?: true

Size: 896 Bytes

Versions: 31

Compression:

Stored size: 896 Bytes

Contents

module Blacklight
  module Rendering
    class LinkToFacet < AbstractStep
      def render
        # TODO: We should rename the config variable, because it creates a link to a facet.
        return next_step(values) unless config.link_to_search
        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_search == true
          config.link_to_search
        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

31 entries across 31 versions & 1 rubygems

Version Path
blacklight-6.25.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.24.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.23.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.22.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.21.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.20.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.19.2 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.19.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.19.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.18.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.17.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.16.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.15.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.14.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.14.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.13.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.12.0 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.11.2 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.11.1 app/presenters/blacklight/rendering/link_to_facet.rb
blacklight-6.11.0 app/presenters/blacklight/rendering/link_to_facet.rb