{% extends "wagtailadmin/base.html" %}
{% load wagtailusers_tags wagtailadmin_tags i18n %}

{% block titletag %}{% trans "Editing" %} {{ group.name }}{% endblock %}

{% block extra_css %}
    {{ block.super }}

    <link rel="stylesheet" href="{% versioned_static 'wagtailusers/css/groups_edit.css' %}" type="text/css" />
    {{ form_media.css }}
{% endblock %}

{% block content %}

    {% trans "Editing" as editing_str %}
    {% include "wagtailadmin/shared/header.html" with title=editing_str subtitle=group.name icon="group" %}

    <div class="nice-padding">
        <form action="{% url 'wagtailusers_groups:edit' group.id %}" method="POST" novalidate>
            {% csrf_token %}

            <ul class="fields">
                {% include "wagtailadmin/shared/field_as_li.html" with field=form.name %}

                <li>
                    {% format_permissions permission_bound_field=form.permissions %}
                </li>

                {% for panel in permission_panels %}
                    <li>
                        {{ panel.as_admin_panel }}
                    </li>
                {% endfor %}
                <li>
                    <input type="submit" value="{% trans 'Save' %}" class="button" />

                    {% if perms.auth.delete_group %}
                        <a href="{% url 'wagtailusers_groups:delete' group.id %}" class="button button-secondary no">{% trans "Delete group" %}</a>
                    {% endif %}
                </li>
            </ul>

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

{% block extra_js %}
    {{ block.super }}
    {% include "wagtailusers/groups/includes/group_form_js.html" %}
{% endblock %}
