{% if users %}
    <table class="table">
    <thead>
      <tr>
        <th class="sortByColumn clickable">
            {{'fom.user.user.index.name'|trans }}
              <span class="fa fa-sort-amount-asc" title="{{ 'mb.actions.sort_descending'|trans }}"></span>
        </th>
        <th class="sortByColumn clickable">
            {{'fom.user.user.index.email'|trans}}
              <span class="fa fa-sort" title="{{ 'mb.actions.sort_ascending'|trans }}"></span>
        </th>
        {% if show_groups %}
        <th class="sortByColumn clickable">
            {{'fom.user.user.index.groups'|trans}}
            <span class="fa fa-sort" title="{{ 'mb.actions.sort_ascending'|trans }}"></span>
        </th>
        {% endif %}
        <th></th>
      </tr>
    </thead>
    <tbody id="listFilterUsers">
      {% for user in users|sort((a,b) => a.username|lower <=> b.username|lower) %}
        <tr class="filterItem">
          <td>
            {% if is_granted(constant('FOM\\UserBundle\\Security\\Permission\\ResourceDomainInstallation::ACTION_EDIT_USERS')) %}
            <a href="{{ path('fom_user_user_edit', {'id': user.id}) }}" title="{{ 'fom.user.user.index.edit_user' | trans }}">{{ user.username }}</a>
            {% else %}
            {{ user.username }}
            {% endif %}
          </td>
          <td><a href="mailto:{{ user.email }}" title="{{ 'fom.user.user.index.contact_user' | trans }}">{{ user.email }}</a></td>
          {% if show_groups %}
          <td>
            <ul class="list-unstyled">
              {% for group in user.groups %}
              <li>
                {% if is_granted(constant('FOM\\UserBundle\\Security\\Permission\\ResourceDomainInstallation::ACTION_EDIT_GROUPS')) %}
                  <a href="{{ path('fom_user_group_edit', { 'id': group.id }) }}" title="{{ 'fom.user.user.index.edit_group' | trans }}">{{ group.title }}</a></li>
                {% else %}
                  <span>{{ group.title }}</span>
                {% endif %}
              {% endfor %}
            </ul>
          </td>
          {% endif %}
          <td class="iconColumn">
            {% if is_granted(constant('FOM\\UserBundle\\Security\\Permission\\ResourceDomainInstallation::ACTION_EDIT_USERS')) %}
              <a class="hover-highlight-effect" href="{{ path('fom_user_user_edit',  {'id': user.id }) }}" title="{{ 'fom.user.user.index.edit_user' | trans }}"><i class="fas fa-pencil"></i></a>
            {% endif %}
            {% if user.id != 1 and is_granted(constant('FOM\\UserBundle\\Security\\Permission\\ResourceDomainInstallation::ACTION_DELETE_USERS')) %}
              <span class="-fn-delete hover-highlight-effect"
                data-title="{{ 'fom.user.user.index.delete_user' | trans ({'%user_username%': user.username }) }}"
                title="{{ 'fom.security.resource.installation.delete_users' | trans }}"
                data-url="{{ path('fom_user_user_delete', { 'id': user.id}) }}"
                data-id="{{ user.id }}"
                data-token="{{ csrf_token('user_delete') }}"
                data-test="{{ user.username }}-user-delete"
              ><i class="far fa-trash-can"></i></span>
            {% endif %}
          </td>
        </tr>
      {% endfor %}
    </tbody>
  </table>
{% else %}
  <p>{{"fom.user.user.index.no_users_available"|trans}}</p>
{% endif %}
