Class: Hyrax::Forms::WorkForm
- Inherits:
-
Object
- Object
- Hyrax::Forms::WorkForm
- Includes:
- HydraEditor::Form, HydraEditor::Form::Permissions
- Defined in:
- app/forms/hyrax/forms/work_form.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#agreement_accepted ⇒ Object
readonly
Returns the value of attribute agreement_accepted.
-
#current_ability ⇒ Object
Returns the value of attribute current_ability.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#collections_for_select ⇒ Object
Get a list of collection id/title pairs for the select form.
-
#initialize(model, current_ability, controller) ⇒ WorkForm
constructor
A new instance of WorkForm.
-
#initialize_field(key) ⇒ Object
The value for some fields should not be set to the defaults ([”]) because it should be an empty array instead.
-
#primary_terms ⇒ Object
Fields that are automatically drawn on the page above the fold.
-
#secondary_terms ⇒ Object
Fields that are automatically drawn on the page below the fold.
-
#select_files ⇒ Hash
The possible values for the representative_id dropdown.
- #version ⇒ Object
- #work_members ⇒ Object
Constructor Details
#initialize(model, current_ability, controller) ⇒ WorkForm
Returns a new instance of WorkForm.
37 38 39 40 41 42 |
# File 'app/forms/hyrax/forms/work_form.rb', line 37 def initialize(model, current_ability, controller) @current_ability = current_ability @agreement_accepted = !model.new_record? @controller = controller super(model) end |
Instance Attribute Details
#agreement_accepted ⇒ Object (readonly)
Returns the value of attribute agreement_accepted.
21 22 23 |
# File 'app/forms/hyrax/forms/work_form.rb', line 21 def agreement_accepted @agreement_accepted end |
#current_ability ⇒ Object
Returns the value of attribute current_ability.
6 7 8 |
# File 'app/forms/hyrax/forms/work_form.rb', line 6 def current_ability @current_ability end |
Class Method Details
.build_permitted_params ⇒ Object
99 100 101 102 103 104 105 106 107 |
# File 'app/forms/hyrax/forms/work_form.rb', line 99 def self.build_permitted_params super + [ :on_behalf_of, :version, { work_members_attributes: [:id, :_destroy] } ] end |
.sanitize_params(form_params) ⇒ Object
90 91 92 93 94 95 96 97 |
# File 'app/forms/hyrax/forms/work_form.rb', line 90 def self.sanitize_params(form_params) admin_set_id = form_params[:admin_set_id] if admin_set_id && workflow_for(admin_set_id: admin_set_id).allows_access_grant? return super end = permitted_params.reject { |arg| arg.respond_to?(:key?) && arg.key?(:permissions_attributes) } form_params.permit(*) end |
Instance Method Details
#[](key) ⇒ Object
54 55 56 57 |
# File 'app/forms/hyrax/forms/work_form.rb', line 54 def [](key) return model.member_of_collection_ids if key == :member_of_collection_ids super end |
#collections_for_select ⇒ Object
Get a list of collection id/title pairs for the select form
85 86 87 88 |
# File 'app/forms/hyrax/forms/work_form.rb', line 85 def collections_for_select service = Hyrax::CollectionsService.new(@controller) CollectionOptionsPresenter.new(service).(:edit) end |
#initialize_field(key) ⇒ Object
The value for some fields should not be set to the defaults ([”]) because it should be an empty array instead
50 51 52 |
# File 'app/forms/hyrax/forms/work_form.rb', line 50 def initialize_field(key) super unless [:embargo_release_date, :lease_expiration_date].include?(key) end |
#primary_terms ⇒ Object
Fields that are automatically drawn on the page above the fold
66 67 68 |
# File 'app/forms/hyrax/forms/work_form.rb', line 66 def primary_terms required_fields end |
#secondary_terms ⇒ Object
Fields that are automatically drawn on the page below the fold
71 72 73 74 75 76 77 78 |
# File 'app/forms/hyrax/forms/work_form.rb', line 71 def secondary_terms terms - primary_terms - [:files, :visibility_during_embargo, :embargo_release_date, :visibility_after_embargo, :visibility_during_lease, :lease_expiration_date, :visibility_after_lease, :visibility, :thumbnail_id, :representative_id, :ordered_member_ids, :member_of_collection_ids, :in_works_ids, :admin_set_id] end |
#select_files ⇒ Hash
The possible values for the representative_id dropdown
61 62 63 |
# File 'app/forms/hyrax/forms/work_form.rb', line 61 def select_files Hash[file_presenters.map { |file| [file.to_s, file.id] }] end |
#version ⇒ Object
44 45 46 |
# File 'app/forms/hyrax/forms/work_form.rb', line 44 def version model.etag end |
#work_members ⇒ Object
80 81 82 |
# File 'app/forms/hyrax/forms/work_form.rb', line 80 def work_members model.works end |