Consistency for #595

This commit is contained in:
James Cole
2017-03-10 16:08:58 +01:00
parent ef0057d88d
commit ebc712f6b5
7 changed files with 100 additions and 78 deletions

View File

@@ -25,6 +25,7 @@ use FireflyIII\Models\Transaction;
use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Account\AccountTaskerInterface; use FireflyIII\Repositories\Account\AccountTaskerInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface; use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@@ -229,16 +230,18 @@ class AccountController extends Controller
/** /**
* @param Request $request * @param Request $request
* @param Account $account * @param JournalRepositoryInterface $repository
* @param string $moment * @param Account $account
* @param string $moment
*
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
*/ */
public function show(Request $request, Account $account, string $moment = '') public function show(Request $request, JournalRepositoryInterface $repository, Account $account, string $moment = '')
{ {
if ($account->accountType->type === AccountType::INITIAL_BALANCE) { if ($account->accountType->type === AccountType::INITIAL_BALANCE) {
return $this->redirectToOriginalAccount($account); return $this->redirectToOriginalAccount($account);
} }
$subTitle = $account->name;
$range = Preferences::get('viewRange', '1M')->data; $range = Preferences::get('viewRange', '1M')->data;
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type); $subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page')); $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
@@ -250,29 +253,34 @@ class AccountController extends Controller
// prep for "all" view. // prep for "all" view.
if ($moment === 'all') { if ($moment === 'all') {
$subTitle = $account->name . ' (' . strtolower(strval(trans('firefly.everything'))) . ')'; $subTitle = trans('firefly.all_journals_for_account', ['name' => $account->name]);
$chartUri = route('chart.account.all', [$account->id]); $chartUri = route('chart.account.all', [$account->id]);
$first = $repository->first();
$start = $first->date ?? new Carbon;
$end = new Carbon;
} }
// prep for "specific date" view. // prep for "specific date" view.
if (strlen($moment) > 0 && $moment !== 'all') { if (strlen($moment) > 0 && $moment !== 'all') {
$start = new Carbon($moment); $start = new Carbon($moment);
$end = Navigation::endOfPeriod($start, $range); $end = Navigation::endOfPeriod($start, $range);
$subTitle = $account->name . ' (' . strval( $subTitle = trans(
trans( 'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
'firefly.from_to_breadcrumb', 'end' => $end->formatLocalized($this->monthAndDayFormat)]
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)] );
)
) . ')';
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d')]); $chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d')]);
$periods = $this->periodEntries($account); $periods = $this->periodEntries($account);
} }
// prep for current period // prep for current period
if (strlen($moment) === 0) { if (strlen($moment) === 0) {
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range)); $start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range)); $end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
$periods = $this->periodEntries($account); $subTitle = trans(
'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
'end' => $end->formatLocalized($this->monthAndDayFormat)]
);
$periods = $this->periodEntries($account);
} }
$accountType = $account->accountType->type; $accountType = $account->accountType->type;
@@ -299,8 +307,16 @@ class AccountController extends Controller
} }
} }
// fix title:
if ((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) {
$subTitle = trans(
'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
'end' => $end->formatLocalized($this->monthAndDayFormat)]
);
}
return view('accounts.show', compact('account', 'accountType', 'periods', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri'));
return view('accounts.show', compact('account','moment', 'accountType', 'periods', 'subTitleIcon', 'journals', 'subTitle', 'start', 'end', 'chartUri'));
} }
/** /**

View File

@@ -215,10 +215,7 @@ class BudgetController extends Controller
if (strlen($moment) > 0 && $moment !== 'all') { if (strlen($moment) > 0 && $moment !== 'all') {
$start = new Carbon($moment); $start = new Carbon($moment);
$end = Navigation::endOfPeriod($start, $range); $end = Navigation::endOfPeriod($start, $range);
$subTitle = trans( $subTitle = trans('firefly.without_budget_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]);
'firefly.without_budget_between',
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
);
$periods = $this->noBudgetPeriodEntries(); $periods = $this->noBudgetPeriodEntries();
} }
@@ -257,7 +254,12 @@ class BudgetController extends Controller
} }
} }
return view('budgets.no-budget', compact('journals', 'subTitle', 'periods', 'start', 'end')); // fix title:
if ((strlen($moment) > 0 && $moment !== 'all') || strlen($moment) === 0) {
$subTitle = trans('firefly.without_budget_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]);
}
return view('budgets.no-budget', compact('journals', 'subTitle', 'moment', 'periods', 'start', 'end'));
} }
/** /**

View File

@@ -67,32 +67,25 @@ Breadcrumbs::register(
); );
Breadcrumbs::register( Breadcrumbs::register(
'accounts.show', function (BreadCrumbGenerator $breadcrumbs, Account $account) { 'accounts.show', function (BreadCrumbGenerator $breadcrumbs, Account $account, string $moment, Carbon $start, Carbon $end) {
$what = config('firefly.shortNamesByFullName.' . $account->accountType->type); $what = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$breadcrumbs->parent('accounts.index', $what); $breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push($account->name, route('accounts.show', [$account->id])); $breadcrumbs->push($account->name, route('accounts.show', [$account->id]));
}
);
Breadcrumbs::register( // push when is all:
'accounts.show.date', function (BreadCrumbGenerator $breadcrumbs, Account $account, Carbon $start = null, Carbon $end = null) { if ($moment === 'all') {
$breadcrumbs->push(trans('firefly.all_journals_for_account', ['name' => $account->name]), route('accounts.show', [$account->id]));
$title = '';
$route = '';
if (!is_null($start) && !is_null($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_breadcrumb', ['start' => $startString, 'end' => $endString]));
$route = route('accounts.show.date', [$account->id, $start->format('Y-m-d')]);
} }
if (is_null($start) && is_null($end)) { // when is specific period:
$title = $title = $account->name . ' (' . strtolower(strval(trans('firefly.everything'))) . ')'; if (strlen($moment) > 0 && $moment !== 'all') {
$route = route('accounts.show.date', [$account->id, 'all']); $title = trans('firefly.journals_in_period_for_account', ['name' => $account->name,
'start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
$breadcrumbs->push($title, route('accounts.show', [$account->id, $moment]));
} }
$breadcrumbs->parent('accounts.show', $account);
$breadcrumbs->push($title, $route);
} }
); );
@@ -256,9 +249,23 @@ Breadcrumbs::register(
); );
Breadcrumbs::register( Breadcrumbs::register(
'budgets.no-budget', function (BreadCrumbGenerator $breadcrumbs, $subTitle) { 'budgets.no-budget', function (BreadCrumbGenerator $breadcrumbs, string $moment, Carbon $start, Carbon $end) {
$breadcrumbs->parent('budgets.index'); $breadcrumbs->parent('budgets.index');
$breadcrumbs->push($subTitle, route('budgets.no-budget')); $breadcrumbs->push(trans('firefly.journals_without_budget'), route('budgets.no-budget'));
// push when is all:
if ($moment === 'all') {
$breadcrumbs->push(trans('firefly.all_journals_without_budget'), route('budgets.no-budget', ['all']));
}
// when is specific period:
if (strlen($moment) > 0 && $moment !== 'all') {
$title = trans('firefly.without_budget_between', ['start' => $start->formatLocalized(strval(trans('config.month_and_day'))),
'end' => $end->formatLocalized(strval(trans('config.month_and_day')))]
);
$breadcrumbs->push($title, route('budgets.no-budget', [$moment]));
}
} }
); );
@@ -792,15 +799,16 @@ Breadcrumbs::register(
Breadcrumbs::register( Breadcrumbs::register(
'transactions.mass.edit', function (BreadCrumbGenerator $breadcrumbs, Collection $journals) { 'transactions.mass.edit', function (BreadCrumbGenerator $breadcrumbs, Collection $journals) {
if($journals->count() > 0) { if ($journals->count() > 0) {
$journalIds = $journals->pluck('id')->toArray(); $journalIds = $journals->pluck('id')->toArray();
$what = strtolower($journals->first()->transactionType->type); $what = strtolower($journals->first()->transactionType->type);
$breadcrumbs->parent('transactions.index', $what); $breadcrumbs->parent('transactions.index', $what);
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', $journalIds)); $breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', $journalIds));
return;
}
$breadcrumbs->parent('index'); return;
}
$breadcrumbs->parent('index');
} }
); );

View File

@@ -116,6 +116,9 @@ return [
'multi_select_all_selected' => 'All selected', 'multi_select_all_selected' => 'All selected',
'multi_select_filter_placeholder' => 'Find..', 'multi_select_filter_placeholder' => 'Find..',
'all_journals_without_budget' => 'All transactions without a budget', 'all_journals_without_budget' => 'All transactions without a budget',
'journals_without_budget' => 'Transactions without a budget',
'all_journals_for_account' => 'All transactions for account :name',
'journals_in_period_for_account' => 'All transactions for account :name between :start and :end',
// repeat frequencies: // repeat frequencies:

View File

@@ -1,7 +1,7 @@
{% extends "./layout/default" %} {% extends "./layout/default" %}
{% block breadcrumbs %} {% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account, start, end) }} {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account, moment, start, end) }}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@@ -9,12 +9,8 @@
<div class="col-lg-12 col-md-10 col-sm-12"> <div class="col-lg-12 col-md-10 col-sm-12">
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">{{ account.name }} <h3 class="box-title">
{% if start and end %} {{ subTitle }}
({{ trans('firefly.from_to_breadcrumb', {start: start.formatLocalized(monthAndDayFormat), end: end.formatLocalized(monthAndDayFormat)}) }})
{% else %}
({{ trans('firefly.everything')|lower }})
{% endif %}
</h3> </h3>
<!-- ACTIONS MENU --> <!-- ACTIONS MENU -->
<div class="box-tools pull-right"> <div class="box-tools pull-right">
@@ -74,7 +70,7 @@
{% if periods.count > 0 %} {% if periods.count > 0 %}
<div class="row"> <div class="row">
<div class="col-lg-offset-10 col-lg-2 col-md-offset-10 col-md-2 col-sm-12 col-xs-12"> <div class="col-lg-offset-10 col-lg-2 col-md-offset-10 col-md-2 col-sm-12 col-xs-12">
<p class="small text-center"><a href="{{ route('accounts.show.date',[account.id, 'all']) }}">{{ 'showEverything'|_ }}</a></p> <p class="small text-center"><a href="{{ route('accounts.show',[account.id, 'all']) }}">{{ 'showEverything'|_ }}</a></p>
</div> </div>
</div> </div>
{% endif %} {% endif %}
@@ -90,7 +86,7 @@
{% if periods.count > 0 %} {% if periods.count > 0 %}
<p> <p>
<i class="fa fa-calendar" aria-hidden="true"></i> <i class="fa fa-calendar" aria-hidden="true"></i>
<a href="{{ route('accounts.show.date', [account.id, 'all']) }}"> <a href="{{ route('accounts.show', [account.id, 'all']) }}">
{{ 'show_all_no_filter'|_ }} {{ 'show_all_no_filter'|_ }}
</a> </a>
</p> </p>
@@ -111,7 +107,7 @@
{% if (entry[2] != 0 or entry[3] != 0) or (accountType == 'Asset account') %} {% if (entry[2] != 0 or entry[3] != 0) or (accountType == 'Asset account') %}
<div class="box {% if entry[4] == start %}box-solid box-primary{% endif %}"> <div class="box {% if entry[4] == start %}box-solid box-primary{% endif %}">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title"><a href="{{ route('accounts.show.date',[account.id,entry[0]]) }}">{{ entry[1] }}</a> <h3 class="box-title"><a href="{{ route('accounts.show',[account.id,entry[0]]) }}">{{ entry[1] }}</a>
</h3> </h3>
</div> </div>
<div class="box-body no-padding"> <div class="box-body no-padding">
@@ -133,7 +129,7 @@
</div> </div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<p class="small text-center"><a href="{{ route('accounts.show.date',[account.id, 'all']) }}">{{ 'showEverything'|_ }}</a></p> <p class="small text-center"><a href="{{ route('accounts.show',[account.id, 'all']) }}">{{ 'showEverything'|_ }}</a></p>
</div> </div>
{% endif %} {% endif %}
</div> </div>

View File

@@ -1,7 +1,7 @@
{% extends "./layout/default" %} {% extends "./layout/default" %}
{% block breadcrumbs %} {% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, subTitle) }} {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, moment, start, end) }}
{% endblock %} {% endblock %}
{% block content %} {% block content %}
@@ -41,22 +41,20 @@
{% if periods.count > 0 %} {% if periods.count > 0 %}
<div class="col-lg-2 col-md-2 col-sm-12 col-xs-12"> <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12">
{% for entry in periods %} {% for entry in periods %}
{% if entry[2] > 0 %} <div class="box {% if entry[3] == start %}box-solid box-primary{% endif %}">
<div class="box {% if entry[3] == start %}box-solid box-primary{% endif %}"> <div class="box-header with-border">
<div class="box-header with-border"> <h3 class="box-title"><a href="{{ route('budgets.no-budget',[entry[0]]) }}">{{ entry[1] }}</a>
<h3 class="box-title"><a href="{{ route('budgets.no-budget',[entry[0]]) }}">{{ entry[1] }}</a> </h3>
</h3>
</div>
<div class="box-body no-padding">
<table class="table table-hover">
<tr>
<td style="width:33%;">{{ 'transactions'|_ }}</td>
<td style="text-align: right;">{{ entry[2] }}</td>
</tr>
</table>
</div>
</div> </div>
{% endif %} <div class="box-body no-padding">
<table class="table table-hover">
<tr>
<td style="width:33%;">{{ 'transactions'|_ }}</td>
<td style="text-align: right;">{{ entry[2] }}</td>
</tr>
</table>
</div>
</div>
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}

View File

@@ -87,8 +87,7 @@ Route::group(
Route::get('edit/{account}', ['uses' => 'AccountController@edit', 'as' => 'edit']); Route::get('edit/{account}', ['uses' => 'AccountController@edit', 'as' => 'edit']);
Route::get('delete/{account}', ['uses' => 'AccountController@delete', 'as' => 'delete']); Route::get('delete/{account}', ['uses' => 'AccountController@delete', 'as' => 'delete']);
Route::get('show/{account}', ['uses' => 'AccountController@show', 'as' => 'show']); Route::get('show/{account}/{moment?}', ['uses' => 'AccountController@show', 'as' => 'show']);
Route::get('show/{account}/{date}', ['uses' => 'AccountController@show', 'as' => 'show.date']);
Route::post('store', ['uses' => 'AccountController@store', 'as' => 'store']); Route::post('store', ['uses' => 'AccountController@store', 'as' => 'store']);
Route::post('update/{account}', ['uses' => 'AccountController@update', 'as' => 'update']); Route::post('update/{account}', ['uses' => 'AccountController@update', 'as' => 'update']);