Bug fix for build order allocation sorting

This commit is contained in:
Oliver 2021-06-22 10:30:15 +10:00
parent ba8d5fa3f4
commit 6886570d0f
2 changed files with 15 additions and 11 deletions

View File

@ -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;
}
},

View File

@ -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 || {};