Class: CurationConcerns::WorkflowPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/curation_concerns/workflow_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(solr_document, current_ability) ⇒ WorkflowPresenter

Returns a new instance of WorkflowPresenter.



3
4
5
6
# File 'app/presenters/curation_concerns/workflow_presenter.rb', line 3

def initialize(solr_document, current_ability)
  @solr_document = solr_document
  @current_ability = current_ability
end

Instance Attribute Details

#current_abilityObject (readonly)

Returns the value of attribute current_ability.



8
9
10
# File 'app/presenters/curation_concerns/workflow_presenter.rb', line 8

def current_ability
  @current_ability
end

#solr_documentObject (readonly)

Returns the value of attribute solr_document.



8
9
10
# File 'app/presenters/curation_concerns/workflow_presenter.rb', line 8

def solr_document
  @solr_document
end

Instance Method Details

#actionsObject

Returns an array of tuples (key, label) appropriate for a radio group



20
21
22
23
24
# File 'app/presenters/curation_concerns/workflow_presenter.rb', line 20

def actions
  return [] unless sipity_entity && current_ability
  actions = CurationConcerns::Workflow::PermissionQuery.scope_permitted_workflow_actions_available_for_current_state(entity: sipity_entity, user: current_ability.current_user)
  actions.map { |action| [action.name, action_label(action)] }
end

#commentsObject



26
27
28
29
# File 'app/presenters/curation_concerns/workflow_presenter.rb', line 26

def comments
  return [] unless sipity_entity
  sipity_entity.comments
end

#stateObject



10
11
12
# File 'app/presenters/curation_concerns/workflow_presenter.rb', line 10

def state
  sipity_entity.workflow_state_name if sipity_entity
end

#state_labelObject

TODO: maybe i18n here?



15
16
17
# File 'app/presenters/curation_concerns/workflow_presenter.rb', line 15

def state_label
  state
end