Sha256: a474df6c0332302e4260438150aa1650d05fb03b2c383bacfb6f1ba9e9152572

Contents?: true

Size: 1.35 KB

Versions: 20

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module Blacklight
  module Document
    # Render a the set of actions for a document. One of the default actions is the bookmark control.
    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|
          with_action(component: a.component, action: a)
        end
      end

      def render?
        actions.present?
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
blacklight-8.6.1 app/components/blacklight/document/actions_component.rb
blacklight-8.6.0 app/components/blacklight/document/actions_component.rb
blacklight-8.5.1 app/components/blacklight/document/actions_component.rb
blacklight-8.5.0 app/components/blacklight/document/actions_component.rb
blacklight-8.4.0 app/components/blacklight/document/actions_component.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-8.3.0/app/components/blacklight/document/actions_component.rb
blacklight-8.3.0 app/components/blacklight/document/actions_component.rb
blacklight-8.2.2 app/components/blacklight/document/actions_component.rb
blacklight-8.2.1 app/components/blacklight/document/actions_component.rb
blacklight-8.2.0 app/components/blacklight/document/actions_component.rb
blacklight-8.1.0 app/components/blacklight/document/actions_component.rb
blacklight-8.0.1 app/components/blacklight/document/actions_component.rb
blacklight-8.0.0 app/components/blacklight/document/actions_component.rb
blacklight-8.0.0.beta8 app/components/blacklight/document/actions_component.rb
blacklight-8.0.0.beta7 app/components/blacklight/document/actions_component.rb
blacklight-8.0.0.beta6 app/components/blacklight/document/actions_component.rb
blacklight-8.0.0.beta5 app/components/blacklight/document/actions_component.rb
blacklight-8.0.0.beta4 app/components/blacklight/document/actions_component.rb
blacklight-8.0.0.beta3 app/components/blacklight/document/actions_component.rb
blacklight-8.0.0.beta2 app/components/blacklight/document/actions_component.rb