Sha256: 2a2cc6687667042df95f6e97794490f4e56158067fbdd4b1071c5ff32a035b9d

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Europeana
  module Blacklight
    ##
    # Blacklight document presenter for Europeana documents
    class DocumentPresenter < ::Blacklight::DocumentPresenter
      include ActionView::Helpers::AssetTagHelper # ?

      def render_document_show_field_value(field, options = {})
        render_nested_field_value(field, :show, options)
      end

      def render_index_field_value(field, options = {})
        render_nested_field_value(field, :index, options)
      end

      def render_nested_field_value(field, context, options = {})
        key = @document.nested_field_key(field)
        container = @document.nested_field_container(field)

        field_config = @configuration.send(:"#{context}_fields")[key]
        value = options[:value] || begin
          [container].flatten.compact.map do |target|
            presenter = self.class.new(target, @controller, @configuration)
            presenter.get_field_values(key, field_config, options)
          end.compact.flatten
        end

        render_field_value(value, field_config)
      end

      def get_field_values(field, field_config, options = {})
        @document.localize_lang_map(super)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
europeana-blacklight-1.3.1 app/presenters/europeana/blacklight/document_presenter.rb
europeana-blacklight-1.3.0 app/presenters/europeana/blacklight/document_presenter.rb