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

{% block titletag %}{% trans "Editing" %} {{ site.hostname }}{% endblock %}
{% block bodyclass %}menu-sites{% endblock %}

{% block content %}

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

    <div class="nice-padding">
        <form action="{% url 'wagtailsites_edit' site.id %}" method="POST">
            {% csrf_token %}
        
            <ul class="fields">
                {% include "wagtailadmin/shared/field_as_li.html" with field=form.hostname %}
                {% include "wagtailadmin/shared/field_as_li.html" with field=form.port %}

                <li>
                    {% trans "Change page" as choose_another_text_str %}
                    {% trans "Choose page" as choose_one_text_str %}
                    
                    {% if form.instance.root_page %}
                        {% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.root_page page=form.instance.root_page is_chosen=True choose_one_text_str=choose_one_text_str choose_another_text_str=choose_another_text_str only %}
                    {% else %}
                        {% include "wagtailadmin/edit_handlers/page_chooser_panel.html" with field=form.root_page is_chosen=False choose_one_text_str=choose_one_text_str choose_another_text_str=choose_another_text_str only %}
                    {% endif %}
                </li>

                {% include "wagtailadmin/shared/field_as_li.html" with field=form.is_default_site %}
                
                <li>
                    <input type="submit" value="{% trans 'Save' %}" />
                    {% if perms.site.delete_site %}
                        <a href="{% url 'wagtailsites_delete' site.id %}" class="button button-secondary no">{% trans "Delete site" %}</a>
                    {% endif %}
                </li>
            </ul>
        </form>
    </div>
{% endblock %}

{% block extra_js %}
    {% include "wagtailadmin/pages/_editor_js.html" %}

    <script>
        {% include "wagtailsites/includes/site_form.js" %}
    </script>
{% endblock %}
