Sha256: 0d0de34803f354ba04c978a4e44b1054f5615035331bdabe78c528cfd583f7ad

Contents?: true

Size: 748 Bytes

Versions: 12

Compression:

Stored size: 748 Bytes

Contents

module Hyrax
  # Presents the options for the Collection widget on the create/edit form
  class CollectionOptionsPresenter
    # @param [Hyrax::CollectionsService] service
    def initialize(service)
      @service = service
    end

    # Return Collection selectbox options based on access type
    # @param [Symbol] access :read or :edit
    def select_options(access = :edit)
      option_values = results(access).map do |solr_doc|
        [solr_doc.to_s, solr_doc.id]
      end
      option_values.sort do |a, b|
        if a.first && b.first
          a.first <=> b.first
        else
          a.first ? -1 : 1
        end
      end
    end

    private

      def results(access)
        @service.search_results(access)
      end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
hyrax-2.0.3 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.2 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.1 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.0 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.0.rc3 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.0.rc2 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.0.rc1 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.0.beta5 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.0.beta4 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.0.beta3 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.0.beta2 app/presenters/hyrax/collection_options_presenter.rb
hyrax-2.0.0.beta1 app/presenters/hyrax/collection_options_presenter.rb