Consistency for #595

This commit is contained in:
James Cole 2017-03-10 16:08:58 +01:00
parent ef0057d88d
commit ebc712f6b5
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
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\AccountTaskerInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\CacheProperties;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
@ -229,16 +230,18 @@ class AccountController extends Controller
/**
* @param Request $request
* @param Account $account
* @param string $moment
* @param Request $request
* @param JournalRepositoryInterface $repository
* @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) {
return $this->redirectToOriginalAccount($account);
}
$subTitle = $account->name;
$range = Preferences::get('viewRange', '1M')->data;
$subTitleIcon = config('firefly.subIconsByIdentifier.' . $account->accountType->type);
$page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));
@ -250,29 +253,34 @@ class AccountController extends Controller
// prep for "all" view.
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]);
$first = $repository->first();
$start = $first->date ?? new Carbon;
$end = new Carbon;
}
// prep for "specific date" view.
if (strlen($moment) > 0 && $moment !== 'all') {
$start = new Carbon($moment);
$end = Navigation::endOfPeriod($start, $range);
$subTitle = $account->name . ' (' . strval(
trans(
'firefly.from_to_breadcrumb',
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
)
) . ')';
$subTitle = trans(
'firefly.journals_in_period_for_account', ['name' => $account->name, 'start' => $start->formatLocalized($this->monthAndDayFormat),
'end' => $end->formatLocalized($this->monthAndDayFormat)]
);
$chartUri = route('chart.account.period', [$account->id, $start->format('Y-m-d')]);
$periods = $this->periodEntries($account);
}
// prep for current period
if (strlen($moment) === 0) {
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
$periods = $this->periodEntries($account);
$start = clone session('start', Navigation::startOfPeriod(new Carbon, $range));
$end = clone session('end', Navigation::endOfPeriod(new Carbon, $range));
$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;
@ -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') {
$start = new Carbon($moment);
$end = Navigation::endOfPeriod($start, $range);
$subTitle = trans(
'firefly.without_budget_between',
['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]
);
$subTitle = trans('firefly.without_budget_between', ['start' => $start->formatLocalized($this->monthAndDayFormat), 'end' => $end->formatLocalized($this->monthAndDayFormat)]);
$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(
'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);
$breadcrumbs->parent('accounts.index', $what);
$breadcrumbs->push($account->name, route('accounts.show', [$account->id]));
}
);
Breadcrumbs::register(
'accounts.show.date', function (BreadCrumbGenerator $breadcrumbs, Account $account, Carbon $start = null, Carbon $end = null) {
$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')]);
// push when is all:
if ($moment === 'all') {
$breadcrumbs->push(trans('firefly.all_journals_for_account', ['name' => $account->name]), route('accounts.show', [$account->id]));
}
if (is_null($start) && is_null($end)) {
$title = $title = $account->name . ' (' . strtolower(strval(trans('firefly.everything'))) . ')';
$route = route('accounts.show.date', [$account->id, 'all']);
// when is specific period:
if (strlen($moment) > 0 && $moment !== '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(
'budgets.no-budget', function (BreadCrumbGenerator $breadcrumbs, $subTitle) {
'budgets.no-budget', function (BreadCrumbGenerator $breadcrumbs, string $moment, Carbon $start, Carbon $end) {
$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(
'transactions.mass.edit', function (BreadCrumbGenerator $breadcrumbs, Collection $journals) {
if($journals->count() > 0) {
$journalIds = $journals->pluck('id')->toArray();
$what = strtolower($journals->first()->transactionType->type);
$breadcrumbs->parent('transactions.index', $what);
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', $journalIds));
return;
}
if ($journals->count() > 0) {
$journalIds = $journals->pluck('id')->toArray();
$what = strtolower($journals->first()->transactionType->type);
$breadcrumbs->parent('transactions.index', $what);
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', $journalIds));
$breadcrumbs->parent('index');
return;
}
$breadcrumbs->parent('index');
}
);

View File

@ -116,6 +116,9 @@ return [
'multi_select_all_selected' => 'All selected',
'multi_select_filter_placeholder' => 'Find..',
'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:

View File

@ -1,7 +1,7 @@
{% extends "./layout/default" %}
{% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account, start, end) }}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, account, moment, start, end) }}
{% endblock %}
{% block content %}
@ -9,12 +9,8 @@
<div class="col-lg-12 col-md-10 col-sm-12">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">{{ account.name }}
{% if start and end %}
({{ trans('firefly.from_to_breadcrumb', {start: start.formatLocalized(monthAndDayFormat), end: end.formatLocalized(monthAndDayFormat)}) }})
{% else %}
({{ trans('firefly.everything')|lower }})
{% endif %}
<h3 class="box-title">
{{ subTitle }}
</h3>
<!-- ACTIONS MENU -->
<div class="box-tools pull-right">
@ -74,7 +70,7 @@
{% if periods.count > 0 %}
<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">
<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 %}
@ -90,7 +86,7 @@
{% if periods.count > 0 %}
<p>
<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'|_ }}
</a>
</p>
@ -111,7 +107,7 @@
{% 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-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>
</div>
<div class="box-body no-padding">
@ -133,7 +129,7 @@
</div>
{% endif %}
{% 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>
{% endif %}
</div>

View File

@ -1,7 +1,7 @@
{% extends "./layout/default" %}
{% block breadcrumbs %}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, subTitle) }}
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, moment, start, end) }}
{% endblock %}
{% block content %}
@ -41,22 +41,20 @@
{% if periods.count > 0 %}
<div class="col-lg-2 col-md-2 col-sm-12 col-xs-12">
{% for entry in periods %}
{% if entry[2] > 0 %}
<div class="box {% if entry[3] == start %}box-solid box-primary{% endif %}">
<div class="box-header with-border">
<h3 class="box-title"><a href="{{ route('budgets.no-budget',[entry[0]]) }}">{{ entry[1] }}</a>
</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 class="box {% if entry[3] == start %}box-solid box-primary{% endif %}">
<div class="box-header with-border">
<h3 class="box-title"><a href="{{ route('budgets.no-budget',[entry[0]]) }}">{{ entry[1] }}</a>
</h3>
</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 %}
</div>
{% endif %}

View File

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