Class: Hyrax::Forms::AdminSetForm

Inherits:
CollectionForm show all
Defined in:
app/forms/hyrax/forms/admin_set_form.rb

Instance Attribute Summary

Attributes inherited from CollectionForm

#scope

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CollectionForm

#available_parent_collections, #banner_info, #display_additional_fields?, #initialize, #list_child_collections, #list_parent_collections, #logo_info, #primary_terms, #secondary_terms, #select_files

Constructor Details

This class inherits a constructor from Hyrax::Forms::CollectionForm

Class Method Details

.multiple?(_term) ⇒ Boolean

This determines whether the allowed parameters are single or multiple. By default it delegates to the model.

Returns:

  • (Boolean)

28
29
30
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 28

def multiple?(_term)
  false
end

.sanitize_params(form_params) ⇒ Object

Overriden to cast 'title' and 'description' to an array


33
34
35
36
37
38
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 33

def sanitize_params(form_params)
  super.tap do |params|
    params['title'] = Array.wrap(params['title']) if params.key?('title')
    params['description'] = Array.wrap(params['description']) if params.key?('description')
  end
end

Instance Method Details

#[](key) ⇒ Object

Cast any array values on the model to scalars.


8
9
10
11
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 8

def [](key)
  return super if key == :thumbnail_id
  super.first
end

#permission_templateObject


13
14
15
16
17
18
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 13

def permission_template
  @permission_template ||= begin
                             template_model = PermissionTemplate.find_or_create_by(source_id: model.id)
                             PermissionTemplateForm.new(template_model)
                           end
end

#thumbnail_titleObject


20
21
22
23
# File 'app/forms/hyrax/forms/admin_set_form.rb', line 20

def thumbnail_title
  return unless model.thumbnail
  model.thumbnail.title.first
end