{% extends 'realm/realm_detailed.jinja2' %}
{% import 'macros/form_macros.jinja2' as mform %}
{% import 'macros/utils_macros.jinja2' as mutils %}

{% block detail_content %}
    {% if not form %}
        <h3>Gruppe {{ group.name }}</h3>
        <ul class="list-group list-group-flush w-100 mb-3">
            <li class="list-group-item">Ldap Domain: {{ group.dn }}</li>

            {% if group.description %}
                <li class="list-group-item">Beschreibung: {{ group.description }}</li>
            {% endif %}
        </ul>
        <h3>Mitglieder</h3>
        {{ mutils.get_user_table(realm, users) }}
        <div class="d-flex mt-3">
            <a href="{{ url('realm-group-update', args = [realm.id, group.dn]) }}" class="btn btn-primary mr-auto p-2">
                <i class="fas fa-pen-square"></i> Gruppe bearbeiten</a>
            <a href="{{ url('realm-group-delete-confirm', args = [realm.id, group.dn]) }}" class="btn btn-danger p-2"><i
                    class="fas fa-trash"></i> <span class="d-sm-none d-md-inline-block">Gruppe löschen</span></a>
        </div>
    {% else %}
        {{ mutils.get_warning_box(extra_error) }}
        <form method="post">
            <input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
            {{ mform.text_input(form.name) }}
            {{ mform.textarea_input(form.description) }}
            {{ form.members.label }}
            {{ mutils.get_data_table_search_field() }}
            {{ mform.user_select_table_input(users, field=form.members) }}
            <div class="d-flex mt-4">
                <button type="submit" class="btn btn-primary mr-auto p-2">Speichern</button>
                <a href="{{ url('realm-group-detail', args = [realm.id, group.dn]) }}"
                   class="btn btn-secondary p-2">Abbrechen</a>
            </div>
        </form>
    {% endif %}
{% endblock %}