diff --git a/InvenTree/part/templates/part/category.html b/InvenTree/part/templates/part/category.html index 1c7980ba9b..1f5ee7c48b 100644 --- a/InvenTree/part/templates/part/category.html +++ b/InvenTree/part/templates/part/category.html @@ -115,8 +115,11 @@ + +{% block part_list %}
+{% endblock part_list %} {% endblock %} {% block js_load %} @@ -242,4 +245,16 @@ }, ); + loadParametricPartTable( + "#parametric-part-table", + "{% url 'api-part-list' %}", + { + params: { + {% if category %}category: {{ category.id }}, + {% else %}category: "null", + {% endif %} + }, + }, + ); + {% endblock %} \ No newline at end of file diff --git a/InvenTree/part/templates/part/category_parametric.html b/InvenTree/part/templates/part/category_parametric.html new file mode 100644 index 0000000000..7139a539b0 --- /dev/null +++ b/InvenTree/part/templates/part/category_parametric.html @@ -0,0 +1,12 @@ +{% extends "part/category.html" %} +{% load static %} +{% load i18n %} + +{% block part_list %} + +{% include 'part/category_tabs.html' with tab='parametric-table' %} + + +
+ +{% endblock %} diff --git a/InvenTree/part/templates/part/category_partlist.html b/InvenTree/part/templates/part/category_partlist.html new file mode 100644 index 0000000000..bf4aef52a8 --- /dev/null +++ b/InvenTree/part/templates/part/category_partlist.html @@ -0,0 +1,12 @@ +{% extends "part/category.html" %} +{% load static %} +{% load i18n %} + +{% block part_list %} + +{% include 'part/category_tabs.html' with tab='part-list' %} + + +
+ +{% endblock %} diff --git a/InvenTree/part/templates/part/category_tabs.html b/InvenTree/part/templates/part/category_tabs.html new file mode 100644 index 0000000000..b5d8d3c214 --- /dev/null +++ b/InvenTree/part/templates/part/category_tabs.html @@ -0,0 +1,11 @@ +{% load i18n %} +{% load inventree_extras %} + + diff --git a/InvenTree/part/urls.py b/InvenTree/part/urls.py index e61947e243..88d15c1b5b 100644 --- a/InvenTree/part/urls.py +++ b/InvenTree/part/urls.py @@ -77,7 +77,8 @@ part_category_urls = [ url(r'^edit/?', views.CategoryEdit.as_view(), name='category-edit'), url(r'^delete/?', views.CategoryDelete.as_view(), name='category-delete'), - url('^.*$', views.CategoryDetail.as_view(), name='category-detail'), + url(r'^parametric/?', views.CategoryDetail.as_view(template_name='part/category_parametric.html'), name='category-parametric'), + url(r'^.*$', views.CategoryDetail.as_view(template_name='part/category_partlist.html'), name='category-detail'), ] part_bom_urls = [ diff --git a/InvenTree/part/views.py b/InvenTree/part/views.py index ccf607afc0..3c94afc5a5 100644 --- a/InvenTree/part/views.py +++ b/InvenTree/part/views.py @@ -1875,7 +1875,18 @@ class CategoryDetail(DetailView): model = PartCategory context_object_name = 'category' queryset = PartCategory.objects.all().prefetch_related('children') - template_name = 'part/category.html' + template_name = 'part/category_partlist.html' + + def get_context_data(self, **kwargs): + + context = super(CategoryDetail, self).get_context_data(**kwargs).copy() + + try: + context['part_count'] = kwargs['object'].partcount() + except KeyError: + context['part_count'] = 0 + + return context class CategoryEdit(AjaxUpdateView): diff --git a/InvenTree/templates/js/part.html b/InvenTree/templates/js/part.html index 5576d91367..0b32ef61b9 100644 --- a/InvenTree/templates/js/part.html +++ b/InvenTree/templates/js/part.html @@ -163,6 +163,51 @@ function loadSimplePartTable(table, url, options={}) { } +function loadParametricPartTable(table, url, options={}) { + /* Load parametric part data into specified table. + * + * Args: + * - table: HTML reference to the table + * - url: Base URL for API query + */ + + // Ensure category detail is included + options.params['category_detail'] = true; + + var params = options.params || {}; + console.log(params) + + var filters = {}; + for (var key in params) { + filters[key] = params[key]; + } + console.log(filters) + + var columns = [ + { + field: 'pk', + title: 'ID', + visible: true, + switchable: true, + searchable: false, + } + ]; + + $(table).inventreeTable({ + url: url, + sortName: 'pk', + method: 'get', + queryParams: filters, + groupBy: false, + name: options.name || 'part', + original: params, + formatNoMatches: function() { return "{% trans "No parts found" %}"; }, + columns: columns, + showColumns: true, + }); +} + + function loadPartTable(table, url, options={}) { /* Load part listing data into specified table. *