Class: Hyrax::WorkflowPresenter
- Inherits:
-
Object
- Object
- Hyrax::WorkflowPresenter
- Includes:
- ActionView::Helpers::TagHelper
- Defined in:
- app/presenters/hyrax/workflow_presenter.rb
Instance Attribute Summary collapse
-
#current_ability ⇒ Object
readonly
Returns the value of attribute current_ability.
-
#solr_document ⇒ Object
readonly
Returns the value of attribute solr_document.
Instance Method Summary collapse
-
#actions ⇒ Object
Returns an array of tuples (key, label) appropriate for a radio group.
- #badge ⇒ Object
- #comments ⇒ Object
-
#initialize(solr_document, current_ability) ⇒ WorkflowPresenter
constructor
A new instance of WorkflowPresenter.
- #state ⇒ Object
- #state_label ⇒ Object
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_ability ⇒ Object (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_document ⇒ Object (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
#actions ⇒ Object
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 |
#badge ⇒ Object
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 |
#comments ⇒ Object
29 30 31 32 |
# File 'app/presenters/hyrax/workflow_presenter.rb', line 29 def comments return [] unless sipity_entity sipity_entity.comments end |
#state ⇒ Object
13 14 15 |
# File 'app/presenters/hyrax/workflow_presenter.rb', line 13 def state sipity_entity&.workflow_state_name end |
#state_label ⇒ Object
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 |