mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
Consistency for #595
This commit is contained in:
@@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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');
|
||||
}
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user