1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-09-15 18:57:05 +00:00

Added tag deletion from tags list

Fixed #2952
This commit is contained in:
Nicolas Lœuillet 2022-06-14 16:45:02 +02:00 committed by Jeremy Benoist
parent 2984c0dfcc
commit 4feca1ccd5
No known key found for this signature in database
GPG key ID: BCA73962457ACC3C
3 changed files with 75 additions and 0 deletions

View file

@ -222,4 +222,29 @@ class TagController extends Controller
return $this->redirect($this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true));
}
/**
* Delete a given tag for the current user.
*
* @Route("/tag/delete/{slug}", name="tag_delete")
* @ParamConverter("tag", options={"mapping": {"slug": "slug"}})
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function removeTagAction(Tag $tag, Request $request) {
foreach ($tag->getEntriesByUserId($this->getUser()->getId()) as $entry) {
$this->get('wallabag_core.entry_repository')->removeTag($this->getUser()->getId(), $tag);
}
// remove orphan tag in case no entries are associated to it
if (0 === \count($tag->getEntries())) {
$em = $this->getDoctrine()->getManager();
$em->remove($tag);
$em->flush();
}
$redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true);
return $this->redirect($redirectUrl);
}
}

View file

@ -26,6 +26,9 @@
<i class="material-icons">mode_edit</i>
</a>
{% endif %}
<a href="{{ path('tag_delete', {'slug': tag.slug})}}">
<i class="material-icons">mode_delete</i>
</a>
{% if app.user.config.feedToken %}
<a rel="alternate" type="application/atom+xml" href="{{ path('tag_feed', {'username': app.user.username, 'token': app.user.config.feedToken, 'slug': tag.slug}) }}" class="card-tag-icon"><i class="material-icons">rss_feed</i></a>
{% endif %}