Class: Blacklight::Gallery::SlideshowPreviewComponent

Inherits:
DocumentComponent
  • Object
show all
Defined in:
app/components/blacklight/gallery/slideshow_preview_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(document:, document_counter: nil, **args) ⇒ SlideshowPreviewComponent

Returns a new instance of SlideshowPreviewComponent.



8
9
10
11
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 8

def initialize(document:, document_counter: nil, **args)
  super(document: document, document_counter: document_counter, **args)
  @document_counter = document_counter || @counter
end

Instance Method Details

#before_renderObject



13
14
15
16
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 13

def before_render
  populate_thumbnail_slot if thumbnail.blank?
  super
end

#populate_thumbnail_slotObject

populate the thumbnail slot with a value if one wasn’t explicitly provided



19
20
21
22
23
24
25
26
27
28
29
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 19

def populate_thumbnail_slot
  thumbnail_content = presenter.thumbnail.render({ alt: presenter.heading }) if presenter.thumbnail.exists?
  unless thumbnail_content.present?
    thumbnail_content = (
      :div,
      t(:missing_image, scope: %i[blacklight_gallery catalog grid_slideshow]),
      class: 'thumbnail thumbnail-placeholder'
    )
  end
  with_thumbnail(thumbnail_content)
end

#presenterObject



31
32
33
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 31

def presenter
  @presenter ||= @view_context.document_presenter(@document)
end

#render_document_class(*args) ⇒ Object



35
36
37
# File 'app/components/blacklight/gallery/slideshow_preview_component.rb', line 35

def render_document_class(*args)
  @view_context.render_document_class(*args)
end