Expand and fix sort columns

This commit is contained in:
James Cole
2024-04-30 20:22:31 +02:00
parent 69d839997a
commit 4bd19e0627
2 changed files with 41 additions and 37 deletions

View File

@@ -73,7 +73,7 @@ class IndexController extends Controller
// depending on the sort parameters, this list must not be split, because the // depending on the sort parameters, this list must not be split, because the
// order is calculated in the account transformer and by that time it's too late. // order is calculated in the account transformer and by that time it's too late.
$first = array_key_first($sorting); $first = array_key_first($sorting);
$disablePagination = in_array($first, ['last_activity', 'balance_difference'], true); $disablePagination = in_array($first, ['last_activity','balance', 'balance_difference'], true);
if (!$disablePagination) { if (!$disablePagination) {
$accounts = $accounts->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize); $accounts = $accounts->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
} }

View File

@@ -87,14 +87,18 @@ class AccountTransformer extends AbstractTransformer
// get object groups // get object groups
$this->getObjectGroups($objects); $this->getObjectGroups($objects);
// sort:
$objects = $this->sortAccounts($objects);
// if pagination is disabled, do it now: // if pagination is disabled, do it now:
if(true === $this->parameters->get('disablePagination')) { if (true === $this->parameters->get('disablePagination')) {
$page = (int) $this->parameters->get('page'); $page = (int) $this->parameters->get('page');
$size = (int) $this->parameters->get('pageSize'); $size = (int) $this->parameters->get('pageSize');
$objects = $objects->slice(($page-1) * $size, $size); $objects = $objects->slice(($page - 1) * $size, $size);
} }
return $this->sortAccounts($objects); return $objects;
} }
private function getDate(): Carbon private function getDate(): Carbon
@@ -218,7 +222,7 @@ class AccountTransformer extends AbstractTransformer
'links' => [ 'links' => [
[ [
'rel' => 'self', 'rel' => 'self',
'uri' => '/accounts/'.$account->id, 'uri' => '/accounts/' . $account->id,
], ],
], ],
]; ];