Class: Blacklight::DocumentTitleComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Blacklight::DocumentTitleComponent
- Defined in:
- app/components/blacklight/document_title_component.rb
Instance Attribute Summary collapse
-
#presenter ⇒ Object
rubocop:enable Metrics/ParameterLists.
Instance Method Summary collapse
-
#actions ⇒ Object
Content for the document actions area.
- #counter ⇒ Object
-
#initialize(title = nil, presenter:, as: :h3, counter: nil, classes: 'index_title document-title-heading col h5', 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
reset_compiler!, sidecar_files, upstream_sidecar_files
Constructor Details
#initialize(title = nil, presenter:, as: :h3, counter: nil, classes: 'index_title document-title-heading col h5', 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 23 |
# File 'app/components/blacklight/document_title_component.rb', line 10 def initialize(title = nil, presenter:, as: :h3, counter: nil, classes: 'index_title document-title-heading col h5', link_to_document: true, document_component: nil, actions: true) @title = title @presenter = presenter @as = as || :h3 @counter = counter @classes = classes @link_to_document = link_to_document @document_component = document_component @actions = actions @document = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(@presenter.document, "Don't use the @document instance variable. Instead use @presenter", ActiveSupport::Deprecation.new) end |
Instance Attribute Details
#presenter ⇒ Object
rubocop:enable Metrics/ParameterLists
26 27 28 |
# File 'app/components/blacklight/document_title_component.rb', line 26 def presenter @presenter end |
Instance Method Details
#actions ⇒ Object
Content for the document actions area
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/components/blacklight/document_title_component.rb', line 38 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 mb-4 mb-sm-0')] end |
#counter ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/components/blacklight/document_title_component.rb', line 51 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
29 30 31 32 33 34 35 |
# File 'app/components/blacklight/document_title_component.rb', line 29 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 |