Class: Hyrax::Forms::BatchUploadForm
- Defined in:
- app/forms/hyrax/forms/batch_upload_form.rb
Defined Under Namespace
Classes: Name
Instance Attribute Summary collapse
-
#payload_concern ⇒ Object
a Class name: what is form creating a batch of?.
Attributes inherited from WorkForm
Class Method Summary collapse
-
.model_name ⇒ Object
Override of ActiveModel::Model name that allows us to use our custom name class.
Instance Method Summary collapse
-
#depositor ⇒ Object
The WorkForm delegates ‘#depositor` to `:model`, but `:model` in the BatchUpload context is a blank work with a `nil` depositor value.
- #form_class ⇒ Object
- #model_name ⇒ Object
- #payload_class ⇒ Object
-
#primary_terms ⇒ Object
On the batch upload, title is set per-file.
- #required_fields ⇒ Object
-
#to_model ⇒ Object
This is required for routing to the BatchUploadController.
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_concern ⇒ Object
a Class name: what is form creating a batch of?
11 12 13 |
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 11 def payload_concern @payload_concern end |
Class Method Details
.model_name ⇒ Object
Override of ActiveModel::Model name that allows us to use our custom name class
45 46 47 48 49 50 51 52 |
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 45 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
#depositor ⇒ Object
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.
18 19 20 |
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 18 def depositor current_ability.current_user end |
#form_class ⇒ Object
36 37 38 |
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 36 def form_class @form_class ||= "#{payload_class}Form".safe_constantize end |
#model_name ⇒ Object
54 55 56 |
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 54 def model_name self.class.model_name end |
#payload_class ⇒ Object
32 33 34 |
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 32 def payload_class @payload_class ||= Valkyrie.config.resource_class_resolver.call(payload_concern) end |
#primary_terms ⇒ Object
On the batch upload, title is set per-file.
23 24 25 |
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 23 def primary_terms super - [:title] end |
#required_fields ⇒ Object
27 28 29 30 |
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 27 def required_fields return super unless Hyrax.config.use_valkyrie? form_class.required_fields end |
#to_model ⇒ Object
This is required for routing to the BatchUploadController
59 60 61 |
# File 'app/forms/hyrax/forms/batch_upload_form.rb', line 59 def to_model self end |