app/components/blacklight/document_metadata_component.rb in blacklight-7.40.0 vs app/components/blacklight/document_metadata_component.rb in blacklight-8.0.0.beta1
- old
+ new
@@ -1,36 +1,31 @@
# frozen_string_literal: true
module Blacklight
class DocumentMetadataComponent < Blacklight::Component
renders_many :fields, (lambda do |component: nil, **kwargs|
- (component || Blacklight::MetadataFieldComponent).new(**kwargs)
+ component.new(**kwargs)
end)
with_collection_parameter :fields
# @param fields [Enumerable<Blacklight::FieldPresenter>] Document field presenters
- def initialize(fields: [], tag: 'dl', classes: %w[document-metadata dl-invert row], show: false, field_layout: nil, **component_args)
+ def initialize(fields: [], show: false, view_type: nil)
@fields = fields
- @tag = tag
- @classes = classes
@show = show
- @field_layout = field_layout
- @component_args = component_args
+ @view_type = view_type
end
def before_render
return unless fields
@fields.each do |field|
- with_field(component: field_component(field), field: field, show: @show, layout: @field_layout)
+ field(component: field.component, field: field, show: @show, view_type: @view_type)
end
end
def render?
fields.present?
end
- def field_component(field)
- field&.component || Blacklight::MetadataFieldComponent
- end
+ attr_reader :view_type
end
end