{% load bootstrap3 %}
{% load i18n %}

{% include 'editor/fragment_levels.html' %}

{% if extra_json_data %}
    {{ extra_json_data|json_script:"sidebar-extra-data" }}
{% endif %}

<h3>
    {% if new %}
        {% blocktrans %}New {{ model_title }}{% endblocktrans %}
    {% else %}
        {% blocktrans %}Edit {{ model_title }}{% endblocktrans %}
    {% endif %}
    {% if on_top_of %}
        {% with on_top_of.title as on_top_of_level_title %}
            <small>{% blocktrans %}on top of {{ on_top_of_level_title }}{% endblocktrans %}</small>
        {% endwith %}
    {% endif %}
</h3>
{% bootstrap_messages %}
<form action="{{ path }}" method="post" {% if nozoom %}data-nozoom {% endif %}data-onbeforeunload {% if new %}data-new="{{ model_name }}" data-geomtype="{{ geomtype }}" {% if default_geomtype %}data-default-geomtype="{{ default_geomtype }}{% endif %}"{% else %}data-editing="{{ model_name }}-{{ pk }}"{% endif %}{% if access_restriction_select %} data-access-restriction-select{% endif %}>
    {% csrf_token %}
    {% bootstrap_form form %}
    {% if door %}
        <hr>
        <h4>{% trans 'Connecting spaces:' %}</h4>
        <ul>
        {% for space in door.spaces.values %}
            <li>
                {{ space.title }}
                {% if space.access_restriction %}
                    <small>({{ space.access_restriction.title }})</small>
                {% else %}
                    <small>(<em>no restriction</em>)</small>
                {% endif %}
            </li>
        {% endfor %}
        </ul>
        {% bootstrap_form door.form %}
        <hr>
    {% endif %}
    {% buttons %}
    <button class="invisiblesubmit" type="submit"></button>
    {% if can_edit %}
        {% if not new and not nosave %}
            <button type="submit" name="delete" value="1" class="btn btn-danger">
                {% trans 'Delete' %}
            </button>
        {% endif %}
        {% if not nosave %}
            <button type="submit" accesskey="m" class="btn btn-primary pull-right">
                {% trans 'Save' %}
            </button>
        {% endif %}
    {% endif %}
    <a class="btn {% if new %}btn-danger{% else %}btn-default {% if can_edit %}pull-right{% endif %}{% endif %} cancel-btn" href="{{ back_url }}">
        {% if can_edit %}
            {% trans 'Cancel' %}
        {% else %}
            {% trans 'Back' %}
        {% endif %}
    </a>
    {% endbuttons %}
</form>
