mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-02 13:39:19 -06:00
Hide some boxes when the user has no bills.
This commit is contained in:
parent
eb78cf20c2
commit
dbbc85a576
@ -19,6 +19,7 @@ use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
|||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\Tag;
|
use FireflyIII\Models\Tag;
|
||||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||||
|
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
@ -121,7 +122,6 @@ class HomeController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function index(ARI $repository)
|
public function index(ARI $repository)
|
||||||
{
|
{
|
||||||
|
|
||||||
$types = config('firefly.accountTypesByIdentifier.asset');
|
$types = config('firefly.accountTypesByIdentifier.asset');
|
||||||
$count = $repository->count($types);
|
$count = $repository->count($types);
|
||||||
|
|
||||||
@ -142,6 +142,11 @@ class HomeController extends Controller
|
|||||||
$accounts = $repository->getAccountsById($frontPage->data);
|
$accounts = $repository->getAccountsById($frontPage->data);
|
||||||
$showDepositsFrontpage = Preferences::get('showDepositsFrontpage', false)->data;
|
$showDepositsFrontpage = Preferences::get('showDepositsFrontpage', false)->data;
|
||||||
|
|
||||||
|
// zero bills? Hide some elements from view.
|
||||||
|
/** @var BillRepositoryInterface $billRepository */
|
||||||
|
$billRepository = app(BillRepositoryInterface::class);
|
||||||
|
$billCount = $billRepository->getBills()->count();
|
||||||
|
|
||||||
foreach ($accounts as $account) {
|
foreach ($accounts as $account) {
|
||||||
$collector = app(JournalCollectorInterface::class);
|
$collector = app(JournalCollectorInterface::class);
|
||||||
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit(10)->setPage(1);
|
$collector->setAccounts(new Collection([$account]))->setRange($start, $end)->setLimit(10)->setPage(1);
|
||||||
@ -153,7 +158,7 @@ class HomeController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'index', compact('count', 'showTour', 'title', 'subTitle', 'mainTitleIcon', 'transactions', 'showDepositsFrontpage')
|
'index', compact('count', 'showTour', 'title', 'subTitle', 'mainTitleIcon', 'transactions', 'showDepositsFrontpage', 'billCount')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,10 +210,7 @@ class HomeController extends Controller
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private
|
private function startsWithAny(array $array, string $needle): bool
|
||||||
function startsWithAny(
|
|
||||||
array $array, string $needle
|
|
||||||
): bool
|
|
||||||
{
|
{
|
||||||
foreach ($array as $entry) {
|
foreach ($array as $entry) {
|
||||||
if ((substr($needle, 0, strlen($entry)) === $entry)) {
|
if ((substr($needle, 0, strlen($entry)) === $entry)) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* globals $, columnChart,showTour, Tour, google, pieChart, stackedColumnChart */
|
/* globals $, columnChart,showTour, Tour, google, pieChart, stackedColumnChart, billCount */
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
@ -33,7 +33,9 @@ function endTheTour() {
|
|||||||
function drawChart() {
|
function drawChart() {
|
||||||
"use strict";
|
"use strict";
|
||||||
lineChart('chart/account/frontpage', 'accounts-chart');
|
lineChart('chart/account/frontpage', 'accounts-chart');
|
||||||
pieChart('chart/bill/frontpage', 'bills-chart');
|
if (billCount > 0) {
|
||||||
|
pieChart('chart/bill/frontpage', 'bills-chart');
|
||||||
|
}
|
||||||
stackedColumnChart('chart/budget/frontpage', 'budgets-chart');
|
stackedColumnChart('chart/budget/frontpage', 'budgets-chart');
|
||||||
columnChart('chart/category/frontpage', 'categories-chart');
|
columnChart('chart/category/frontpage', 'categories-chart');
|
||||||
columnChart('chart/account/expense', 'expense-accounts-chart');
|
columnChart('chart/account/expense', 'expense-accounts-chart');
|
||||||
|
@ -43,20 +43,21 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-4 col-md-6 col-sm-12">
|
<div class="col-lg-4 col-md-6 col-sm-12">
|
||||||
|
{% if billCount > 0 %}
|
||||||
|
<!-- BILLS -->
|
||||||
|
<div class="box">
|
||||||
|
<div class="box-header with-border">
|
||||||
|
<h3 class="box-title">{{ 'bills'|_ }}</h3>
|
||||||
|
|
||||||
<!-- BILLS -->
|
|
||||||
<div class="box">
|
|
||||||
<div class="box-header with-border">
|
|
||||||
<h3 class="box-title">{{ 'bills'|_ }}</h3>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="box-body">
|
|
||||||
<div style="width:60%;margin:0 auto;">
|
|
||||||
<canvas id="bills-chart" style="width:100%;height:175px;" height="175"></canvas>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="box-body">
|
||||||
|
<div style="width:60%;margin:0 auto;">
|
||||||
|
<canvas id="bills-chart" style="width:100%;height:175px;" height="175"></canvas>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endif %}
|
||||||
|
|
||||||
<!-- TRANSACTIONS -->
|
<!-- TRANSACTIONS -->
|
||||||
{% for data in transactions %}
|
{% for data in transactions %}
|
||||||
@ -129,6 +130,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
showTour = false;
|
showTour = false;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
var billCount = {{ billCount }};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript" src="js/lib/Chart.bundle.min.js"></script>
|
<script type="text/javascript" src="js/lib/Chart.bundle.min.js"></script>
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
|
{# Set box sizes: #}
|
||||||
|
{% if billCount > 0 %}
|
||||||
|
{% set boxClasses = 'col-lg-3 col-md-3 col-sm-6 col-xs-12' %}
|
||||||
|
{% else %}
|
||||||
|
{# Zero bills? Remove the boxes. #}
|
||||||
|
{% set boxClasses = 'col-lg-4 col-md-4 col-sm-6 col-xs-12' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Info boxes -->
|
<!-- Info boxes -->
|
||||||
<div class="row hidden-sm hidden-xs">
|
<div class="row hidden-sm hidden-xs">
|
||||||
<div class="col-md-3 col-sm-6 col-xs-12">
|
<div class="{{ boxClasses }}">
|
||||||
<div class="info-box">
|
<div class="info-box">
|
||||||
<span class="info-box-icon bg-red">
|
<span class="info-box-icon bg-red">
|
||||||
<i class="fa fa-upload fa-fw"></i>
|
<i class="fa fa-upload fa-fw"></i>
|
||||||
@ -10,12 +18,9 @@
|
|||||||
<span class="info-box-text">{{ 'moneyOut'|_ }}</span>
|
<span class="info-box-text">{{ 'moneyOut'|_ }}</span>
|
||||||
<span class="info-box-number" id="box-out"></span>
|
<span class="info-box-number" id="box-out"></span>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box-content -->
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box -->
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /.col -->
|
<div class="{{ boxClasses }}">
|
||||||
<div class="col-md-3 col-sm-6 col-xs-12">
|
|
||||||
<div class="info-box">
|
<div class="info-box">
|
||||||
<span class="info-box-icon bg-green">
|
<span class="info-box-icon bg-green">
|
||||||
<i class="fa fa-download faw-fw"></i>
|
<i class="fa fa-download faw-fw"></i>
|
||||||
@ -25,43 +30,34 @@
|
|||||||
<span class="info-box-text">{{ 'moneyIn'|_ }}</span>
|
<span class="info-box-text">{{ 'moneyIn'|_ }}</span>
|
||||||
<span class="info-box-number" id="box-in"></span>
|
<span class="info-box-number" id="box-in"></span>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box-content -->
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box -->
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /.col -->
|
{% if billCount > 0 %}
|
||||||
|
<div class="clearfix visible-sm-block"></div>
|
||||||
|
|
||||||
<!-- fix for small devices only -->
|
<div class="{{ boxClasses }}">
|
||||||
<div class="clearfix visible-sm-block"></div>
|
<div class="info-box">
|
||||||
|
|
||||||
<div class="col-md-3 col-sm-6 col-xs-12">
|
|
||||||
<div class="info-box">
|
|
||||||
<span class="info-box-icon bg-blue">
|
<span class="info-box-icon bg-blue">
|
||||||
<i class="fa fa-calendar fa-fw"></i>
|
<i class="fa fa-calendar fa-fw"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div class="info-box-content">
|
<div class="info-box-content">
|
||||||
<span class="info-box-text">{{ 'billsToPay'|_ }}</span>
|
<span class="info-box-text">{{ 'billsToPay'|_ }}</span>
|
||||||
<span class="info-box-number" id="box-bills-unpaid"></span>
|
<span class="info-box-number" id="box-bills-unpaid"></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box-content -->
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box -->
|
<div class="{{ boxClasses }}">
|
||||||
</div>
|
<div class="info-box">
|
||||||
<!-- /.col -->
|
|
||||||
<div class="col-md-3 col-sm-6 col-xs-12">
|
|
||||||
<div class="info-box">
|
|
||||||
<span class="info-box-icon bg-aqua">
|
<span class="info-box-icon bg-aqua">
|
||||||
<i class="fa fa-line-chart fa-fw"></i>
|
<i class="fa fa-line-chart fa-fw"></i>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<div class="info-box-content">
|
<div class="info-box-content">
|
||||||
<span class="info-box-text">{{ 'billsPaid'|_ }}</span>
|
<span class="info-box-text">{{ 'billsPaid'|_ }}</span>
|
||||||
<span class="info-box-number" id="box-bills-paid"></span>
|
<span class="info-box-number" id="box-bills-paid"></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box-content -->
|
|
||||||
</div>
|
</div>
|
||||||
<!-- /.info-box -->
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<!-- /.col -->
|
|
||||||
</div><!-- /.row -->
|
|
||||||
|
Loading…
Reference in New Issue
Block a user