mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Add a button to go back to the v1 layout.
This commit is contained in:
parent
a5b15bbc16
commit
3a339382d4
@ -46,7 +46,7 @@ class IndexController extends Controller
|
|||||||
function ($request, $next) {
|
function ($request, $next) {
|
||||||
$this->repository = app(AccountRepositoryInterface::class);
|
$this->repository = app(AccountRepositoryInterface::class);
|
||||||
// new way of user group validation
|
// new way of user group validation
|
||||||
$userGroup = $this->validateUserGroup($request);
|
$userGroup = $this->validateUserGroup($request);
|
||||||
if (null !== $userGroup) {
|
if (null !== $userGroup) {
|
||||||
$this->repository->setUserGroup($userGroup);
|
$this->repository->setUserGroup($userGroup);
|
||||||
}
|
}
|
||||||
@ -61,11 +61,11 @@ class IndexController extends Controller
|
|||||||
$this->repository->resetAccountOrder();
|
$this->repository->resetAccountOrder();
|
||||||
|
|
||||||
// get accounts of the specified type, and return.
|
// get accounts of the specified type, and return.
|
||||||
$types = $request->getAccountTypes();
|
$types = $request->getAccountTypes();
|
||||||
|
|
||||||
// get from repository
|
// get from repository
|
||||||
$accounts = $this->repository->getAccountsInOrder($types, $request->getSortInstructions('accounts'), $request->getStartRow(), $request->getEndRow());
|
$accounts = $this->repository->getAccountsInOrder($types, $request->getSortInstructions('accounts'), $request->getStartRow(), $request->getEndRow());
|
||||||
$total = $this->repository->countAccounts($types);
|
$total = $this->repository->countAccounts($types);
|
||||||
$count = $request->getEndRow() - $request->getStartRow();
|
$count = $request->getEndRow() - $request->getStartRow();
|
||||||
$paginator = new LengthAwarePaginator($accounts, $total, $count, $this->parameters->get('page'));
|
$paginator = new LengthAwarePaginator($accounts, $total, $count, $this->parameters->get('page'));
|
||||||
$transformer = new AccountTransformer();
|
$transformer = new AccountTransformer();
|
||||||
@ -73,6 +73,7 @@ class IndexController extends Controller
|
|||||||
|
|
||||||
return response()
|
return response()
|
||||||
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
|
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
|
||||||
->header('Content-Type', self::CONTENT_TYPE);
|
->header('Content-Type', self::CONTENT_TYPE)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,11 @@ abstract class Controller extends BaseController
|
|||||||
$authGuard = config('firefly.authentication_guard');
|
$authGuard = config('firefly.authentication_guard');
|
||||||
$logoutUrl = config('firefly.custom_logout_url');
|
$logoutUrl = config('firefly.custom_logout_url');
|
||||||
|
|
||||||
|
// overrule v2 layout back to v1.
|
||||||
|
if ('true' === request()->get('force_default_layout') && 'v2' === config('firefly.layout')) {
|
||||||
|
app('view')->getFinder()->setPaths([realpath(base_path('resources/views'))]);
|
||||||
|
}
|
||||||
|
|
||||||
app('view')->share('authGuard', $authGuard);
|
app('view')->share('authGuard', $authGuard);
|
||||||
app('view')->share('logoutUrl', $logoutUrl);
|
app('view')->share('logoutUrl', $logoutUrl);
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
|||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Log;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ReconcileController
|
* Class ReconcileController
|
||||||
@ -119,10 +118,10 @@ class ReconcileController extends Controller
|
|||||||
$clearedAmount = $this->processJournal($account, $accountCurrency, $journal, $clearedAmount);
|
$clearedAmount = $this->processJournal($account, $accountCurrency, $journal, $clearedAmount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log::debug(sprintf('Start balance: "%s"', $startBalance));
|
\Log::debug(sprintf('Start balance: "%s"', $startBalance));
|
||||||
Log::debug(sprintf('End balance: "%s"', $endBalance));
|
\Log::debug(sprintf('End balance: "%s"', $endBalance));
|
||||||
Log::debug(sprintf('Cleared amount: "%s"', $clearedAmount));
|
\Log::debug(sprintf('Cleared amount: "%s"', $clearedAmount));
|
||||||
Log::debug(sprintf('Amount: "%s"', $amount));
|
\Log::debug(sprintf('Amount: "%s"', $amount));
|
||||||
$difference = bcadd(bcadd(bcsub($startBalance, $endBalance), $clearedAmount), $amount);
|
$difference = bcadd(bcadd(bcsub($startBalance, $endBalance), $clearedAmount), $amount);
|
||||||
$diffCompare = bccomp($difference, '0');
|
$diffCompare = bccomp($difference, '0');
|
||||||
$countCleared = count($clearedJournals);
|
$countCleared = count($clearedJournals);
|
||||||
|
@ -75,52 +75,45 @@ class IndexController extends Controller
|
|||||||
$objectType = 'transfer';
|
$objectType = 'transfer';
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a split for the (future) v2 release.
|
$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
|
||||||
$periods = [];
|
$types = config('firefly.transactionTypesByType.'.$objectType);
|
||||||
$groups = [];
|
$page = (int)$request->get('page');
|
||||||
$subTitle = 'TODO page subtitle in v2';
|
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||||
|
|
||||||
$subTitleIcon = config('firefly.transactionIconsByType.'.$objectType);
|
if (null === $start) {
|
||||||
$types = config('firefly.transactionTypesByType.'.$objectType);
|
$start = session('start');
|
||||||
$page = (int)$request->get('page');
|
$end = session('end');
|
||||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
|
||||||
|
|
||||||
if ('v2' !== (string)config('firefly.layout')) {
|
|
||||||
if (null === $start) {
|
|
||||||
$start = session('start');
|
|
||||||
$end = session('end');
|
|
||||||
}
|
|
||||||
if (null === $end) {
|
|
||||||
// get last transaction ever?
|
|
||||||
$last = $this->repository->getLast();
|
|
||||||
$end = null !== $last ? $last->date : session('end');
|
|
||||||
}
|
|
||||||
|
|
||||||
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
|
||||||
$startStr = $start->isoFormat($this->monthAndDayFormat);
|
|
||||||
$endStr = $end->isoFormat($this->monthAndDayFormat);
|
|
||||||
$subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
|
|
||||||
$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
|
||||||
$firstJournal = $this->repository->firstNull();
|
|
||||||
$startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;
|
|
||||||
$endPeriod = clone $end;
|
|
||||||
$periods = $this->getTransactionPeriodOverview($objectType, $startPeriod, $endPeriod);
|
|
||||||
|
|
||||||
/** @var GroupCollectorInterface $collector */
|
|
||||||
$collector = app(GroupCollectorInterface::class);
|
|
||||||
|
|
||||||
$collector->setRange($start, $end)
|
|
||||||
->setTypes($types)
|
|
||||||
->setLimit($pageSize)
|
|
||||||
->setPage($page)
|
|
||||||
->withBudgetInformation()
|
|
||||||
->withCategoryInformation()
|
|
||||||
->withAccountInformation()
|
|
||||||
->withAttachmentInformation()
|
|
||||||
;
|
|
||||||
$groups = $collector->getPaginatedGroups();
|
|
||||||
$groups->setPath($path);
|
|
||||||
}
|
}
|
||||||
|
if (null === $end) {
|
||||||
|
// get last transaction ever?
|
||||||
|
$last = $this->repository->getLast();
|
||||||
|
$end = null !== $last ? $last->date : session('end');
|
||||||
|
}
|
||||||
|
|
||||||
|
[$start, $end] = $end < $start ? [$end, $start] : [$start, $end];
|
||||||
|
$startStr = $start->isoFormat($this->monthAndDayFormat);
|
||||||
|
$endStr = $end->isoFormat($this->monthAndDayFormat);
|
||||||
|
$subTitle = (string)trans(sprintf('firefly.title_%s_between', $objectType), ['start' => $startStr, 'end' => $endStr]);
|
||||||
|
$path = route('transactions.index', [$objectType, $start->format('Y-m-d'), $end->format('Y-m-d')]);
|
||||||
|
$firstJournal = $this->repository->firstNull();
|
||||||
|
$startPeriod = null === $firstJournal ? new Carbon() : $firstJournal->date;
|
||||||
|
$endPeriod = clone $end;
|
||||||
|
$periods = $this->getTransactionPeriodOverview($objectType, $startPeriod, $endPeriod);
|
||||||
|
|
||||||
|
/** @var GroupCollectorInterface $collector */
|
||||||
|
$collector = app(GroupCollectorInterface::class);
|
||||||
|
|
||||||
|
$collector->setRange($start, $end)
|
||||||
|
->setTypes($types)
|
||||||
|
->setLimit($pageSize)
|
||||||
|
->setPage($page)
|
||||||
|
->withBudgetInformation()
|
||||||
|
->withCategoryInformation()
|
||||||
|
->withAccountInformation()
|
||||||
|
->withAttachmentInformation()
|
||||||
|
;
|
||||||
|
$groups = $collector->getPaginatedGroups();
|
||||||
|
$groups->setPath($path);
|
||||||
|
|
||||||
return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'periods', 'start', 'end'));
|
return view('transactions.index', compact('subTitle', 'objectType', 'subTitleIcon', 'groups', 'periods', 'start', 'end'));
|
||||||
}
|
}
|
||||||
|
@ -252,10 +252,8 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
#[\Override]
|
||||||
* @inheritDoc
|
public function getAccountsInOrder(array $types, array $sort, int $startRow, int $endRow): Collection
|
||||||
*/
|
|
||||||
#[\Override] public function getAccountsInOrder(array $types, array $sort, int $startRow, int $endRow): Collection
|
|
||||||
{
|
{
|
||||||
$query = $this->userGroup->accounts();
|
$query = $this->userGroup->accounts();
|
||||||
if (0 !== count($types)) {
|
if (0 !== count($types)) {
|
||||||
@ -280,12 +278,14 @@ class AccountRepository implements AccountRepositoryInterface
|
|||||||
return $query->get(['accounts.*']);
|
return $query->get(['accounts.*']);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[\Override] public function countAccounts(array $types): int
|
#[\Override]
|
||||||
|
public function countAccounts(array $types): int
|
||||||
{
|
{
|
||||||
$query = $this->userGroup->accounts();
|
$query = $this->userGroup->accounts();
|
||||||
if (0 !== count($types)) {
|
if (0 !== count($types)) {
|
||||||
$query->accountTypeIn($types);
|
$query->accountTypeIn($types);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->count();
|
return $query->count();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,15 +53,8 @@ interface AccountRepositoryInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Used in the infinite accounts list.
|
* Used in the infinite accounts list.
|
||||||
*
|
|
||||||
* @param array $types
|
|
||||||
* @param array $sort
|
|
||||||
* @param int $startRow
|
|
||||||
* @param int $endRow
|
|
||||||
*
|
|
||||||
* @return Collection
|
|
||||||
*/
|
*/
|
||||||
public function getAccountsInOrder(array $types, array $sort, int $startRow, int $endRow): Collection;
|
public function getAccountsInOrder(array $types, array $sort, int $startRow, int $endRow): Collection;
|
||||||
|
|
||||||
public function getActiveAccountsByType(array $types): Collection;
|
public function getActiveAccountsByType(array $types): Collection;
|
||||||
|
|
||||||
|
@ -917,7 +917,7 @@ return [
|
|||||||
'sorting' => [
|
'sorting' => [
|
||||||
'allowed' => [
|
'allowed' => [
|
||||||
'transactions' => ['description', 'amount'],
|
'transactions' => ['description', 'amount'],
|
||||||
'accounts' => ['name'],
|
'accounts' => ['name'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="{{ route(Route::current()->getName(), Route::current()->parameters()) }}?force_default_layout=true">
|
||||||
|
<i class="fa-solid fa-landmark"></i>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</li>
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item dropdown">
|
||||||
<a class="nav-link" data-bs-toggle="dropdown" href="#">
|
<a class="nav-link" data-bs-toggle="dropdown" href="#">
|
||||||
<i class="fa-solid fa-gears"></i>
|
<i class="fa-solid fa-gears"></i>
|
||||||
|
Loading…
Reference in New Issue
Block a user