Display table of parameters

This commit is contained in:
Oliver 2021-06-21 00:39:18 +10:00
parent a00441a1c0
commit 70b6a3c13f
3 changed files with 96 additions and 3 deletions

View File

@ -7,7 +7,7 @@
{% endblock %}
{% block heading %}
{% trans "Supplier Parts" %}
{% trans "Suppliers" %}
{% endblock %}
{% block details %}
@ -30,6 +30,30 @@
{% endblock %}
{% block post_content_panels %}
<div class='panel panel-default panel-inventree'>
<div class='panel-heading'>
<h4>{% trans "Parameters" %}</h4>
</div>
<div class='panel-content'>
<div id='parameter-toolbar'>
<div class='btn-group'>
<button class='btn btn-success' id='parameter-create'>
<span class='fas fa-plus-circle'></span> {% trans "New Parameter" %}
</button>
<div id='param-dropdown' class='btn-group'>
<!-- TODO -->
</div>
</div>
</div>
<table class='table table-striped table-condensed' id='parameter-table' data-toolbar='#parameter-toolbar'></table>
</div>
</div>
{% 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 %}

View File

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

View File

@ -43,6 +43,9 @@
</div>
{% endblock %}
{% block pre_content_panels %}
{% endblock %}
{% block content_panels %}
<div class='panel panel-default panel-inventree'>
<div class='panel-heading'>
@ -63,6 +66,9 @@
</div>
{% endblock %}
{% block post_content_panels %}
{% endblock %}
{% endblock %}
{% block js_ready %}