Class: CurationConcerns::Forms::WorkForm
- Inherits:
-
Object
- Object
- CurationConcerns::Forms::WorkForm
- Includes:
- HydraEditor::Form
- Defined in:
- app/forms/curation_concerns/forms/work_form.rb
Overview
Instance Attribute Summary collapse
Class Method Summary collapse
- .build_permitted_params ⇒ Object
-
.multiple?(term) ⇒ Boolean
This determines whether the allowed parameters are single or multiple.
Instance Method Summary collapse
-
#collections_for_select ⇒ Object
Get a list of collection id/title pairs for the select form.
-
#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.
- #version ⇒ Object
Constructor Details
#initialize(model, current_ability) ⇒ WorkForm
Returns a new instance of WorkForm.
25 26 27 28 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 25 def initialize(model, current_ability) @current_ability = current_ability super(model) end |
Instance Attribute Details
#current_ability ⇒ Object
5 6 7 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 5 def current_ability @current_ability end |
Class Method Details
.build_permitted_params ⇒ Object
67 68 69 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 67 def build_permitted_params super + [:version] end |
.multiple?(term) ⇒ Boolean
This determines whether the allowed parameters are single or multiple. By default it delegates to the model.
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 54 def multiple?(term) case term.to_s when 'ordered_member_ids' true when 'in_works_ids' true when 'member_of_collection_ids' true else super end end |
Instance Method Details
#collections_for_select ⇒ Object
Get a list of collection id/title pairs for the select form
47 48 49 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 47 def collections_for_select ::Collection.all.map { |col| [col.first_title, col.id] } end |
#initialize_field(key) ⇒ Object
The value for embargo_relase_date and lease_expiration_date should not be initialized to empty string
36 37 38 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 36 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
42 43 44 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 42 def select_files Hash[file_presenters.map { |file| [file.to_s, file.id] }] end |
#version ⇒ Object
30 31 32 |
# File 'app/forms/curation_concerns/forms/work_form.rb', line 30 def version model.etag end |