Class: Arclight::BreadcrumbComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Arclight::BreadcrumbComponent
- Defined in:
- app/components/arclight/breadcrumb_component.rb
Overview
Display the document hierarchy as “breadcrumbs”
Instance Method Summary collapse
- #build_repository_link ⇒ Object
- #call ⇒ Object
- #components {|build_repository_link| ... } ⇒ Object
-
#initialize(document:, count: nil, offset: 0) ⇒ BreadcrumbComponent
constructor
A new instance of BreadcrumbComponent.
Constructor Details
#initialize(document:, count: nil, offset: 0) ⇒ BreadcrumbComponent
Returns a new instance of BreadcrumbComponent.
7 8 9 10 11 12 |
# File 'app/components/arclight/breadcrumb_component.rb', line 7 def initialize(document:, count: nil, offset: 0) @document = document @count = count @offset = offset super end |
Instance Method Details
#build_repository_link ⇒ Object
36 37 38 |
# File 'app/components/arclight/breadcrumb_component.rb', line 36 def build_repository_link render Arclight::RepositoryBreadcrumbComponent.new(document: @document) end |
#call ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/components/arclight/breadcrumb_component.rb', line 14 def call = components.drop(@offset) if @count && .length > @count = .first(@count) << tag.li('…'.html_safe, class: 'breadcrumb-item') end tag.ol class: 'breadcrumb' do safe_join() end end |
#components {|build_repository_link| ... } ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/components/arclight/breadcrumb_component.rb', line 26 def components return to_enum(:components) unless block_given? yield build_repository_link @document.parents.each do |parent| yield tag.li(class: 'breadcrumb-item') { link_to(parent.label, solr_document_path(parent.id)) } end end |