mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1706 from SchrodingersGat/build-item-sorting
Bug fix for build order allocation sorting
This commit is contained in:
commit
df7b0c961d
@ -57,8 +57,6 @@ $("#attachment-table").on('click', '.attachment-delete-button', function() {
|
|||||||
|
|
||||||
var url = `/order/purchase-order/attachment/${button.attr('pk')}/delete/`;
|
var url = `/order/purchase-order/attachment/${button.attr('pk')}/delete/`;
|
||||||
|
|
||||||
console.log("url: " + url);
|
|
||||||
|
|
||||||
launchModalForm(url, {
|
launchModalForm(url, {
|
||||||
reload: true,
|
reload: true,
|
||||||
});
|
});
|
||||||
|
@ -418,6 +418,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
|||||||
sub_part_detail: true,
|
sub_part_detail: true,
|
||||||
sub_part_trackable: trackable,
|
sub_part_trackable: trackable,
|
||||||
},
|
},
|
||||||
|
disablePagination: true,
|
||||||
formatNoMatches: function() {
|
formatNoMatches: function() {
|
||||||
return '{% trans "No BOM items found" %}';
|
return '{% trans "No BOM items found" %}';
|
||||||
},
|
},
|
||||||
@ -667,6 +668,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
|||||||
{
|
{
|
||||||
field: 'sub_part_detail.stock',
|
field: 'sub_part_detail.stock',
|
||||||
title: '{% trans "Available" %}',
|
title: '{% trans "Available" %}',
|
||||||
|
sortable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'allocated',
|
field: 'allocated',
|
||||||
@ -686,14 +688,13 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
|||||||
return makeProgressBar(allocated, required);
|
return makeProgressBar(allocated, required);
|
||||||
},
|
},
|
||||||
sorter: function(valA, valB, rowA, rowB) {
|
sorter: function(valA, valB, rowA, rowB) {
|
||||||
|
// Custom sorting function for progress bars
|
||||||
|
|
||||||
var aA = sumAllocations(rowA);
|
var aA = sumAllocations(rowA);
|
||||||
var aB = sumAllocations(rowB);
|
var aB = sumAllocations(rowB);
|
||||||
|
|
||||||
var qA = rowA.quantity;
|
var qA = requiredQuantity(rowA);
|
||||||
var qB = rowB.quantity;
|
var qB = requiredQuantity(rowB);
|
||||||
|
|
||||||
qA *= output.quantity;
|
|
||||||
qB *= output.quantity;
|
|
||||||
|
|
||||||
// Handle the case where both numerators are zero
|
// Handle the case where both numerators are zero
|
||||||
if ((aA == 0) && (aB == 0)) {
|
if ((aA == 0) && (aB == 0)) {
|
||||||
@ -713,6 +714,8 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
|
|||||||
return (qA < qB) ? 1 : -1;
|
return (qA < qB) ? 1 : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (progressA == progressB) return 0;
|
||||||
|
|
||||||
return (progressA < progressB) ? 1 : -1;
|
return (progressA < progressB) ? 1 : -1;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -603,7 +603,6 @@ function loadStockTable(table, options) {
|
|||||||
|
|
||||||
// REJECTED
|
// REJECTED
|
||||||
if (row.status == {{ StockStatus.REJECTED }}) {
|
if (row.status == {{ StockStatus.REJECTED }}) {
|
||||||
console.log("REJECTED - {{ StockStatus.REJECTED }}");
|
|
||||||
html += makeIconBadge('fa-times-circle icon-red', '{% trans "Stock item has been rejected" %}');
|
html += makeIconBadge('fa-times-circle icon-red', '{% trans "Stock item has been rejected" %}');
|
||||||
}
|
}
|
||||||
// LOST
|
// LOST
|
||||||
|
@ -134,12 +134,14 @@ $.fn.inventreeTable = function(options) {
|
|||||||
var varName = tableName + '-pagesize';
|
var varName = tableName + '-pagesize';
|
||||||
|
|
||||||
// Pagingation options (can be server-side or client-side as specified by the caller)
|
// Pagingation options (can be server-side or client-side as specified by the caller)
|
||||||
options.pagination = true;
|
if (!options.disablePagination) {
|
||||||
options.paginationVAlign = options.paginationVAlign || 'both';
|
options.pagination = true;
|
||||||
options.pageSize = inventreeLoad(varName, 25);
|
options.paginationVAlign = options.paginationVAlign || 'both';
|
||||||
options.pageList = [25, 50, 100, 250, 'all'];
|
options.pageSize = inventreeLoad(varName, 25);
|
||||||
options.totalField = 'count';
|
options.pageList = [25, 50, 100, 250, 'all'];
|
||||||
options.dataField = 'results';
|
options.totalField = 'count';
|
||||||
|
options.dataField = 'results';
|
||||||
|
}
|
||||||
|
|
||||||
// Extract query params
|
// Extract query params
|
||||||
var filters = options.queryParams || options.filters || {};
|
var filters = options.queryParams || options.filters || {};
|
||||||
|
Loading…
Reference in New Issue
Block a user