aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php2
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php15
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig6
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig2
4 files changed, 18 insertions, 7 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index b3ec7729..5157653c 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -535,7 +535,7 @@ class EntryController extends Controller
535 // defined as null by default because each repository method have the right field as default value too 535 // defined as null by default because each repository method have the right field as default value too
536 // like `getBuilderForStarredByUser` will have `starredAt` sort by default 536 // like `getBuilderForStarredByUser` will have `starredAt` sort by default
537 $sortBy = null; 537 $sortBy = null;
538 if (in_array($request->get('sort', 'createdAt'), ['id', 'title', 'createdAt', 'updatedAt', 'starredAt', 'archivedAt'], true)) { 538 if (\in_array($request->get('sort', 'createdAt'), ['id', 'title', 'createdAt', 'updatedAt', 'starredAt', 'archivedAt'], true)) {
539 $sortBy = $request->get('sort', null); 539 $sortBy = $request->get('sort', null);
540 } 540 }
541 541
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index cf1cdb8a..aa761df3 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -24,6 +24,8 @@ class EntryRepository extends EntityRepository
24 */ 24 */
25 public function getBuilderForAllByUser($userId, $sortBy = 'id', $direction = 'DESC') 25 public function getBuilderForAllByUser($userId, $sortBy = 'id', $direction = 'DESC')
26 { 26 {
27 $sortBy = $sortBy ?: 'id';
28
27 return $this 29 return $this
28 ->getSortedQueryBuilderByUser($userId, $sortBy, $direction) 30 ->getSortedQueryBuilderByUser($userId, $sortBy, $direction)
29 ; 31 ;
@@ -40,6 +42,8 @@ class EntryRepository extends EntityRepository
40 */ 42 */
41 public function getBuilderForUnreadByUser($userId, $sortBy = 'id', $direction = 'DESC') 43 public function getBuilderForUnreadByUser($userId, $sortBy = 'id', $direction = 'DESC')
42 { 44 {
45 $sortBy = $sortBy ?: 'id';
46
43 return $this 47 return $this
44 ->getSortedQueryBuilderByUser($userId, $sortBy, $direction) 48 ->getSortedQueryBuilderByUser($userId, $sortBy, $direction)
45 ->andWhere('e.isArchived = false') 49 ->andWhere('e.isArchived = false')
@@ -57,6 +61,8 @@ class EntryRepository extends EntityRepository
57 */ 61 */
58 public function getBuilderForArchiveByUser($userId, $sortBy = 'archivedAt', $direction = 'DESC') 62 public function getBuilderForArchiveByUser($userId, $sortBy = 'archivedAt', $direction = 'DESC')
59 { 63 {
64 $sortBy = $sortBy ?: 'archivedAt';
65
60 return $this 66 return $this
61 ->getSortedQueryBuilderByUser($userId, $sortBy, $direction) 67 ->getSortedQueryBuilderByUser($userId, $sortBy, $direction)
62 ->andWhere('e.isArchived = true') 68 ->andWhere('e.isArchived = true')
@@ -74,6 +80,8 @@ class EntryRepository extends EntityRepository
74 */ 80 */
75 public function getBuilderForStarredByUser($userId, $sortBy = 'starredAt', $direction = 'DESC') 81 public function getBuilderForStarredByUser($userId, $sortBy = 'starredAt', $direction = 'DESC')
76 { 82 {
83 $sortBy = $sortBy ?: 'starredAt';
84
77 return $this 85 return $this
78 ->getSortedQueryBuilderByUser($userId, $sortBy, $direction) 86 ->getSortedQueryBuilderByUser($userId, $sortBy, $direction)
79 ->andWhere('e.isStarred = true') 87 ->andWhere('e.isStarred = true')
@@ -579,6 +587,11 @@ class EntryRepository extends EntityRepository
579 */ 587 */
580 private function sortQueryBuilder(QueryBuilder $qb, $sortBy = 'createdAt', $direction = 'desc') 588 private function sortQueryBuilder(QueryBuilder $qb, $sortBy = 'createdAt', $direction = 'desc')
581 { 589 {
582 return $qb->orderBy(sprintf('e.%s', $sortBy), $direction); 590 // in case one of these isn't defined, don't apply the orderBy
591 if (!$sortBy || !$direction) {
592 return $qb;
593 }
594
595 return $qb->orderBy(sprintf('e.%s', $sortBy), strtoupper($direction));
583 } 596 }
584} 597}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
index deeb19a3..1654a0e0 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
@@ -210,8 +210,7 @@
210 {% endif %} 210 {% endif %}
211 211
212 <!-- Sort --> 212 <!-- Sort -->
213 <div id="sort" class="side-nav fixed right-aligned"> 213 <div id="sort" class="side-nav right-aligned">
214
215 <h4 class="center">{{ 'entry.sort.title'|trans }}</h4> 214 <h4 class="center">{{ 'entry.sort.title'|trans }}</h4>
216 215
217 <div class="row"> 216 <div class="row">
@@ -239,9 +238,8 @@
239 </div> 238 </div>
240 </div> 239 </div>
241 </div> 240 </div>
242
243 </div> 241 </div>
244 242
245 {% include "WallabagCoreBundle:Entry:pager.html.twig" with {'entries': entries} %} 243 {# {% include "WallabagCoreBundle:Entry:pager.html.twig" with {'entries': entries} %} #}
246 244
247{% endblock %} 245{% endblock %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
index 95d7da9a..0c3d4d5b 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
@@ -93,7 +93,7 @@
93 </a> 93 </a>
94 </li> 94 </li>
95 <li id="button_sort"> 95 <li id="button_sort">
96 <a title="{{ 'menu.top.sort_entries'|trans }}" href="#" data-activates="sort" class="nav-panel-menu button-collapse-right"> 96 <a class="nav-panel-menu button-collapse-right tooltipped js-sort-action" data-position="bottom" data-delay="50" data-tooltip="{{ 'menu.top.sort_entries'|trans }}" href="#" data-activates="sort">
97 <i class="material-icons">sort_by_alpha</i> 97 <i class="material-icons">sort_by_alpha</i>
98 </a> 98 </a>
99 </li> 99 </li>