Class: Hyrax::Forms::ResourceBatchEditForm

Inherits:
ResourceForm show all
Includes:
ContainedInWorksBehavior, DepositAgreementBehavior, LeaseabilityBehavior, PermissionBehavior
Defined in:
app/forms/hyrax/forms/resource_batch_edit_form.rb

Constant Summary

Constants included from ContainedInWorksBehavior

ContainedInWorksBehavior::InWorksPrepopulator

Constants inherited from ResourceForm

Hyrax::Forms::ResourceForm::LockKeyPrepopulator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PermissionBehavior

included, #permission_populator

Methods included from LeaseabilityBehavior

#embargo_populator, included, #lease_populator, #visibility_populator

Methods included from DepositAgreementBehavior

included

Methods included from ContainedInWorksBehavior

included

Methods inherited from ResourceForm

#[]=, check_if_flexible, #display_additional_fields?, expose_class, for, inherited, #model_class, #primary_terms, required_fields, required_fields=, schema_definitions, schema_definitions=, #secondary_terms

Methods included from BasedNearFieldBehavior

#deserialize, included

Methods inherited from ChangeSet

for

Constructor Details

#initialize(model, _current_ability, batch_document_ids) ⇒ ResourceBatchEditForm



26
27
28
29
30
31
32
33
34
35
# File 'app/forms/hyrax/forms/resource_batch_edit_form.rb', line 26

def initialize(model, _current_ability, batch_document_ids)
  @names = []
  @batch_document_ids = batch_document_ids
  if @batch_document_ids.present?
    combined_fields = model_attributes(model, initialize_combined_fields)
    super(resource: model.class.new(combined_fields))
  else
    super(resource: model)
  end
end

Instance Attribute Details

#batch_document_idsObject (readonly)

Returns the value of attribute batch_document_ids.



37
38
39
# File 'app/forms/hyrax/forms/resource_batch_edit_form.rb', line 37

def batch_document_ids
  @batch_document_ids
end

#namesObject

Contains a list of titles of all the works in the batch



21
22
23
# File 'app/forms/hyrax/forms/resource_batch_edit_form.rb', line 21

def names
  @names
end

Class Method Details

.additional_permitted_paramsObject

Returns a list of parameters other than those terms for the form rubocop:disable Metrics/MethodLength



46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/forms/hyrax/forms/resource_batch_edit_form.rb', line 46

def self.additional_permitted_params
  [{ permissions_attributes: [:type, :name, :access, :id, :_destroy] },
   :on_behalf_of,
   :version,
   :add_works_to_collection,
   :visibility_during_embargo,
   :embargo_release_date,
   :visibility_after_embargo,
   :visibility_during_lease,
   :lease_expiration_date,
   :visibility_after_lease,
   :visibility,
   { based_near_attributes: [:id, :_destroy] }]
end

.build_permitted_paramsObject

Returns a list of parameters we accept from the form



40
41
42
# File 'app/forms/hyrax/forms/resource_batch_edit_form.rb', line 40

def self.build_permitted_params
  terms_permitted_params + additional_permitted_params
end

.terms_permitted_paramsObject

Returns a list of permitted parameters for the terms



65
66
67
68
69
70
71
72
73
# File 'app/forms/hyrax/forms/resource_batch_edit_form.rb', line 65

def self.terms_permitted_params
  [].tap do |params|
    terms.each do |term|
      h = {}
      h[term] = []
      params << h
    end
  end
end

Instance Method Details

#column_for_attribute(name) ⇒ Symbol

Note:

Added for ActiveModel compatibility.



78
79
80
# File 'app/forms/hyrax/forms/resource_batch_edit_form.rb', line 78

def column_for_attribute(name)
  name
end