Sha256: b37fe6eedd18186019cb9f7acc2678109601623e65fb63d4c409dc0940e7008d
Contents?: true
Size: 1.07 KB
Versions: 6
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Blacklight module Document # Render a bookmark widget to bookmark / unbookmark a document class BookmarkComponent < Blacklight::Document::ActionComponent # @param [Blacklight::Document] document # @param [Blacklight::Configuration::ToolConfig] action # @param [Boolean] checked # @param [Object] bookmark_path the rails route to use for bookmarks 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 def bookmarked? return @checked unless @checked.nil? helpers.bookmarked? @document end def bookmark_icon return unless helpers.blacklight_config.bookmark_icon_component render helpers.blacklight_config.bookmark_icon_component.new(name: 'bookmark') end def bookmark_path @bookmark_path || helpers.bookmark_path(@document) end end end end
Version data entries
6 entries across 6 versions & 1 rubygems