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
(cherry picked from commit 62199aedf5
)
This commit is contained in:
parent
f88d03db88
commit
7c892263f8
@ -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 {
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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',
|
||||||
]
|
]
|
||||||
|
@ -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 %}
|
Loading…
Reference in New Issue
Block a user