From c37515f880bd05b86e3e848cc184018295ec1920 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 27 Apr 2017 15:58:32 +0200 Subject: Add filter to users management page Signed-off-by: Thomas Citharel --- .../Resources/translations/messages.da.yml | 3 ++ .../Resources/translations/messages.de.yml | 3 ++ .../Resources/translations/messages.en.yml | 3 ++ .../Resources/translations/messages.es.yml | 3 ++ .../Resources/translations/messages.fa.yml | 3 ++ .../Resources/translations/messages.fr.yml | 3 ++ .../Resources/translations/messages.it.yml | 3 ++ .../Resources/translations/messages.oc.yml | 3 ++ .../Resources/translations/messages.pl.yml | 3 ++ .../Resources/translations/messages.pt.yml | 3 ++ .../Resources/translations/messages.ro.yml | 3 ++ .../Resources/translations/messages.tr.yml | 3 ++ .../UserBundle/Controller/ManageController.php | 42 +++++++++++++++ src/Wallabag/UserBundle/Form/SearchUserType.php | 29 ++++++++++ .../UserBundle/Repository/UserRepository.php | 15 ++++++ .../Resources/views/Manage/index.html.twig | 61 ++++++++++++---------- .../Resources/views/Manage/search_form.html.twig | 15 ++++++ 17 files changed, 170 insertions(+), 28 deletions(-) create mode 100644 src/Wallabag/UserBundle/Form/SearchUserType.php create mode 100644 src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 72493fe3..68fcec5c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -512,6 +512,9 @@ user: # delete: Delete # delete_confirm: Are you sure? # back_to_list: Back to list + search: + # label: Filter + # placeholder: Filter by username or email error: # page_title: An error occurred diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index dbad8b16..be117231 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -512,6 +512,9 @@ user: delete: Löschen delete_confirm: Bist du sicher? back_to_list: Zurück zur Liste + search: + # label: Filter + # placeholder: Filter by username or email error: page_title: Ein Fehler ist aufgetreten diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 42a12b2a..b3850893 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -512,6 +512,9 @@ user: delete: Delete delete_confirm: Are you sure? back_to_list: Back to list + search: + label: Filter + placeholder: Filter by username or email error: page_title: An error occurred diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 6e21614e..ebf6745a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -512,6 +512,9 @@ user: delete: Eliminar delete_confirm: ¿Estás seguro? back_to_list: Volver a la lista + search: + # label: Filter + # placeholder: Filter by username or email error: page_title: Ha ocurrido un error diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index b938c80a..46460e13 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -512,6 +512,9 @@ user: # delete: Delete # delete_confirm: Are you sure? # back_to_list: Back to list + search: + # label: Filter + # placeholder: Filter by username or email error: # page_title: An error occurred diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 9abcda45..c968f7ab 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -512,6 +512,9 @@ user: delete: "Supprimer" delete_confirm: "Voulez-vous vraiment ?" back_to_list: "Revenir à la liste" + search: + label: Filtrer + placeholder: Filtrer par nom d'utilisateur ou email error: page_title: Une erreur est survenue diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 58d0962a..53b5e1b9 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -512,6 +512,9 @@ user: # delete: Delete # delete_confirm: Are you sure? # back_to_list: Back to list + search: + # label: Filter + # placeholder: Filter by username or email error: # page_title: An error occurred diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 825a0efd..c6614a63 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -512,6 +512,9 @@ user: delete: 'Suprimir' delete_confirm: 'Sètz segur ?' back_to_list: 'Tornar a la lista' + search: + # label: Filter + # placeholder: Filter by username or email error: page_title: Una error s'es produsida diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index b02aa4ec..b464d0f6 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -512,6 +512,9 @@ user: delete: Usuń delete_confirm: Jesteś pewien? back_to_list: Powrót do listy + search: + # label: Filter + # placeholder: Filter by username or email error: page_title: Wystąpił błąd diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index 8aa7e5af..2b0b1686 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@ -512,6 +512,9 @@ user: delete: 'Apagar' delete_confirm: 'Tem certeza?' back_to_list: 'Voltar para a lista' + search: + # label: Filter + # placeholder: Filter by username or email error: # page_title: An error occurred diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index ce8d8d52..210978d0 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -512,6 +512,9 @@ user: # delete: Delete # delete_confirm: Are you sure? # back_to_list: Back to list + search: + # label: Filter + # placeholder: Filter by username or email error: # page_title: An error occurred diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index d8903608..5ff5e012 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -512,6 +512,9 @@ user: # delete: Delete # delete_confirm: Are you sure? # back_to_list: Back to list + search: + # label: Filter + # placeholder: Filter by username or email error: # page_title: An error occurred diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php index 92ee2b41..f0e3d4de 100644 --- a/src/Wallabag/UserBundle/Controller/ManageController.php +++ b/src/Wallabag/UserBundle/Controller/ManageController.php @@ -10,6 +10,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Wallabag\UserBundle\Entity\User; use Wallabag\CoreBundle\Entity\Config; +use Wallabag\UserBundle\Form\SearchUserType; /** * User controller. @@ -146,4 +147,45 @@ class ManageController extends Controller ->getForm() ; } + + /** + * @param Request $request + * @param int $page + * + * @Route("/search/{page}", name="user-search", defaults={"page" = 1}) + * + * Default parameter for page is hardcoded (in duplication of the defaults from the Route) + * because this controller is also called inside the layout template without any page as argument + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function searchFormAction(Request $request, $page = 1, $currentRoute = null) + { + // fallback to retrieve currentRoute from query parameter instead of injected one (when using inside a template) + if (null === $currentRoute && $request->query->has('currentRoute')) { + $currentRoute = $request->query->get('currentRoute'); + } + + $form = $this->createForm(SearchUserType::class); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->get('logger')->info('searching users'); + $em = $this->getDoctrine()->getManager(); + + $searchTerm = (isset($request->get('search_user')['term']) ? $request->get('search_user')['term'] : ''); + + $users = $em->getRepository('WallabagUserBundle:User')->getUsersForSearch($searchTerm); + + return $this->render('WallabagUserBundle:Manage:index.html.twig', array( + 'users' => $users, + )); + } + + return $this->render('WallabagUserBundle:Manage:search_form.html.twig', [ + 'form' => $form->createView(), + 'currentRoute' => $currentRoute, + ]); + } } diff --git a/src/Wallabag/UserBundle/Form/SearchUserType.php b/src/Wallabag/UserBundle/Form/SearchUserType.php new file mode 100644 index 00000000..9ce46ee1 --- /dev/null +++ b/src/Wallabag/UserBundle/Form/SearchUserType.php @@ -0,0 +1,29 @@ +setMethod('GET') + ->add('term', TextType::class, [ + 'required' => true, + 'label' => 'user.new.form_search.term_label', + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'csrf_protection' => false, + ]); + } +} diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php index f913f52d..66bbab39 100644 --- a/src/Wallabag/UserBundle/Repository/UserRepository.php +++ b/src/Wallabag/UserBundle/Repository/UserRepository.php @@ -52,4 +52,19 @@ class UserRepository extends EntityRepository ->getQuery() ->getSingleScalarResult(); } + + /** + * Retrieves users filtered with a search term. + * + * @param string $term + * + * @return QueryBuilder + */ + public function getUsersForSearch($term) + { + return $this->createQueryBuilder('u') + ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%'.$term.'%') + ->getQuery() + ->getResult(); + } } diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig index daba29e4..abc02852 100644 --- a/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig @@ -8,36 +8,41 @@
-
+

