Sha256: 9b33c15dd7ebfcf369c062b9a7b4ca70a5f5798023c2140530e49817139ff4d4

Contents?: true

Size: 1.41 KB

Versions: 15

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

module Blacklight
  module Response
    # Render a group of facet fields
    class FacetGroupComponent < Blacklight::Component
      renders_one :body

      # @param [Blacklight::Response] response
      # @param [Array<Blacklight::Configuration::FacetField>] fields facet fields to render
      # @param [String] title the title of the facet group section
      # @param [String] id a unique identifier for the group
      def initialize(id:, title: nil, fields: [], response: nil)
        @groupname = id
        @id = id ? "facets-#{id}" : 'facets'
        @title = title || I18n.t("blacklight.search.#{@id}.title")
        @panel_id = id ? "facet-panel-#{id}-collapse" : 'facet-panel-collapse'

        # deprecated variables
        @fields = fields
        @response = response
      end

      # Provide fallback behavior for rendering this object without a body slot
      def before_render
        set_slot(:body, nil) { default_body } unless body?
      end

      def render?
        body.present?
      end

      private

      # @deprecated
      def default_body
        Blacklight.deprecation.warn('Rendering the Blacklight::FacetGroupComponent without a body slot is deprecated.')
        helpers.render(Blacklight::FacetComponent.with_collection(@fields, response: @response))
      end

      # @deprecated
      def blacklight_config
        helpers.blacklight_config
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/app/components/blacklight/response/facet_group_component.rb
blacklight-8.3.0 app/components/blacklight/response/facet_group_component.rb
blacklight-8.2.2 app/components/blacklight/response/facet_group_component.rb
blacklight-8.2.1 app/components/blacklight/response/facet_group_component.rb
blacklight-8.2.0 app/components/blacklight/response/facet_group_component.rb
blacklight-8.1.0 app/components/blacklight/response/facet_group_component.rb
blacklight-8.0.1 app/components/blacklight/response/facet_group_component.rb
blacklight-8.0.0 app/components/blacklight/response/facet_group_component.rb
blacklight-8.0.0.beta8 app/components/blacklight/response/facet_group_component.rb
blacklight-8.0.0.beta7 app/components/blacklight/response/facet_group_component.rb
blacklight-8.0.0.beta6 app/components/blacklight/response/facet_group_component.rb
blacklight-8.0.0.beta5 app/components/blacklight/response/facet_group_component.rb
blacklight-8.0.0.beta4 app/components/blacklight/response/facet_group_component.rb
blacklight-8.0.0.beta3 app/components/blacklight/response/facet_group_component.rb
blacklight-8.0.0.beta2 app/components/blacklight/response/facet_group_component.rb