Class: Hyrax::Forms::WorkflowResponsibilityForm

Inherits:
Object
  • Object
show all
Defined in:
app/forms/hyrax/forms/workflow_responsibility_form.rb

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ WorkflowResponsibilityForm

Returns a new instance of WorkflowResponsibilityForm.



4
5
6
7
8
9
# File 'app/forms/hyrax/forms/workflow_responsibility_form.rb', line 4

def initialize(params = {})
  model_instance.workflow_role_id = params[:workflow_role_id]
  return unless params[:user_id]
  user = ::User.find(params[:user_id])
  model_instance.agent = user.to_sipity_agent
end

Instance Method Details

#model_instanceObject



11
12
13
# File 'app/forms/hyrax/forms/workflow_responsibility_form.rb', line 11

def model_instance
  @model ||= Sipity::WorkflowResponsibility.new
end

#to_modelObject



15
16
17
# File 'app/forms/hyrax/forms/workflow_responsibility_form.rb', line 15

def to_model
  model_instance
end

#user_idObject



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

def user_id
  nil
end

#user_optionsObject



25
26
27
# File 'app/forms/hyrax/forms/workflow_responsibility_form.rb', line 25

def user_options
  ::User.all
end

#workflow_role_optionsObject

The select options for choosing a responsibility sorted by label



30
31
32
33
34
35
# File 'app/forms/hyrax/forms/workflow_responsibility_form.rb', line 30

def workflow_role_options
  options = Sipity::WorkflowRole.all.map do |wf_role|
    [Hyrax::Admin::WorkflowRolePresenter.new(wf_role).label, wf_role.id]
  end
  options.sort_by(&:first)
end