Class: Hyrax::AdminSetSelectionPresenter
- Inherits:
-
Object
- Object
- Hyrax::AdminSetSelectionPresenter
- Defined in:
- app/presenters/hyrax/admin_set_selection_presenter.rb
Overview
this supersedes the older Hyrax::AdminSetOptionsPresenter
, which actied more like a “service” sending database queries to Solr and ActiveRecord. this version seeks only to present the input data and relies on its caller to pass in the right data.
Presents select options for admin sets.
Each entry in the #select_options return value provides a label for display, an id to serve as the value, and a data hash which is used as HTML5 data entries. The data entries can be used as hooks for Javascript to control input validation taking into account the Admin Set and ‘PermissionTemplate` rules (`visibility_component.es6` does this, for example).
Defined Under Namespace
Classes: OptionsEntry
Instance Method Summary collapse
-
#initialize(admin_sets:) ⇒ AdminSetSelectionPresenter
constructor
A new instance of AdminSetSelectionPresenter.
-
#select_options ⇒ Array<Array<String, String, Hash>>
An array suitable for a form input ‘collection:` parameter.
Constructor Details
#initialize(admin_sets:) ⇒ AdminSetSelectionPresenter
Returns a new instance of AdminSetSelectionPresenter.
23 24 25 |
# File 'app/presenters/hyrax/admin_set_selection_presenter.rb', line 23 def initialize(admin_sets:) @admin_sets = admin_sets end |
Instance Method Details
#select_options ⇒ Array<Array<String, String, Hash>>
Returns an array suitable for a form input ‘collection:` parameter. it should contain a label, an id, and a hash of HTML5 data attributes.
31 32 33 34 35 36 37 38 39 40 |
# File 'app/presenters/hyrax/admin_set_selection_presenter.rb', line 31 def @admin_sets.map do |admin_set| case admin_set when OptionsEntry admin_set.result else OptionsEntry.new(admin_set: admin_set).result end end end |