Add search results for part-category and stock-location

This commit is contained in:
Oliver Walters 2019-06-02 19:15:05 +10:00
parent 3427f81a34
commit fd2e2a71f9
6 changed files with 83 additions and 2 deletions

View File

@ -51,7 +51,7 @@ class CategoryList(generics.ListCreateAPIView):
filter_backends = [
DjangoFilterBackend,
# filters.SearchFilter,
filters.SearchFilter,
filters.OrderingFilter,
]

View File

@ -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

View File

@ -17,10 +17,14 @@ InvenTree | Search Results
<br><br>
<hr>
{% 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' %}",
{

View File

@ -0,0 +1,14 @@
{% extends "collapse.html" %}
{% block collapse_title %}
<h4>Part Categories</h4>
{% endblock %}
{% block collapse_heading %}
<h4><span id='category-results-count'>{% include "InvenTree/searching.html" %}</span></h4>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' data-toolbar="#button-toolbar" id='category-results-table'>
</table>
{% endblock %}

View File

@ -0,0 +1,14 @@
{% extends "collapse.html" %}
{% block collapse_title %}
<h4>Stock Locations</h4>
{% endblock %}
{% block collapse_heading %}
<h4><span id='location-results-count'>{% include "InvenTree/searching.html" %}</span></h4>
{% endblock %}
{% block collapse_content %}
<table class='table table-striped table-condensed' data-toolbar="#button-toolbar" id='location-results-table'>
</table>
{% endblock %}

View File

@ -1 +1 @@
<span class='glyphicon glyphicon-refresh glyphicon-refresh-animate'></span> Searching...
<span class='glyphicon glyphicon-refresh glyphicon-refresh-animate'></span> Searching