Sha256: 6c9b8cc1500676943b7c2e60c52f9c376f153548dabfebf699cf0d97eb0a4d90

Contents?: true

Size: 741 Bytes

Versions: 25

Compression:

Stored size: 741 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  module Document
    # Render a bookmark widget to bookmark / unbookmark a document
    class BookmarkComponent < Blacklight::Component
      # @param [Blacklight::Document] document
      # @param [Boolean] checked
      # @param [Object] bookmark_path the rails route to use for bookmarks
      def initialize(document:, checked: nil, bookmark_path: nil)
        @document = document
        @checked = checked
        @bookmark_path = bookmark_path
      end

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

        helpers.bookmarked? @document
      end

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

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
blacklight-7.26.0 app/components/blacklight/document/bookmark_component.rb
blacklight-7.25.3 app/components/blacklight/document/bookmark_component.rb
blacklight-7.25.2 app/components/blacklight/document/bookmark_component.rb
blacklight-7.25.1 app/components/blacklight/document/bookmark_component.rb
blacklight-7.25.0 app/components/blacklight/document/bookmark_component.rb