kopia lustrzana https://github.com/wagtail/wagtail
Extract spreadsheet export buttons to shared export_buttons.html template
rodzic
85dfb2c7e7
commit
45ab2630ef
|
@ -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>
|
||||
|
|
|
@ -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>
|
|
@ -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"
|
||||
|
|
|
@ -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 %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Ładowanie…
Reference in New Issue