3 UserRole::ALL_ROLES.reduce("".html_safe) do |acc, elem|
4 "#{acc} #{role_icon(user, elem)}"
8 def role_icon(user, role)
9 if current_user&.administrator?
10 if user.has_role?(role)
11 image = "roles/#{role}"
12 alt = t("users.show.role.revoke.#{role}")
13 title = t("users.show.role.revoke.#{role}")
14 url = revoke_role_path(:display_name => user.display_name, :role => role)
15 confirm = t("user_role.revoke.are_you_sure", :name => user.display_name, :role => role)
17 image = "roles/blank_#{role}"
18 alt = t("users.show.role.grant.#{role}")
19 title = t("users.show.role.grant.#{role}")
20 url = grant_role_path(:display_name => user.display_name, :role => role)
21 confirm = t("user_role.grant.are_you_sure", :name => user.display_name, :role => role)
23 elsif user.has_role?(role)
24 image = "roles/#{role}"
25 alt = t("users.show.role.#{role}")
26 title = t("users.show.role.#{role}")
30 svg_icon = tag("source", :srcset => image_path("#{image}.svg"), :type => "image/svg+xml")
31 png_icon = image_tag("#{image}.png", :srcset => image_path("#{image}.svg"), :size => "20x20", :border => 0, :alt => alt, :title => title)
32 icon = tag.picture(svg_icon + png_icon)
33 icon = link_to(icon, url, :method => :post, :confirm => confirm) if url