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