Enhance CSV export functionality by allowing custom filenames and adding export links for active worklogs
This commit is contained in:
parent
a050ff7c1e
commit
4061065430
3 changed files with 29 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
|||
async function export_csv(ids, csv_route) {
|
||||
async function export_csv(ids, csv_route, filename=`${csv_route}_export.csv`) {
|
||||
const payload = ids;
|
||||
|
||||
try {
|
||||
|
@ -20,7 +20,7 @@ async function export_csv(ids, csv_route) {
|
|||
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.download = `${csv_route}_export.csv`;
|
||||
link.download = `${filename}.csv`;
|
||||
link.click();
|
||||
|
||||
console.log(url);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<a href="{{ url_for('main.' + endpoint, **arguments) }}"
|
||||
class="d-flex flex-column justify-content-center link-success link-underline-opacity-0">
|
||||
{% if icon_html %}
|
||||
{{ icon_html | safe }}
|
||||
{{ icon_html | safe }}
|
||||
{% endif %}
|
||||
{{ label }}
|
||||
</a>
|
||||
|
@ -18,13 +18,13 @@
|
|||
<!-- Navigation Link Fragment -->
|
||||
|
||||
{% if not active %}
|
||||
{% set active = request.endpoint == 'main.' + endpoint %}
|
||||
{% set active = request.endpoint == 'main.' + endpoint %}
|
||||
{% endif %}
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="{{ url_for('main.' + endpoint, **arguments) }}" class="nav-link{% if active %} active{% endif %}">
|
||||
{% if icon_html %}
|
||||
{{ icon_html | safe }}
|
||||
{{ icon_html | safe }}
|
||||
{% endif %}
|
||||
{{ label }}
|
||||
</a>
|
||||
|
@ -34,7 +34,19 @@
|
|||
{% macro entry_link(endpoint, id) %}
|
||||
<!-- Entry Link Fragment -->
|
||||
|
||||
<a href="{{ url_for('main.' + endpoint, id=id) }}" class="link-success link-underline-opacity-0">
|
||||
<a href="{{ url_for('main.' + endpoint, id=id) }}" class="link-success link-underline-opacity-0">
|
||||
{{ icons.render_icon('link', 12) }}
|
||||
</a>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro export_link(id, endpoint, ids) %}
|
||||
<!-- Export Link Fragment -->
|
||||
<a class="link-success link-underline-opacity-0" onclick="export_{{ id }}_csv()">{{ icons.render_icon('box-arrow-up', 12) }}</a>
|
||||
|
||||
<script>
|
||||
function export_{{ id }}_csv() {
|
||||
const payload = {{ ids }};
|
||||
export_csv(payload, '{{ endpoint }}', '{{ id }}_export');
|
||||
}
|
||||
</script>
|
||||
{% endmacro %}
|
|
@ -13,7 +13,17 @@
|
|||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Active Worklogs</h5>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">You have {{ active_count }} active worklogs.</h6>
|
||||
<h6 class="card-subtitle mb-2 text-body-secondary">
|
||||
You have {{ active_count }} active worklogs.
|
||||
{% set ids %}
|
||||
{ids: [{% for row in active_worklog_rows %}{{ row['id'] }}, {% endfor %}]}
|
||||
{% endset %}
|
||||
{{ links.export_link(
|
||||
'active_worklog',
|
||||
'worklog',
|
||||
ids
|
||||
) }}
|
||||
</h6>
|
||||
{{ tables.render_table(
|
||||
headers = active_worklog_headers,
|
||||
rows = active_worklog_rows,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue