From 70b6a3c13f5a092ca7c28daf6872bf922af960d7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 21 Jun 2021 00:39:18 +1000 Subject: [PATCH] Display table of parameters --- .../company/manufacturer_part_suppliers.html | 36 +++++++++++- InvenTree/templates/js/company.js | 57 ++++++++++++++++++- InvenTree/templates/two_column.html | 6 ++ 3 files changed, 96 insertions(+), 3 deletions(-) diff --git a/InvenTree/company/templates/company/manufacturer_part_suppliers.html b/InvenTree/company/templates/company/manufacturer_part_suppliers.html index 647bf4750d..7a3f56a152 100644 --- a/InvenTree/company/templates/company/manufacturer_part_suppliers.html +++ b/InvenTree/company/templates/company/manufacturer_part_suppliers.html @@ -7,7 +7,7 @@ {% endblock %} {% block heading %} -{% trans "Supplier Parts" %} +{% trans "Suppliers" %} {% endblock %} {% block details %} @@ -30,6 +30,30 @@ {% endblock %} +{% block post_content_panels %} + +
+
+

{% trans "Parameters" %}

+
+
+
+
+ +
+ +
+
+
+ +
+
+
+ +{% endblock %} + {% block js_ready %} {{ block.super }} @@ -84,6 +108,16 @@ loadSupplierPartTable( } ); +loadManufacturerPartParameterTable( + "#parameter-table", + "{% url 'api-manufacturer-part-parameter-list' %}", + { + params: { + manufacturer_part: {{ part.id }}, + } + } +); + linkButtonsToSelection($("#supplier-table"), ['#supplier-part-options']) {% endblock %} \ No newline at end of file diff --git a/InvenTree/templates/js/company.js b/InvenTree/templates/js/company.js index c64a2fa062..f0b0b4bd37 100644 --- a/InvenTree/templates/js/company.js +++ b/InvenTree/templates/js/company.js @@ -126,7 +126,7 @@ function loadManufacturerPartTable(table, url, options) { queryParams: filters, name: 'manufacturerparts', groupBy: false, - formatNoMatches: function() { return "{% trans "No manufacturer parts found" %}"; }, + formatNoMatches: function() { return '{% trans "No manufacturer parts found" %}'; }, columns: [ { checkbox: true, @@ -199,6 +199,59 @@ function loadManufacturerPartTable(table, url, options) { } +function loadManufacturerPartParameterTable(table, url, options) { + /* + * Load table of ManufacturerPartParameter objects + */ + + var params = options.params || {}; + + // Load filters + var filters = loadTableFilters("manufacturer-part-parameters"); + + // Overwrite explicit parameters + for (var key in params) { + filters[key] = params[key]; + } + + // setupFilterList("manufacturer-part-parameters", $(table)); + + $(table).inventreeTable({ + url: url, + method: 'get', + original: params, + queryParams: filters, + name: 'manufacturerpartparameters', + groupBy: false, + formatNoMatches: function() { return '{% trans "No parameters found" %}'; }, + columns: [ + { + checkbox: true, + switchable: false, + }, + { + field: 'name', + title: '{% trans "Name" %}', + switchable: false, + sortable: true, + }, + { + field: 'value', + title: '{% trans "Value" %}', + switchable: false, + sortable: true, + }, + { + field: 'units', + title: '{% trans "Units" %}', + switchable: true, + sortable: true, + } + ], + }); +} + + function loadSupplierPartTable(table, url, options) { /* * Load supplier part table @@ -224,7 +277,7 @@ function loadSupplierPartTable(table, url, options) { queryParams: filters, name: 'supplierparts', groupBy: false, - formatNoMatches: function() { return "{% trans "No supplier parts found" %}"; }, + formatNoMatches: function() { return '{% trans "No supplier parts found" %}'; }, columns: [ { checkbox: true, diff --git a/InvenTree/templates/two_column.html b/InvenTree/templates/two_column.html index 1eb1b5388e..c942bef1fa 100644 --- a/InvenTree/templates/two_column.html +++ b/InvenTree/templates/two_column.html @@ -43,6 +43,9 @@ {% endblock %} +{% block pre_content_panels %} +{% endblock %} + {% block content_panels %}
@@ -63,6 +66,9 @@
{% endblock %} +{% block post_content_panels %} +{% endblock %} + {% endblock %} {% block js_ready %}