From 6886570d0fa5c9c59dc5617180c119bfaa91aade Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 22 Jun 2021 10:30:15 +1000 Subject: [PATCH 1/2] Bug fix for build order allocation sorting --- InvenTree/templates/js/build.js | 12 +++++++----- InvenTree/templates/js/tables.js | 14 ++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/InvenTree/templates/js/build.js b/InvenTree/templates/js/build.js index e8af981817..22d8ea7ea3 100644 --- a/InvenTree/templates/js/build.js +++ b/InvenTree/templates/js/build.js @@ -418,6 +418,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { sub_part_detail: true, sub_part_trackable: trackable, }, + disablePagination: true, formatNoMatches: function() { return '{% trans "No BOM items found" %}'; }, @@ -667,6 +668,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { { field: 'sub_part_detail.stock', title: '{% trans "Available" %}', + sortable: true, }, { field: 'allocated', @@ -686,14 +688,12 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { return makeProgressBar(allocated, required); }, sorter: function(valA, valB, rowA, rowB) { + console.log("sorting!"); var aA = sumAllocations(rowA); var aB = sumAllocations(rowB); - var qA = rowA.quantity; - var qB = rowB.quantity; - - qA *= output.quantity; - qB *= output.quantity; + var qA = requiredQuantity(rowA); + var qB = requiredQuantity(rowB); // Handle the case where both numerators are zero if ((aA == 0) && (aB == 0)) { @@ -713,6 +713,8 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { return (qA < qB) ? 1 : -1; } + if (progressA == progressB) return 0; + return (progressA < progressB) ? 1 : -1; } }, diff --git a/InvenTree/templates/js/tables.js b/InvenTree/templates/js/tables.js index 645e54fcbb..96eb3f8123 100644 --- a/InvenTree/templates/js/tables.js +++ b/InvenTree/templates/js/tables.js @@ -134,12 +134,14 @@ $.fn.inventreeTable = function(options) { var varName = tableName + '-pagesize'; // Pagingation options (can be server-side or client-side as specified by the caller) - options.pagination = true; - options.paginationVAlign = options.paginationVAlign || 'both'; - options.pageSize = inventreeLoad(varName, 25); - options.pageList = [25, 50, 100, 250, 'all']; - options.totalField = 'count'; - options.dataField = 'results'; + if (!options.disablePagination) { + options.pagination = true; + options.paginationVAlign = options.paginationVAlign || 'both'; + options.pageSize = inventreeLoad(varName, 25); + options.pageList = [25, 50, 100, 250, 'all']; + options.totalField = 'count'; + options.dataField = 'results'; + } // Extract query params var filters = options.queryParams || options.filters || {}; From 650d31ae32fd30ac8212c57a4dcb3d696382cc98 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 22 Jun 2021 10:43:00 +1000 Subject: [PATCH 2/2] Remove debug statements --- InvenTree/order/templates/order/po_attachments.html | 2 -- InvenTree/templates/js/build.js | 3 ++- InvenTree/templates/js/stock.js | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/InvenTree/order/templates/order/po_attachments.html b/InvenTree/order/templates/order/po_attachments.html index a0ab77975a..40052c1ec6 100644 --- a/InvenTree/order/templates/order/po_attachments.html +++ b/InvenTree/order/templates/order/po_attachments.html @@ -57,8 +57,6 @@ $("#attachment-table").on('click', '.attachment-delete-button', function() { var url = `/order/purchase-order/attachment/${button.attr('pk')}/delete/`; - console.log("url: " + url); - launchModalForm(url, { reload: true, }); diff --git a/InvenTree/templates/js/build.js b/InvenTree/templates/js/build.js index 22d8ea7ea3..3e5e438add 100644 --- a/InvenTree/templates/js/build.js +++ b/InvenTree/templates/js/build.js @@ -688,7 +688,8 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) { return makeProgressBar(allocated, required); }, sorter: function(valA, valB, rowA, rowB) { - console.log("sorting!"); + // Custom sorting function for progress bars + var aA = sumAllocations(rowA); var aB = sumAllocations(rowB); diff --git a/InvenTree/templates/js/stock.js b/InvenTree/templates/js/stock.js index 4dd2093896..06bbb7c20e 100644 --- a/InvenTree/templates/js/stock.js +++ b/InvenTree/templates/js/stock.js @@ -603,7 +603,6 @@ function loadStockTable(table, options) { // REJECTED if (row.status == {{ StockStatus.REJECTED }}) { - console.log("REJECTED - {{ StockStatus.REJECTED }}"); html += makeIconBadge('fa-times-circle icon-red', '{% trans "Stock item has been rejected" %}'); } // LOST