]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Show untagged entries count on tag list
authorKevin Decherf <kevin@kdecherf.com>
Sun, 2 Sep 2018 14:43:49 +0000 (16:43 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Wed, 5 Jun 2019 15:03:51 +0000 (17:03 +0200)
Closes #3235

Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
src/Wallabag/CoreBundle/Controller/TagController.php
src/Wallabag/CoreBundle/Repository/EntryRepository.php
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Tag/tags.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Tag/tags.html.twig

index d0155c6018bde6877786e1817a637deee6b18604..bd50de7fb87aeb2784cae3755c18ba1182d225eb 100644 (file)
@@ -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,
         ]);
     }
 
index 16c448851f444e73f3652313e1baffaa09ea9e40..77d88c9c25e73f1e98f670559d6ec98ac97cedc5 100644 (file)
@@ -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.
      *
index ae8403bd695099486f59930984728ad67286c2bf..cddd6e13d3e6827be7e456caf73493f99c5fbf97 100644 (file)
@@ -31,6 +31,6 @@
     </ul>
 
     <div>
-        <a href="{{ path('untagged') }}">{{ 'tag.list.see_untagged_entries'|trans }}</a>
+        <a href="{{ path('untagged') }}">{{ 'tag.list.see_untagged_entries'|trans }} ({{untagged}})</a>
     </div>
 {% endblock %}
index 79907bbb51f971a5aff744ff03b5da1847a821a5..552cafc948aad8be691fccfee716ca3a914f5ae4 100644 (file)
@@ -34,6 +34,6 @@
     </div>
 
     <div>
-        <a href="{{ path('untagged') }}">{{ 'tag.list.see_untagged_entries'|trans }}</a>
+        <a href="{{ path('untagged') }}">{{ 'tag.list.see_untagged_entries'|trans }} ({{untagged}})</a>
     </div>
 {% endblock %}