diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php index 4d00919c56..4bca8b1585 100644 --- a/app/Http/Controllers/Json/BoxController.php +++ b/app/Http/Controllers/Json/BoxController.php @@ -125,12 +125,13 @@ class BoxController extends Controller $cache->addProperty($end); $cache->addProperty('box-balance'); if ($cache->has()) { - return response()->json($cache->get()); // @codeCoverageIgnore + return response()->json($cache->get()); // @codeCoverageIgnore } // prep some arrays: $incomes = []; $expenses = []; $sums = []; + $currency = app('amount')->getDefaultCurrency(); // collect income of user: /** @var GroupCollectorInterface $collector */ @@ -178,10 +179,11 @@ class BoxController extends Controller } $response = [ - 'incomes' => $incomes, - 'expenses' => $expenses, - 'sums' => $sums, - 'size' => count($sums), + 'incomes' => $incomes, + 'expenses' => $expenses, + 'sums' => $sums, + 'size' => count($sums), + 'preferred' => $currency->id, ]; diff --git a/public/v1/js/ff/index.js b/public/v1/js/ff/index.js index 1a615fc672..939aa0d7b6 100644 --- a/public/v1/js/ff/index.js +++ b/public/v1/js/ff/index.js @@ -113,9 +113,23 @@ function getBalanceBox() { // do not use "sums", only use list. $('#box-balance-progress').remove(); 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 + '' + string + '' + '
'); + } + } + // then list the others (only 1 space) + var count = 0; for (x in data.sums) { - if (count > 1) { + if (count > 2) { return; } current = $('#box-balance-list').html(); @@ -123,9 +137,11 @@ function getBalanceBox() { expense = data.expenses[x]; income = data.incomes[x]; string = income + ' / ' + expense + ': ' + sum; - - $('#box-balance-list').html(current + '' + string + '' + '
'); + if (data.preferred != x) { + $('#box-balance-list').html(current + '' + string + '' + '
'); + } count++; + } }); } \ No newline at end of file diff --git a/resources/views/v1/partials/boxes.twig b/resources/views/v1/partials/boxes.twig index 95fc6ea5d8..6bbe4ecb81 100644 --- a/resources/views/v1/partials/boxes.twig +++ b/resources/views/v1/partials/boxes.twig @@ -1,5 +1,5 @@