Class: CurationConcerns::Forms::WorkForm
- Inherits:
-
Object
- Object
- CurationConcerns::Forms::WorkForm
- Includes:
- HydraEditor::Form
- Defined in:
- app/forms/curation_concerns/forms/work_form.rb
Instance Attribute Summary collapse
-
#current_ability ⇒ Object
Returns the value of attribute current_ability.
Class Method Summary collapse
-
.multiple?(term) ⇒ Boolean
This determines whether the allowed parameters are single or multiple.
-
.sanitize_params(form_params) ⇒ Object
Overriden to cast ‘rights’ to an array.
Instance Method Summary collapse
-
#initialize(model, current_ability) ⇒ WorkForm
constructor
A new instance of WorkForm.
-
#initialize_field(key) ⇒ Object
The value for embargo_relase_date and lease_expiration_date should not be initialized to empty string.
-
#select_files ⇒ Hash
The possible values for the representative_id dropdown.
Constructor Details
#initialize(model, current_ability) ⇒ WorkForm
21 22 23 24 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 21 def initialize(model, current_ability) @current_ability = current_ability super(model) end |
Instance Attribute Details
#current_ability ⇒ Object
Returns the value of attribute current_ability.
5 6 7 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 5 def current_ability @current_ability end |
Class Method Details
.multiple?(term) ⇒ Boolean
This determines whether the allowed parameters are single or multiple. By default it delegates to the model, but we need to override for ‘rights’ which only has a single value on the form.
42 43 44 45 46 47 48 49 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 42 def multiple?(term) case term.to_s when 'rights' false else super end end |
.sanitize_params(form_params) ⇒ Object
Overriden to cast ‘rights’ to an array
52 53 54 55 56 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 52 def sanitize_params(form_params) super.tap do |params| params['rights'] = Array(params['rights']) if params.key?('rights') end end |
Instance Method Details
#initialize_field(key) ⇒ Object
The value for embargo_relase_date and lease_expiration_date should not be initialized to empty string
28 29 30 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 28 def initialize_field(key) super unless [:embargo_release_date, :lease_expiration_date].include?(key) end |
#select_files ⇒ Hash
The possible values for the representative_id dropdown
34 35 36 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 34 def select_files Hash[file_presenters.map { |file| [file.to_s, file.id] }] end |