Class: Blacklight::DocumentComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Blacklight::DocumentComponent
- Includes:
- ContentAreasShim
- Defined in:
- app/components/blacklight/document_component.rb
Instance Method Summary collapse
- #before_render ⇒ Object
-
#classes ⇒ Object
HTML classes to apply to the root element.
-
#initialize(document: nil, presenter: nil, id: nil, classes: [], component: :article, title_component: nil, metadata_component: nil, embed_component: nil, thumbnail_component: nil, counter: nil, document_counter: nil, counter_offset: 0, show: false) ⇒ DocumentComponent
constructor
rubocop:disable Metrics/ParameterLists.
Methods included from ContentAreasShim
Constructor Details
#initialize(document: nil, presenter: nil, id: nil, classes: [], component: :article, title_component: nil, metadata_component: nil, embed_component: nil, thumbnail_component: nil, counter: nil, document_counter: nil, counter_offset: 0, show: false) ⇒ DocumentComponent
rubocop:disable Metrics/ParameterLists
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/components/blacklight/document_component.rb', line 77 def initialize(document: nil, presenter: nil, id: nil, classes: [], component: :article, title_component: nil, metadata_component: nil, embed_component: nil, thumbnail_component: nil, counter: nil, document_counter: nil, counter_offset: 0, show: false) if presenter.nil? && document.nil? raise ArgumentError, 'missing keyword: :document or :presenter' end @document = document || presenter&.document @presenter = presenter @component = component @title_component = title_component @id = id || ('document' if show) @classes = classes Deprecation.warn(Blacklight::DocumentComponent, 'Passing embed_component is deprecated') if @embed_component.present? @embed_component = Deprecation.warn(Blacklight::DocumentComponent, 'Passing metadata_component is deprecated') if @metadata_component.present? @metadata_component = || Blacklight::DocumentMetadataComponent Deprecation.warn(Blacklight::DocumentComponent, 'Passing thumbnail_component is deprecated') if @thumbnail_component.present? @thumbnail_component = thumbnail_component || Blacklight::Document::ThumbnailComponent @document_counter = document_counter @counter = counter @counter ||= document_counter + 1 + counter_offset if document_counter.present? @show = show end |
Instance Method Details
#before_render ⇒ Object
123 124 125 126 127 128 |
# File 'app/components/blacklight/document_component.rb', line 123 def before_render set_slot(:title, nil) unless title set_slot(:thumbnail, nil, component: @thumbnail_component || presenter.view_config&.thumbnail_component) unless thumbnail || show? set_slot(:metadata, nil, component: @metadata_component, fields: presenter.field_presenters) unless set_slot(:embed, nil, component: @embed_component || presenter.view_config&.) unless end |
#classes ⇒ Object
HTML classes to apply to the root element
114 115 116 117 118 119 120 121 |
# File 'app/components/blacklight/document_component.rb', line 114 def classes [ @classes, helpers.render_document_class(@document), 'document', ("document-position-#{@counter}" if @counter) ].compact.flatten end |