From 812b4a906fcf2e7a491753b536f5d76ba4075cbe Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Fri, 23 Sep 2022 15:16:38 +0200 Subject: [PATCH] Add `nbEntries` to the API tags list response So client will be able to do the same as in the web UI. Also remove empty `div` from the tags template. --- src/Wallabag/ApiBundle/Controller/TagRestController.php | 2 +- .../Resources/views/themes/material/Tag/tags.html.twig | 4 ---- tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php | 3 +-- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Wallabag/ApiBundle/Controller/TagRestController.php b/src/Wallabag/ApiBundle/Controller/TagRestController.php index f3498f55a..1b9f3aea2 100644 --- a/src/Wallabag/ApiBundle/Controller/TagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/TagRestController.php @@ -23,7 +23,7 @@ class TagRestController extends WallabagRestController $tags = $this->getDoctrine() ->getRepository('WallabagCoreBundle:Tag') - ->findAllTags($this->getUser()->getId()); + ->findAllFlatTagsWithNbEntries($this->getUser()->getId()); $json = $this->get('jms_serializer')->serialize($tags, 'json'); 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 50afa6d5d..942d063c7 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 @@ -33,8 +33,4 @@ {% endfor %} - -
- -
{% endblock %} diff --git a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php index 9daa94cd5..6d50891d0 100644 --- a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php @@ -20,14 +20,13 @@ class TagRestControllerTest extends WallabagApiTestCase $this->assertGreaterThan(0, $content); $this->assertArrayHasKey('id', $content[0]); $this->assertArrayHasKey('label', $content[0]); + $this->assertArrayHasKey('nbEntries', $content[0]); $tagLabels = array_map(function ($i) { return $i['label']; }, $content); $this->assertNotContains($this->otherUserTagLabel, $tagLabels, 'There is a possible tag leak'); - - return end($content); } public function testDeleteUserTag()