More API fixes

- Allow searching supplier parts by manufacturer name
- Better rendering of supplier part table
This commit is contained in:
Oliver Walters 2020-04-13 19:33:44 +10:00
parent a50ecb24c1
commit 62199aedf5
4 changed files with 39 additions and 34 deletions

View File

@ -127,6 +127,22 @@ function loadSupplierPartTable(table, url, options) {
return html; return html;
} }
}, },
{
sortable: true,
field: 'supplier',
title: "Supplier",
formatter: function(value, row, index, field) {
if (value) {
var name = row.supplier_detail.name;
var url = `/company/${value}/`;
var html = imageHoverIcon(row.supplier_detail.image) + renderLink(name, url);
return html;
} else {
return "-";
}
},
},
{ {
sortable: true, sortable: true,
field: 'SKU', field: 'SKU',
@ -138,11 +154,12 @@ function loadSupplierPartTable(table, url, options) {
{ {
sortable: true, sortable: true,
field: 'manufacturer', field: 'manufacturer',
title: '"Manufacturer"', title: 'Manufacturer',
formatter: function(value, row, index, field) { formatter: function(value, row, index, field) {
if (value) { if (value) {
var name = row.manufacturer_detail.name; var name = row.manufacturer_detail.name;
var html = imageHoverIcon(row.manufacturer_detail.image) + renderLink(name, '/company/' + value + '/'); var url = `/company/${value}/`;
var html = imageHoverIcon(row.manufacturer_detail.image) + renderLink(name, url);
return html; return html;
} else { } else {

View File

@ -229,7 +229,13 @@ function loadStockTable(table, options) {
name += row.part__revision; name += row.part__revision;
} }
var url = `/supplier-part/${row.supplier_part}/`; var url = '';
if (row.supplier_part) {
url = `/supplier-part/${row.supplier_part}/`;
} else {
url = `/part/${row.part}/`;
}
return imageHoverIcon(row.part__thumbnail) + renderLink(name, url); return imageHoverIcon(row.part__thumbnail) + renderLink(name, url);
} }

View File

@ -130,7 +130,7 @@ class SupplierPartList(generics.ListCreateAPIView):
search_fields = [ search_fields = [
'SKU', 'SKU',
'supplier__name', 'supplier__name',
'manufacturer_name', 'manufacturer__name',
'description', 'description',
'MPN', 'MPN',
] ]

View File

@ -140,36 +140,18 @@ InvenTree | {% trans "Search Results" %}
serach: "{{ query }}", serach: "{{ query }}",
} }
}); });
$("#supplier-part-results-table").inventreeTable({ loadSupplierPartTable(
url: "{% url 'api-part-supplier-list' %}", "#supplier-part-results-table",
queryParams: { "{% url 'api-supplier-part-list' %}",
search: "{{ query }}", {
}, params: {
columns: [ search: "{{ query }}",
{ part_detail: true,
field: 'supplier_name', supplier_detail: true,
title: 'Supplier', manufacturer_detail: true
formatter: function(value, row, index, field) {
return imageHoverIcon(row.supplier_logo) + renderLink(value, '/company/' + row.supplier + '/');
}
}, },
{ }
field: 'SKU', );
title: 'SKU',
formatter: function(value, row, index, field) {
return renderLink(value, row.url);
}
},
{
field: 'manufacturer',
title: 'Manufacturer',
},
{
field: 'MPN',
title: 'MPN',
}
]
});
{% endblock %} {% endblock %}