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

Conversation

cbeer
Copy link
Member

@cbeer cbeer commented Apr 29, 2025

This makes DocumentMetadataComponent similar to the other document sub-components.

@@ -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.

@cbeer cbeer force-pushed the doc-metadata-args branch from e976bdf to 8622844 Compare April 29, 2025 17:52
@ebenenglish
Copy link
Contributor

+1 to this change. I recently found myself having to subclass Blacklight::DocumentComponent to be able to explicitly pass document as an argument to my custom MetadataComponent. This change would make that unnecessary.

@jcoyne
Copy link
Member

jcoyne commented Apr 29, 2025

This needs #3586 to be merged first I believe.

@jcoyne
Copy link
Member

jcoyne commented Apr 29, 2025

@cbeer please rebase on main since #3586 has been merged

@cbeer cbeer force-pushed the doc-metadata-args branch from 8622844 to ea02c7a Compare April 29, 2025 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants