Class: Blacklight::Hierarchy::SelectedQfacetValueComponent

Inherits:
QfacetValueComponent
  • Object
show all
Defined in:
app/components/blacklight/hierarchy/selected_qfacet_value_component.rb

Overview

Standard display of a SELECTED facet value, no link, special span with class, and ‘remove’ button. This is similar to Blacklight::Facet::SelectedValueComponent

Instance Attribute Summary collapse

Attributes inherited from QfacetValueComponent

#id, #suppress_link

Instance Method Summary collapse

Methods inherited from QfacetValueComponent

#facet_config, #facet_item_presenter_class, #field_name_prefix, #hierarchy_config, #label_value, #path_for_facet, #render_facet_count

Constructor Details

#initialize(field_name:, item:) ⇒ SelectedQfacetValueComponent

Returns a new instance of SelectedQfacetValueComponent.



8
9
10
11
# File 'app/components/blacklight/hierarchy/selected_qfacet_value_component.rb', line 8

def initialize(field_name:, item:)
  @field_name = field_name
  @item = item
end

Instance Attribute Details

#field_nameObject (readonly)

Returns the value of attribute field_name.



13
14
15
# File 'app/components/blacklight/hierarchy/selected_qfacet_value_component.rb', line 13

def field_name
  @field_name
end

#itemObject (readonly)

Returns the value of attribute item.



13
14
15
# File 'app/components/blacklight/hierarchy/selected_qfacet_value_component.rb', line 13

def item
  @item
end

Instance Method Details

#remove_hrefObject



15
16
17
# File 'app/components/blacklight/hierarchy/selected_qfacet_value_component.rb', line 15

def remove_href
  helpers.search_action_path(helpers.search_state.filter(field_name).remove(item.qvalue).params)
end


19
20
21
22
23
24
# File 'app/components/blacklight/hierarchy/selected_qfacet_value_component.rb', line 19

def remove_link
  link_to(remove_href, class: "remove ps-2", rel: "nofollow") do
    render(Blacklight::Icons::RemoveComponent.new(aria_hidden: true)) +
      tag.span(t(:'blacklight.search.facets.selected.remove'), class: 'visually-hidden')
  end
end