{{ 'user.description'|trans|raw }}

- - - - - - - - - - - - {% for user in users %} - - - - - - - {% endfor %} - -
{{ 'user.form.username_label'|trans }}{{ 'user.form.email_label'|trans }}{{ 'user.form.last_login_label'|trans }}{{ 'user.list.actions'|trans }}
{{ user.username }}{{ user.email }}{% if user.lastLogin %}{{ user.lastLogin|date('Y-m-d H:i:s') }}{% endif %} - {{ 'user.list.edit_action'|trans }} -
-
-

- {{ 'user.list.create_new_one'|trans }} -

+
+
+ {{ render(controller("WallabagUserBundle:Manage:searchForm", {'currentRoute': app.request.attributes.get('_route')})) }} +
+
+ + + + + + + + + + + + {% for user in users %} + + + + + + + {% endfor %} + +
{{ 'user.form.username_label'|trans }}{{ 'user.form.email_label'|trans }}{{ 'user.form2017-03-10 16:51:07.last_login_label'|trans }}{{ 'user.list.actions'|trans }}
{{ user.username }}{{ user.email }}{% if user.lastLogin %}{{ user.lastLogin|date('Y-m-d H:i:s') }}{% endif %} + {{ 'user.list.edit_action'|trans }} +
+
+

+ {{ 'user.list.create_new_one'|trans }} +

diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig new file mode 100644 index 00000000..f59388d0 --- /dev/null +++ b/src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig @@ -0,0 +1,15 @@ +
+ {% if form_errors(form) %} + {{ form_errors(form) }} + {% endif %} + + {% if form_errors(form.term) %} + {{ form_errors(form.term) }} + {% endif %} + + search + {{ form_widget(form.term, { 'attr': {'autocomplete': 'off', 'placeholder': 'user.search.placeholder'} }) }} + + + {{ form_rest(form) }} +
-- cgit v1.2.3 From 50cfd8108b8e318fd28564d2e9d30943ab12aac0 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 27 Apr 2017 16:23:54 +0200 Subject: Add pagination Signed-off-by: Thomas Citharel --- .../UserBundle/Controller/ManageController.php | 43 ++++++++++++++++++---- .../UserBundle/Repository/UserRepository.php | 6 +-- .../Resources/views/Manage/index.html.twig | 8 +++- 3 files changed, 45 insertions(+), 12 deletions(-) diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php index f0e3d4de..86fcd431 100644 --- a/src/Wallabag/UserBundle/Controller/ManageController.php +++ b/src/Wallabag/UserBundle/Controller/ManageController.php @@ -4,12 +4,14 @@ namespace Wallabag\UserBundle\Controller; use FOS\UserBundle\Event\UserEvent; use FOS\UserBundle\FOSUserEvents; +use Pagerfanta\Adapter\DoctrineORMAdapter; +use Pagerfanta\Exception\OutOfRangeCurrentPageException; +use Pagerfanta\Pagerfanta; use Symfony\Component\HttpFoundation\Request; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Wallabag\UserBundle\Entity\User; -use Wallabag\CoreBundle\Entity\Config; use Wallabag\UserBundle\Form\SearchUserType; /** @@ -20,17 +22,32 @@ class ManageController extends Controller /** * Lists all User entities. * - * @Route("/", name="user_index") + * @Route("/index/{page}", name="user_index") * @Method("GET") + * + * @param int $page + * + * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response */ - public function indexAction() + public function indexAction($page = 1) { $em = $this->getDoctrine()->getManager(); - $users = $em->getRepository('WallabagUserBundle:User')->findAll(); + $qb = $em->getRepository('WallabagUserBundle:User')->createQueryBuilder('u'); + $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false); + $pagerFanta = new Pagerfanta($pagerAdapter); + $pagerFanta->setMaxPerPage(50); + + try { + $pagerFanta->setCurrentPage($page); + } catch (OutOfRangeCurrentPageException $e) { + if ($page > 1) { + return $this->redirect($this->generateUrl('user_index', ['page' => $pagerFanta->getNbPages()]), 302); + } + } return $this->render('WallabagUserBundle:Manage:index.html.twig', array( - 'users' => $users, + 'users' => $pagerFanta, )); } @@ -176,10 +193,22 @@ class ManageController extends Controller $searchTerm = (isset($request->get('search_user')['term']) ? $request->get('search_user')['term'] : ''); - $users = $em->getRepository('WallabagUserBundle:User')->getUsersForSearch($searchTerm); + $qb = $em->getRepository('WallabagUserBundle:User')->getQueryBuilderForSearch($searchTerm); + + $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false); + $pagerFanta = new Pagerfanta($pagerAdapter); + $pagerFanta->setMaxPerPage(50); + + try { + $pagerFanta->setCurrentPage($page); + } catch (OutOfRangeCurrentPageException $e) { + if ($page > 1) { + return $this->redirect($this->generateUrl('user_index', ['page' => $pagerFanta->getNbPages()]), 302); + } + } return $this->render('WallabagUserBundle:Manage:index.html.twig', array( - 'users' => $users, + 'users' => $pagerFanta, )); } diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php index 66bbab39..6adbe329 100644 --- a/src/Wallabag/UserBundle/Repository/UserRepository.php +++ b/src/Wallabag/UserBundle/Repository/UserRepository.php @@ -60,11 +60,9 @@ class UserRepository extends EntityRepository * * @return QueryBuilder */ - public function getUsersForSearch($term) + public function getQueryBuilderForSearch($term) { return $this->createQueryBuilder('u') - ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%'.$term.'%') - ->getQuery() - ->getResult(); + ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%'.$term.'%'); } } diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig index abc02852..7a76f157 100644 --- a/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig @@ -7,6 +7,9 @@
+ {% if users.getNbPages > 1 %} + {{ pagerfanta(users, 'twitter_bootstrap_translated', {'proximity': 1}) }} + {% endif %}

{{ 'user.description'|trans|raw }}

@@ -22,7 +25,7 @@ {{ 'user.form.username_label'|trans }} {{ 'user.form.email_label'|trans }} - {{ 'user.form2017-03-10 16:51:07.last_login_label'|trans }} + {{ 'user.form.last_login_label'|trans }} {{ 'user.list.actions'|trans }} @@ -43,6 +46,9 @@

{{ 'user.list.create_new_one'|trans }}

