Sha256: 1bb7c4ea40712588e62262569c8dacd2e228aa204e2b5c6f1057a5dbdc1ab84e

Contents?: true

Size: 1018 Bytes

Versions: 3

Compression:

Stored size: 1018 Bytes

Contents

# frozen_string_literal: true

module Blacklight
  class MetadataFieldComponent < ::ViewComponent::Base
    with_collection_parameter :field

    # @param field [Blacklight::FieldPresenter]
    # @param layout [Blacklight::MetadataFieldLayoutComponent] alternate layout component to use
    # @param show [Boolean] are we showing only a single document (vs a list of search results); used for backwards-compatibility
    def initialize(field:, layout: nil, show: false)
      @field = field
      @layout = layout || Blacklight::MetadataFieldLayoutComponent
      @show = show
    end

    # @private
    def label
      Deprecation.silence(Blacklight::BlacklightHelperBehavior) do
        if @show
          helpers.render_document_show_field_label @field.document, label: @field.label('show'), field: @field.key
        else
          helpers.render_index_field_label @field.document, label: @field.label, field: @field.key
        end
      end
    end

    def render?
      @field.render_field?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blacklight-7.24.0 app/components/blacklight/metadata_field_component.rb
blacklight-7.23.0.1 app/components/blacklight/metadata_field_component.rb
blacklight-7.23.0 app/components/blacklight/metadata_field_component.rb