Skip to content
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

Restore to_html method to nested related item field. #177

Merged
merged 1 commit into from
Dec 11, 2023
Merged
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
14 changes: 14 additions & 0 deletions lib/mods_display/fields/nested_related_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ def fields
end
end

# Used by exhibits
def to_html(view_context = ApplicationController.renderer)
helpers = view_context.respond_to?(:simple_format) ? view_context : ApplicationController.new.view_context

component = ModsDisplay::ListFieldComponent.with_collection(
fields,
value_transformer: ->(value) { helpers.format_mods_html(value.to_s) },
list_html_attributes: { class: 'mods_display_nested_related_items' },
list_item_html_attributes: { class: 'mods_display_nested_related_item open' }
)

view_context.render component, layout: false
end

# this class provides html markup and is subclassed in purl application
class ValueRenderer
def initialize(related_item_element)
Expand Down