Fix bar, also multi currency #2977

This commit is contained in:
James Cole
2020-03-21 15:12:23 +01:00
parent 790e29f15e
commit cf4f76f211
5 changed files with 61 additions and 2 deletions

View File

@@ -133,10 +133,34 @@ function updateTotalBudgetedAmount(currencyId) {
// get new amount:
$.get(totalBudgetedUri.replace('REPLACEME',currencyId)).done(function (data) {
// set thing:
$('span.budgeted_amount[data-currency="' + currencyId + '"]')
.html(data.budgeted_formatted)
// fade back:
.fadeTo(300, 1.0);
// set bar:
var pct = parseFloat(data.percentage);
if (pct <= 100) {
console.log('<100 (' + pct + ')');
console.log($('div.budgeted_bar[data-currency="' + currencyId + '"]'));
// red bar to 0
$('div.budgeted_bar[data-currency="' + currencyId + '"] div.progress-bar-danger').width('0%');
// orange to 0:
$('div.budgeted_bar[data-currency="' + currencyId + '"] div.progress-bar-warning').width('0%');
// blue to the rest:
$('div.budgeted_bar[data-currency="' + currencyId + '"] div.progress-bar-info').width(pct + '%');
} else {
var newPct = (100 / pct) * 100;
// red bar to new pct
$('div.budgeted_bar[data-currency="' + currencyId + '"] div.progress-bar-danger').width(newPct + '%');
// orange to the rest:
$('div.budgeted_bar[data-currency="' + currencyId + '"] div.progress-bar-warning').width((100 - newPct) + '%');
// blue to 0:
$('div.budgeted_bar[data-currency="' + currencyId + '"] div.progress-bar-info').width('0%');
}
});
}