Refactor worklog export button to streamline functionality and remove redundant script

This commit is contained in:
Yaro Kasear 2025-07-17 09:45:32 -05:00
parent e24b6d06bd
commit 7b908d7fa3

View file

@ -88,6 +88,15 @@
}
{% endset %}
{% set buttonBar %}
{% if worklog %}
<button class="btn btn-primary" type="button" onclick="export_csv({ids: [{% for row in worklog %}{{ row['id'] }}, {% endfor %}]}, 'worklog', '{{ item.identifier
| replace('Name: ', '')
| replace('ID:', '')
| replace('Serial: ', '')
| replace('Barcode: ', '')
| lower
}}_worklog_export');">Export WorkLog</button>
{% endif %}
<div class="btn-group">
{{ buttons.render_button(
id='save',
@ -105,23 +114,6 @@
{% endif %}
</div>
{% 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(
id='inventory',
left=breadcrumbs.breadcrumb_header(
@ -130,7 +122,6 @@
],
title=title
),
center=middleBar,
right=buttonBar
) }}
{% if item.condition in ["Removed", "Disposed"] %}