Sha256: ebe5a100e81b6e2ead27be603ded784a8c88d8a069923b3e978f117bc2aa62e6

Contents?: true

Size: 990 Bytes

Versions: 29

Compression:

Stored size: 990 Bytes

Contents

# frozen_string_literal: true
module Hyrax
  module Admin
    # Displays a single workflow role
    class WorkflowRolePresenter
      def initialize(workflow_role)
        @workflow = workflow_role.workflow
        @role = workflow_role.role
        @source_id = workflow.permission_template.source_id
      end

      # @todo This is a hack; I don't want to include reference to the admin set;
      #       However based on the current UI, in which we list all workflows (spanning all admin sets) this is required.
      # @return [String] A meaningful label for the given WorkflowRole
      def label
        "#{admin_set_label(source_id)} - #{role.name} (#{workflow.name})"
      end

      private

      attr_accessor :workflow, :role, :source_id

      def admin_set_label(id)
        result = Hyrax::SolrService.search_by_id(id, fl: 'title_tesim')
        result['title_tesim'].first
      rescue Hyrax::ObjectNotFoundError
        "[AdminSet ID=#{id}]"
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
hyrax-5.1.0.pre.beta1 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-5.0.4 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-5.0.3 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-5.0.2 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-5.0.1 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-5.0.0 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-5.0.0.rc3 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-5.0.0.rc2 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-5.0.0.rc1 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-3.6.0 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-4.0.0 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-4.0.0.rc3 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-4.0.0.rc2 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-4.0.0.rc1 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-3.5.0 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-4.0.0.beta2 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-3.4.2 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-4.0.0.beta1 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-3.4.1 app/presenters/hyrax/admin/workflow_role_presenter.rb
hyrax-3.4.0 app/presenters/hyrax/admin/workflow_role_presenter.rb