Skip to content

Pass document + presenter through to DocumentMetadataComponent. #3587

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/components/blacklight/document_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class DocumentComponent < Blacklight::Component

component ||= view_config.metadata_component || Blacklight::DocumentMetadataComponent

component.new(*args, fields: fields || @presenter&.field_presenters || [], **kwargs)
component.new(*args, document: @document, presenter: @presenter, fields: fields || @presenter&.field_presenters || [], **kwargs)
end)

# Additional metadata sections
Expand Down
4 changes: 3 additions & 1 deletion app/components/blacklight/document_metadata_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class DocumentMetadataComponent < Blacklight::Component

# @param fields [Enumerable<Blacklight::FieldPresenter>] Document field presenters
# rubocop:disable Metrics/ParameterLists
def initialize(fields: [], tag: 'dl', classes: %w[document-metadata dl-invert row], show: false, view_type: nil, field_layout: nil, **component_args)
def initialize(fields: [], document: nil, presenter: nil, tag: 'dl', classes: %w[document-metadata dl-invert row], show: false, view_type: nil, field_layout: nil, **component_args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need both document + presenter? Wouldn't presenter be sufficient as it's a wrapper around the document and thus we can get the document via presenter.document?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 we pass both to all the other subcomponents.

@fields = fields
@document = document # be consistent with other subcomponents.
@presenter = presenter # be consistent with other subcomponents.
@tag = tag
@classes = classes
@show = show
Expand Down