Sha256: f48c61db84537a8122998db211be74dbda7ac3bbb4a7b3090271c0fbbbd54a36

Contents?: true

Size: 746 Bytes

Versions: 8

Compression:

Stored size: 746 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 AdminSet 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

8 entries across 8 versions & 1 rubygems

Version Path
hyrax-1.1.1 app/presenters/hyrax/collection_options_presenter.rb
hyrax-1.1.0 app/presenters/hyrax/collection_options_presenter.rb
hyrax-1.0.5 app/presenters/hyrax/collection_options_presenter.rb
hyrax-1.0.4 app/presenters/hyrax/collection_options_presenter.rb
hyrax-1.0.3 app/presenters/hyrax/collection_options_presenter.rb
hyrax-1.0.2 app/presenters/hyrax/collection_options_presenter.rb
hyrax-1.0.1 app/presenters/hyrax/collection_options_presenter.rb
hyrax-1.0.0.rc2 app/presenters/hyrax/collection_options_presenter.rb