Module: Hyrax::AbilityHelper

Included in:
HyraxHelperBehavior
Defined in:
app/helpers/hyrax/ability_helper.rb

Instance Method Summary collapse

Instance Method Details



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/helpers/hyrax/ability_helper.rb', line 23

def render_visibility_link(document)
  # Anchor must match with a tab in
  # https://github.com/samvera/hyrax/blob/master/app/views/hyrax/base/_guts4form.html.erb#L2
  path = if document.collection?
           hyrax.edit_dashboard_collection_path(document, anchor: 'share')
         else
           edit_polymorphic_path([main_app, document], anchor: 'share')
         end
  link_to(
    visibility_badge(document.visibility),
    path,
    id: "permission_#{document.id}",
    class: 'visibility-link'
  )
end

#visibility_badge(value) ⇒ Object



19
20
21
# File 'app/helpers/hyrax/ability_helper.rb', line 19

def visibility_badge(value)
  PermissionBadge.new(value).render
end

#visibility_options(variant) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/hyrax/ability_helper.rb', line 3

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