+ {% if users.getNbPages > 1 %} + {{ pagerfanta(users, 'twitter_bootstrap_translated', {'proximity': 1}) }} + {% endif %}
-- cgit v1.2.3 From a2daa32d0c6f71aa8553aed3c6ed58d7aa861baa Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 27 Apr 2017 16:40:18 +0200 Subject: Fix tests Signed-off-by: Thomas Citharel --- .../Resources/views/Manage/search_form.html.twig | 2 +- .../UserBundle/Controller/ManageControllerTest.php | 26 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig index f59388d0..1d4df204 100644 --- a/src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig @@ -1,4 +1,4 @@ -
+ {% if form_errors(form) %} {{ form_errors(form) }} {% endif %} diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php index 4faddfc4..4154ad12 100644 --- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php +++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php @@ -10,7 +10,7 @@ class ManageControllerTest extends WallabagCoreTestCase { $client = $this->getClient(); - $client->request('GET', '/users/'); + $client->request('GET', '/users/index'); $this->assertEquals(302, $client->getResponse()->getStatusCode()); $this->assertContains('login', $client->getResponse()->headers->get('location')); @@ -22,7 +22,7 @@ class ManageControllerTest extends WallabagCoreTestCase $client = $this->getClient(); // Create a new user in the database - $crawler = $client->request('GET', '/users/'); + $crawler = $client->request('GET', '/users/index'); $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/'); $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link()); @@ -36,7 +36,7 @@ class ManageControllerTest extends WallabagCoreTestCase $client->submit($form); $client->followRedirect(); - $crawler = $client->request('GET', '/users/'); + $crawler = $client->request('GET', '/users/index'); // Check data in the show view $this->assertGreaterThan(0, $crawler->filter('td:contains("test_user")')->count(), 'Missing element td:contains("test_user")'); @@ -57,7 +57,7 @@ class ManageControllerTest extends WallabagCoreTestCase // Check the element contains an attribute with value equals "Foo User" $this->assertGreaterThan(0, $crawler->filter('[value="Foo User"]')->count(), 'Missing element [value="Foo User"]'); - $crawler = $client->request('GET', '/users/'); + $crawler = $client->request('GET', '/users/index'); $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); // Delete the user @@ -78,4 +78,22 @@ class ManageControllerTest extends WallabagCoreTestCase $this->assertEquals('disabled', $disabled[0]); } + + public function testUserSearch() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + // Search on unread list + $crawler = $client->request('GET', '/users/index'); + + $form = $crawler->filter('form[name=search_users]')->form(); + $data = [ + 'search_user[term]' => 'admin', + ]; + + $crawler = $client->submit($form, $data); + + $this->assertCount(2, $crawler->filter('tr')); // 1 result + table header + } } -- cgit v1.2.3 From d01dc5a81e7fde37d98fe6b10b9329b53add5b6a Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Sat, 29 Apr 2017 19:39:51 +0200 Subject: rename index to list Signed-off-by: Thomas Citharel --- src/Wallabag/UserBundle/Controller/ManageController.php | 2 +- tests/Wallabag/UserBundle/Controller/ManageControllerTest.php | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php index 86fcd431..3ea773ee 100644 --- a/src/Wallabag/UserBundle/Controller/ManageController.php +++ b/src/Wallabag/UserBundle/Controller/ManageController.php @@ -22,7 +22,7 @@ class ManageController extends Controller /** * Lists all User entities. * - * @Route("/index/{page}", name="user_index") + * @Route("/list/{page}", name="user_index") * @Method("GET") * * @param int $page diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php index 4154ad12..44b9a030 100644 --- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php +++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php @@ -10,7 +10,7 @@ class ManageControllerTest extends WallabagCoreTestCase { $client = $this->getClient(); - $client->request('GET', '/users/index'); + $client->request('GET', '/users/list'); $this->assertEquals(302, $client->getResponse()->getStatusCode()); $this->assertContains('login', $client->getResponse()->headers->get('location')); @@ -22,7 +22,7 @@ class ManageControllerTest extends WallabagCoreTestCase $client = $this->getClient(); // Create a new user in the database - $crawler = $client->request('GET', '/users/index'); + $crawler = $client->request('GET', '/users/list'); $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/'); $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link()); @@ -36,7 +36,7 @@ class ManageControllerTest extends WallabagCoreTestCase $client->submit($form); $client->followRedirect(); - $crawler = $client->request('GET', '/users/index'); + $crawler = $client->request('GET', '/users/list'); // Check data in the show view $this->assertGreaterThan(0, $crawler->filter('td:contains("test_user")')->count(), 'Missing element td:contains("test_user")'); @@ -57,7 +57,7 @@ class ManageControllerTest extends WallabagCoreTestCase // Check the element contains an attribute with value equals "Foo User" $this->assertGreaterThan(0, $crawler->filter('[value="Foo User"]')->count(), 'Missing element [value="Foo User"]'); - $crawler = $client->request('GET', '/users/index'); + $crawler = $client->request('GET', '/users/list'); $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); // Delete the user @@ -85,7 +85,7 @@ class ManageControllerTest extends WallabagCoreTestCase $client = $this->getClient(); // Search on unread list - $crawler = $client->request('GET', '/users/index'); + $crawler = $client->request('GET', '/users/list'); $form = $crawler->filter('form[name=search_users]')->form(); $data = [ -- cgit v1.2.3 From b5b6877976bc32f23e51c2fb0f3f973f0d571b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 2 May 2017 15:27:58 +0200 Subject: Merged list and search methods --- .../Resources/translations/messages.da.yml | 1 - .../Resources/translations/messages.de.yml | 1 - .../Resources/translations/messages.en.yml | 1 - .../Resources/translations/messages.es.yml | 1 - .../Resources/translations/messages.fa.yml | 1 - .../Resources/translations/messages.fr.yml | 141 ++++++++++----------- .../Resources/translations/messages.it.yml | 1 - .../Resources/translations/messages.oc.yml | 1 - .../Resources/translations/messages.pl.yml | 1 - .../Resources/translations/messages.pt.yml | 1 - .../Resources/translations/messages.ro.yml | 1 - .../Resources/translations/messages.tr.yml | 1 - .../UserBundle/Controller/ManageController.php | 72 +++-------- .../Resources/views/Manage/index.html.twig | 14 +- .../Resources/views/Manage/search_form.html.twig | 15 --- 15 files changed, 99 insertions(+), 154 deletions(-) delete mode 100644 src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 68fcec5c..23390c12 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml @@ -513,7 +513,6 @@ user: # delete_confirm: Are you sure? # back_to_list: Back to list search: - # label: Filter # placeholder: Filter by username or email error: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index be117231..71c935c8 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml @@ -513,7 +513,6 @@ user: delete_confirm: Bist du sicher? back_to_list: Zurück zur Liste search: - # label: Filter # placeholder: Filter by username or email error: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index b3850893..a5540c86 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml @@ -513,7 +513,6 @@ user: delete_confirm: Are you sure? back_to_list: Back to list search: - label: Filter placeholder: Filter by username or email error: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index ebf6745a..ba8bdc5a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml @@ -513,7 +513,6 @@ user: delete_confirm: ¿Estás seguro? back_to_list: Volver a la lista search: - # label: Filter # placeholder: Filter by username or email error: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index 46460e13..7ef39e40 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml @@ -513,7 +513,6 @@ user: # delete_confirm: Are you sure? # back_to_list: Back to list search: - # label: Filter # placeholder: Filter by username or email error: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index c968f7ab..48036cf7 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml @@ -46,7 +46,7 @@ footer: social: "Social" powered_by: "propulsé par" about: "À propos" - stats: Depuis le %user_creation%, vous avez lu %nb_archives% articles. Ce qui fait %per_day% par jour ! + stats: "Depuis le %user_creation%, vous avez lu %nb_archives% articles. Ce qui fait %per_day% par jour !" config: page_title: "Configuration" @@ -71,16 +71,16 @@ config: 300_word: "Je lis environ 300 mots par minute" 400_word: "Je lis environ 400 mots par minute" action_mark_as_read: - label: 'Où souhaitez-vous être redirigé après avoir marqué un article comme lu ?' - redirect_homepage: "À la page d'accueil" - redirect_current_page: 'À la page courante' - pocket_consumer_key_label: Clé d’authentification Pocket pour importer les données - android_configuration: Configurez votre application Android - help_theme: "L'affichage de wallabag est personnalisable. C'est ici que vous choisissez le thème que vous préférez." - help_items_per_page: "Vous pouvez définir le nombre d'articles affichés sur chaque page." + label: "Où souhaitez-vous être redirigé après avoir marqué un article comme lu ?" + redirect_homepage: "À la page d’accueil" + redirect_current_page: "À la page courante" + pocket_consumer_key_label: "Clé d’authentification Pocket pour importer les données" + android_configuration: "Configurez votre application Android" + help_theme: "L’affichage de wallabag est personnalisable. C’est ici que vous choisissez le thème que vous préférez." + help_items_per_page: "Vous pouvez définir le nombre d’articles affichés sur chaque page." help_reading_speed: "wallabag calcule une durée de lecture pour chaque article. Vous pouvez définir ici, grâce à cette liste déroulante, si vous lisez plus ou moins vite. wallabag recalculera la durée de lecture de chaque article." - help_language: "Vous pouvez définir la langue de l'interface de wallabag." - help_pocket_consumer_key: "Nécessaire pour l'import depuis Pocket. Vous pouvez le créer depuis votre compte Pocket." + help_language: "Vous pouvez définir la langue de l’interface de wallabag." + help_pocket_consumer_key: "Nécessaire pour l’import depuis Pocket. Vous pouvez le créer depuis votre compte Pocket." form_rss: description: "Les flux RSS fournis par wallabag vous permettent de lire vos articles sauvegardés dans votre lecteur de flux préféré. Pour pouvoir les utiliser, vous devez d’abord créer un jeton." token_label: "Jeton RSS" @@ -100,18 +100,18 @@ config: twoFactorAuthentication_label: "Double authentification" help_twoFactorAuthentication: "Si vous activez 2FA, à chaque tentative de connexion à wallabag, vous recevrez un code par email." delete: - title: Supprimer mon compte (attention danger !) - description: Si vous confirmez la suppression de votre compte, TOUS les articles, TOUS les tags, TOUTES les annotations et votre compte seront DÉFINITIVEMENT supprimé (c'est IRRÉVERSIBLE). Vous serez ensuite déconnecté. - confirm: Vous êtes vraiment sûr ? (C'EST IRRÉVERSIBLE) - button: 'Supprimer mon compte' + title: "Supprimer mon compte (attention danger !)" + description: "Si vous confirmez la suppression de votre compte, TOUS les articles, TOUS les tags, TOUTES les annotations et votre compte seront DÉFINITIVEMENT supprimé (c’est IRRÉVERSIBLE). Vous serez ensuite déconnecté." + confirm: "Vous êtes vraiment sûr ? (C’EST IRRÉVERSIBLE)" + button: "Supprimer mon compte" reset: - title: Réinitialisation (attention danger !) - description: En cliquant sur les boutons ci-dessous vous avez la possibilité de supprimer certaines informations de votre compte. Attention, ces actions sont IRRÉVERSIBLES ! - annotations: Supprimer TOUTES les annotations - tags: Supprimer TOUS les tags - entries: Supprimer TOUS les articles - archived: Supprimer TOUS les articles archivés - confirm: Êtes-vous vraiment vraiment sûr ? (C'EST IRRÉVERSIBLE) + title: "Réinitialisation (attention danger !)" + description: "En cliquant sur les boutons ci-dessous vous avez la possibilité de supprimer certaines informations de votre compte. Attention, ces actions sont IRRÉVERSIBLES !" + annotations: "Supprimer TOUTES les annotations" + tags: "Supprimer TOUS les tags" + entries: "Supprimer TOUS les articles" + archived: "Supprimer TOUS les articles archivés" + confirm: "Êtes-vous vraiment vraiment sûr ? (C’EST IRRÉVERSIBLE)" form_password: description: "Vous pouvez changer ici votre mot de passe. Le mot de passe doit contenir au moins 8 caractères." old_password_label: "Mot de passe actuel" @@ -163,7 +163,7 @@ entry: archived: "Articles lus" filtered: "Articles filtrés" filtered_tags: "Articles filtrés par tags :" - filtered_search: 'Articles filtrés par recherche :' + filtered_search: "Articles filtrés par recherche :" untagged: "Article sans tag" list: number_on_the_page: "{0} Il n’y a pas d’article.|{1} Il y a un article.|]1,Inf[ Il y a %count% articles." @@ -187,7 +187,7 @@ entry: preview_picture_label: "A une photo" preview_picture_help: "Photo" language_label: "Langue" - http_status_label: 'Statut HTTP' + http_status_label: "Statut HTTP" reading_time: label: "Durée de lecture en minutes" from: "de" @@ -297,32 +297,32 @@ howto: bookmarklet: description: "Glissez et déposez ce lien dans votre barre de favoris :" shortcuts: - page_description: Voici les raccourcis disponibles dans wallabag. - shortcut: Raccourci - action: Action - all_pages_title: Raccourcis disponibles dans toutes les pages - go_unread: Afficher les articles non lus - go_starred: Afficher les articles favoris - go_archive: Afficher les articles lus - go_all: Afficher tous les articles - go_tags: Afficher les tags - go_config: Aller à la configuration - go_import: Aller aux imports - go_developers: Aller à la section Développeurs - go_howto: Afficher l'aide (cette page !) - go_logout: Se déconnecter - list_title: Raccourcis disponibles dans les pages de liste - search: Afficher le formulaire de recherche - article_title: Raccourcis disponibles quand on affiche un article - open_original: Ouvrir l'URL originale de l'article - toggle_favorite: Changer le statut Favori de l'article - toggle_archive: Changer le status Lu de l'article - delete: Supprimer l'article - material_title: Raccourcis disponibles avec le thème Material uniquement - add_link: Ajouter un nouvel article - hide_form: Masquer le formulaire courant (recherche ou nouvel article) - arrows_navigation: Naviguer à travers les articles - open_article: Afficher l'article sélectionné + page_description: "Voici les raccourcis disponibles dans wallabag." + shortcut: "Raccourci" + action: "Action" + all_pages_title: "Raccourcis disponibles dans toutes les pages" + go_unread: "Afficher les articles non lus" + go_starred: "Afficher les articles favoris" + go_archive: "Afficher les articles lus" + go_all: "Afficher tous les articles" + go_tags: "Afficher les tags" + go_config: "Aller à la configuration" + go_import: "Aller aux imports" + go_developers: "Aller à la section Développeurs" + go_howto: "Afficher l’aide (cette page !)" + go_logout: "Se déconnecter" + list_title: "Raccourcis disponibles dans les pages de liste" + search: "Afficher le formulaire de recherche" + article_title: "Raccourcis disponibles quand on affiche un article" + open_original: "Ouvrir l’URL originale de l’article" + toggle_favorite: "Changer le statut Favori de l’article" + toggle_archive: "Changer le status Lu de l’article" + delete: "Supprimer l’article" + material_title: "Raccourcis disponibles avec le thème Material uniquement" + add_link: "Ajouter un nouvel article" + hide_form: "Masquer le formulaire courant (recherche ou nouvel article)" + arrows_navigation: "Naviguer à travers les articles" + open_article: "Afficher l’article sélectionné" quickstart: page_title: "Pour bien débuter" @@ -384,8 +384,8 @@ tag: number_on_the_page: "{0} Il n’y a pas de tag.|{1} Il y a un tag.|]1,Inf[ Il y a %count% tags." see_untagged_entries: "Voir les articles sans tag" new: - add: 'Ajouter' - placeholder: 'Vous pouvez ajouter plusieurs tags, séparés par une virgule.' + add: "Ajouter" + placeholder: "Vous pouvez ajouter plusieurs tags, séparés par une virgule." import: page_title: "Importer" @@ -419,7 +419,7 @@ import: how_to: "Choisissez le fichier de votre export Readability et cliquez sur le bouton ci-dessous pour l’importer." worker: enabled: "Les imports sont asynchrones. Une fois l’import commencé un worker externe traitera les messages un par un. Le service activé est :" - download_images_warning: "Vous avez configuré le téléchagement des images pour vos articles. Combiné à l'import classique, cette opération peut être très très longue (voire échouer). Nous vous conseillons vivement d'activer les imports asynchrones." + download_images_warning: "Vous avez configuré le téléchagement des images pour vos articles. Combiné à l’import classique, cette opération peut être très très longue (voire échouer). Nous vous conseillons vivement d’activer les imports asynchrones." firefox: page_title: "Import > Firefox" description: "Cet outil va vous permettre d’importer tous vos marques-pages de Firefox. Ouvrez le panneau des marques-pages (Ctrl+Maj+O), puis dans « Importation et sauvegarde », choisissez « Sauvegarde… ». Vous allez récupérer un fichier .json.

" @@ -488,16 +488,16 @@ developer: back: "Retour" user: - page_title: Gestion des utilisateurs - new_user: Créer un nouvel utilisateur - edit_user: Éditer un utilisateur existant - description: Ici vous pouvez gérer vos utilisateurs (création, mise à jour et suppression) + page_title: "Gestion des utilisateurs" + new_user: "Créer un nouvel utilisateur" + edit_user: "Éditer un utilisateur existant" + description: "Ici vous pouvez gérer vos utilisateurs (création, mise à jour et suppression)" list: - actions: Actions - edit_action: Éditer - yes: Oui - no: Non - create_new_one: Créer un nouvel utilisateur + actions: "Actions" + edit_action: "Éditer" + yes: "Oui" + no: "Non" + create_new_one: "Créer un nouvel utilisateur" form: username_label: "Nom d’utilisateur" name_label: "Nom" @@ -513,11 +513,10 @@ user: delete_confirm: "Voulez-vous vraiment ?" back_to_list: "Revenir à la liste" search: - label: Filtrer - placeholder: Filtrer par nom d'utilisateur ou email + placeholder: "Filtrer par nom d’utilisateur ou email" error: - page_title: Une erreur est survenue + page_title: "Une erreur est survenue" flashes: config: @@ -530,10 +529,10 @@ flashes: tagging_rules_updated: "Règles mises à jour" tagging_rules_deleted: "Règle supprimée" rss_token_updated: "Jeton RSS mis à jour" - annotations_reset: Annotations supprimées - tags_reset: Tags supprimés - entries_reset: Articles supprimés - archived_reset: Articles archivés supprimés + annotations_reset: "Annotations supprimées" + tags_reset: "Tags supprimés" + entries_reset: "Articles supprimés" + archived_reset: "Articles archivés supprimés" entry: notice: entry_already_saved: "Article déjà sauvegardé le %date%" @@ -565,6 +564,6 @@ flashes: client_deleted: "Client %name% supprimé" user: notice: - added: 'Utilisateur "%username%" ajouté' - updated: 'Utilisateur "%username%" mis à jour' - deleted: 'Utilisateur "%username%" supprimé' + added: "Utilisateur \"%username%\" ajouté" + updated: "Utilisateur \"%username%\" mis à jour" + deleted: "Utilisateur \"%username%\" supprimé" diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 53b5e1b9..364e9a1f 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml @@ -513,7 +513,6 @@ user: # delete_confirm: Are you sure? # back_to_list: Back to list search: - # label: Filter # placeholder: Filter by username or email error: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index c6614a63..4877238e 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml @@ -513,7 +513,6 @@ user: delete_confirm: 'Sètz segur ?' back_to_list: 'Tornar a la lista' search: - # label: Filter # placeholder: Filter by username or email error: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index b464d0f6..9e61162a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml @@ -513,7 +513,6 @@ user: delete_confirm: Jesteś pewien? back_to_list: Powrót do listy search: - # label: Filter # placeholder: Filter by username or email error: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index 2b0b1686..30705c0a 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml @@ -513,7 +513,6 @@ user: delete_confirm: 'Tem certeza?' back_to_list: 'Voltar para a lista' search: - # label: Filter # placeholder: Filter by username or email error: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 210978d0..d3c5a0f8 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml @@ -513,7 +513,6 @@ user: # delete_confirm: Are you sure? # back_to_list: Back to list search: - # label: Filter # placeholder: Filter by username or email error: diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index 5ff5e012..27b43606 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml @@ -513,7 +513,6 @@ user: # delete_confirm: Are you sure? # back_to_list: Back to list search: - # label: Filter # placeholder: Filter by username or email error: diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php index 3ea773ee..1c5c86d4 100644 --- a/src/Wallabag/UserBundle/Controller/ManageController.php +++ b/src/Wallabag/UserBundle/Controller/ManageController.php @@ -19,38 +19,6 @@ use Wallabag\UserBundle\Form\SearchUserType; */ class ManageController extends Controller { - /** - * Lists all User entities. - * - * @Route("/list/{page}", name="user_index") - * @Method("GET") - * - * @param int $page - * - * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response - */ - public function indexAction($page = 1) - { - $em = $this->getDoctrine()->getManager(); - - $qb = $em->getRepository('WallabagUserBundle:User')->createQueryBuilder('u'); - $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false); - $pagerFanta = new Pagerfanta($pagerAdapter); - $pagerFanta->setMaxPerPage(50); - - try { - $pagerFanta->setCurrentPage($page); - } catch (OutOfRangeCurrentPageException $e) { - if ($page > 1) { - return $this->redirect($this->generateUrl('user_index', ['page' => $pagerFanta->getNbPages()]), 302); - } - } - - return $this->render('WallabagUserBundle:Manage:index.html.twig', array( - 'users' => $pagerFanta, - )); - } - /** * Creates a new User entity. * @@ -169,52 +137,44 @@ class ManageController extends Controller * @param Request $request * @param int $page * - * @Route("/search/{page}", name="user-search", defaults={"page" = 1}) + * @Route("/list/{page}", name="user_index", defaults={"page" = 1}) * * Default parameter for page is hardcoded (in duplication of the defaults from the Route) * because this controller is also called inside the layout template without any page as argument * * @return \Symfony\Component\HttpFoundation\Response */ - public function searchFormAction(Request $request, $page = 1, $currentRoute = null) + public function searchFormAction(Request $request, $page = 1) { - // fallback to retrieve currentRoute from query parameter instead of injected one (when using inside a template) - if (null === $currentRoute && $request->query->has('currentRoute')) { - $currentRoute = $request->query->get('currentRoute'); - } + $em = $this->getDoctrine()->getManager(); + $qb = $em->getRepository('WallabagUserBundle:User')->createQueryBuilder('u'); $form = $this->createForm(SearchUserType::class); - $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $this->get('logger')->info('searching users'); - $em = $this->getDoctrine()->getManager(); $searchTerm = (isset($request->get('search_user')['term']) ? $request->get('search_user')['term'] : ''); $qb = $em->getRepository('WallabagUserBundle:User')->getQueryBuilderForSearch($searchTerm); + } - $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false); - $pagerFanta = new Pagerfanta($pagerAdapter); - $pagerFanta->setMaxPerPage(50); + $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false); + $pagerFanta = new Pagerfanta($pagerAdapter); + $pagerFanta->setMaxPerPage(50); - try { - $pagerFanta->setCurrentPage($page); - } catch (OutOfRangeCurrentPageException $e) { - if ($page > 1) { - return $this->redirect($this->generateUrl('user_index', ['page' => $pagerFanta->getNbPages()]), 302); - } + try { + $pagerFanta->setCurrentPage($page); + } catch (OutOfRangeCurrentPageException $e) { + if ($page > 1) { + return $this->redirect($this->generateUrl('user_index', ['page' => $pagerFanta->getNbPages()]), 302); } - - return $this->render('WallabagUserBundle:Manage:index.html.twig', array( - 'users' => $pagerFanta, - )); } - return $this->render('WallabagUserBundle:Manage:search_form.html.twig', [ - 'form' => $form->createView(), - 'currentRoute' => $currentRoute, + return $this->render('WallabagUserBundle:Manage:index.html.twig', [ + 'searchForm' => $form->createView(), + 'users' => $pagerFanta, ]); } } diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig index 7a76f157..15002632 100644 --- a/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig +++ b/src/Wallabag/UserBundle/Resources/views/Manage/index.html.twig @@ -16,7 +16,19 @@
- {{ render(controller("WallabagUserBundle:Manage:searchForm", {'currentRoute': app.request.attributes.get('_route')})) }} + + {% if form_errors(searchForm) %} + {{ form_errors(searchForm) }} + {% endif %} + + {% if form_errors(searchForm.term) %} + {{ form_errors(searchForm.term) }} + {% endif %} + + {{ form_widget(searchForm.term, { 'attr': {'autocomplete': 'off', 'placeholder': 'user.search.placeholder'} }) }} + + {{ form_rest(searchForm) }} +
diff --git a/src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig b/src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig deleted file mode 100644 index 1d4df204..00000000 --- a/src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig +++ /dev/null @@ -1,15 +0,0 @@ -
- {% if form_errors(form) %} - {{ form_errors(form) }} - {% endif %} - - {% if form_errors(form.term) %} - {{ form_errors(form.term) }} - {% endif %} - - search - {{ form_widget(form.term, { 'attr': {'autocomplete': 'off', 'placeholder': 'user.search.placeholder'} }) }} - - - {{ form_rest(form) }} -
-- cgit v1.2.3