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.
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_ability ⇒ Object (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_document ⇒ Object (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
#actions ⇒ Object
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 |
#badge ⇒ Object
33 34 35 36 |
# File 'app/presenters/hyrax/workflow_presenter.rb', line 33 def badge return unless state content_tag(:span, state_label, class: "state state-#{state} label label-primary") end |
#comments ⇒ Object
28 29 30 31 |
# File 'app/presenters/hyrax/workflow_presenter.rb', line 28 def comments return [] unless sipity_entity sipity_entity.comments end |
#state ⇒ Object
12 13 14 |
# File 'app/presenters/hyrax/workflow_presenter.rb', line 12 def state sipity_entity.workflow_state_name if sipity_entity end |
#state_label ⇒ Object
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 |