2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-15 11:35:41 +00:00

Add results for part categories and stock locations

This commit is contained in:
Oliver Walters
2022-03-29 23:27:44 +11:00
parent a551bf1e81
commit 1f003b3f54
3 changed files with 60 additions and 25 deletions

View File

@ -1044,4 +1044,5 @@ a {
border-top: 1px solid var(--border-color); border-top: 1px solid var(--border-color);
padding: 3px; padding: 3px;
margin-top: 3px; margin-top: 3px;
overflow: hidden;
} }

View File

@ -10,7 +10,9 @@
renderCompany, renderCompany,
renderManufacturerPart, renderManufacturerPart,
renderOwner, renderOwner,
renderPart,
renderPartCategory, renderPartCategory,
renderStockItem,
renderStockLocation, renderStockLocation,
renderSupplierPart, renderSupplierPart,
*/ */

View File

@ -78,32 +78,64 @@ function updateSearch() {
// Show the "searching" text // Show the "searching" text
$('#offcanvas-search').find('#search-pending').show(); $('#offcanvas-search').find('#search-pending').show();
// Search for matching parts if (user_settings.SEARCH_PREVIEW_SHOW_PARTS) {
addSearchQuery( // Search for matching parts
'part', addSearchQuery(
'{% trans "Parts" %}', 'part',
'{% url "api-part-list" %}', '{% trans "Parts" %}',
{}, '{% url "api-part-list" %}',
renderPart, {},
{ renderPart,
url: '/part', {
} url: '/part',
); }
);
}
// Search for matching stock items if (user_settings.SEARCH_PREVIEW_SHOW_CATEGORIES) {
addSearchQuery( // Search for matching part categories
'stock', addSearchQuery(
'{% trans "Stock Items" %}', 'category',
'{% url "api-stock-list" %}', '{% trans "Part Categories" %}',
{ '{% url "api-part-category-list" %}',
part_detail: true, {},
location_detail: true, renderPartCategory,
}, {
renderStockItem, url: '/part/category',
{ },
url: '/stock/item', );
} }
);
if (user_settings.SEARCH_PREVIEW_SHOW_STOCK) {
// Search for matching stock items
addSearchQuery(
'stock',
'{% trans "Stock Items" %}',
'{% url "api-stock-list" %}',
{
part_detail: true,
location_detail: true,
},
renderStockItem,
{
url: '/stock/item',
}
);
}
if (user_settings.SEARCH_PREVIEW_SHOW_LOCATIONS) {
// Search for matching stock locations
addSearchQuery(
'location',
'{% trans "Stock Locations" %}',
'{% url "api-location-list" %}',
{},
renderStockLocation,
{
url: '/stock/location',
}
);
}
// Wait until all the pending queries are completed // Wait until all the pending queries are completed
$.when.apply($, searchQueries).done(function() { $.when.apply($, searchQueries).done(function() {