mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
More API fixes
- Allow searching supplier parts by manufacturer name - Better rendering of supplier part table
This commit is contained in:
parent
a50ecb24c1
commit
62199aedf5
@ -127,6 +127,22 @@ function loadSupplierPartTable(table, url, options) {
|
||||
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,
|
||||
field: 'SKU',
|
||||
@ -138,11 +154,12 @@ function loadSupplierPartTable(table, url, options) {
|
||||
{
|
||||
sortable: true,
|
||||
field: 'manufacturer',
|
||||
title: '"Manufacturer"',
|
||||
title: 'Manufacturer',
|
||||
formatter: function(value, row, index, field) {
|
||||
if (value) {
|
||||
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;
|
||||
} else {
|
||||
|
@ -229,7 +229,13 @@ function loadStockTable(table, options) {
|
||||
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);
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class SupplierPartList(generics.ListCreateAPIView):
|
||||
search_fields = [
|
||||
'SKU',
|
||||
'supplier__name',
|
||||
'manufacturer_name',
|
||||
'manufacturer__name',
|
||||
'description',
|
||||
'MPN',
|
||||
]
|
||||
|
@ -141,35 +141,17 @@ InvenTree | {% trans "Search Results" %}
|
||||
}
|
||||
});
|
||||
|
||||
$("#supplier-part-results-table").inventreeTable({
|
||||
url: "{% url 'api-part-supplier-list' %}",
|
||||
queryParams: {
|
||||
search: "{{ query }}",
|
||||
},
|
||||
columns: [
|
||||
{
|
||||
field: 'supplier_name',
|
||||
title: 'Supplier',
|
||||
formatter: function(value, row, index, field) {
|
||||
return imageHoverIcon(row.supplier_logo) + renderLink(value, '/company/' + row.supplier + '/');
|
||||
}
|
||||
loadSupplierPartTable(
|
||||
"#supplier-part-results-table",
|
||||
"{% url 'api-supplier-part-list' %}",
|
||||
{
|
||||
params: {
|
||||
search: "{{ query }}",
|
||||
part_detail: true,
|
||||
supplier_detail: true,
|
||||
manufacturer_detail: true
|
||||
},
|
||||
{
|
||||
field: 'SKU',
|
||||
title: 'SKU',
|
||||
formatter: function(value, row, index, field) {
|
||||
return renderLink(value, row.url);
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'manufacturer',
|
||||
title: 'Manufacturer',
|
||||
},
|
||||
{
|
||||
field: 'MPN',
|
||||
title: 'MPN',
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user