diff --git a/InvenTree/InvenTree/static/css/inventree.css b/InvenTree/InvenTree/static/css/inventree.css
index 71e518560b..eca502425a 100644
--- a/InvenTree/InvenTree/static/css/inventree.css
+++ b/InvenTree/InvenTree/static/css/inventree.css
@@ -455,6 +455,10 @@
-webkit-opacity: 10%;
}
+.table-condensed {
+ font-size: 90%;
+}
+
/* grid display for part images */
.table-img-grid tr {
diff --git a/InvenTree/templates/js/translated/bom.js b/InvenTree/templates/js/translated/bom.js
index 66916c193e..4f3ae912d5 100644
--- a/InvenTree/templates/js/translated/bom.js
+++ b/InvenTree/templates/js/translated/bom.js
@@ -143,6 +143,93 @@ function newPartFromBomWizard(e) {
}
+/*
+ * Launch a modal dialog displaying the "substitute parts" for a particular BomItem
+ *
+ * If editable, allows substitutes to be added and deleted
+ */
+function bomSubstitutesDialog(bom_item_id, substitutes, options={}) {
+
+ function renderSubstituteRow(substitute) {
+
+ var pk = substitute.pk;
+
+ var thumb = thumbnailImage(substitute.part_detail.thumbnail || substitute.part_detail.image);
+
+ var buttons = '';
+
+ buttons += makeIconButton('fa-times icon-red', 'button-row-remove', pk, '{% trans "Remove substitute part" %}');
+
+ // Render a single row
+ var html = `
+
+ {% trans "Select and add a new variant item using the input below" %}
+
+ `;
+
+ constructForm('{% url "api-bom-substitute-list" %}', {
+ method: 'POST',
+ fields: {
+ part: {
+ required: false,
+ },
+ },
+ preFormContent: html,
+ title: '{% trans "Edit BOM Item Substitutes" %}',
+ afterRender: function(fields, opts) {
+ // TODO
+ },
+ onSubmit: function(fields, opts) {
+ // TODO
+ }
+ });
+
+}
+
+
function loadBomTable(table, options) {
/* Load a BOM table with some configurable options.
*
@@ -311,10 +398,10 @@ function loadBomTable(table, options) {
searchable: false,
sortable: true,
formatter: function(value, row) {
- if (row.substitutes) {
+ if (row.substitutes && row.substitutes.length > 0) {
return row.substitutes.length;
} else {
- return '-';
+ return `-`;
}
}
});
@@ -438,18 +525,17 @@ function loadBomTable(table, options) {
if (row.part == options.parent_id) {
- var bValidate = ``;
+ var bDelt = makeIconButton('fa-trash-alt icon-red', 'bom-delete-button', row.pk, '{% trans "Delete BOM Item" %}');
- html += bEdit;
- html += bDelt;
+ var html = `
`;
if (!row.validated) {
html += bValidate;
@@ -457,6 +543,10 @@ function loadBomTable(table, options) {
html += bValid;
}
+ html += bEdit;
+ html += bSubs;
+ html += bDelt;
+
html += `
`;
return html;
@@ -508,6 +598,7 @@ function loadBomTable(table, options) {
treeEnable: !options.editable,
rootParentId: parent_id,
idField: 'pk',
+ uniqueId: 'pk',
parentIdField: 'parentId',
treeShowField: 'sub_part',
showColumns: true,
@@ -584,19 +675,27 @@ function loadBomTable(table, options) {
// In editing mode, attached editables to the appropriate table elements
if (options.editable) {
+ // Callback for "delete" button
table.on('click', '.bom-delete-button', function() {
var pk = $(this).attr('pk');
+ var html = `
+
+ {% trans "Are you sure you want to delete this BOM item?" %}
+
`;
+
constructForm(`/api/bom/${pk}/`, {
method: 'DELETE',
title: '{% trans "Delete BOM Item" %}',
+ preFormContent: html,
onSuccess: function() {
reloadBomTable(table);
}
});
});
+ // Callback for "edit" button
table.on('click', '.bom-edit-button', function() {
var pk = $(this).attr('pk');
@@ -613,6 +712,7 @@ function loadBomTable(table, options) {
});
});
+ // Callback for "validate" button
table.on('click', '.bom-validate-button', function() {
var pk = $(this).attr('pk');
@@ -631,5 +731,21 @@ function loadBomTable(table, options) {
}
);
});
+
+ // Callback for "substitutes" button
+ table.on('click', '.bom-substitutes-button', function() {
+ var pk = $(this).attr('pk');
+
+ var row = table.bootstrapTable('getRowByUniqueId', pk);
+ var subs = row.substitutes || [];
+
+ bomSubstitutesDialog(
+ pk,
+ subs,
+ {
+
+ }
+ );
+ });
}
}
diff --git a/InvenTree/templates/js/translated/model_renderers.js b/InvenTree/templates/js/translated/model_renderers.js
index 33eef49e48..cf675ff4f7 100644
--- a/InvenTree/templates/js/translated/model_renderers.js
+++ b/InvenTree/templates/js/translated/model_renderers.js
@@ -159,21 +159,25 @@ function renderPart(name, data, parameters, options) {
html += ` -
${data.description}`;
}
- var stock = '';
+ var extra = '';
// Display available part quantity
if (user_settings.PART_SHOW_QUANTITY_IN_FORMS) {
if (data.in_stock == 0) {
- stock = `
{% trans "No Stock" %}`;
+ extra += `
{% trans "No Stock" %}`;
} else {
- stock = `
{% trans "In Stock" %}: ${data.in_stock}`;
+ extra += `
{% trans "Stock" %}: ${data.in_stock}`;
}
}
+ if (!data.active) {
+ extra += `
{% trans "Inactive" %}`;
+ }
+
html += `
- ${stock}
+ ${extra}
{% trans "Part ID" %}: ${data.pk}
`;