Add export functionality for worklogs with dynamic filename generation

This commit is contained in:
Yaro Kasear 2025-07-17 09:33:00 -05:00
parent 4061065430
commit e24b6d06bd

View file

@ -105,6 +105,23 @@
{% endif %} {% endif %}
</div> </div>
{% endset %} {% endset %}
{% set middleBar %}
{% if worklog %}
<button class="btn btn-primary" type="button" onclick="export_worklog_csv()">Export WorkLog</button>
<script>
function export_worklog_csv() {
const ids = [{% for row in worklog %}{{ row['id'] }}, {% endfor %}];
export_csv({ids: ids}, 'worklog', '{{ item.identifier
| replace('Name: ', '')
| replace('ID:', '')
| replace('Serial: ', '')
| replace('Barcode: ', '')
| lower
}}_worklog_export');
}
</script>
{% endif %}
{% endset %}
{{ toolbars.render_toolbar( {{ toolbars.render_toolbar(
id='inventory', id='inventory',
left=breadcrumbs.breadcrumb_header( left=breadcrumbs.breadcrumb_header(
@ -113,6 +130,7 @@
], ],
title=title title=title
), ),
center=middleBar,
right=buttonBar right=buttonBar
) }} ) }}
{% if item.condition in ["Removed", "Disposed"] %} {% if item.condition in ["Removed", "Disposed"] %}