{% extends "wagtailadmin/base.html" %}
{% load i18n %}
{% block titletag %}{% blocktrans with form_title=form_page.title|capfirst %}Submissions of {{ form_title }}{% endblocktrans %}{% endblock %}
{% block extra_js %}
    {{ block.super }}
    {% include "wagtailadmin/shared/datetimepicker_translations.html" %}

    <script>
        $(function() {
            $('#id_date_from').datetimepicker({
                timepicker: false,
                format: 'Y-m-d',
                i18n: {
                    lang: window.dateTimePickerTranslations
                },
                lang: 'lang'
            });
            $('#id_date_to').datetimepicker({
                timepicker: false,
                format: 'Y-m-d',
                i18n: {
                    lang: window.dateTimePickerTranslations
                },
                lang: 'lang'
            });
        });
    </script>
{% endblock %}
{% block content %}
    <header class="nice-padding">
        <form action="" method="get" novalidate>
            <div class="row">
                <div class="left">
                    <div class="col">
                        <h1 class="icon icon-form">
                        {% blocktrans with form_title=form_page.title|capfirst %}Form data <span>{{ form_title }}</span>{% endblocktrans %}
                        </h1>
                    </div>
                    <div class="col search-bar">
                        <ul class="fields row rowflush">
                            {% for field in select_date_form %}
                                {% include "wagtailadmin/shared/field_as_li.html" with field=field field_classes="field-small" li_classes="col4" %}
                            {% endfor %}
                            <li class="submit col2">
                                <button name="action" value="filter" class="button">{% trans 'Filter' %}</button>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="right">
                   <button name="action" value="CSV" class="button bicolor icon icon-download">{% trans 'Download CSV' %}</button>
                </div>
            </div>
        </form>
    </header>
    <div class="nice-padding">
        {% if submissions %}
            {% include "wagtailforms/list_submissions.html" %}

            {% include "wagtailadmin/shared/pagination_nav.html" with items=submissions is_searching=False linkurl='-' %}
            {# Here we pass an invalid non-empty URL name as linkurl to generate pagination links with the URL path omitted #}
        {% else %}
            <p class="no-results-message">{% blocktrans with title=form_page.title %}There have been no submissions of the '{{ title }}' form.{% endblocktrans %}</p>
        {% endif %}
    </div>
{% endblock %}
