diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index 500b4a2bdf..acfb02144d 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -51,7 +51,7 @@ class CategoryList(generics.ListCreateAPIView): filter_backends = [ DjangoFilterBackend, - # filters.SearchFilter, + filters.SearchFilter, filters.OrderingFilter, ] diff --git a/InvenTree/stock/api.py b/InvenTree/stock/api.py index dd899ebe0a..b1c746cdd6 100644 --- a/InvenTree/stock/api.py +++ b/InvenTree/stock/api.py @@ -236,6 +236,11 @@ class StockLocationList(generics.ListCreateAPIView): 'parent', ] + search_fields = [ + 'name', + 'description', + ] + class StockList(generics.ListCreateAPIView): """ API endpoint for list view of Stock objects diff --git a/InvenTree/templates/InvenTree/search.html b/InvenTree/templates/InvenTree/search.html index f8631dfbd4..2f88d3caed 100644 --- a/InvenTree/templates/InvenTree/search.html +++ b/InvenTree/templates/InvenTree/search.html @@ -17,10 +17,14 @@ InvenTree | Search Results


+{% include "InvenTree/search_part_category.html" with collapse_id="categories" %} + {% include "InvenTree/search_parts.html" with collapse_id='parts' %} {% include "InvenTree/search_supplier_parts.html" with collapse_id='supplier_parts' %} +{% include "InvenTree/search_stock_location.html" with collapse_id="locations" %} + {% endblock %} {% block js_load %} @@ -50,10 +54,54 @@ InvenTree | Search Results }); } + onSearchResults("#category-results-table", "#category-results-count"); + + onSearchResults("#location-results-table", "#location-results-count"); + onSearchResults('#part-results-table', '#part-result-count'); onSearchResults('#supplier-part-results-table', '#supplier-part-result-count'); + $("#category-results-table").bootstrapTable({ + url: "{% url 'api-part-category-list' %}", + queryParams: { + search: "{{ query }}", + }, + columns: [ + { + field: 'name', + title: 'Name', + formatter: function(value, row, index, field) { + return renderLink(value, '/part/category/' + row.pk + '/'); + }, + }, + { + field: 'description', + title: 'Description', + }, + ], + }); + + $("#location-results-table").bootstrapTable({ + url: "{% url 'api-location-list' %}", + queryParams: { + search: "{{ query }}", + }, + columns: [ + { + field: 'name', + title: 'Name', + formatter: function(value, row, index, field) { + return renderLink(value, '/stock/location/' + row.pk + '/'); + }, + }, + { + field: 'description', + title: 'Description', + }, + ], + }); + loadPartTable("#part-results-table", "{% url 'api-part-list' %}", { diff --git a/InvenTree/templates/InvenTree/search_part_category.html b/InvenTree/templates/InvenTree/search_part_category.html new file mode 100644 index 0000000000..899aca094c --- /dev/null +++ b/InvenTree/templates/InvenTree/search_part_category.html @@ -0,0 +1,14 @@ +{% extends "collapse.html" %} + +{% block collapse_title %} +

Part Categories

+{% endblock %} + +{% block collapse_heading %} +

{% include "InvenTree/searching.html" %}

+{% endblock %} + +{% block collapse_content %} + +
+{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/search_stock_location.html b/InvenTree/templates/InvenTree/search_stock_location.html new file mode 100644 index 0000000000..923635b13e --- /dev/null +++ b/InvenTree/templates/InvenTree/search_stock_location.html @@ -0,0 +1,14 @@ +{% extends "collapse.html" %} + +{% block collapse_title %} +

Stock Locations

+{% endblock %} + +{% block collapse_heading %} +

{% include "InvenTree/searching.html" %}

+{% endblock %} + +{% block collapse_content %} + +
+{% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/InvenTree/searching.html b/InvenTree/templates/InvenTree/searching.html index 9d111fe257..5821515ad7 100644 --- a/InvenTree/templates/InvenTree/searching.html +++ b/InvenTree/templates/InvenTree/searching.html @@ -1 +1 @@ - Searching... \ No newline at end of file + Searching \ No newline at end of file