Class: Hyrax::CollectionOptionsPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/hyrax/collection_options_presenter.rb

Overview

Presents the options for the Collection widget on the create/edit form

Instance Method Summary collapse

Constructor Details

#initialize(service) ⇒ CollectionOptionsPresenter

Returns a new instance of CollectionOptionsPresenter.

Parameters:


5
6
7
8
# File 'app/presenters/hyrax/collection_options_presenter.rb', line 5

def initialize(service)
  @service = service
  Deprecation.warn(self, 'CollectionOptionsPresenter is deprecated and will be removed in Hyrax 3')
end

Instance Method Details

#select_options(access = :edit) ⇒ Object

Return Collection selectbox options based on access type

Parameters:

  • access (Symbol) (defaults to: :edit)

    :read or :edit


12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/presenters/hyrax/collection_options_presenter.rb', line 12

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