[% IF profile_user.roles.list.size == 0 %]
  &lt;none&gt;
[% ELSE %]
  <table class="w-full rowhover">
    [% has_admin = profile_user.check_user_roles("admin") %]
    [% FOREACH r = profile_user.roles.list.sort %]
      <tr[% IF has_admin && r != "authorized_for_admin" %] style="display: none;" class="js-hidden_roles"[% END %]>
        <td class="align-top">[% r %]</td>
        <td class="pl-2">
          [% IF profile_user.roles_from_groups.exists(r) %](from contact group: [% profile_user.roles_from_groups.$r.join(', ') %])
          [% ELSIF profile_user.roles_from_teams.exists(r) %](from teams: [% profile_user.roles_from_teams.$r.join(', ') %])
          [% ELSIF profile_user.roles_from_profile.exists(r) %](from user profile)
          [% ELSIF profile_user.roles_from_cgi_cfg.exists(r) %](from cgi.cfg)
          [% ELSIF profile_user.roles_from_session.exists(r) %](from session)
          [% ELSIF r == "read_only" %][% IF !profile_user.can_submit_commands %](from contacts can_submit_commands)[% END %]
          [% ELSIF r != "admin" && has_admin %](from admin role)
          [% ELSIF r == "admin" %](from role system_commands and<br>role configuration_information)
          [% END %]
        </td>
      </tr>
    [% END %]
    [% IF has_admin  %]
      <tr class="js-show_roles">
        <td class="align-top clickable hoverable rounded" colspan="2" onclick="jQuery('.js-hidden_roles').show(); jQuery('.js-show_roles').hide(); jQuery('.js-show_less_roles').show();">
          <i class="uil uil-angle-down"></i>show all...
        </td>
      </tr>
      <tr class="js-show_less_roles" style="display: none;">
        <td class="align-top clickable hoverable rounded" colspan="2" onclick="jQuery('.js-hidden_roles').hide(); jQuery('.js-show_roles').show(); jQuery('.js-show_less_roles').hide();">
          <i class="uil uil-angle-up"></i>show less...
        </td>
      </tr>
    [% END %]
  </table>
[% END %]
