Class: Blacklight::Document::BookmarkComponent
- Inherits:
-
ActionComponent
- Object
- ViewComponent::Base
- Component
- ActionComponent
- Blacklight::Document::BookmarkComponent
- 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
Instance Method Summary collapse
- #bookmark_icon ⇒ Object
- #bookmark_path ⇒ Object
- #bookmarked? ⇒ Boolean
-
#initialize(document:, action: nil, checked: nil, bookmark_path: nil, **kwargs) ⇒ BookmarkComponent
constructor
A new instance of BookmarkComponent.
Methods inherited from ActionComponent
#key, #label, #link_to_modal_control, #render_control, #render_partial, #url, #using_default_document_action?
Methods inherited from Component
Constructor Details
#initialize(document:, action: nil, checked: nil, bookmark_path: nil, **kwargs) ⇒ BookmarkComponent
Returns a new instance of BookmarkComponent.
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_icon ⇒ Object
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_path ⇒ Object
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
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 |