Extract spreadsheet export buttons to shared export_buttons.html template

pull/10626/head
Sage Abdullah 2023-07-03 11:11:03 +01:00
rodzic 85dfb2c7e7
commit 45ab2630ef
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: EB1A33CC51CC0217
5 zmienionych plików z 21 dodań i 33 usunięć

Wyświetl plik

@ -8,13 +8,7 @@
<div class="report__actions">
{% block actions %}
{% if view.list_export %}
<div class="dropdown dropdown-button match-width">
<a href="{{ view.xlsx_export_url }}" class="button bicolor button--icon">{% icon name="download" wrapped=1 %}{% trans 'Download XLSX' %}</a>
<div class="dropdown-toggle">{% icon name="arrow-down" %}</div>
<ul>
<li><a class="button bicolor button--icon" href="{{ view.csv_export_url }}">{% icon name="download" wrapped=1 %}{% trans 'Download CSV' %}</a></li>
</ul>
</div>
{% include view.export_buttons_template_name %}
{% endif %}
{% endblock %}
</div>

Wyświetl plik

@ -0,0 +1,16 @@
{% load i18n wagtailadmin_tags %}
{% comment "text/markdown" %}
Variables accepted by this template:
- `view` - a view instance (usually of `SpreadsheetExportMixin`) that has `xlsx_export_url` and `csv_export_url` properties.
{% endcomment %}
<div class="dropdown dropdown-button match-width col">
<a href="{{ view.xlsx_export_url }}" class="button bicolor button--icon">{% icon name="download" wrapped=1 %}{% trans 'Download XLSX' %}</a>
<div class="dropdown-toggle">{% icon name="arrow-down" %}</div>
<ul>
<li><a class="button bicolor button--icon" href="{{ view.csv_export_url }}">{% icon name="download" wrapped=1 %}{% trans 'Download CSV' %}</a></li>
</ul>
</div>

Wyświetl plik

@ -152,6 +152,8 @@ class SpreadsheetExportMixin:
# A dictionary of column heading overrides in the format {field: heading}
export_headings = {}
export_buttons_template_name = "wagtailadmin/shared/export_buttons.html"
def get_filename(self):
"""Gets the base filename for the exported spreadsheet, without extensions"""
return "spreadsheet-export"

Wyświetl plik

@ -82,19 +82,7 @@
{% endblock %}
{% block content %}
{% fragment as form_actions %}
<div class="dropdown dropdown-button">
<a href="{{ view.xlsx_export_url }}" class="button bicolor button--icon">
{% icon name="download" wrapped=1 %}{% trans 'Download XLSX' %}
</a>
<div class="dropdown-toggle">{% icon name="arrow-down" %}</div>
<ul>
<li>
<a class="button bicolor button--icon" href="{{ view.csv_export_url }}">
{% icon name="download" wrapped=1 %}{% trans 'Download CSV' %}
</a>
</li>
</ul>
</div>
{% include view.export_buttons_template_name %}
{% endfragment %}
{% include "wagtailadmin/shared/header.html" with classname="w-header--no-border" title=page_title subtitle=form_page.title|capfirst icon="form" merged=1 extra_actions=form_actions %}

Wyświetl plik

@ -28,19 +28,7 @@
{% include 'modeladmin/includes/button.html' with button=view.button_helper.add_button %}
{% endif %}
{% if view.list_export %}
<div class="dropdown dropdown-button match-width col">
<a href="?export=xlsx&{{ request.GET.urlencode }}" class="button bicolor button--icon">
{% icon name="download" wrapped=1 %}{% trans 'Download XLSX' %}
</a>
<div class="dropdown-toggle">{% icon name="arrow-down" %}</div>
<ul>
<li>
<a class="button bicolor button--icon" href="?export=csv&{{ request.GET.urlencode }}">{% icon name="download" wrapped=1 %}
{% trans 'Download CSV' %}
</a>
</li>
</ul>
</div>
{% include view.export_buttons_template_name %}
{% endif %}
</div>
{% endif %}