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.



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

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.



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

def current_ability
  @current_ability
end

#solr_documentObject (readonly)

Returns the value of attribute solr_document.



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

def solr_document
  @solr_document
end

Instance Method Details

#actionsObject

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



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

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



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

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

#commentsObject



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

def comments
  return [] unless sipity_entity
  sipity_entity.comments
end

#stateObject



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

def state
  sipity_entity&.workflow_state_name
end

#state_labelObject



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

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