mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #2086 from SchrodingersGat/search-fix
Fix for search page
(cherry picked from commit 172d184a4d
)
This commit is contained in:
parent
9c2f4ce491
commit
827534138b
@ -117,7 +117,7 @@
|
|||||||
"{% url 'api-part-list' %}",
|
"{% url 'api-part-list' %}",
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
},
|
},
|
||||||
checkbox: false,
|
checkbox: false,
|
||||||
disableFilters: true,
|
disableFilters: true,
|
||||||
@ -126,24 +126,10 @@
|
|||||||
|
|
||||||
addItem('category', '{% trans "Part Categories" %}', 'fa-sitemap');
|
addItem('category', '{% trans "Part Categories" %}', 'fa-sitemap');
|
||||||
|
|
||||||
$("#table-category").inventreeTable({
|
loadPartCategoryTable($("#table-category"), {
|
||||||
url: "{% url 'api-part-category-list' %}",
|
params: {
|
||||||
queryParams: {
|
original_search: "{{ query }}",
|
||||||
search: "{{ query }}",
|
}
|
||||||
},
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
field: 'name',
|
|
||||||
title: '{% trans "Name" %}',
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
return renderLink(value, '/part/category/' + row.pk + '/');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'description',
|
|
||||||
title: '{% trans "Description" %}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addItem('manufacturer-part', '{% trans "Manufacturer Parts" %}', 'fa-toolbox');
|
addItem('manufacturer-part', '{% trans "Manufacturer Parts" %}', 'fa-toolbox');
|
||||||
@ -153,7 +139,7 @@
|
|||||||
"{% url 'api-manufacturer-part-list' %}",
|
"{% url 'api-manufacturer-part-list' %}",
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
supplier_detail: true,
|
supplier_detail: true,
|
||||||
manufacturer_detail: true
|
manufacturer_detail: true
|
||||||
@ -168,7 +154,7 @@
|
|||||||
"{% url 'api-supplier-part-list' %}",
|
"{% url 'api-supplier-part-list' %}",
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
supplier_detail: true,
|
supplier_detail: true,
|
||||||
manufacturer_detail: true
|
manufacturer_detail: true
|
||||||
@ -186,7 +172,7 @@
|
|||||||
|
|
||||||
loadBuildTable('#table-build-order', {
|
loadBuildTable('#table-build-order', {
|
||||||
params: {
|
params: {
|
||||||
search: '{{ query }}',
|
original_search: '{{ query }}',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -197,105 +183,23 @@
|
|||||||
|
|
||||||
addItem('stock', '{% trans "Stock Items" %}', 'fa-boxes');
|
addItem('stock', '{% trans "Stock Items" %}', 'fa-boxes');
|
||||||
|
|
||||||
$('#table-stock').inventreeTable({
|
loadStockTable($('#table-stock'), {
|
||||||
|
filterKey: 'stocksearch',
|
||||||
url: "{% url 'api-stock-list' %}",
|
url: "{% url 'api-stock-list' %}",
|
||||||
queryParams: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
part_detail: true,
|
part_detail: true,
|
||||||
location_detail: true,
|
location_detail: true
|
||||||
},
|
}
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
field: 'part',
|
|
||||||
title: "{% trans "Part" %}",
|
|
||||||
sortable: true,
|
|
||||||
formatter: function(value, row) {
|
|
||||||
var url = `/stock/item/${row.pk}/`;
|
|
||||||
var thumb = row.part_detail.thumbnail;
|
|
||||||
var name = row.part_detail.full_name;
|
|
||||||
|
|
||||||
html = imageHoverIcon(thumb) + renderLink(name, url);
|
|
||||||
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'part_description',
|
|
||||||
title: '{% trans "Description" %}',
|
|
||||||
sortable: true,
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
return row.part_detail.description;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'quantity',
|
|
||||||
title: '{% trans "Stock" %}',
|
|
||||||
sortable: true,
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
|
|
||||||
var val = parseFloat(value);
|
|
||||||
|
|
||||||
// If there is a single unit with a serial number, use the serial number
|
|
||||||
if (row.serial && row.quantity == 1) {
|
|
||||||
val = '# ' + row.serial;
|
|
||||||
} else {
|
|
||||||
val = +val.toFixed(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
var html = renderLink(val, `/stock/item/${row.pk}/`);
|
|
||||||
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'status',
|
|
||||||
title: '{% trans "Status" %}',
|
|
||||||
sortable: 'true',
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
return stockStatusDisplay(value);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'location_detail.pathstring',
|
|
||||||
title: '{% trans "Location" %}',
|
|
||||||
sortable: true,
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
if (value) {
|
|
||||||
return renderLink(value, `/stock/location/${row.location}/`);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (row.customer) {
|
|
||||||
var text = "{% trans "Shipped to customer" %}";
|
|
||||||
return renderLink(text, `/company/${row.customer}/assigned-stock/`);
|
|
||||||
} else {
|
|
||||||
return '<em>{% trans "No stock location set" %}</em>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addItem('location', '{% trans "Stock Locations" %}', 'fa-map-marker-alt');
|
addItem('location', '{% trans "Stock Locations" %}', 'fa-map-marker-alt');
|
||||||
|
|
||||||
$("#table-location").inventreeTable({
|
loadStockLocationTable($("#table-location"), {
|
||||||
url: "{% url 'api-location-list' %}",
|
filterKey: 'locationsearch',
|
||||||
queryParams: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
},
|
},
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
field: 'name',
|
|
||||||
title: '{% trans "Name" %}',
|
|
||||||
formatter: function(value, row, index, field) {
|
|
||||||
return renderLink(row.pathstring, '/stock/location/' + row.pk + '/');
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'description',
|
|
||||||
title: '{% trans "Description" %}',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -307,7 +211,7 @@
|
|||||||
|
|
||||||
loadCompanyTable('#table-manufacturer', "{% url 'api-company-list' %}", {
|
loadCompanyTable('#table-manufacturer', "{% url 'api-company-list' %}", {
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
is_manufacturer: "true",
|
is_manufacturer: "true",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -317,7 +221,7 @@
|
|||||||
|
|
||||||
loadCompanyTable('#table-supplier', "{% url 'api-company-list' %}", {
|
loadCompanyTable('#table-supplier', "{% url 'api-company-list' %}", {
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
is_supplier: "true",
|
is_supplier: "true",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -326,7 +230,7 @@
|
|||||||
|
|
||||||
loadPurchaseOrderTable('#table-purchase-order', {
|
loadPurchaseOrderTable('#table-purchase-order', {
|
||||||
params: {
|
params: {
|
||||||
search: '{{ query }}',
|
original_search: '{{ query }}',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -337,7 +241,7 @@
|
|||||||
|
|
||||||
loadCompanyTable('#table-customer', "{% url 'api-company-list' %}", {
|
loadCompanyTable('#table-customer', "{% url 'api-company-list' %}", {
|
||||||
params: {
|
params: {
|
||||||
search: "{{ query }}",
|
original_search: "{{ query }}",
|
||||||
is_customer: "true",
|
is_customer: "true",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -346,7 +250,7 @@
|
|||||||
|
|
||||||
loadSalesOrderTable('#table-sales-orders', {
|
loadSalesOrderTable('#table-sales-orders', {
|
||||||
params: {
|
params: {
|
||||||
search: '{{ query }}',
|
original_search: '{{ query }}',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ function loadCompanyTable(table, url, options={}) {
|
|||||||
field: 'parts_supplied',
|
field: 'parts_supplied',
|
||||||
title: '{% trans "Parts Supplied" %}',
|
title: '{% trans "Parts Supplied" %}',
|
||||||
formatter: function(value, row) {
|
formatter: function(value, row) {
|
||||||
return renderLink(value, `/company/${row.pk}/parts/`);
|
return renderLink(value, `/company/${row.pk}/?display=supplier-parts`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (options.pagetype == 'manufacturers') {
|
} else if (options.pagetype == 'manufacturers') {
|
||||||
@ -370,7 +370,7 @@ function loadCompanyTable(table, url, options={}) {
|
|||||||
field: 'parts_manufactured',
|
field: 'parts_manufactured',
|
||||||
title: '{% trans "Parts Manufactured" %}',
|
title: '{% trans "Parts Manufactured" %}',
|
||||||
formatter: function(value, row) {
|
formatter: function(value, row) {
|
||||||
return renderLink(value, `/company/${row.pk}/parts/`);
|
return renderLink(value, `/company/${row.pk}/?display=manufacturer-parts`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -469,6 +469,7 @@ function loadManufacturerPartTable(table, url, options) {
|
|||||||
method: 'get',
|
method: 'get',
|
||||||
original: params,
|
original: params,
|
||||||
queryParams: filters,
|
queryParams: filters,
|
||||||
|
sidePagination: 'server',
|
||||||
name: 'manufacturerparts',
|
name: 'manufacturerparts',
|
||||||
groupBy: false,
|
groupBy: false,
|
||||||
formatNoMatches: function() {
|
formatNoMatches: function() {
|
||||||
@ -724,6 +725,7 @@ function loadSupplierPartTable(table, url, options) {
|
|||||||
url: url,
|
url: url,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
original: params,
|
original: params,
|
||||||
|
sidePagination: 'server',
|
||||||
queryParams: filters,
|
queryParams: filters,
|
||||||
name: 'supplierparts',
|
name: 'supplierparts',
|
||||||
groupBy: false,
|
groupBy: false,
|
||||||
|
@ -182,6 +182,15 @@ function convertQueryParameters(params, filters) {
|
|||||||
delete params['sortable'];
|
delete params['sortable'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If "original_search" parameter is provided, add it to the "search"
|
||||||
|
if ('original_search' in params) {
|
||||||
|
var search = params['search'] || '';
|
||||||
|
|
||||||
|
params['search'] = search + ' ' + params['original_search'];
|
||||||
|
|
||||||
|
delete params['original_search'];
|
||||||
|
}
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user