mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Improvements to progress bar function
This commit is contained in:
parent
8ae16a125e
commit
96277edcf1
@ -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';
|
||||
|
@ -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',
|
||||
]
|
||||
|
||||
|
||||
|
@ -75,6 +75,7 @@ class BuildItemSerializer(InvenTreeModelSerializer):
|
||||
fields = [
|
||||
'pk',
|
||||
'build',
|
||||
'install_into',
|
||||
'part',
|
||||
'part_name',
|
||||
'part_image',
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user