Files
WYGIWYH/app/templates/export_app/fragments/restore.html
T
Herculino Trotta 8d6b86b7ca feat(export): export and restore on the page, with progress and messages
The export and restore forms now sit on the Export and Restore page
instead of an offcanvas. Exporting shows a progress line and a toast
when the download starts; restoring splits ZIP and CSV uploads into
tabs and shows errors in the form.

- An empty export warns instead of downloading the message as a file
- Export errors show a message instead of a stuck spinner
- The download link is kept long enough for Safari to save the file
- Non-superusers get a 403 instead of a redirect loop with the login
- The asset classes CSV can be uploaded on its own
- Drop the export form's unknown investment_classes layout field
2026-11-17 13:01:25 -03:00

45 lines
1.7 KiB
HTML

{% load i18n %}
<form hx-post="{% url 'restore_form' %}"
hx-target="this"
hx-swap="outerHTML"
hx-encoding="multipart/form-data"
hx-disabled-elt="find [type=submit]"
hx-indicator="#restore-progress"
id="restore-form"
class="flex flex-col gap-4">
{% csrf_token %}
{% for error in form.non_field_errors %}
<div role="alert" class="alert alert-error alert-soft">
<i class="fa-solid fa-circle-exclamation" aria-hidden="true"></i>{{ error }}
</div>
{% endfor %}
<div class="tabs tabs-border">
<input type="radio" name="restore_source" class="tab" aria-label="{% translate 'ZIP file' %}" checked>
<div class="tab-content pt-4">
<label class="flex flex-col gap-2">
<span class="text-base-content/70">{{ form.zip_file.help_text }}</span>
{{ form.zip_file }}
</label>
</div>
<input type="radio" name="restore_source" class="tab" aria-label="{% translate 'Individual CSV files' %}">
<div class="tab-content pt-4">
<div class="grid gap-4 sm:grid-cols-2">
{% for field in form %}
{% if field.name != "zip_file" %}
<label class="flex flex-col gap-1.5">
<span class="text-sm">{{ field.label }}</span>
{{ field }}
</label>
{% endif %}
{% endfor %}
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">{% translate 'Restore' %}</button>
<p id="restore-progress" role="status" class="hidden [&.htmx-request]:flex items-center gap-2 text-sm text-base-content/70">
<span class="loading loading-spinner loading-sm"></span>
{% translate 'Restoring your data. This can take a while for large backups.' %}
</p>
</form>