Class: Blacklight::Response::ViewTypeButtonComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/blacklight/response/view_type_button_component.rb

Overview

Render spellcheck results for a search query

Instance Method Summary collapse

Constructor Details

#initialize(view:, key: nil, selected: false, search_state: nil, classes: 'btn btn-outline-secondary btn-icon') ⇒ ViewTypeButtonComponent

Returns a new instance of ViewTypeButtonComponent.

Parameters:

  • view (Blacklight::Configuration::View)


9
10
11
12
13
14
15
# File 'app/components/blacklight/response/view_type_button_component.rb', line 9

def initialize(view:, key: nil, selected: false, search_state: nil, classes: 'btn btn-outline-secondary btn-icon')
  @view = view
  @key = key || view.key
  @selected = selected
  @classes = classes
  @search_state = search_state
end

Instance Method Details

#iconObject



17
18
19
20
21
# File 'app/components/blacklight/response/view_type_button_component.rb', line 17

def icon
  Deprecation.silence(Blacklight::CatalogHelperBehavior) do
    helpers.render_view_type_group_icon(@view.icon || @key)
  end
end

#labelObject



23
24
25
26
27
# File 'app/components/blacklight/response/view_type_button_component.rb', line 23

def label
  Deprecation.silence(Blacklight::ConfigurationHelperBehavior) do
    helpers.view_label(@key)
  end
end

#selected?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/components/blacklight/response/view_type_button_component.rb', line 33

def selected?
  @selected
end

#urlObject



29
30
31
# File 'app/components/blacklight/response/view_type_button_component.rb', line 29

def url
  helpers.url_for(@search_state.to_h.merge(view: @key))
end