mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-18 21:15:41 +00:00
Implement filtering which accommodates new inheritable BOM feature
- Can no longer filter bom_items by sub_part - Adds get_used_in_filter() and get_used_in() for part model (returns a query of other part objects)
This commit is contained in:
@ -539,85 +539,3 @@ function loadBomTable(table, options) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function loadUsedInTable(table, options) {
|
||||
/* Load a table which displays all the parts that the given part is used in.
|
||||
*/
|
||||
|
||||
var params = {
|
||||
sub_part: options.part_id,
|
||||
ordering: 'name',
|
||||
}
|
||||
|
||||
if (options.part_detail) {
|
||||
params.part_detail = true;
|
||||
}
|
||||
|
||||
if (options.sub_part_detail) {
|
||||
params.sub_part_detail = true;
|
||||
}
|
||||
|
||||
var filters = {};
|
||||
|
||||
if (!options.disableFilters) {
|
||||
filters = loadTableFilters("usedin");
|
||||
}
|
||||
|
||||
for (var key in params) {
|
||||
filters[key] = params[key];
|
||||
}
|
||||
|
||||
setupFilterList("usedin", $(table));
|
||||
|
||||
// Columns to display in the table
|
||||
var cols = [
|
||||
{
|
||||
field: 'pk',
|
||||
title: 'ID',
|
||||
visible: false,
|
||||
switchable: false,
|
||||
},
|
||||
{
|
||||
field: 'part_detail.full_name',
|
||||
title: '{% trans "Part" %}',
|
||||
sortable: true,
|
||||
formatter: function(value, row, index, field) {
|
||||
var link = `/part/${row.part}/bom/`;
|
||||
var html = imageHoverIcon(row.part_detail.thumbnail) + renderLink(row.part_detail.full_name, link);
|
||||
|
||||
if (!row.part_detail.active) {
|
||||
html += "<span class='label label-warning' style='float: right;'>{% trans 'INACTIVE' %}</span>";
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'part_detail.description',
|
||||
title: '{% trans "Description" %}',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
sortable: true,
|
||||
field: 'quantity',
|
||||
title: '{% trans "Uses" %}',
|
||||
formatter: function(value, row, index, field) {
|
||||
return parseFloat(value);
|
||||
},
|
||||
}
|
||||
];
|
||||
|
||||
// Load the table
|
||||
$(table).inventreeTable({
|
||||
url: "{% url 'api-bom-list' %}",
|
||||
formatNoMatches: function() {
|
||||
return '{% trans "No matching parts found" %}';
|
||||
},
|
||||
columns: cols,
|
||||
showColumns: true,
|
||||
sortable: true,
|
||||
serach: true,
|
||||
queryParams: filters,
|
||||
original: params,
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user