From: Kevin Decherf Date: Sun, 2 Sep 2018 14:43:49 +0000 (+0200) Subject: Show untagged entries count on tag list X-Git-Url: https://git.immae.eu/?p=github%2Fwallabag%2Fwallabag.git;a=commitdiff_plain;h=ad51743e8bd15782a25c5e717c87786d34091ce3 Show untagged entries count on tag list Closes #3235 Signed-off-by: Kevin Decherf --- diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index d0155c60..bd50de7f 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -87,6 +87,8 @@ class TagController extends Controller { $tags = $this->get('wallabag_core.tag_repository') ->findAllFlatTagsWithNbEntries($this->getUser()->getId()); + $untagged = $this->get('wallabag_core.entry_repository') + ->countUntaggedEntriesForUser($this->getUser()->getId()); $renameForms = []; foreach ($tags as $tag) { @@ -96,6 +98,7 @@ class TagController extends Controller return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [ 'tags' => $tags, 'renameForms' => $renameForms, + 'untagged' => $untagged, ]); } diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 16c44885..77d88c9c 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -129,6 +129,20 @@ class EntryRepository extends EntityRepository ->andWhere('t.id is null'); } + /** + * Retrieve the number of untagged entries for a user. + * + * @param int $userId + * + * @return int + */ + public function countUntaggedEntriesByUser($userId) + { + return $this->getRawBuilderForUntaggedByUser($userId) + ->select('count(e.id)') + ->getSingleScalarResult(); + } + /** * Find Entries. * diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Tag/tags.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Tag/tags.html.twig index ae8403bd..cddd6e13 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Tag/tags.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Tag/tags.html.twig @@ -31,6 +31,6 @@
- {{ 'tag.list.see_untagged_entries'|trans }} + {{ 'tag.list.see_untagged_entries'|trans }} ({{untagged}})
{% endblock %} diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig index 79907bbb..552cafc9 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig @@ -34,6 +34,6 @@
- {{ 'tag.list.see_untagged_entries'|trans }} + {{ 'tag.list.see_untagged_entries'|trans }} ({{untagged}})
{% endblock %}