Sha256: 586c7a20d372c2c4b57c96fca983cf3b4c787895a610e88710ce0886c3d3c472

Contents?: true

Size: 803 Bytes

Versions: 19

Compression:

Stored size: 803 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  class DocumentMetadataComponent < ::ViewComponent::Base
    renders_many :fields, (lambda do |component: nil, **kwargs|
      (component || Blacklight::MetadataFieldComponent).new(**kwargs)
    end)
    with_collection_parameter :fields

    # @param fields [Enumerable<Blacklight::FieldPresenter>] Document field presenters
    def initialize(fields: [], show: false)
      @fields = fields
      @show = show
    end

    def before_render
      return unless fields

      @fields.each do |field|
        field(component: field_component(field), field: field, show: @show)
      end
    end

    def render?
      fields.present?
    end

    def field_component(field)
      field&.component || Blacklight::MetadataFieldComponent
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
blacklight-7.24.0 app/components/blacklight/document_metadata_component.rb
blacklight-7.23.0.1 app/components/blacklight/document_metadata_component.rb
blacklight-7.23.0 app/components/blacklight/document_metadata_component.rb
blacklight-7.22.2 app/components/blacklight/document_metadata_component.rb
blacklight-7.22.1 app/components/blacklight/document_metadata_component.rb
blacklight-7.22.0 app/components/blacklight/document_metadata_component.rb
blacklight-7.21.2 app/components/blacklight/document_metadata_component.rb
blacklight-7.21.1 app/components/blacklight/document_metadata_component.rb
blacklight-7.21.0 app/components/blacklight/document_metadata_component.rb
blacklight-7.20.1 app/components/blacklight/document_metadata_component.rb
blacklight-7.20.0 app/components/blacklight/document_metadata_component.rb
blacklight-7.19.2 app/components/blacklight/document_metadata_component.rb
blacklight-7.19.1 app/components/blacklight/document_metadata_component.rb
blacklight-7.19.0 app/components/blacklight/document_metadata_component.rb
blacklight-7.18.1 app/components/blacklight/document_metadata_component.rb
blacklight-7.18.0 app/components/blacklight/document_metadata_component.rb
blacklight-7.17.2 app/components/blacklight/document_metadata_component.rb
blacklight-7.17.1 app/components/blacklight/document_metadata_component.rb
blacklight-7.17.0 app/components/blacklight/document_metadata_component.rb