mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-01-20 21:43:08 -06:00
Add fallback for empty front page account preferences thing.
This commit is contained in:
parent
e3433aa95b
commit
7c56c14fa0
@ -58,10 +58,11 @@ class PreferencesController extends Controller
|
|||||||
public function index(AccountRepositoryInterface $repository)
|
public function index(AccountRepositoryInterface $repository)
|
||||||
{
|
{
|
||||||
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
$accounts = $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET]);
|
||||||
|
$accountIds = $accounts->pluck('id')->toArray();
|
||||||
$viewRangePref = app('preferences')->get('viewRange', '1M');
|
$viewRangePref = app('preferences')->get('viewRange', '1M');
|
||||||
/** @noinspection NullPointerExceptionInspection */
|
/** @noinspection NullPointerExceptionInspection */
|
||||||
$viewRange = $viewRangePref->data;
|
$viewRange = $viewRangePref->data;
|
||||||
$frontPageAccounts = app('preferences')->get('frontPageAccounts', []);
|
$frontPageAccounts = app('preferences')->get('frontPageAccounts', $accountIds);
|
||||||
$language = app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;
|
$language = app('preferences')->get('language', config('firefly.default_language', 'en_US'))->data;
|
||||||
$listPageSize = app('preferences')->get('listPageSize', 50)->data;
|
$listPageSize = app('preferences')->get('listPageSize', 50)->data;
|
||||||
$customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data;
|
$customFiscalYear = app('preferences')->get('customFiscalYear', 0)->data;
|
||||||
@ -69,6 +70,12 @@ class PreferencesController extends Controller
|
|||||||
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
|
$fiscalYearStart = date('Y') . '-' . $fiscalYearStartStr;
|
||||||
$tjOptionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
$tjOptionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
||||||
|
|
||||||
|
// an important fallback is that the frontPageAccount array gets refilled automatically
|
||||||
|
// when it turns up empty.
|
||||||
|
if (\count($frontPageAccounts->data) === 0) {
|
||||||
|
$frontPageAccounts = $accountIds;
|
||||||
|
}
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
'preferences.index',
|
'preferences.index',
|
||||||
compact(
|
compact(
|
||||||
@ -98,7 +105,7 @@ class PreferencesController extends Controller
|
|||||||
{
|
{
|
||||||
// front page accounts
|
// front page accounts
|
||||||
$frontPageAccounts = [];
|
$frontPageAccounts = [];
|
||||||
if (\is_array($request->get('frontPageAccounts'))) {
|
if (\is_array($request->get('frontPageAccounts')) && \count($request->get('frontPageAccounts')) > 0) {
|
||||||
foreach ($request->get('frontPageAccounts') as $id) {
|
foreach ($request->get('frontPageAccounts') as $id) {
|
||||||
$frontPageAccounts[] = (int)$id;
|
$frontPageAccounts[] = (int)$id;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user