Class: Arclight::SearchResultBreadcrumbsComponent

Inherits:
Blacklight::MetadataFieldComponent
  • Object
show all
Defined in:
app/components/arclight/search_result_breadcrumbs_component.rb

Overview

Render the breadcrumbs for a search result document

Instance Method Summary collapse

Constructor Details

#initialize(field:, **kwargs) ⇒ SearchResultBreadcrumbsComponent

Returns a new instance of SearchResultBreadcrumbsComponent.



8
9
10
11
# File 'app/components/arclight/search_result_breadcrumbs_component.rb', line 8

def initialize(field:, **kwargs)
  @field = field
  super
end

Instance Method Details



27
28
29
# File 'app/components/arclight/search_result_breadcrumbs_component.rb', line 27

def breadcrumb_count
  @field.field_config.compact&.dig(:count) if compact?
end


13
14
15
16
17
# File 'app/components/arclight/search_result_breadcrumbs_component.rb', line 13

def breadcrumbs
  offset = grouped? ? 2 : 0

  Arclight::BreadcrumbComponent.new(document: document, count: breadcrumb_count, offset: offset)
end

#compact?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'app/components/arclight/search_result_breadcrumbs_component.rb', line 33

def compact?
  helpers.document_index_view_type == :compact
end

#render?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'app/components/arclight/search_result_breadcrumbs_component.rb', line 23

def render?
  rendered_breadcrumbs.present?
end

#rendered_breadcrumbsObject



19
20
21
# File 'app/components/arclight/search_result_breadcrumbs_component.rb', line 19

def rendered_breadcrumbs
  @rendered_breadcrumbs ||= capture { render breadcrumbs }
end