Fix rendering of row sub tables

This commit is contained in:
Oliver 2021-10-06 16:38:13 +11:00
parent f9f8527ae5
commit 4d8bec9663
2 changed files with 42 additions and 24 deletions

View File

@ -549,7 +549,7 @@ class SOLineItemSerializer(InvenTreeModelSerializer):
order_detail = SalesOrderSerializer(source='order', many=False, read_only=True) order_detail = SalesOrderSerializer(source='order', many=False, read_only=True)
part_detail = PartBriefSerializer(source='part', many=False, read_only=True) part_detail = PartBriefSerializer(source='part', many=False, read_only=True)
allocations = SalesOrderAllocationSerializer(many=True, read_only=True) allocations = SalesOrderAllocationSerializer(many=True, read_only=True, location_detail=True)
quantity = serializers.FloatField() quantity = serializers.FloatField()

View File

@ -580,14 +580,12 @@ function loadPurchaseOrderTable(table, options) {
return '{% trans "No purchase orders found" %}'; return '{% trans "No purchase orders found" %}';
}, },
columns: [ columns: [
/*
{ {
title: '', title: '',
visible: true, visible: true,
checkbox: true, checkbox: true,
switchable: false, switchable: false,
}, },
*/
{ {
field: 'reference', field: 'reference',
title: '{% trans "Purchase Order" %}', title: '{% trans "Purchase Order" %}',
@ -1160,7 +1158,6 @@ function showAllocationSubTable(index, row, element, options) {
showHeader: false, showHeader: false,
columns: [ columns: [
{ {
width: '50%',
field: 'allocated', field: 'allocated',
title: '{% trans "Quantity" %}', title: '{% trans "Quantity" %}',
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
@ -1179,12 +1176,24 @@ function showAllocationSubTable(index, row, element, options) {
field: 'location', field: 'location',
title: '{% trans "Location" %}', title: '{% trans "Location" %}',
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
return renderLink(row.location_path, `/stock/location/${row.location}/`);
// Location specified
if (row.location) {
return renderLink(
row.location_detail.pathstring || '{% trans "Location" %}',
`/stock/location/${row.location}/`
);
} else {
return `<i>{% trans "Stock location not specified" %}`;
}
}, },
}, },
// TODO: ?? What is 'po' field all about?
/*
{ {
field: 'po' field: 'po'
}, },
*/
{ {
field: 'buttons', field: 'buttons',
title: '{% trans "Actions" %}', title: '{% trans "Actions" %}',
@ -1332,16 +1341,19 @@ function loadSalesOrderLineItemTable(table, options={}) {
// Table columns to display // Table columns to display
var columns = [ var columns = [
/*
{ {
checkbox: true, checkbox: true,
visible: true, visible: true,
switchable: false, switchable: false,
}, },
*/
{ {
sortable: true, sortable: true,
sortName: 'part__name', sortName: 'part__name',
field: 'part', field: 'part',
title: '{% trans "Part" %}', title: '{% trans "Part" %}',
switchable: false,
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
if (row.part) { if (row.part) {
return imageHoverIcon(row.part_detail.thumbnail) + renderLink(row.part_detail.full_name, `/part/${value}/`); return imageHoverIcon(row.part_detail.thumbnail) + renderLink(row.part_detail.full_name, `/part/${value}/`);
@ -1356,7 +1368,8 @@ function loadSalesOrderLineItemTable(table, options={}) {
{ {
sortable: true, sortable: true,
field: 'reference', field: 'reference',
title: '{% trans "Reference" %}' title: '{% trans "Reference" %}',
switchable: false,
}, },
{ {
sortable: true, sortable: true,
@ -1369,6 +1382,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
return sum + i return sum + i
}, 0) }, 0)
}, },
switchable: false,
}, },
{ {
sortable: true, sortable: true,
@ -1402,11 +1416,12 @@ function loadSalesOrderLineItemTable(table, options={}) {
title: '{% trans "In Stock" %}', title: '{% trans "In Stock" %}',
formatter: function(value, row) { formatter: function(value, row) {
return row.part_detail.stock; return row.part_detail.stock;
} },
}, },
{ {
field: 'allocated', field: 'allocated',
title: pending ? '{% trans "Allocated" %}' : '{% trans "Fulfilled" %}', title: pending ? '{% trans "Allocated" %}' : '{% trans "Fulfilled" %}',
switchable: false,
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
var quantity = pending ? row.allocated : row.fulfilled; var quantity = pending ? row.allocated : row.fulfilled;
@ -1433,6 +1448,8 @@ function loadSalesOrderLineItemTable(table, options={}) {
field: 'notes', field: 'notes',
title: '{% trans "Notes" %}', title: '{% trans "Notes" %}',
}, },
// TODO: Re-introduce the "PO" field, once it is fixed
/*
{ {
field: 'po', field: 'po',
title: '{% trans "PO" %}', title: '{% trans "PO" %}',
@ -1452,6 +1469,7 @@ function loadSalesOrderLineItemTable(table, options={}) {
return `<div>` + po_name + `</div>`; return `<div>` + po_name + `</div>`;
} }
}, },
*/
]; ];
if (pending) { if (pending) {
@ -1633,23 +1651,23 @@ function loadSalesOrderLineItemTable(table, options={}) {
url: options.url, url: options.url,
showFooter: true, showFooter: true,
uniqueId: 'pk', uniqueId: 'pk',
// detailView: show_detail, detailView: show_detail,
// detailViewByClick: show_detail, detailViewByClick: show_detail,
// detailFilter: function(index, row) { detailFilter: function(index, row) {
// if (pending) { if (pending) {
// // Order is pending // Order is pending
// return row.allocated > 0; return row.allocated > 0;
// } else { } else {
// return row.fulfilled > 0; return row.fulfilled > 0;
// } }
// }, },
// detailFormatter: function(index, row, element) { detailFormatter: function(index, row, element) {
// if (pending) { if (pending) {
// return showAllocationSubTable(index, row, element, options); return showAllocationSubTable(index, row, element, options);
// } else { } else {
// return showFulfilledSubTable(index, row, element, options); return showFulfilledSubTable(index, row, element, options);
// } }
// }, },
columns: columns, columns: columns,
}); });
} }