aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-06-28 14:59:31 +0200
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2020-04-28 10:10:42 +0200
commit8d2527ec528d1631be21967137f63d2fc0cf218f (patch)
treef5c0bf049a92e06df3fc0124cdb4498a4af7f341
parentd50c93f05585485157668888afa3660f88f3a572 (diff)
downloadwallabag-8d2527ec528d1631be21967137f63d2fc0cf218f.tar.gz
wallabag-8d2527ec528d1631be21967137f63d2fc0cf218f.tar.zst
wallabag-8d2527ec528d1631be21967137f63d2fc0cf218f.zip
Start work on sort function.
Backend is ready. Needs tests and proper UI
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php13
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php13
2 files changed, 16 insertions, 10 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index 9b2954e7..cef29990 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -532,24 +532,27 @@ class EntryController extends Controller
532 $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : ''); 532 $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
533 $currentRoute = (null !== $request->query->get('currentRoute') ? $request->query->get('currentRoute') : ''); 533 $currentRoute = (null !== $request->query->get('currentRoute') ? $request->query->get('currentRoute') : '');
534 534
535 $sortBy = $request->get('sort', 'id');
536 $direction = $request->get('direction', 'DESC');
537
535 switch ($type) { 538 switch ($type) {
536 case 'search': 539 case 'search':
537 $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute); 540 $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute);
538 break; 541 break;
539 case 'untagged': 542 case 'untagged':
540 $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId()); 543 $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId(), $sortBy, $direction);
541 break; 544 break;
542 case 'starred': 545 case 'starred':
543 $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId()); 546 $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId(), $sortBy, $direction);
544 break; 547 break;
545 case 'archive': 548 case 'archive':
546 $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId()); 549 $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId(), $sortBy, $direction);
547 break; 550 break;
548 case 'unread': 551 case 'unread':
549 $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId()); 552 $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId(), $sortBy, $direction);
550 break; 553 break;
551 case 'all': 554 case 'all':
552 $qb = $repository->getBuilderForAllByUser($this->getUser()->getId()); 555 $qb = $repository->getBuilderForAllByUser($this->getUser()->getId(), $sortBy, $direction);
553 break; 556 break;
554 default: 557 default:
555 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); 558 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index bfd07937..92d1867b 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -20,10 +20,10 @@ class EntryRepository extends EntityRepository
20 * 20 *
21 * @return QueryBuilder 21 * @return QueryBuilder
22 */ 22 */
23 public function getBuilderForAllByUser($userId) 23 public function getBuilderForAllByUser($userId, $sortBy = 'id', $direction = 'DESC')
24 { 24 {
25 return $this 25 return $this
26 ->getSortedQueryBuilderByUser($userId) 26 ->getSortedQueryBuilderByUser($userId, $sortBy, $direction)
27 ; 27 ;
28 } 28 }
29 29
@@ -34,11 +34,12 @@ class EntryRepository extends EntityRepository
34 * 34 *
35 * @return QueryBuilder 35 * @return QueryBuilder
36 */ 36 */
37 public function getBuilderForUnreadByUser($userId) 37 public function getBuilderForUnreadByUser($userId, $sortBy = 'id', $direction = 'DESC')
38 { 38 {
39 return $this 39 return $this
40 ->getSortedQueryBuilderByUser($userId) 40 ->getSortedQueryBuilderByUser($userId)
41 ->andWhere('e.isArchived = false') 41 ->andWhere('e.isArchived = false')
42 ->orderBy('e.'.$sortBy, $direction)
42 ; 43 ;
43 } 44 }
44 45
@@ -49,11 +50,12 @@ class EntryRepository extends EntityRepository
49 * 50 *
50 * @return QueryBuilder 51 * @return QueryBuilder
51 */ 52 */
52 public function getBuilderForArchiveByUser($userId) 53 public function getBuilderForArchiveByUser($userId, $sortBy = 'id', $direction = 'DESC')
53 { 54 {
54 return $this 55 return $this
55 ->getSortedQueryBuilderByUser($userId, 'archivedAt', 'desc') 56 ->getSortedQueryBuilderByUser($userId, 'archivedAt', 'desc')
56 ->andWhere('e.isArchived = true') 57 ->andWhere('e.isArchived = true')
58 ->orderBy('e.'.$sortBy, $direction)
57 ; 59 ;
58 } 60 }
59 61
@@ -64,11 +66,12 @@ class EntryRepository extends EntityRepository
64 * 66 *
65 * @return QueryBuilder 67 * @return QueryBuilder
66 */ 68 */
67 public function getBuilderForStarredByUser($userId) 69 public function getBuilderForStarredByUser($userId, $sortBy = 'id', $direction = 'DESC')
68 { 70 {
69 return $this 71 return $this
70 ->getSortedQueryBuilderByUser($userId, 'starredAt', 'desc') 72 ->getSortedQueryBuilderByUser($userId, 'starredAt', 'desc')
71 ->andWhere('e.isStarred = true') 73 ->andWhere('e.isStarred = true')
74 ->orderBy('e.'.$sortBy, $direction)
72 ; 75 ;
73 } 76 }
74 77