Sha256: bf9d8230481d323cd8ea5511f56957ba2e7dfedc125b6592eedf1e799c38d450

Contents?: true

Size: 1.16 KB

Versions: 64

Compression:

Stored size: 1.16 KB

Contents

module CurationConcerns
  module AbilityHelper
    # Returns true if can create at least one type of work
    def can_ever_create_works?
      can = false
      CurationConcerns.config.curation_concerns.each do |curation_concern_type|
        break if can
        can = can?(:create, curation_concern_type)
      end
      can
    end

    def visibility_options(variant)
      options = [
        Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC,
        Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED,
        Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE
      ]
      case variant
      when :restrict
        options.delete_at(0)
        options.reverse!
      when :loosen
        options.delete_at(2)
      end
      options.map { |value| [visibility_text(value), value] }
    end

    def visibility_badge(value)
      klass = t("curation_concerns.visibility.#{value}.class", default: 'label-info')
      content_tag :span, visibility_text(value), class: "label #{klass}"
    end

    private

      def visibility_text(value)
        t("curation_concerns.visibility.#{value}.text", default: value)
      end
  end
end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
curation_concerns-1.7.8 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.7.7 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-2.0.0 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-2.0.0.rc2 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.7.6 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.7.5 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.7.4 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.7.3 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.7.2 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-2.0.0.rc1 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.7.1 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.7.0 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.7.0.beta1 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.6.3 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.6.2 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.6.1 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.6.0 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.5.0 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.4.0 app/helpers/curation_concerns/ability_helper.rb
curation_concerns-1.3.3 app/helpers/curation_concerns/ability_helper.rb