{% load i18n %}
{% trans "Choose a document" as  choose_str %}
{% include "wagtailadmin/shared/header.html" with title=choose_str tabbed=1 merged=1 icon="doc-full-inverse" %}


{% if uploadform %}
    <ul class="tab-nav merged">
        <li class="{% if not uploadform.errors %}active {% endif %}"><a href="#search">{% trans "Search" %}</a></li>
        <li class="{% if uploadform.errors %}active {% endif %}"><a href="#upload">{% trans "Upload" %}</a></li>
    </ul>
{% endif %}

<div class="tab-content">
    <section id="search" class="{% if not uploadform.errors %}active {% endif %}nice-padding">
        <form class="document-search search-bar" action="{% url 'wagtaildocs_chooser' %}" method="GET">
            <ul class="fields">
                {% for field in searchform %}
                    {% include "wagtailadmin/shared/field_as_li.html" with field=field %}
                {% endfor %}
                <li class="submit"><input type="submit" value="{% trans 'Search' %}" /></li>
            </ul>
        </form>
        <div id="search-results" class="listing documents">
            {% include "wagtaildocs/chooser/results.html" %}
        </div>
    </section>
    {% if uploadform %}
        <section id="upload" class="{% if uploadform.errors %}active {% endif %}nice-padding">
            <form class="document-upload" action="{% url 'wagtaildocs_chooser_upload' %}" method="POST" enctype="multipart/form-data">
                {% csrf_token %}
                <ul class="fields">
                    {% for field in uploadform %}
                        {% include "wagtailadmin/shared/field_as_li.html" with field=field %}
                    {% endfor %}
                    <li><input type="submit" value="{% trans 'Save' %}" /></li>
                </ul>
            </form>
        </section>
    {% endif %}
</div>
