{% if part.bom_checked_date %}
{% if part.is_bom_valid %}
{% else %}
The BOM for {{ part.full_name }} has changed, and must be validated.
{% endif %}
The BOM for {{ part.full_name }} was last checked by {{ part.bom_checked_by }} on {{ part.bom_checked_date }}
{% else %}
The BOM for {{ part.full_name }} has not been validated.
{% endif %}
{% if editing_enabled %}
{% if part.variant_of %}
{% endif %}
{% elif part.active %}
{% if roles.part.change %}
{% if part.is_bom_valid == False %}
{% endif %}
{% endif %}
{% endif %}
{% endblock %}
{% block js_load %}
{{ block.super }}
{% endblock %}
{% block js_ready %}
{{ block.super }}
// Load the BOM table data
loadBomTable($("#bom-table"), {
editable: {{ editing_enabled }},
bom_url: "{% url 'api-bom-list' %}",
part_url: "{% url 'api-part-list' %}",
parent_id: {{ part.id }} ,
sub_part_detail: true,
});
linkButtonsToSelection($("#bom-table"),
[
"#bom-item-delete",
]
);
{% if editing_enabled %}
$("#editing-finished").click(function() {
location.href = "{% url 'part-bom' part.id %}";
});
$('#bom-item-delete').click(function() {
// Get a list of the selected BOM items
var rows = $("#bom-table").bootstrapTable('getSelections');
// TODO - In the future, display (in the dialog) which items are going to be deleted
showQuestionDialog(
'{% trans "Delete selected BOM items?" %}',
'{% trans "All selected BOM items will be deleted" %}',
{
accept: function() {
// Delete each row one at a time!
function deleteRow(idx) {
if (idx >= rows.length) {
// All selected rows deleted - reload the table
$("#bom-table").bootstrapTable('refresh');
}
var row = rows[idx];
var url = `/api/bom/${row.pk}/`;
inventreeDelete(
url,
{
complete: function(xhr, status) {
deleteRow(idx + 1);
}
}
)
}
// Start the deletion!
deleteRow(0);
}
}
);
});
$('#bom-upload').click(function() {
location.href = "{% url 'upload-bom' part.id %}";
});
$('#bom-duplicate').click(function() {
launchModalForm(
"{% url 'duplicate-bom' part.id %}",
{
success: function() {
$('#bom-table').bootstrapTable('refresh');
}
}
);
});
$("#bom-item-new").click(function () {
launchModalForm(
"{% url 'bom-item-create' %}?parent={{ part.id }}",
{
success: function() {
$("#bom-table").bootstrapTable('refresh');
},
secondary: [
{
field: 'sub_part',
label: 'New Part',
title: 'Create New Part',
url: "{% url 'part-create' %}",
},
]
}
);
});
{% else %}
$("#validate-bom").click(function() {
launchModalForm(
"{% url 'bom-validate' part.id %}",
{
reload: true,
}
);
});
$("#edit-bom").click(function () {
location.href = "{% url 'part-bom' part.id %}?edit=1";
});
$("#download-bom").click(function () {
launchModalForm("{% url 'bom-export' part.id %}",
{
success: function(response) {
location.href = response.url;
},
}
);
});
{% endif %}
{% endblock %}