From 7e0ef6d43e61dbbddb8beb7050c330c0f6ee80a9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 12 Dec 2016 20:02:33 +0100 Subject: [PATCH] Better view for accounts and I fixed a html error. --- app/Http/Controllers/AccountController.php | 8 +- app/Http/breadcrumbs.php | 30 +++--- resources/lang/en_US/firefly.php | 1 + resources/views/accounts/show-by-date.twig | 110 --------------------- resources/views/accounts/show.twig | 63 ++++++------ resources/views/categories/show.twig | 4 +- resources/views/search/partials/tags.twig | 4 +- 7 files changed, 60 insertions(+), 160 deletions(-) delete mode 100644 resources/views/accounts/show-by-date.twig diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 9fc18dc35d..28c9726917 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -248,7 +248,7 @@ class AccountController extends Controller // generate entries for each period (and cache those) $entries = $this->periodEntries($account); - return view('accounts.show', compact('account', 'what', 'entries', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri')); + return view('accounts.show', compact('account', 'entries', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri')); } /** @@ -274,7 +274,8 @@ class AccountController extends Controller $start = $repository->oldestJournalDate($account); $end = $repository->newestJournalDate($account); - return view('accounts.show-by-date', compact('account', 'journals', 'subTitle', 'start', 'end','chartUri')); + // same call, except "entries". + return view('accounts.show', compact('account', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri')); } /** @@ -300,7 +301,8 @@ class AccountController extends Controller $journals = $collector->getPaginatedJournals(); $journals->setPath('accounts/show/' . $account->id . '/' . $date); - return view('accounts.show-by-date', compact('category', 'date', 'account', 'journals', 'subTitle', 'carbon', 'start', 'end','chartUri')); + // same call, except "entries". + return view('accounts.show', compact('account', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri')); } /** diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php index 8e70cd9dd7..0e960d730d 100644 --- a/app/Http/breadcrumbs.php +++ b/app/Http/breadcrumbs.php @@ -67,30 +67,34 @@ Breadcrumbs::register( Breadcrumbs::register( 'accounts.show', function (BreadCrumbGenerator $breadcrumbs, Account $account) { - $what = config('firefly.shortNamesByFullName.' . $account->accountType->type); + $what = config('firefly.shortNamesByFullName.' . $account->accountType->type); + $breadcrumbs->parent('accounts.index', $what); - $breadcrumbs->push(e($account->name), route('accounts.show', [$account->id])); + $breadcrumbs->push($account->name, route('accounts.show', [$account->id])); } ); Breadcrumbs::register( - 'accounts.show.date', function (BreadCrumbGenerator $breadcrumbs, Account $account, Carbon $date) { + 'accounts.show.date', function (BreadCrumbGenerator $breadcrumbs, Account $account, Carbon $start, Carbon $end) { + + $startString = $start->formatLocalized(strval(trans('config.month_and_day'))); + $endString = $end->formatLocalized(strval(trans('config.month_and_day'))); + $title = sprintf('%s (%s)', $account->name, trans('firefly.from_to', ['start' => $startString, 'end' => $endString])); + $breadcrumbs->parent('accounts.show', $account); - - $range = Preferences::get('viewRange', '1M')->data; - $title = $account->name . ' (' . Navigation::periodShow($date, $range) . ')'; - - $breadcrumbs->push($title, route('accounts.show.date', [$account->id, $date->format('Y-m-d')])); + $breadcrumbs->push($title, route('accounts.show.date', [$account->id, $start->format('Y-m-d')])); } ); Breadcrumbs::register( - 'accounts.show.all', function (BreadCrumbGenerator $breadcrumbs, Account $account) { + 'accounts.show.all', function (BreadCrumbGenerator $breadcrumbs, Account $account, Carbon $start, Carbon $end) { + + $startString = $start->formatLocalized(strval(trans('config.month_and_day'))); + $endString = $end->formatLocalized(strval(trans('config.month_and_day'))); + $title = sprintf('%s (%s)', $account->name, trans('firefly.from_to', ['start' => $startString, 'end' => $endString])); + $breadcrumbs->parent('accounts.show', $account); - - $title = sprintf('%s (%s)', $account->name, strtolower(trans('firefly.everything'))); - - $breadcrumbs->push($title, route('accounts.show.all', [$account->id])); + $breadcrumbs->push($title, route('accounts.show.all', [$account->id, $start->format('Y-m-d')])); } ); diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 1781cfc683..cec77e6586 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -526,6 +526,7 @@ return [ 'select_more_than_one_account' => 'Please select more than one account', 'select_more_than_one_category' => 'Please select more than one category', 'select_more_than_one_budget' => 'Please select more than one budget', + 'from_to' => 'From :start to :end', // categories: 'new_category' => 'New category', diff --git a/resources/views/accounts/show-by-date.twig b/resources/views/accounts/show-by-date.twig deleted file mode 100644 index bc298b3be1..0000000000 --- a/resources/views/accounts/show-by-date.twig +++ /dev/null @@ -1,110 +0,0 @@ -{% extends "./layout/default" %} - -{% block breadcrumbs %} - - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account, carbon) }} -{% endblock %} - -{% block content %} - -
-
-
-
-

