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