Sha256: afafa3a4218c415554b68cf9bc01a029395832d474bcb66a16d911189c3babb9

Contents?: true

Size: 1.39 KB

Versions: 25

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

module Blacklight
  class SearchBarPresenter
    extend Deprecation
    attr_reader :configuration, :view_context, :controller

    # Set the partial this presenter draws
    class_attribute :partial
    self.partial = 'catalog/search_form'

    def initialize(controller, configuration = view_context.blacklight_config)
      @controller = controller
      @view_context = controller.view_context
      @configuration = configuration
    end

    def render
      view_context.render partial, presenter: self
    end
    deprecation_deprecate render: "The SearchBarPresenter has been deprecated. Call `render Blacklight::SearchBarComponent.new' instead"

    ##
    # @return [Boolean] should autocomplete be enabled in the UI
    def autocomplete_enabled?
      configuration.autocomplete_enabled.present? &&
        configuration.autocomplete_path.present?
    end

    ##
    # If no search parameters have been given, we should
    # auto-focus the user's cursor into the searchbox
    #
    # @return [Boolean]
    def autofocus?
      configuration.enable_search_bar_autofocus.present? &&
        configuration.enable_search_bar_autofocus &&
        controller.is_a?(Blacklight::Catalog) &&
        controller.action_name == "index" &&
        !controller.has_search_parameters?
    end

    def advanced_search_enabled?
      configuration.advanced_search.enabled
    end
  end
end

Version data entries

25 entries across 25 versions & 2 rubygems

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