{{ 'overview'|_ }} (period)

- - - - -
-
- -
-
-
-
- -
-
-
-
-

{{ 'expenses_by_category'|_ }}

-
-
-
- -
-
-
-
-
-
-
-

{{ 'expenses_by_budget'|_ }}

-
-
-
- -
-
-
-
-
-
-
-

{{ 'income_by_category'|_ }}

-
-
-
- -
-
-
-
-
- -
-
-
-
-

{{ 'transactions'|_ }}

-
-
- {% include 'list.journals-tasker' with {sorting:true} %} -
-
-
-
- - - -{% endblock %} - -{% block scripts %} - - - - - - - - -{% endblock %} diff --git a/resources/views/accounts/show.twig b/resources/views/accounts/show.twig index 6b37740fe5..42068245e4 100644 --- a/resources/views/accounts/show.twig +++ b/resources/views/accounts/show.twig @@ -1,7 +1,7 @@ {% extends "./layout/default" %} {% block breadcrumbs %} - {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account) }} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account, start, end) }} {% endblock %} {% block content %} @@ -9,7 +9,8 @@
-

{{ account.name }}

+

{{ account.name }} + ({{ trans('firefly.from_to', {start: start.formatLocalized(monthAndDayFormat), end: end.formatLocalized(monthAndDayFormat)}) }})

@@ -68,7 +69,7 @@
-
+

{{ 'transactions'|_ }}

@@ -84,35 +85,37 @@
-
- {% for entry in entries %} - {% if entry[2] != 0 or entry[3] != 0 %} -
-
-

{{ entry[1] }} -

+ {% if entries %} +
+ {% for entry in entries %} + {% if entry[2] != 0 or entry[3] != 0 %} +
+ +
+ + {% if entry[2] != 0 %} + + + + + {% endif %} + {% if entry[3] != 0 %} + + + + + {% endif %} +
{{ 'spent'|_ }}{{ entry[2]|formatAmount }}
{{ 'earned'|_ }}{{ entry[3]|formatAmount }}
+
-
- - {% if entry[2] != 0 %} - - - - - {% endif %} - {% if entry[3] != 0 %} - - - - - {% endif %} -
{{ 'spent'|_ }}{{ entry[2]|formatAmount }}
{{ 'earned'|_ }}{{ entry[3]|formatAmount }}
-
-
- {% endif %} + {% endif %} - {% endfor %} -
+ {% endfor %} +
+ {% endif %}
diff --git a/resources/views/categories/show.twig b/resources/views/categories/show.twig index 9ff1006823..92e130e683 100644 --- a/resources/views/categories/show.twig +++ b/resources/views/categories/show.twig @@ -9,7 +9,7 @@
-

{{ 'overview'|_ }} (month)

+

{{ 'overview'|_ }} ({{ 'month'|_ }})

@@ -19,7 +19,7 @@
-

{{ 'overview'|_ }} (all)

+

{{ 'overview'|_ }} ({{ 'all'|_ }})

diff --git a/resources/views/search/partials/tags.twig b/resources/views/search/partials/tags.twig index 919fa19daf..fd4342c67b 100644 --- a/resources/views/search/partials/tags.twig +++ b/resources/views/search/partials/tags.twig @@ -16,8 +16,8 @@
- {{ tag.tag }}< - /td> + {{ tag.tag }} + {{ ('tag'~tag.tagMode)|_ }} {% endfor %}