Class: CurationConcerns::Forms::WorkForm

Inherits:
Object
  • Object
show all
Includes:
HydraEditor::Form
Defined in:
app/forms/curation_concerns/forms/work_form.rb

Overview

Since:

  • 0.14.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(model, current_ability) ⇒ WorkForm

Returns a new instance of WorkForm.

Parameters:

  • model (ActiveFedora::Base, #member_ids)
  • current_ability (Ability)

Since:

  • 0.14.0



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_abilityObject

Since:

  • 0.14.0



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_paramsObject

Since:

  • 0.14.0



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.

Returns:

  • (Boolean)

Since:

  • 0.14.0



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_selectObject

Get a list of collection id/title pairs for the select form

Since:

  • 0.14.0



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

Since:

  • 0.14.0



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_filesHash

The possible values for the representative_id dropdown

Returns:

  • (Hash)

    All file sets in the collection, file.to_s is the key, file.id is the value

Since:

  • 0.14.0



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

#versionObject

Since:

  • 0.14.0



30
31
32
# File 'app/forms/curation_concerns/forms/work_form.rb', line 30

def version
  model.etag
end