{#
 * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
 <info@champs-libres.coop> / <http://www.champs-libres.coop>
 *
 * This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
#}

{% extends "@ChillMain/layout.html.twig" %}

{% block title "Download export"|trans ~ export.title|trans %}

{% block js %}
<script type="text/javascript">
window.export_generate_url = "{{  path('chill_main_export_generate', { 'alias' : alias } ) }}";
</script>
{{ encore_entry_link_tags('page_download_exports') }}
{% endblock %}

{% block css %}
    {{ encore_entry_script_tags('page_download_exports') }}
{% endblock %}

{% block content %}
    <div class="col-md-10">

        {{ include('@ChillMain/Export/_breadcrumb.html.twig') }}

        <h1>{{ export.title|trans }}</h1>
        <h2>{{ "Download export"|trans }}</h2>

        <div id="download_container"
             data-alias="{{ alias|escape('html_attr') }}"
             {%- if mime_type is defined %}
                 data-mime-type="{{- mime_type|escape('html_attr') -}}"
             {% endif -%}
             data-download-text="{{ "Download your report"|trans|escape('html_attr') }}"
        ><span id="waiting_text">{{ "Waiting for your report"|trans ~ '...' }}</span></div>

        <ul class="record_actions sticky-form-buttons">
            <li class="cancel"><a href="{{ chill_return_path_or('chill_main_export_index') }}" class="btn btn-cancel">{{ 'Back to the list'|trans }}</a></li>

            {% if not app.request.query.has('prevent_save') %}
                {% if saved_export is null %}
                <li>
                    <a href="{{ chill_path_add_return_path('chill_main_export_save_from_key', { alias: alias, key: app.request.query.get('key')}) }}" class="btn btn-save">{{ 'Save'|trans }}</a>
                </li>
                {% else %}
                <li>
                    <div class="dropdown">
                        <button class="btn btn-save dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                            {{ 'Save'|trans }}
                        </button>
                        <ul class="dropdown-menu">
                            <li><a href="{{ chill_path_add_return_path('chill_main_export_save_from_key', { alias: alias, key: app.request.query.get('key')}) }}" class="dropdown-item">{{ 'Save'|trans }}</a></li>
                            <li><a href="{{ chill_path_add_return_path('chill_main_export_saved_edit_options_from_key', { id: saved_export.id(), key: app.request.query.get('key') }) }}" class="dropdown-item">{{ 'saved_export.Update existing'|trans }}</a></li>
                        </ul>
                    </div>
                </li>
                {% endif %}
            {% endif %}
        </ul>
</div>
{% endblock content %}
