Sha256: 563cbf15e71c6e4f9ffb43e2a6e715f9c2a93dbf48c52c859a8a88871321610a

Contents?: true

Size: 1.32 KB

Versions: 15

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Blacklight
  module Document
    # Render a bookmark widget to bookmark / unbookmark a document
    class ActionsComponent < Blacklight::Component
      renders_many :actions, (lambda do |action:, component: nil, **kwargs|
        component ||= action.component || Blacklight::Document::ActionComponent
        component.new(action: action, document: @document, options: @options, url_opts: @url_opts, link_classes: @link_classes, **kwargs)
      end)

      # @param [Blacklight::Document] document
      # rubocop:disable Metrics/ParameterLists
      def initialize(document: nil, actions: [], options: {}, url_opts: nil, tag: :div, classes: 'index-document-functions', wrapping_tag: nil, wrapping_classes: nil, link_classes: 'nav-link')
        @document = document
        @actions = actions
        @tag = tag
        @classes = classes
        @options = options
        @url_opts = url_opts
        @wrapping_tag = wrapping_tag
        @wrapping_classes = wrapping_classes
        @link_classes = link_classes
      end
      # rubocop:enable Metrics/ParameterLists

      def before_render
        return if actions.present?

        @actions.each do |a|
          action(component: a.component, action: a)
        end
      end

      def render?
        actions.present?
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
blacklight-7.33.1 app/components/blacklight/document/actions_component.rb
blacklight-7.33.0 app/components/blacklight/document/actions_component.rb
blacklight-7.32.0 app/components/blacklight/document/actions_component.rb
blacklight-7.31.0 app/components/blacklight/document/actions_component.rb
blacklight-7.30.0 app/components/blacklight/document/actions_component.rb
blacklight-7.29.0 app/components/blacklight/document/actions_component.rb
blacklight-7.28.0 app/components/blacklight/document/actions_component.rb
blacklight-7.27.1 app/components/blacklight/document/actions_component.rb
blacklight-7.27.0 app/components/blacklight/document/actions_component.rb
blacklight-7.26.1 app/components/blacklight/document/actions_component.rb
blacklight-7.26.0 app/components/blacklight/document/actions_component.rb
blacklight-7.25.3 app/components/blacklight/document/actions_component.rb
blacklight-7.25.2 app/components/blacklight/document/actions_component.rb
blacklight-7.25.1 app/components/blacklight/document/actions_component.rb
blacklight-7.25.0 app/components/blacklight/document/actions_component.rb