Class: ModsDisplay::NestedRelatedItem
- Includes:
- RelatedItemConcerns
- Defined in:
- lib/mods_display/fields/nested_related_item.rb
Overview
This class will hopefully take over for related item support more broadly. Currently there is behavior in RelatedItem and Collection that would need to be accounted for when adding nested metadata support.
Instance Method Summary collapse
Methods inherited from Field
Constructor Details
This class inherits a constructor from ModsDisplay::Field
Instance Method Details
#fields ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mods_display/fields/nested_related_item.rb', line 9 def fields @fields ||= begin return_fields = @values.map do |value| next if (value) next unless (value) (value) end.compact collapse_fields(return_fields) end end |
#to_html ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mods_display/fields/nested_related_item.rb', line 21 def to_html return if fields.empty? || @config.ignore? @to_html ||= begin output = '' fields.each do |field| next unless field.values.any? { |f| f && !f.empty? } output << "<dt#{label_class} #{sanitized_field_title(field.label)}>#{field.label}</dt>" output << "<dd#{value_class}>" output << '<ul class="mods_display_nested_related_items">' output << field.values.map do |val| "<li class='mods_display_nested_related_item open'>#{link_urls_and_email(val.to_s)}</li>" end.join output << '</ul>' output << '</dd>' end output end end |