mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Load testresult table for stock item
- Uses the API / bootstrap table - Is pretty! - Provides link to the attachment (if one exists)
This commit is contained in:
parent
3b53437f46
commit
e23a9c1269
@ -10,11 +10,30 @@
|
|||||||
<hr>
|
<hr>
|
||||||
<h4>{% trans "Test Results" %}</h4>
|
<h4>{% trans "Test Results" %}</h4>
|
||||||
|
|
||||||
<table class='table table-striped table-condensed' id='test-result-table'></table>
|
<div id='button-toolbar'>
|
||||||
|
<div class='button-toolbar container-fluid' style="float: right;">
|
||||||
|
<!-- TODO - Add a button here to manually upload a new test result -->
|
||||||
|
<div class='filter-list' id='filter-list-stocktests'>
|
||||||
|
<!-- Empty div -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='test-result-table'></table>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js_ready %}
|
{% block js_ready %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
|
loadStockTestResultsTable(
|
||||||
|
$("#test-result-table"), {
|
||||||
|
params: {
|
||||||
|
stock_item: {{ item.id }},
|
||||||
|
user_detail: true,
|
||||||
|
attachment_detail: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -18,6 +18,110 @@ function removeStockRow(e) {
|
|||||||
$('#' + row).remove();
|
$('#' + row).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function passFailBadge(result) {
|
||||||
|
|
||||||
|
if (result) {
|
||||||
|
return `<span class='label label-green'>{% trans "PASS" %}</span>`;
|
||||||
|
} else {
|
||||||
|
return `<span class='label label-red'>{% trans "FAIL" %}</span>`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadStockTestResultsTable(table, options) {
|
||||||
|
/*
|
||||||
|
* Load StockItemTestResult table
|
||||||
|
*/
|
||||||
|
|
||||||
|
var params = options.params || {};
|
||||||
|
|
||||||
|
// HTML element to setup the filtering
|
||||||
|
var filterListElement = options.filterList || '#filter-list-stocktests';
|
||||||
|
|
||||||
|
var filters = {};
|
||||||
|
|
||||||
|
filters = loadTableFilters("stocktests");
|
||||||
|
|
||||||
|
var original = {};
|
||||||
|
|
||||||
|
for (var key in params) {
|
||||||
|
original[key] = params[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
setupFilterList("stocktests", table, filterListElement);
|
||||||
|
|
||||||
|
// Override the default values, or add new ones
|
||||||
|
for (var key in params) {
|
||||||
|
filters[key] = params[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
table.inventreeTable({
|
||||||
|
method: 'get',
|
||||||
|
formatNoMatches: function() {
|
||||||
|
return '{% trans "No test results matching query" %}';
|
||||||
|
},
|
||||||
|
url: "{% url 'api-stock-test-result-list' %}",
|
||||||
|
queryParams: filters,
|
||||||
|
original: original,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
field: 'pk',
|
||||||
|
title: 'ID',
|
||||||
|
visible: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'test',
|
||||||
|
title: '{% trans "Test" %}',
|
||||||
|
sortable: true,
|
||||||
|
formatter: function(value, row) {
|
||||||
|
var html = value;
|
||||||
|
|
||||||
|
if (row.attachment_detail) {
|
||||||
|
html += `<a href='${row.attachment_detail.attachment}'><span class='fas fa-file-alt label-right'></span></a>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'result',
|
||||||
|
title: "{% trans "Result" %}",
|
||||||
|
sortable: true,
|
||||||
|
formatter: function(value) {
|
||||||
|
return passFailBadge(value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'value',
|
||||||
|
title: "{% trans "Value" %}",
|
||||||
|
sortable: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'notes',
|
||||||
|
title: '{% trans "Notes" %}',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'date',
|
||||||
|
title: '{% trans "Uploaded" %}',
|
||||||
|
sortable: true,
|
||||||
|
formatter: function(value, row) {
|
||||||
|
var html = value;
|
||||||
|
|
||||||
|
if (row.user_detail) {
|
||||||
|
html += `<span class='badge'>${row.user_detail.username}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'buttons',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function loadStockTable(table, options) {
|
function loadStockTable(table, options) {
|
||||||
/* Load data into a stock table with adjustable options.
|
/* Load data into a stock table with adjustable options.
|
||||||
* Fetches data (via AJAX) and loads into a bootstrap table.
|
* Fetches data (via AJAX) and loads into a bootstrap table.
|
||||||
|
@ -37,6 +37,16 @@ function getAvailableTableFilters(tableKey) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filters for the 'stock test' table
|
||||||
|
if (tableKey == 'stocktests') {
|
||||||
|
return {
|
||||||
|
result: {
|
||||||
|
type: 'bool',
|
||||||
|
title: "{% trans 'Test result' %}",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Filters for the "Build" table
|
// Filters for the "Build" table
|
||||||
if (tableKey == 'build') {
|
if (tableKey == 'build') {
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user