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

{% block js %}
    {{ parent() }}
    {{ encore_entry_script_tags('page_download_exports') }}
{% endblock %}

{% block css %}
    {{ parent() }}
    {{ encore_entry_link_tags('page_download_exports') }}
{% endblock %}

 {% block title exportGeneration.linkedToSavedExport ? exportGeneration.savedExport.title : ('Download export'|trans) %}

{% block content %}
    <h1>{{ block('title') }}</h1>
    <div id="app"
         data-export-generation-id="{{ exportGeneration.id | escape('html_attr') }}"
         data-export-generation-date="{{ exportGeneration.createdAt.format('Ymd-His') }}"
         data-export-title="{{ export.title|trans }}"
    ></div>

    <ul class="sticky-form-buttons record_actions">
        <li class="cancel">
            <a href="{{ chill_return_path_or('chill_main_export_saved_list_my') }}" class="btn btn-cancel">
                {{ 'export.generation.Come back later'|trans|chill_return_path_label }}
            </a>
        </li>
        {% if not exportGeneration.linkedToSavedExport %}
            <li>
                <a href="{{ chill_path_add_return_path('chill_main_export_saved_create_from_export_generation', {'id': exportGeneration.id}) }}" class="btn btn-save">
                    {{ 'Save'|trans }}
                </a>
            </li>
        {% else %}
            {% if exportGeneration.configurationDifferentFromSavedExport %}
                <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 dropdown-menu-end">
                            <li class="dropdown-item">
                                <a href="{{ chill_path_add_return_path('chill_main_export_saved_create_from_export_generation', {'id': exportGeneration.id, 'title': exportGeneration.savedExport.title ~ ' (' ~ 'saved_export.Duplicated'|trans ~ ' ' ~ null|format_datetime('short', 'medium') ~ ')'}) }}" class="btn">
                                    <i class="bi bi-copy"></i> {{ 'saved_export.Save to new saved export'|trans }}
                                </a>
                            </li>
                            {% if is_granted('CHILL_MAIN_EXPORT_SAVED_EDIT', exportGeneration.savedExport) %}
                                <li class="dropdown-item">
                                    <form method="POST" action="{{ path('chill_main_export_saved_options_edit', {'savedExport': exportGeneration.savedExport.id, 'exportGeneration': exportGeneration.id }) }}">
                                        <button type="submit" class="btn">
                                            <i class="bi bi-floppy"></i> {{ 'saved_export.Update current saved export'|trans }}
                                        </button>
                                    </form>
                                </li>
                            {% endif %}
                        </ul>
                    </div>
                </li>
            {% endif %}
        {% endif %}
    </ul>
{% endblock content %}
