mirror of
https://github.com/inventree/InvenTree.git
synced 2025-06-21 06:16:29 +00:00
[UI] Search Improvements (#9137)
* Harden playwright tests * Refactor search drawer - Allow result groups to collapse * Add tooltip * Fix menu position * Navigate through to complete list of results * Refactor table headers * Add index pages for SupplierPart and ManufacturerPart models * backend: allow split search by company type * Fix panel naming bug * Fix model URLs * Split company results by company type - Allows better routing to results list * Remove debug msg * Fix 'button within button' issue * Additional playwright tests
This commit is contained in:
src
backend
InvenTree
InvenTree
frontend
src
components
pages
tables
tests
@ -522,6 +522,9 @@ class APISearchView(GenericAPIView):
|
||||
return {
|
||||
'build': build.api.BuildList,
|
||||
'company': company.api.CompanyList,
|
||||
'supplier': company.api.CompanyList,
|
||||
'manufacturer': company.api.CompanyList,
|
||||
'customer': company.api.CompanyList,
|
||||
'manufacturerpart': company.api.ManufacturerPartList,
|
||||
'supplierpart': company.api.SupplierPartList,
|
||||
'part': part.api.PartList,
|
||||
@ -534,6 +537,14 @@ class APISearchView(GenericAPIView):
|
||||
'stocklocation': stock.api.StockLocationList,
|
||||
}
|
||||
|
||||
def get_result_filters(self):
|
||||
"""Provide extra filtering options for particular search groups."""
|
||||
return {
|
||||
'supplier': {'is_supplier': True},
|
||||
'manufacturer': {'is_manufacturer': True},
|
||||
'customer': {'is_customer': True},
|
||||
}
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""Perform search query against available models."""
|
||||
data = request.data
|
||||
@ -552,6 +563,8 @@ class APISearchView(GenericAPIView):
|
||||
if 'search' not in data:
|
||||
raise ValidationError({'search': 'Search term must be provided'})
|
||||
|
||||
search_filters = self.get_result_filters()
|
||||
|
||||
for key, cls in self.get_result_types().items():
|
||||
# Only return results which are specifically requested
|
||||
if key in data:
|
||||
@ -560,6 +573,11 @@ class APISearchView(GenericAPIView):
|
||||
for k, v in pass_through_params.items():
|
||||
params[k] = request.data.get(k, v)
|
||||
|
||||
# Add in any extra filters for this particular search type
|
||||
if key in search_filters:
|
||||
for k, v in search_filters[key].items():
|
||||
params[k] = v
|
||||
|
||||
# Enforce json encoding
|
||||
params['format'] = 'json'
|
||||
|
||||
|
Reference in New Issue
Block a user