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

{% block titletag %}{% trans "Editing" %} {{ group.name }}{% endblock %}
{% block bodyclass %}menu-groups{% endblock %}

{% block extra_css %}
    {% compress css %}
        <link rel="stylesheet" href="{{ STATIC_URL }}wagtailusers/scss/groups_edit.scss" type="text/x-scss" />
    {% endcompress %}
{% 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">
            {% 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>
                <li>
                    {% include "wagtailusers/groups/includes/page_permissions_formset.html" with formset=formset only %}
                </li>
                <li>
                    <input type="submit" value="{% trans 'Save' %}" />

                    {% 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 %}
    {% include "wagtailadmin/pages/_editor_js.html" %}

    <script>
        {% include "wagtailusers/groups/includes/page_permissions_formset.js" with formset=formset only %}
    </script>
{% endblock %}
