Class: Sufia::Forms::WorkForm
- Inherits:
-
CurationConcerns::Forms::WorkForm
- Object
- CurationConcerns::Forms::WorkForm
- Sufia::Forms::WorkForm
- Includes:
- HydraEditor::Form::Permissions
- Defined in:
- app/forms/sufia/forms/work_form.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#agreement_accepted ⇒ Object
readonly
Returns the value of attribute agreement_accepted.
Class Method Summary collapse
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(model, current_ability) ⇒ WorkForm
constructor
A new instance of WorkForm.
-
#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.
- #work_members ⇒ Object
Constructor Details
#initialize(model, current_ability) ⇒ WorkForm
Returns a new instance of WorkForm.
15 16 17 18 |
# File 'app/forms/sufia/forms/work_form.rb', line 15 def initialize(model, current_ability) @agreement_accepted = !model.new_record? super end |
Instance Attribute Details
#agreement_accepted ⇒ Object (readonly)
Returns the value of attribute agreement_accepted.
10 11 12 |
# File 'app/forms/sufia/forms/work_form.rb', line 10 def agreement_accepted @agreement_accepted end |
Class Method Details
.build_permitted_params ⇒ Object
58 59 60 61 62 |
# File 'app/forms/sufia/forms/work_form.rb', line 58 def self.build_permitted_params super + [:on_behalf_of, { collection_ids: [] }, { work_members_attributes: [:id, :_destroy] }] end |
.multiple?(term) ⇒ Boolean
44 45 46 47 |
# File 'app/forms/sufia/forms/work_form.rb', line 44 def self.multiple?(term) return true if [:rights, :collection_ids].include? term super end |
.sanitize_params(form_params) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'app/forms/sufia/forms/work_form.rb', line 49 def self.sanitize_params(form_params) admin_set_id = form_params[:admin_set_id] if admin_set_id && Sipity::Workflow.find_by!(name: Sufia::PermissionTemplate.find_by!(admin_set_id: admin_set_id).workflow_name).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
20 21 22 23 |
# File 'app/forms/sufia/forms/work_form.rb', line 20 def [](key) return model.in_collection_ids if key == :collection_ids super end |
#primary_terms ⇒ Object
Fields that are automatically drawn on the page above the fold
26 27 28 |
# File 'app/forms/sufia/forms/work_form.rb', line 26 def primary_terms required_fields end |
#secondary_terms ⇒ Object
Fields that are automatically drawn on the page below the fold
31 32 33 34 35 36 37 38 |
# File 'app/forms/sufia/forms/work_form.rb', line 31 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, :collection_ids, :in_works_ids, :admin_set_id] end |
#work_members ⇒ Object
40 41 42 |
# File 'app/forms/sufia/forms/work_form.rb', line 40 def work_members model.members.to_a.reject { |m| m.is_a? FileSet } end |