Class: Blacklight::ConstraintLayoutComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/blacklight/constraint_layout_component.rb

Direct Known Subclasses

SearchHistoryConstraintLayoutComponent

Constant Summary

Constants inherited from Component

Blacklight::Component::EXCLUDE_VARIABLES

Instance Method Summary collapse

Methods inherited from Component

compiler, config, #inspect

Constructor Details

#initialize(value:, label: nil, remove_path: nil, classes: nil, search_state: nil) ⇒ ConstraintLayoutComponent

Returns a new instance of ConstraintLayoutComponent.



5
6
7
8
9
10
11
# File 'app/components/blacklight/constraint_layout_component.rb', line 5

def initialize(value:, label: nil, remove_path: nil, classes: nil, search_state: nil)
  @value = value
  @label = label
  @remove_path = remove_path
  @classes = Array(classes).join(' ')
  @search_state = search_state
end

Instance Method Details

#remove_aria_labelObject



13
14
15
16
17
18
19
# File 'app/components/blacklight/constraint_layout_component.rb', line 13

def remove_aria_label
  if @label.blank?
    t('blacklight.search.filters.remove.value', value: @value)
  else
    t('blacklight.search.filters.remove.label_value', label: @label, value: @value)
  end
end

#render?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'app/components/blacklight/constraint_layout_component.rb', line 21

def render?
  @value.present?
end