mirror of
https://github.com/wallabag/wallabag.git
synced 2025-10-15 19:42:08 +00:00
Add sorting function to filter view
Fixes #2178 Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
parent
a97e84a21e
commit
7e8a3c432f
5 changed files with 54 additions and 3 deletions
|
@ -627,6 +627,16 @@ class EntryController extends AbstractController
|
|||
$currentEntryId = $request->attributes->getInt('id');
|
||||
|
||||
$formOptions = [];
|
||||
$direction = 'desc';
|
||||
$sortBy = null;
|
||||
|
||||
if (null !== $request->get('entry_filter') && null !== $request->get('entry_filter')['sortType'] && '' !== $request->get('entry_filter')['sortType']) {
|
||||
$direction = (null !== $request->get('entry_filter')['sortOrder'] && \in_array($request->get('entry_filter')['sortOrder'], ['asc', 'desc'], true)) ? $request->get('entry_filter')['sortOrder'] : 'desc';
|
||||
|
||||
if (\in_array($request->get('entry_filter')['sortType'], ['id','title','createdAt'], true)) {
|
||||
$sortBy = $request->get('entry_filter')['sortType'];
|
||||
}
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'search':
|
||||
|
@ -654,7 +664,7 @@ class EntryController extends AbstractController
|
|||
$qb = $this->entryRepository->getBuilderForSameDomainByUser($this->getUser()->getId(), $currentEntryId);
|
||||
break;
|
||||
case 'all':
|
||||
$qb = $this->entryRepository->getBuilderForAllByUser($this->getUser()->getId());
|
||||
$qb = $this->entryRepository->getBuilderForAllByUser($this->getUser()->getId(), $sortBy, $direction);
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(\sprintf('Type "%s" is not implemented.', $type));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue