{% extends "MapbenderManagerBundle::manager.html.twig" %}

{% block title %}{{ "fom.user.group.index.groups" | trans }}{% endblock %}

{% block css %}
  {{parent()}}
{% endblock %}

{% block js %}
  {{parent()}}
  <script type="application/javascript" src="{{ asset('bundles/mapbendermanager/js/user-control.js') }}"></script>
{% endblock %}

{% block manager_content %}

{% if create_permission %}
<a class="iconAdd iconBig right" href="{{path('fom_user_group_new')}}" title="{{"fom.user.group.index.add_new_group"|trans}}"></a>
{% endif %}

{% if groups|length > 0 %}
  <label for="inputFilterGroups" class="labelInput left">{{"fom.user.group.index.filter"|trans}}</label>
  <input id="inputFilterGroups" type="text" class="input left listFilterInput"/>

  <div class="clearContainer"></div>
  <table id="listFilterGroups" class="table userControlTable listFilterContainer">
    <thead id="groupsHead">
      <tr class="doNotFilter">
        <th>{{ "fom.user.group.index.title" | trans }}</th>
        <th>{{ "fom.user.group.index.description" | trans }}</th>
        <th class="iconColumn"></th>
      </tr>
    </thead>
    <tbody id="groupsBody">
      {% for group in groups %}
      <tr id="app-{{ group.id }}" class="filterItem">
        <td>
          <a class="labelText" href="{{ path('fom_user_group_edit', {'id': group.id}) }}" title="{{ 'fom.user.group.index.edit_group' | trans }} {{ group.title }}">{{ group.title }}</a>
        </td>
        <td class="description">{{ group.description }}</td>
        <td class="iconColumn">
            {% if is_granted('EDIT', group) %}
            <a class="iconEdit iconSmall" href="{{ path('fom_user_group_edit',  {'id': group.id }) }}" title="{{ 'fom.user.group.index.edit_group' | trans }} {{ group.title }}"></a>
            {% endif %}
            {% if is_granted('DELETE', group) %}
            <span class="iconRemove iconSmall"
              title="{{"fom.user.group.index.delete_group"|trans}} {{ group.title }}"
              data-url="{{ path('fom_user_group_delete', { 'id': group.id}) }}"
              data-id="{{ group.id }}"
            ></span>
            {% endif %}
        </td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
{% else %}
  <p class="description left">{{"fom.user.group.index.no_groups_available"|trans}}</p>
  <div class="clearContainer"></div>
{% endif %}
{% endblock %}