Class: Hyrax::Forms::BatchUploadForm

Inherits:
WorkForm
  • Object
show all
Defined in:
app/forms/hyrax/forms/batch_upload_form.rb

Defined Under Namespace

Classes: Name

Instance Attribute Summary collapse

Attributes inherited from WorkForm

#current_ability

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from WorkForm

#[], #agreement_accepted?, build_permitted_params, #display_additional_fields?, #find_child_work, #initialize, #initialize_field, #member_of_collections, #member_of_collections_json, sanitize_params, #secondary_terms, #select_files, #version, #work_members, #work_members_json

Constructor Details

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

Instance Attribute Details

#payload_concernObject

a Class name: what is form creating a batch of?



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

def payload_concern
  @payload_concern
end

Class Method Details

.model_nameObject

Override of ActiveModel::Model name that allows us to use our custom name class



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

def self.model_name
  @_model_name ||= begin
    namespace = module_parents.detect do |n|
      n.respond_to?(:use_relative_model_naming?) && n.use_relative_model_naming?
    end
    Name.new(model_class, namespace)
  end
end

Instance Method Details

#depositorObject

The WorkForm delegates ‘#depositor` to `:model`, but `:model` in the BatchUpload context is a blank work with a `nil` depositor value. This causes the “Sharing With” widget to display the Depositor as “()”. We should be able to reliably pull back the depositor of the new batch of works by asking the form’s Ability what its ‘current_user` is.



16
17
18
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 16

def depositor
  current_ability.current_user
end

#model_nameObject



40
41
42
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 40

def model_name
  self.class.model_name
end

#primary_termsObject

On the batch upload, title is set per-file.



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

def primary_terms
  super - [:title]
end

#to_modelObject

This is required for routing to the BatchUploadController



45
46
47
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 45

def to_model
  self
end