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;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeProgressBar(value, maximum, opts) {
|
function makeProgressBar(value, maximum, opts={}) {
|
||||||
/*
|
/*
|
||||||
* Render a progessbar!
|
* Render a progessbar!
|
||||||
*
|
*
|
||||||
@ -120,20 +120,35 @@ function makeProgressBar(value, maximum, opts) {
|
|||||||
|
|
||||||
var extraclass = '';
|
var extraclass = '';
|
||||||
|
|
||||||
if (maximum) {
|
if (value > maximum) {
|
||||||
// TODO - Special color?
|
|
||||||
}
|
|
||||||
else if (value > maximum) {
|
|
||||||
extraclass='progress-bar-over';
|
extraclass='progress-bar-over';
|
||||||
} else if (value < maximum) {
|
} else if (value < maximum) {
|
||||||
extraclass = 'progress-bar-under';
|
extraclass = 'progress-bar-under';
|
||||||
}
|
}
|
||||||
|
|
||||||
var text = value;
|
var style = options.style || '';
|
||||||
|
|
||||||
if (maximum) {
|
var text = '';
|
||||||
text += ' / ';
|
|
||||||
text += maximum;
|
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';
|
var id = options.id || 'progress-bar';
|
||||||
|
@ -119,6 +119,7 @@ class BuildItemList(generics.ListCreateAPIView):
|
|||||||
return query
|
return query
|
||||||
|
|
||||||
def filter_queryset(self, queryset):
|
def filter_queryset(self, queryset):
|
||||||
|
|
||||||
queryset = super().filter_queryset(queryset)
|
queryset = super().filter_queryset(queryset)
|
||||||
|
|
||||||
# Does the user wish to filter by part?
|
# Does the user wish to filter by part?
|
||||||
@ -135,7 +136,8 @@ class BuildItemList(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
filter_fields = [
|
filter_fields = [
|
||||||
'build',
|
'build',
|
||||||
'stock_item'
|
'stock_item',
|
||||||
|
'install_into',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -75,6 +75,7 @@ class BuildItemSerializer(InvenTreeModelSerializer):
|
|||||||
fields = [
|
fields = [
|
||||||
'pk',
|
'pk',
|
||||||
'build',
|
'build',
|
||||||
|
'install_into',
|
||||||
'part',
|
'part',
|
||||||
'part_name',
|
'part_name',
|
||||||
'part_image',
|
'part_image',
|
||||||
|
@ -102,6 +102,15 @@ function loadBuildTable(table, options) {
|
|||||||
field: 'quantity',
|
field: 'quantity',
|
||||||
title: '{% trans "Quantity" %}',
|
title: '{% trans "Quantity" %}',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
|
formatter: function(value, row, index, field) {
|
||||||
|
return makeProgressBar(
|
||||||
|
row.completed,
|
||||||
|
row.quantity,
|
||||||
|
{
|
||||||
|
style: 'max',
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'status',
|
field: 'status',
|
||||||
|
Loading…
Reference in New Issue
Block a user