mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-19 02:45:58 +00:00
Fix #1860
This commit is contained in:
@@ -125,12 +125,13 @@ class BoxController extends Controller
|
|||||||
$cache->addProperty($end);
|
$cache->addProperty($end);
|
||||||
$cache->addProperty('box-balance');
|
$cache->addProperty('box-balance');
|
||||||
if ($cache->has()) {
|
if ($cache->has()) {
|
||||||
return response()->json($cache->get()); // @codeCoverageIgnore
|
return response()->json($cache->get()); // @codeCoverageIgnore
|
||||||
}
|
}
|
||||||
// prep some arrays:
|
// prep some arrays:
|
||||||
$incomes = [];
|
$incomes = [];
|
||||||
$expenses = [];
|
$expenses = [];
|
||||||
$sums = [];
|
$sums = [];
|
||||||
|
$currency = app('amount')->getDefaultCurrency();
|
||||||
|
|
||||||
// collect income of user:
|
// collect income of user:
|
||||||
/** @var GroupCollectorInterface $collector */
|
/** @var GroupCollectorInterface $collector */
|
||||||
@@ -178,10 +179,11 @@ class BoxController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$response = [
|
$response = [
|
||||||
'incomes' => $incomes,
|
'incomes' => $incomes,
|
||||||
'expenses' => $expenses,
|
'expenses' => $expenses,
|
||||||
'sums' => $sums,
|
'sums' => $sums,
|
||||||
'size' => count($sums),
|
'size' => count($sums),
|
||||||
|
'preferred' => $currency->id,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
22
public/v1/js/ff/index.js
vendored
22
public/v1/js/ff/index.js
vendored
@@ -113,9 +113,23 @@ function getBalanceBox() {
|
|||||||
// do not use "sums", only use list.
|
// do not use "sums", only use list.
|
||||||
$('#box-balance-progress').remove();
|
$('#box-balance-progress').remove();
|
||||||
var expense, string, sum, income, current;
|
var expense, string, sum, income, current;
|
||||||
|
|
||||||
|
// first loop, echo only "preferred".
|
||||||
|
for (x in data.sums) {
|
||||||
|
current = $('#box-balance-list').html();
|
||||||
|
sum = data.sums[x];
|
||||||
|
expense = data.expenses[x];
|
||||||
|
income = data.incomes[x];
|
||||||
|
string = income + ' / ' + expense + ': ' + sum;
|
||||||
|
if (data.preferred == x) {
|
||||||
|
$('#box-balance-list').html(current + '<span title="' + string + '">' + string + '</span>' + '<br>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// then list the others (only 1 space)
|
||||||
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
for (x in data.sums) {
|
for (x in data.sums) {
|
||||||
if (count > 1) {
|
if (count > 2) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
current = $('#box-balance-list').html();
|
current = $('#box-balance-list').html();
|
||||||
@@ -123,9 +137,11 @@ function getBalanceBox() {
|
|||||||
expense = data.expenses[x];
|
expense = data.expenses[x];
|
||||||
income = data.incomes[x];
|
income = data.incomes[x];
|
||||||
string = income + ' / ' + expense + ': ' + sum;
|
string = income + ' / ' + expense + ': ' + sum;
|
||||||
|
if (data.preferred != x) {
|
||||||
$('#box-balance-list').html(current + '<span title="' + string + '">' + string + '</span>' + '<br>');
|
$('#box-balance-list').html(current + '<span title="' + string + '">' + string + '</span>' + '<br>');
|
||||||
|
}
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
<div class="row hidden-xs">
|
<div class="row hidden-xs">
|
||||||
{# box for in and out#}
|
{# box for in and out (balance) #}
|
||||||
<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
|
<div class="col-lg-3 col-md-6 col-sm-6 col-xs-12">
|
||||||
<div class="info-box bg-aqua-gradient" id="box_out_holder">
|
<div class="info-box bg-aqua-gradient" id="box_out_holder">
|
||||||
<span class="info-box-icon"><i class="fa fa-balance-scale"></i></span>
|
<span class="info-box-icon"><i class="fa fa-balance-scale"></i></span>
|
||||||
|
Reference in New Issue
Block a user