From a664a1d876174e9d61d8324039ee86d2b6bf164d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20HULARD?= Date: Tue, 23 Jan 2018 19:09:03 +0100 Subject: Rename Tag : Add a new FormType --- .../CoreBundle/Form/Type/RenameTagType.php | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/Wallabag/CoreBundle/Form/Type/RenameTagType.php (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Form/Type/RenameTagType.php b/src/Wallabag/CoreBundle/Form/Type/RenameTagType.php new file mode 100644 index 00000000..e6270048 --- /dev/null +++ b/src/Wallabag/CoreBundle/Form/Type/RenameTagType.php @@ -0,0 +1,35 @@ +add('label', TextType::class, [ + 'required' => true, + 'attr' => [ + 'placeholder' => 'tag.rename.placeholder', + ], + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => 'Wallabag\CoreBundle\Entity\Tag', + ]); + } + + public function getBlockPrefix() + { + return 'tag'; + } +} -- cgit v1.2.3 From be326a22f90a5f4006ff41ee7b4ed0ca73a8fddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20HULARD?= Date: Wed, 24 Jan 2018 17:27:16 +0100 Subject: Create a new Tag action to rename tags. The current tag is removed from all the current logged user entries. Then the new one is created and attached. --- .../CoreBundle/Controller/TagController.php | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index b6d28e59..70b273e0 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -11,6 +11,7 @@ use Symfony\Component\HttpFoundation\Request; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Form\Type\NewTagType; +use Wallabag\CoreBundle\Form\Type\RenameTagType; class TagController extends Controller { @@ -130,4 +131,48 @@ class TagController extends Controller 'tag' => $tag, ]); } + + /** + * Rename a given tag with a new label + * Create a new tag with the new name and drop the old one. + * + * @param Tag $tag + * @param Request $request + * + * @Route("/tag/rename/{slug}", name="tag_rename") + * @ParamConverter("tag", options={"mapping": {"slug": "slug"}}) + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function renameTagAction(Tag $tag, Request $request) + { + $form = $this->createForm(RenameTagType::class, new Tag()); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entries = $this->get('wallabag_core.entry_repository')->findAllByTagId( + $this->getUser()->getId(), + $tag->getId() + ); + foreach ($entries as $entry) { + $this->get('wallabag_core.tags_assigner')->assignTagsToEntry( + $entry, + $form->get('label')->getData() + ); + $entry->removeTag($tag); + } + + $em = $this->getDoctrine()->getManager(); + $em->flush(); + } + + $this->get('session')->getFlashBag()->add( + 'notice', + 'flashes.tag.notice.tag_renamed' + ); + + $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true); + + return $this->redirect($redirectUrl); + } } -- cgit v1.2.3 From b846c1e4d03ec51ae6b740040d79d47d9bdec12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20HULARD?= Date: Wed, 24 Jan 2018 18:04:39 +0100 Subject: Add RenameForm as tag list view parameters. This will help handling the CSRF protection token and use symfony HTML generation layer. Also a FormView instance is generated for each tag because we need to render a form for each tag and FormView are not reusable. --- src/Wallabag/CoreBundle/Controller/TagController.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php index 70b273e0..a041510d 100644 --- a/src/Wallabag/CoreBundle/Controller/TagController.php +++ b/src/Wallabag/CoreBundle/Controller/TagController.php @@ -88,8 +88,14 @@ class TagController extends Controller $tags = $this->get('wallabag_core.tag_repository') ->findAllFlatTagsWithNbEntries($this->getUser()->getId()); + $renameForms = []; + foreach ($tags as $tag) { + $renameForms[$tag['id']] = $this->createForm(RenameTagType::class, new Tag())->createView(); + } + return $this->render('WallabagCoreBundle:Tag:tags.html.twig', [ 'tags' => $tags, + 'renameForms' => $renameForms, ]); } -- cgit v1.2.3 From 9b0aef9171389aa9cdc39e8434df0f912ee5bdae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20HULARD?= Date: Wed, 24 Jan 2018 17:29:26 +0100 Subject: Update tag list template to allow renaming. * Add a form on each tag to handle rename action. * Add JavaScript to handle action on the corresponding page inside the global index.js file. * Add support for the 2 active themes : material / baggy The form solution is cleaner than an Ajax one because it let the browser validate input data and make the POST easier without the need to handle JSON response. --- .../Resources/views/themes/baggy/Tag/tags.html.twig | 18 +++++++++++++++--- .../Resources/views/themes/material/Tag/tags.html.twig | 13 ++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) (limited to 'src') 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 070d5629..35351ab1 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 @@ -10,10 +10,22 @@ 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 c15b5146..21e88a9a 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 @@ -13,7 +13,18 @@
    {% for tag in tags %}
  • - {{tag.label}} ({{ tag.nbEntries }}) + + {{ tag.label }} ({{ tag.nbEntries }}) + + {% if renameForms is defined and renameForms[tag.id] is defined %} + + + mode_edit + + {% endif %} {% if app.user.config.rssToken %} rss_feed {% endif %} -- cgit v1.2.3 From 559f708cae6143564284034369771737119a6bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20HULARD?= Date: Wed, 24 Jan 2018 17:29:41 +0100 Subject: Add translations about latest Tag changes. Add new translations in each language file. --- src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml | 5 ++++- src/Wallabag/CoreBundle/Resources/translations/messages.th.yml | 3 +++ src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml | 3 +++ 14 files changed, 43 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index e1384675..c8500ad3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -399,6 +399,8 @@ tag: new: # add: 'Add' # placeholder: 'You can add several tags, separated by a comma.' + rename: + # placeholder: 'You can update tag name.' # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: # tag_added: 'Tag added' + # tag_renamed: 'Tag renamed' import: notice: # failed: 'Import failed, please try again.' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index c297ffb5..888d9b39 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -399,6 +399,8 @@ tag: new: add: 'Hinzufügen' placeholder: 'Du kannst verschiedene Tags, getrennt von einem Komma, hinzufügen.' + rename: + # placeholder: 'You can update tag name.' export: footer_template: '

    Generiert von wallabag mit Hilfe von %method%

    Bitte öffne ein Ticket wenn du ein Problem mit der Darstellung von diesem E-Book auf deinem Gerät hast.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: tag_added: 'Tag hinzugefügt' + #tag_renamed: 'Tag renamed' import: notice: failed: 'Import fehlgeschlagen, bitte erneut probieren.' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index bd81c72f..827bf770 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -399,6 +399,8 @@ tag: new: add: 'Add' placeholder: 'You can add several tags, separated by a comma.' + rename: + placeholder: 'You can update tag name.' export: footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: tag_added: 'Tag added' + tag_renamed: 'Tag renamed' import: notice: failed: 'Import failed, please try again.' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 700190a6..e5878f2c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -399,6 +399,8 @@ tag: new: add: 'Añadir' placeholder: 'Puedes añadir varias etiquetas, separadas por una coma.' + rename: + # placeholder: 'You can update tag name.' # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: tag_added: 'Etiqueta añadida' + # tag_renamed: 'Tag renamed' import: notice: failed: 'Importación fallida, por favor, inténtelo de nuevo.' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 83645933..2e922358 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -399,6 +399,8 @@ tag: new: # add: 'Add' # placeholder: 'You can add several tags, separated by a comma.' + rename: + # placeholder: 'You can update tag name.' # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: tag_added: 'برچسب افزوده شد' + # tag_renamed: 'Tag renamed' import: notice: failed: 'درون‌ریزی شکست خورد. لطفاً دوباره تلاش کنید.' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index edf29654..cf5031d3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -399,6 +399,8 @@ tag: new: add: "Ajouter" placeholder: "Vous pouvez ajouter plusieurs tags, séparés par une virgule." + rename: + placeholder: 'Vous pouvez changer le nom de votre tag.' export: footer_template: '

    Généré par wallabag with %method%

    Merci d''ouvrir un ticket si vous rencontrez des soucis d''affichage avec ce document sur votre support.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: tag_added: "Tag ajouté" + tag_renamed: "Tag renommé" import: notice: failed: "L’import a échoué, veuillez ré-essayer" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 47292116..1563703a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -399,6 +399,8 @@ tag: new: add: 'Aggiungi' placeholder: 'Puoi aggiungere varie etichette, separate da una virgola.' + rename: + # placeholder: 'You can update tag name.' # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: tag_added: 'Etichetta aggiunta' + # tag_renamed: 'Tag renamed' import: notice: failed: 'Importazione fallita, riprova.' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 95bc9560..9e9f8a2f 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -399,6 +399,8 @@ tag: new: add: 'Ajustar' placeholder: "Podètz ajustar mai qu'una etiqueta, separadas per de virgula." + rename: + # placeholder: 'You can update tag name.' export: footer_template: '

    Produch per wallabag amb %method%

    Mercés de dobrir una sollicitacion s’avètz de problèmas amb l’afichatge d’aqueste E-Book sus vòstre periferic.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: tag_added: 'Etiqueta ajustada' + # tag_renamed: 'Tag renamed' import: notice: failed: "L'importacion a fracassat, mercés de tornar ensajar." diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index a64e60b0..4e2238d2 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -399,6 +399,8 @@ tag: new: add: 'Dodaj' placeholder: 'Możesz dodać kilka tagów, oddzielając je przecinkami.' + rename: + # placeholder: 'You can update tag name.' export: footer_template: '

    Stworzone przez wallabag z %method%

    Proszę zgłoś sprawę, jeżeli masz problem z wyświetleniem tego e-booka na swoim urządzeniu.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: tag_added: 'Tag dodany' + # tag_renamed: 'Tag renamed' import: notice: failed: 'Nieudany import, prosimy spróbować ponownie.' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index 7aef9694..127b425e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@ -399,6 +399,8 @@ tag: new: # add: 'Add' # placeholder: 'You can add several tags, separated by a comma.' + rename: + # placeholder: 'You can update tag name.' # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: tag_added: 'Tag adicionada' + # tag_renamed: 'Tag renamed' import: notice: failed: 'Importação falhou, por favor tente novamente.' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 9b7068c6..e68a91ec 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -399,6 +399,8 @@ tag: new: # add: 'Add' # placeholder: 'You can add several tags, separated by a comma.' + rename: + # placeholder: 'You can update tag name.' # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' @@ -585,6 +587,7 @@ flashes: tag: notice: # tag_added: 'Tag added' + # tag_renamed: 'Tag renamed' import: notice: # failed: 'Import failed, please try again.' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml index 5f210c93..d713f13f 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ru.yml @@ -387,6 +387,8 @@ tag: new: add: 'Добавить' placeholder: 'Вы можете добавить несколько тегов, разделенных запятой.' + rename: + # placeholder: 'You can update tag name.' import: page_title: 'Импорт' @@ -547,6 +549,7 @@ flashes: tag: notice: tag_added: 'Тег добавлен' + # tag_renamed: 'Tag renamed' import: notice: failed: 'Во время импорта произошла ошибка, повторите попытку.' @@ -564,4 +567,4 @@ flashes: notice: added: 'Пользователь "%username%" добавлен' updated: 'Пользователь "%username%" обновлен' - deleted: 'Пользователь "%username%" удален' \ No newline at end of file + deleted: 'Пользователь "%username%" удален' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml index 9d22f90d..78e0f0ee 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.th.yml @@ -397,6 +397,8 @@ tag: new: add: 'เพิ่ม' placeholder: 'คุณสามารถเพิ่มได้หลายแท็ก, จากการแบ่งโดย comma' + rename: + # placeholder: 'You can update tag name.' export: footer_template: '

    ผลิตโดย wallabag กับ %method%

    ให้ทำการเปิด ฉบับนี้ ถ้าคุณมีข้อบกพร่องif you have trouble with the display of this E-Book on your device.

    ' @@ -583,6 +585,7 @@ flashes: tag: notice: tag_added: 'แท็กที่เพิ่ม' + # tag_renamed: 'Tag renamed' import: notice: failed: 'นำข้อมูลเข้าล้มเหลว, ลองใหม่อีกครั้ง' diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 5c95fe63..c48a885f 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -397,6 +397,8 @@ tag: new: # add: 'Add' # placeholder: 'You can add several tags, separated by a comma.' + rename: + # placeholder: 'You can update tag name.' # export: # footer_template: '

    Produced by wallabag with %method%

    Please open an issue if you have trouble with the display of this E-Book on your device.

    ' @@ -563,6 +565,7 @@ flashes: tag: notice: tag_added: 'Etiket eklendi' + # tag_renamed: 'Tag renamed' import: notice: # failed: 'Import failed, please try again.' -- cgit v1.2.3