{% extends "main.html" %}
{% import '_pagination.html' as pagination_macros %}

{# Here it is relatively safe to assume that 'ipa' exists and is valid. We would not be here otherwise. #}

{% block title %}{{ _("Group List") }}{% endblock %}

{% block content %}
  {{ super() }}
  <div class="container py-4">
    <div class="row">
      <div class="col-md-8 mx-auto">
        <h4>{{ _("Group List") }}</h4>

        <ul class="list-group">
          {% for group in groups.items %}
          <li class="list-group-item d-flex justify-content-between align-items-center">
              <div class="media align-items-center">
                <i class="fa fa-group fa-2x text-muted mr-3"></i>
                <div class="media-body">
                    <div class="my-0 font-weight-bold">
                      <a href="{{ url_for('.group', groupname=group.name) }}">
                        <span class="title">{{ group.name }}</span>
                      </a>
                    </div>
                    {% if group.description %}
                      <div data-role="description">{{ group.description }}</div>
                    {% endif %}
                </div>
              </div>
              <div data-role="members-count">{{ _('%(member_count)s members', member_count=group.members|length|default(0)) }}</div>
            </li>
          {% endfor %}
        </ul>
        {% if groups.items|count == 0 %}
        <p>{{ _("No groups.") }}</p>
        {% endif %}

        {{ pagination_macros.pagination_bar(groups) }}

      </div>
    </div>
  </div>
{% endblock %}
