2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-04 04:30:56 +00:00

Lots of work towards multiple build output

This commit is contained in:
Oliver Walters
2020-11-02 01:24:31 +11:00
parent f1b83f1c17
commit b02c87ea50
16 changed files with 487 additions and 561 deletions

View File

@ -152,17 +152,7 @@ function loadBomTable(table, options) {
var sub_part = row.sub_part_detail;
if (sub_part.trackable) {
html += makeIconBadge('fa-directions', '{% trans "Trackable part" %}');
}
if (sub_part.virtual) {
html += makeIconBadge('fa-ghost', '{% trans "Virtual part" %}');
}
if (sub_part.is_template) {
html += makeIconBadge('fa-clone', '{% trans "Template part" %}');
}
html += makePartIcons(row.sub_part_detail);
// Display an extra icon if this part is an assembly
if (sub_part.assembly) {
@ -171,10 +161,6 @@ function loadBomTable(table, options) {
html += renderLink(text, `/part/${row.sub_part}/bom/`);
}
if (!sub_part.active) {
html += `<span class='label label-warning label-right'>{% trans "Inactive" %}</span>`;
}
return html;
}
}

View File

@ -36,11 +36,8 @@ function makeBuildOutputActionButtons(output, buildInfo) {
/* Generate action buttons for a build output.
*/
var outputId = 'untracked';
if (output) {
outputId = output.pk;
}
var buildId = buildInfo.pk;
var outputId = output.pk;
var panel = `#allocation-panel-${outputId}`;
@ -54,23 +51,19 @@ function makeBuildOutputActionButtons(output, buildInfo) {
var html = `<div class='btn-group float-right' role='group'>`;
// Add a button to "auto allocate" against the build
if (!output) {
html += makeIconButton(
'fa-magic icon-blue', 'button-output-auto', outputId,
'{% trans "Auto-allocate stock items to this output" %}',
);
}
html += makeIconButton(
'fa-magic icon-blue', 'button-output-auto', outputId,
'{% trans "Auto-allocate stock items to this output" %}',
);
if (output) {
// Add a button to "complete" the particular build output
html += makeIconButton(
'fa-check icon-green', 'button-output-complete', outputId,
'{% trans "Complete build output" %}',
{
disabled: true
}
);
}
// Add a button to "complete" the particular build output
html += makeIconButton(
'fa-check icon-green', 'button-output-complete', outputId,
'{% trans "Complete build output" %}',
{
//disabled: true
}
);
// Add a button to "cancel" the particular build output (unallocate)
html += makeIconButton(
@ -78,18 +71,14 @@ function makeBuildOutputActionButtons(output, buildInfo) {
'{% trans "Unallocate stock from build output" %}',
);
if (output) {
// Add a button to "delete" the particular build output
html += makeIconButton(
'fa-trash-alt icon-red', 'button-output-delete', outputId,
'{% trans "Delete build output" %}',
);
// Add a button to "destroy" the particular build output (mark as damaged, scrap)
// TODO
}
// Add a button to "delete" the particular build output
html += makeIconButton(
'fa-trash-alt icon-red', 'button-output-delete', outputId,
'{% trans "Delete build output" %}',
);
// Add a button to "destroy" the particular build output (mark as damaged, scrap)
// TODO
html += '</div>';
@ -103,13 +92,21 @@ function makeBuildOutputActionButtons(output, buildInfo) {
data: {
output: outputId,
},
reload: true,
success: reloadTable,
}
);
});
$(panel).find(`#button-output-complete-${outputId}`).click(function() {
// TODO
launchModalForm(
`/build/${buildId}/complete/`,
{
success: reloadTable,
data: {
output: outputId,
}
}
);
});
$(panel).find(`#button-output-unallocate-${outputId}`).click(function() {
@ -155,18 +152,12 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
var outputId = null;
if (output) {
outputId = output.pk;
}
outputId = output.pk;
var table = options.table;
if (options.table == null) {
if (outputId != null) {
table = `#allocation-table-${outputId}`;
} else {
table = `#allocation-table-untracked`;
}
table = `#allocation-table-${outputId}`;
}
function reloadTable() {
@ -177,14 +168,7 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
function requiredQuantity(row) {
// Return the requied quantity for a given row
if (output) {
// Tracked stock allocated against a particular BuildOutput
return row.quantity * output.quantity;
} else {
// Untrack stock allocated against the build
return row.quantity * (buildInfo.quantity - buildInfo.completed);
}
return row.quantity * output.quantity;
}
function sumAllocations(row) {
@ -300,7 +284,6 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
queryParams: {
part: partId,
sub_part_detail: true,
sub_part_trackable: outputId != null,
},
formatNoMatches: function() {
return '{% trans "No BOM items found" %}';
@ -357,14 +340,8 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
var allocatedQuantity = sumAllocations(tableRow);
// Is this line item fully allocated?
if (output) {
if (allocatedQuantity >= (tableRow.quantity * output.quantity)) {
allocatedLines += 1;
}
} else {
if (allocatedQuantity >= (tableRow.quantity * (buildInfo.quantity - buildInfo.completed))) {
allocatedLines += 1;
}
if (allocatedQuantity >= (tableRow.quantity * output.quantity)) {
allocatedLines += 1;
}
// Push the updated row back into the main table
@ -506,6 +483,8 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
var html = imageHoverIcon(thumb) + renderLink(name, url);
html += makePartIcons(row.sub_part_detail);
return html;
}
},
@ -547,13 +526,8 @@ function loadBuildOutputAllocationTable(buildInfo, output, options={}) {
var qA = rowA.quantity;
var qB = rowB.quantity;
if (output) {
qA *= output.quantity;
qB *= output.quantity;
} else {
qA *= buildInfo.quantity;
qB *= buildInfo.quantity;
}
qA *= output.quantity;
qB *= output.quantity;
// Handle the case where both numerators are zero
if ((aA == 0) && (aB == 0)) {

View File

@ -61,6 +61,45 @@ function toggleStar(options) {
}
function makePartIcons(part, options={}) {
/* Render a set of icons for the given part.
*/
var html = '';
if (part.trackable) {
html += makeIconBadge('fa-directions', '{% trans "Trackable part" %}');
}
if (part.virtual) {
html += makeIconBadge('fa-ghost', '{% trans "Virtual part" %}');
}
if (part.is_template) {
html += makeIconBadge('fa-clone', '{% trans "Template part" %}');
}
if (part.assembly) {
html += makeIconBadge('fa-tools', '{% trans "Assembled part" %}');
}
if (part.starred) {
html += makeIconBadge('fa-star', '{% trans "Starred part" %}');
}
if (part.salable) {
html += makeIconBadge('fa-dollar-sign', title='{% trans "Salable part" %}');
}
if (!part.active) {
html += `<span class='label label-warning label-right'>{% trans "Inactive" %}</span>`;
}
return html;
}
function loadPartVariantTable(table, partId, options={}) {
/* Load part variant table
*/
@ -340,40 +379,8 @@ function loadPartTable(table, url, options={}) {
var display = imageHoverIcon(row.thumbnail) + renderLink(name, '/part/' + row.pk + '/');
if (row.trackable) {
display += makeIconBadge('fa-directions', '{% trans "Trackable part" %}');
}
display += makePartIcons(row);
if (row.virtual) {
display += makeIconBadge('fa-ghost', '{% trans "Virtual part" %}');
}
if (row.is_template) {
display += makeIconBadge('fa-clone', '{% trans "Template part" %}');
}
if (row.assembly) {
display += makeIconBadge('fa-tools', '{% trans "Assembled part" %}');
}
if (row.starred) {
display += makeIconBadge('fa-star', '{% trans "Starred part" %}');
}
if (row.salable) {
display += makeIconBadge('fa-dollar-sign', title='{% trans "Salable part" %}');
}
/*
if (row.component) {
display = display + `<span class='fas fa-cogs label-right' title='Component part'></span>`;
}
*/
if (!row.active) {
display += `<span class='label label-warning label-right'>{% trans "Inactive" %}</span>`;
}
return display;
}
});

View File

@ -908,7 +908,7 @@ function loadInstalledInTable(table, options) {
url: "{% url 'api-bom-list' %}",
queryParams: {
part: options.part,
trackable: true,
sub_part_trackable: true,
sub_part_detail: true,
},
showColumns: false,