Sha256: c05cee95c77694f4efeb4100c9a3087eb1209e63d53fa599a5bb770e2f2adf22

Contents?: true

Size: 1.5 KB

Versions: 48

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

module Blacklight
  class FacetFieldPresenter
    attr_reader :facet_field, :display_facet, :view_context, :search_state

    delegate :key, to: :facet_field
    delegate :field_name, to: :display_facet

    def initialize(facet_field, display_facet, view_context, search_state = view_context.search_state)
      @facet_field = facet_field
      @display_facet = display_facet
      @view_context = view_context
      @search_state = search_state
    end

    def collapsed?
      Deprecation.silence(Blacklight::FacetsHelperBehavior) do
        view_context.should_collapse_facet?(facet_field)
      end
    end

    def active?
      Deprecation.silence(Blacklight::FacetsHelperBehavior) do
        view_context.facet_field_in_params?(key)
      end
    end

    def in_modal?
      search_state.params[:action] == "facet"
    end

    def modal_path
      return unless paginator

      view_context.search_facet_path(id: key) unless paginator&.last_page?
    end

    def label
      view_context.facet_field_label(key)
    end

    def values
      search_state&.filter(facet_field)&.values || []
    end

    # @private
    # @deprecated
    def html_id
      Deprecation.silence(Blacklight::FacetsHelperBehavior) do
        view_context.facet_field_id(facet_field)
      end
    end

    def paginator
      return unless display_facet

      Deprecation.silence(Blacklight::Facet) do
        @paginator ||= view_context.facet_paginator(facet_field, display_facet)
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 2 rubygems

Version Path
blacklight-7.40.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.39.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.38.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-7.37.0/app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.37.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.36.2 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.36.1 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.36.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.35.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.34.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.33.1 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.33.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.32.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.31.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.30.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.29.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.28.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.27.1 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.27.0 app/presenters/blacklight/facet_field_presenter.rb
blacklight-7.26.1 app/presenters/blacklight/facet_field_presenter.rb