This commit is contained in:
Oliver Walters 2021-08-30 15:54:31 +10:00
parent 51eb40f3bc
commit 0835fe92a0

View File

@ -1,5 +1,25 @@
{% load i18n %}
/* globals
constructForm,
imageHoverIcon,
inventreeGet,
inventreePut,
launchModalForm,
loadTableFilters,
makePartIcons,
renderLink,
setupFilterList,
yesNoLabel,
*/
/* exported
newPartFromBomWizard,
loadBomTable,
removeRowFromBomWizard,
removeColFromBomWizard,
*/
/* BOM management functions.
* Requires follwing files to be loaded first:
* - api.js
@ -28,7 +48,7 @@ function bomItemFields() {
}
function reloadBomTable(table, options) {
function reloadBomTable(table) {
table.bootstrapTable('refresh');
}
@ -157,7 +177,7 @@ function loadBomTable(table, options) {
checkbox: true,
visible: true,
switchable: false,
formatter: function(value, row, index, field) {
formatter: function(value, row) {
// Disable checkbox if the row is defined for a *different* part!
if (row.part != options.parent_id) {
return {
@ -182,7 +202,7 @@ function loadBomTable(table, options) {
field: 'sub_part',
title: '{% trans "Part" %}',
sortable: true,
formatter: function(value, row, index, field) {
formatter: function(value, row) {
var url = `/part/${row.sub_part}/`;
var html = imageHoverIcon(row.sub_part_detail.thumbnail) + renderLink(row.sub_part_detail.full_name, url);
@ -225,7 +245,7 @@ function loadBomTable(table, options) {
title: '{% trans "Quantity" %}',
searchable: false,
sortable: true,
formatter: function(value, row, index, field) {
formatter: function(value, row) {
var text = value;
// The 'value' is a text string with (potentially) multiple trailing zeros
@ -250,7 +270,7 @@ function loadBomTable(table, options) {
title: '{% trans "Available" %}',
searchable: false,
sortable: true,
formatter: function(value, row, index, field) {
formatter: function(value, row) {
var url = `/part/${row.sub_part_detail.pk}/?display=stock`;
var text = value;
@ -284,7 +304,7 @@ function loadBomTable(table, options) {
field: 'price_range',
title: '{% trans "Supplier Cost" %}',
sortable: true,
formatter: function(value, row, index, field) {
formatter: function(value) {
if (value) {
return value;
} else {
@ -314,7 +334,7 @@ function loadBomTable(table, options) {
field: 'inherited',
title: '{% trans "Inherited" %}',
searchable: false,
formatter: function(value, row, index, field) {
formatter: function(value, row) {
// This BOM item *is* inheritable, but is defined for this BOM
if (!row.inherited) {
return yesNoLabel(false);
@ -334,7 +354,7 @@ function loadBomTable(table, options) {
{
'field': 'can_build',
'title': '{% trans "Can Build" %}',
formatter: function(value, row, index, field) {
formatter: function(value, row) {
var can_build = 0;
if (row.quantity > 0) {
@ -379,7 +399,7 @@ function loadBomTable(table, options) {
switchable: false,
field: 'pk',
visible: true,
formatter: function(value, row, index, field) {
formatter: function(value, row) {
if (row.part == options.parent_id) {
@ -459,7 +479,7 @@ function loadBomTable(table, options) {
name: 'bom',
sortable: true,
search: true,
rowStyle: function(row, index) {
rowStyle: function(row) {
var classes = [];
@ -532,7 +552,6 @@ function loadBomTable(table, options) {
table.on('click', '.bom-delete-button', function() {
var pk = $(this).attr('pk');
var url = `/part/bom/${pk}/delete/`;
constructForm(`/api/bom/${pk}/`, {
method: 'DELETE',
@ -546,7 +565,6 @@ function loadBomTable(table, options) {
table.on('click', '.bom-edit-button', function() {
var pk = $(this).attr('pk');
var url = `/part/bom/${pk}/edit/`;
var fields = bomItemFields();