Sha256: e13270205be6502b5a64faff19ba15ad80bbce1c3e9fce700a104db57e865f00

Contents?: true

Size: 1.5 KB

Versions: 10

Compression:

Stored size: 1.5 KB

Contents

module Hyrax
  module Forms
    class CollectionForm
      include HydraEditor::Form

      delegate :id, to: :model

      # TODO: remove this when https://github.com/projecthydra/hydra-editor/pull/115
      # is merged and hydra-editor 3.0.0 is released
      delegate :model_name, to: :model

      self.model_class = ::Collection

      delegate :human_readable_type, :member_ids, to: :model

      self.terms = [:resource_type, :title, :creator, :contributor, :description,
                    :keyword, :rights, :publisher, :date_created, :subject, :language,
                    :representative_id, :thumbnail_id, :identifier, :based_near,
                    :related_url, :visibility]

      self.required_fields = [:title]

      # @return [Hash] All FileSets in the collection, file.to_s is the key, file.id is the value
      def select_files
        Hash[all_files]
      end

      def primary_terms
        [:title]
      end

      def secondary_terms
        [:creator,
         :contributor,
         :description,
         :keyword,
         :rights,
         :publisher,
         :date_created,
         :subject,
         :language,
         :identifier,
         :based_near,
         :related_url,
         :resource_type]
      end

      private

        def all_files
          member_presenters.flat_map(&:file_set_presenters).map { |x| [x.to_s, x.id] }
        end

        def member_presenters
          PresenterFactory.build_presenters(model.member_ids, WorkShowPresenter, nil)
        end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
hyrax-1.1.1 app/forms/hyrax/forms/collection_form.rb
hyrax-1.1.0 app/forms/hyrax/forms/collection_form.rb
hyrax-1.0.5 app/forms/hyrax/forms/collection_form.rb
hyrax-1.0.4 app/forms/hyrax/forms/collection_form.rb
hyrax-1.0.3 app/forms/hyrax/forms/collection_form.rb
hyrax-1.0.2 app/forms/hyrax/forms/collection_form.rb
hyrax-1.0.1 app/forms/hyrax/forms/collection_form.rb
hyrax-1.0.0.rc2 app/forms/hyrax/forms/collection_form.rb
hyrax-1.0.0.rc1 app/forms/hyrax/forms/collection_form.rb
test_hyrax-0.0.1.alpha app/forms/hyrax/forms/collection_form.rb