-
@@ -290,10 +287,6 @@
});
});
- $("#part-export").click(function() {
- downloadTableData($('#part-table'));
- });
-
{% if roles.part.add %}
$("#part-create").click(function() {
diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html
index 172315b50e..9007d91839 100644
--- a/InvenTree/part/templates/part/detail.html
+++ b/InvenTree/part/templates/part/detail.html
@@ -831,12 +831,7 @@
],
url: "{% url 'api-stock-list' %}",
});
-
- $("#stock-export").click(function() {
-
- downloadTableData($("#stock-table"));
- });
-
+
$('#item-create').click(function () {
createNewStockItem({
data: {
diff --git a/InvenTree/stock/templates/stock/location.html b/InvenTree/stock/templates/stock/location.html
index 575a798fb2..1da0030bc6 100644
--- a/InvenTree/stock/templates/stock/location.html
+++ b/InvenTree/stock/templates/stock/location.html
@@ -239,10 +239,6 @@
});
{% endif %}
- $("#stock-export").click(function() {
- downloadTableData($('#stock-table'));
- });
-
$('#location-create').click(function () {
createStockLocation({
diff --git a/InvenTree/templates/js/translated/filters.js b/InvenTree/templates/js/translated/filters.js
index 78ed30eefa..1a8c0267ee 100644
--- a/InvenTree/templates/js/translated/filters.js
+++ b/InvenTree/templates/js/translated/filters.js
@@ -256,7 +256,7 @@ function generateFilterInput(tableKey, filterKey) {
* @param {*} table - bootstrapTable element to update
* @param {*} target - name of target element on page
*/
-function setupFilterList(tableKey, table, target) {
+function setupFilterList(tableKey, table, target, options={}) {
var addClicked = false;
@@ -283,6 +283,11 @@ function setupFilterList(tableKey, table, target) {
var buttons = '';
+ // Add download button
+ if (options.download) {
+ buttons += `
`;
+ }
+
buttons += `
`;
// If there are filters defined for this table, add more buttons
@@ -295,7 +300,7 @@ function setupFilterList(tableKey, table, target) {
}
element.html(`
-
+
${buttons}
`);
@@ -322,6 +327,13 @@ function setupFilterList(tableKey, table, target) {
$(table).bootstrapTable('refresh');
});
+ // Add a callback for downloading table data
+ if (options.download) {
+ element.find(`#download-${tableKey}`).click(function() {
+ downloadTableData($(table));
+ });
+ }
+
// Add a callback for adding a new filter
element.find(`#${add}`).click(function clicked() {
diff --git a/InvenTree/templates/js/translated/part.js b/InvenTree/templates/js/translated/part.js
index d42755a0f0..a0887f9473 100644
--- a/InvenTree/templates/js/translated/part.js
+++ b/InvenTree/templates/js/translated/part.js
@@ -1218,7 +1218,7 @@ function loadPartTable(table, url, options={}) {
filters[key] = params[key];
}
- setupFilterList('parts', $(table), options.filterTarget || null);
+ setupFilterList('parts', $(table), options.filterTarget, {download: true});
var columns = [
{
diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js
index 6239a886ab..dcca969a28 100644
--- a/InvenTree/templates/js/translated/stock.js
+++ b/InvenTree/templates/js/translated/stock.js
@@ -1571,7 +1571,7 @@ function loadStockTable(table, options) {
original[k] = params[k];
}
- setupFilterList(filterKey, table, filterTarget);
+ setupFilterList(filterKey, table, filterTarget, {download: true});
// Override the default values, or add new ones
for (var key in params) {
diff --git a/InvenTree/templates/stock_table.html b/InvenTree/templates/stock_table.html
index a8a4ec6691..d609e78253 100644
--- a/InvenTree/templates/stock_table.html
+++ b/InvenTree/templates/stock_table.html
@@ -11,9 +11,6 @@