Module: CurationConcerns::AbilityHelper

Included in:
MainAppHelpers
Defined in:
app/helpers/curation_concerns/ability_helper.rb

Instance Method Summary collapse

Instance Method Details

#can_ever_create_works?Boolean

Returns true if can create at least one type of work

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
# File 'app/helpers/curation_concerns/ability_helper.rb', line 4

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

#visibility_badge(value) ⇒ Object



29
30
31
32
# File 'app/helpers/curation_concerns/ability_helper.rb', line 29

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

#visibility_options(variant) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/curation_concerns/ability_helper.rb', line 13

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