Sha256: 17c192403c0b057e36633c8991bbe355730949e1bf0d5ef5e40944f55377e178

Contents?: true

Size: 1.41 KB

Versions: 11

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.')
        render(Blacklight::FacetComponent.with_collection(@fields, response: @response))
      end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
blacklight-8.8.4 app/components/blacklight/response/facet_group_component.rb
blacklight-8.8.3 app/components/blacklight/response/facet_group_component.rb
blacklight-8.8.2 app/components/blacklight/response/facet_group_component.rb
blacklight-8.8.1 app/components/blacklight/response/facet_group_component.rb
blacklight-8.8.0 app/components/blacklight/response/facet_group_component.rb
blacklight-8.7.0 app/components/blacklight/response/facet_group_component.rb
blacklight-8.6.1 app/components/blacklight/response/facet_group_component.rb
blacklight-8.6.0 app/components/blacklight/response/facet_group_component.rb
blacklight-8.5.1 app/components/blacklight/response/facet_group_component.rb
blacklight-8.5.0 app/components/blacklight/response/facet_group_component.rb
blacklight-8.4.0 app/components/blacklight/response/facet_group_component.rb