Class: Blacklight::DocumentTitleComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Blacklight::DocumentTitleComponent
- Defined in:
- app/components/blacklight/document_title_component.rb
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
-
#actions ⇒ Object
Content for the document actions area.
- #counter ⇒ Object
-
#initialize(title = nil, document: nil, presenter: nil, as: :h3, counter: nil, classes: 'index_title document-title-heading col', link_to_document: true, document_component: nil, actions: true) ⇒ DocumentTitleComponent
constructor
rubocop:disable Metrics/ParameterLists.
-
#title ⇒ Object
Content for the document title area; should be an inline element.
Methods inherited from Component
Constructor Details
#initialize(title = nil, document: nil, presenter: nil, as: :h3, counter: nil, classes: 'index_title document-title-heading col', link_to_document: true, document_component: nil, actions: true) ⇒ DocumentTitleComponent
rubocop:disable Metrics/ParameterLists
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/components/blacklight/document_title_component.rb', line 10 def initialize(title = nil, document: nil, presenter: nil, as: :h3, counter: nil, classes: 'index_title document-title-heading col', link_to_document: true, document_component: nil, actions: true) raise ArgumentError, 'missing keyword: :document or :presenter' if presenter.nil? && document.nil? @title = title @document = document @presenter = presenter @as = as || :h3 @counter = counter @classes = classes @link_to_document = link_to_document @document_component = document_component @actions = actions end |
Instance Method Details
#actions ⇒ Object
Content for the document actions area
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/components/blacklight/document_title_component.rb', line 35 def actions return [] unless @actions if block_given? @has_actions_slot = true return super end (@has_actions_slot && get_slot(:actions)) || ([@document_component&.actions] if @document_component&.actions.present?) || [helpers.render_index_doc_actions(presenter.document, wrapping_class: 'index-document-functions col-sm-3 col-lg-2')] end |
#counter ⇒ Object
48 49 50 51 52 53 54 |
# File 'app/components/blacklight/document_title_component.rb', line 48 def counter return unless @counter content_tag :span, class: 'document-counter' do t('blacklight.search.documents.counter', counter: @counter) end end |
#title ⇒ Object
Content for the document title area; should be an inline element
26 27 28 29 30 31 32 |
# File 'app/components/blacklight/document_title_component.rb', line 26 def title if @link_to_document helpers.link_to_document presenter.document, @title.presence || content.presence, counter: @counter, itemprop: 'name' else content_tag('span', @title.presence || content.presence || presenter.heading, itemprop: 'name') end end |