Sha256: 96358a2b1e4d77389fee10430fc23c7b02b089b5a50ee6dca9e486175702be90

Contents?: true

Size: 902 Bytes

Versions: 16

Compression:

Stored size: 902 Bytes

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_path
        @bookmark_path || helpers.bookmark_path(@document)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/app/components/blacklight/document/bookmark_component.rb
blacklight-8.3.0 app/components/blacklight/document/bookmark_component.rb
blacklight-8.2.2 app/components/blacklight/document/bookmark_component.rb
blacklight-8.2.1 app/components/blacklight/document/bookmark_component.rb
blacklight-8.2.0 app/components/blacklight/document/bookmark_component.rb
blacklight-8.1.0 app/components/blacklight/document/bookmark_component.rb
blacklight-8.0.1 app/components/blacklight/document/bookmark_component.rb
blacklight-8.0.0 app/components/blacklight/document/bookmark_component.rb
blacklight-8.0.0.beta8 app/components/blacklight/document/bookmark_component.rb
blacklight-8.0.0.beta7 app/components/blacklight/document/bookmark_component.rb
blacklight-8.0.0.beta6 app/components/blacklight/document/bookmark_component.rb
blacklight-8.0.0.beta5 app/components/blacklight/document/bookmark_component.rb
blacklight-8.0.0.beta4 app/components/blacklight/document/bookmark_component.rb
blacklight-8.0.0.beta3 app/components/blacklight/document/bookmark_component.rb
blacklight-8.0.0.beta2 app/components/blacklight/document/bookmark_component.rb
blacklight-8.0.0.beta1 app/components/blacklight/document/bookmark_component.rb