From 41cef1a1901b08645c9d37e7966c0e87bda36231 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 12 May 2023 14:29:29 +1000 Subject: [PATCH] Add reload functionality for build item table (#4799) * Add reload functionality for build item table * Update requirements.txt file (cherry picked from commit c976d06ec75d17e4c2fd4e557eb0bda858ae391e) --- InvenTree/templates/js/translated/build.js | 22 ++++++++++++++++---- InvenTree/templates/js/translated/filters.js | 2 +- requirements.txt | 4 ++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 6e5288257b..cdf3b10f4c 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -1443,8 +1443,9 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { var bom_items = buildInfo.bom_items || null; - // If BOM items have not been provided, load via the API - if (bom_items == null) { + function loadBomData() { + let data = []; + inventreeGet( '{% url "api-bom-list" %}', { @@ -1455,10 +1456,17 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { { async: false, success: function(results) { - bom_items = results; + data = results; } } ); + + return data; + } + + // If BOM items have not been provided, load via the API + if (bom_items == null) { + bom_items = loadBomData(); } // Apply filters to build table @@ -1510,7 +1518,13 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { setupFilterList('builditems', $(table), options.filterTarget, { callback: function(table, filters, options) { - filterBuildAllocationTable(filters); + if (filters == null) { + // Destroy and re-create the table from scratch + $(table).bootstrapTable('destroy'); + loadBuildOutputAllocationTable(buildInfo, output, options); + } else { + filterBuildAllocationTable(filters); + } } }); diff --git a/InvenTree/templates/js/translated/filters.js b/InvenTree/templates/js/translated/filters.js index 0390bc1052..9af6962202 100644 --- a/InvenTree/templates/js/translated/filters.js +++ b/InvenTree/templates/js/translated/filters.js @@ -429,7 +429,7 @@ function setupFilterList(tableKey, table, target, options={}) { // Callback for reloading the table element.find(`#reload-${tableKey}`).click(function() { - reloadTableFilters(table, {}, options); + reloadTableFilters(table, null, options); }); // Add a callback for downloading table data diff --git a/requirements.txt b/requirements.txt index 9b240e56d6..b751b5dd8a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -154,6 +154,8 @@ icalendar==5.0.5 # via django-ical idna==3.4 # via requests +importlib-metadata==6.6.0 + # via markdown inflection==0.5.1 # via drf-spectacular itypes==1.2.0 @@ -291,6 +293,8 @@ xlrd==2.0.1 # via tablib xlwt==1.3.0 # via tablib +zipp==3.15.0 + # via importlib-metadata zopfli==0.2.2 # via fonttools