Improvements to progress bar function

This commit is contained in:
Oliver Walters 2020-10-21 00:49:17 +11:00
parent 8ae16a125e
commit 96277edcf1
4 changed files with 37 additions and 10 deletions

View File

@ -94,7 +94,7 @@ function makeIconButton(icon, cls, pk, title) {
return html;
}
function makeProgressBar(value, maximum, opts) {
function makeProgressBar(value, maximum, opts={}) {
/*
* Render a progessbar!
*
@ -120,20 +120,35 @@ function makeProgressBar(value, maximum, opts) {
var extraclass = '';
if (maximum) {
// TODO - Special color?
}
else if (value > maximum) {
if (value > maximum) {
extraclass='progress-bar-over';
} else if (value < maximum) {
extraclass = 'progress-bar-under';
}
var text = value;
var style = options.style || '';
if (maximum) {
text += ' / ';
text += maximum;
var text = '';
if (style == 'percent') {
// Display e.g. "50%"
text = `${percent}%`;
} else if (style == 'max') {
// Display just the maximum value
text = `${maximum}`;
} else if (style == 'value') {
// Display just the current value
text = `${value}`;
} else if (style == 'blank') {
// No display!
text = '';
} else {
/* Default style
* Display e.g. "5 / 10"
*/
text = `${value} / ${maximum}`;
}
var id = options.id || 'progress-bar';

View File

@ -119,6 +119,7 @@ class BuildItemList(generics.ListCreateAPIView):
return query
def filter_queryset(self, queryset):
queryset = super().filter_queryset(queryset)
# Does the user wish to filter by part?
@ -135,7 +136,8 @@ class BuildItemList(generics.ListCreateAPIView):
filter_fields = [
'build',
'stock_item'
'stock_item',
'install_into',
]

View File

@ -75,6 +75,7 @@ class BuildItemSerializer(InvenTreeModelSerializer):
fields = [
'pk',
'build',
'install_into',
'part',
'part_name',
'part_image',

View File

@ -102,6 +102,15 @@ function loadBuildTable(table, options) {
field: 'quantity',
title: '{% trans "Quantity" %}',
sortable: true,
formatter: function(value, row, index, field) {
return makeProgressBar(
row.completed,
row.quantity,
{
style: 'max',
}
);
}
},
{
field: 'status',