Class: Blacklight::Document::BookmarkComponent

Inherits:
ActionComponent show all
Defined in:
app/components/blacklight/document/bookmark_component.rb

Overview

Render a bookmark widget to bookmark / unbookmark a document

Constant Summary

Constants inherited from Component

Component::EXCLUDE_VARIABLES

Instance Method Summary collapse

Methods inherited from ActionComponent

#key, #label, #link_to_modal_control, #render_control, #render_partial, #url, #using_default_document_action?

Methods inherited from Component

compiler, config, #inspect

Constructor Details

#initialize(document:, action: nil, checked: nil, bookmark_path: nil, **kwargs) ⇒ BookmarkComponent

Returns a new instance of BookmarkComponent.

Parameters:



11
12
13
14
15
16
# File 'app/components/blacklight/document/bookmark_component.rb', line 11

def initialize(document:, action: nil, checked: nil, bookmark_path: nil, **kwargs)
  @document = document
  @checked = checked
  @bookmark_path = bookmark_path
  super(document: document, action: action, **kwargs)
end

Instance Method Details

#bookmark_iconObject



24
25
26
27
28
# File 'app/components/blacklight/document/bookmark_component.rb', line 24

def bookmark_icon
  return unless helpers.blacklight_config.bookmark_icon_component

  render helpers.blacklight_config.bookmark_icon_component.new(name: 'bookmark')
end

#bookmark_pathObject



30
31
32
# File 'app/components/blacklight/document/bookmark_component.rb', line 30

def bookmark_path
  @bookmark_path || helpers.bookmark_path(@document)
end

#bookmarked?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'app/components/blacklight/document/bookmark_component.rb', line 18

def bookmarked?
  return @checked unless @checked.nil?

  helpers.bookmarked? @document
end