Update BOM table display

This commit is contained in:
Oliver Walters 2021-06-01 14:17:31 +10:00
parent 0bd0e57f16
commit 9f407df15a
5 changed files with 24 additions and 14 deletions

View File

@ -352,6 +352,7 @@ class EditBomItemForm(HelperForm):
'reference', 'reference',
'overage', 'overage',
'note', 'note',
'allow_variants',
'inherited', 'inherited',
'optional', 'optional',
] ]

View File

@ -285,11 +285,18 @@ function loadBomTable(table, options) {
title: '{% trans "Optional" %}', title: '{% trans "Optional" %}',
searchable: false, searchable: false,
formatter: function(value) { formatter: function(value) {
if (value == '1') return '{% trans "true" %}'; return yesNoLabel(value);
if (value == '0') return '{% trans "false" %}';
} }
}); });
cols.push({
field: 'allow_variants',
title: '{% trans "Allow Variants" %}',
formatter: function(value) {
return yesNoLabel(value);
}
})
cols.push({ cols.push({
field: 'inherited', field: 'inherited',
title: '{% trans "Inherited" %}', title: '{% trans "Inherited" %}',
@ -297,7 +304,7 @@ function loadBomTable(table, options) {
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
// This BOM item *is* inheritable, but is defined for this BOM // This BOM item *is* inheritable, but is defined for this BOM
if (!row.inherited) { if (!row.inherited) {
return "-"; return yesNoLabel(false);
} else if (row.part == options.parent_id) { } else if (row.part == options.parent_id) {
return '{% trans "Inherited" %}'; return '{% trans "Inherited" %}';
} else { } else {

View File

@ -5,6 +5,14 @@
* Requires api.js to be loaded first * Requires api.js to be loaded first
*/ */
function yesNoLabel(value) {
if (value) {
return `<span class='label label-green'>{% trans "YES" %}</span>`;
} else {
return `<span class='label label-yellow'>{% trans "NO" %}</span>`;
}
}
function toggleStar(options) { function toggleStar(options) {
/* Toggle the 'starred' status of a part. /* Toggle the 'starred' status of a part.
* Performs AJAX queries and updates the display on the button. * Performs AJAX queries and updates the display on the button.
@ -662,16 +670,6 @@ function loadPartCategoryTable(table, options) {
}); });
} }
function yesNoLabel(value) {
if (value) {
return `<span class='label label-green'>{% trans "YES" %}</span>`;
} else {
return `<span class='label label-yellow'>{% trans "NO" %}</span>`;
}
}
function loadPartTestTemplateTable(table, options) { function loadPartTestTemplateTable(table, options) {
/* /*
* Load PartTestTemplate table. * Load PartTestTemplate table.

View File

@ -49,6 +49,10 @@ function getAvailableTableFilters(tableKey) {
inherited: { inherited: {
type: 'bool', type: 'bool',
title: '{% trans "Inherited" %}', title: '{% trans "Inherited" %}',
},
allow_variants: {
type: 'bool',
title: '{% trans "Allow Variant Stock" %}',
} }
}; };
} }