Class: Hyrax::WorkflowPresenter

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
app/presenters/hyrax/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.



5
6
7
8
# File 'app/presenters/hyrax/workflow_presenter.rb', line 5

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.



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

def current_ability
  @current_ability
end

#solr_documentObject (readonly)

Returns the value of attribute solr_document.



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

def solr_document
  @solr_document
end

Instance Method Details

#actionsObject

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



22
23
24
25
26
# File 'app/presenters/hyrax/workflow_presenter.rb', line 22

def actions
  return [] unless sipity_entity && current_ability
  actions = Hyrax::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

#badgeObject



33
34
35
36
# File 'app/presenters/hyrax/workflow_presenter.rb', line 33

def badge
  return unless state
  (:span, state_label, class: "state state-#{state} label label-primary")
end

#commentsObject



28
29
30
31
# File 'app/presenters/hyrax/workflow_presenter.rb', line 28

def comments
  return [] unless sipity_entity
  sipity_entity.comments
end

#stateObject



12
13
14
# File 'app/presenters/hyrax/workflow_presenter.rb', line 12

def state
  sipity_entity&.workflow_state_name
end

#state_labelObject



16
17
18
19
# File 'app/presenters/hyrax/workflow_presenter.rb', line 16

def state_label
  return unless state
  I18n.t("hyrax.workflow.state.#{state}", default: state.humanize)
end