2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-08-14 15:41:10 +00:00

More fixes

- Add a set of template tags for rendering status codes
- Improve build API filtering
- Remove some outdated files
- Fix unit testing
This commit is contained in:
Oliver Walters
2020-04-12 00:10:33 +10:00
parent 59778130cd
commit 7503596ea4
17 changed files with 94 additions and 116 deletions

View File

@@ -1,5 +1,6 @@
{% extends "part/part_base.html" %}
{% block details %}
{% load status_codes %}
{% include "part/tabs.html" with tab="allocation" %}
@@ -17,7 +18,7 @@
<td><a href="{% url 'build-detail' allocation.build.id %}">{{ allocation.build.title }}</a></td>
<td>{{ allocation.build.quantity }} &times <a href="{% url 'part-detail' allocation.build.part.id %}">{{ allocation.build.part.full_name }}</a></td>
<td>{{ allocation.quantity }}</td>
<td>{% include "build_status.html" with build=allocation.build %}</td>
<td>{% build_status allocation.build.status %}</td>
</tr>
{% endfor %}
</table>

View File

@@ -7,9 +7,14 @@
<h3>Part Builds</h3>
<div id='button-toolbar'>
{% if part.active %}
<button class="btn btn-success" id='start-build'>Start New Build</button>
{% endif %}
<div class='button-toolbar container-flui' style='float: right';>
{% if part.active %}
<button class="btn btn-success" id='start-build'>Start New Build</button>
{% endif %}
<div class='filter-list' id='filter-list-build'>
<!-- Empty div for filters -->
</div>
</div>
</div>
<table class='table table-striped table-condensed' data-toolbar='#button-toolbar' id='build-table'>
@@ -31,64 +36,12 @@
});
});
$("#build-table").inventreeTable({
queryParams: function(p) {
return {
part: {{ part.id }},
}
},
columns: [
{
field: 'pk',
title: 'ID',
visible: false,
},
{
field: 'title',
title: 'Title',
formatter: function(value, row, index, field) {
return renderLink(value, row.url);
}
},
{
field: 'quantity',
title: 'Quantity',
},
{
field: 'status',
title: 'Status',
formatter: function(value, row, index, field) {
var color = '';
switch (value) {
case 10: // Pending
color = 'label-info';
break;
case 20: // Allocated
color = 'label-primary';
break;
case 30: // Cancelled
color = 'label-danger';
break;
case 40: // Complete
color = 'label-success';
break;
default:
break;
}
var html = "<span class='label " + color + " label-large'>" + row.status_text + "</span>";
return html;
}
},
{
field: 'completion_date',
title: 'Completed'
}
],
url: "{% url 'api-build-list' %}",
loadBuildTable($("#build-table"), {
url: "{% url 'api-build-list' %}",
params: {
part_detail: "true",
part: {{ part.id }},
}
});
{% endblock %}

View File

@@ -1,10 +0,0 @@
{% for build in builds %}
<tr>
<td><a href="{% url 'build-detail' build.id %}">{{ build.title }}</a></td>
<td>{{ build.quantity }}</td>
<td>
{% include "build_status.html" with build=build %}
</td>
<td>{% if build.completion_date %}{{ build.completion_date }}{% endif %}</td>
</tr>
{% endfor %}