3 UserRole::ALL_ROLES.reduce("".html_safe) { |a, e| a + " " + role_icon(user, e) }
6 def role_icon(user, role)
7 if @user && @user.administrator?
8 if user.has_role?(role)
9 image = "roles/#{role}"
10 alt = t("user.view.role.revoke.#{role}")
11 title = t("user.view.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("user.view.role.grant.#{role}")
17 title = t("user.view.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("user.view.role.#{role}")
24 title = t("user.view.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 = content_tag("picture", svg_icon + png_icon)
31 icon = link_to(icon, url, :method => :post, :confirm => confirm) if url