From 89659c9eae338cd29e5919b5ffde6924189a59ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 20 Aug 2015 15:59:47 +0200 Subject: filters: implement status filter and a new view (to display all entries) --- composer.lock | 22 ++++++------ .../CoreBundle/Controller/EntryController.php | 42 ++++++++++++++++++++++ src/Wallabag/CoreBundle/Filter/EntryFilterType.php | 4 ++- .../CoreBundle/Resources/views/base.html.twig | 3 +- .../views/themes/material/Entry/entries.html.twig | 19 ++++++++-- .../views/themes/material/layout.html.twig | 1 + .../views/themes/material/public/js/init.js | 1 + 7 files changed, 77 insertions(+), 15 deletions(-) diff --git a/composer.lock b/composer.lock index 559a08dc..59f3343e 100644 --- a/composer.lock +++ b/composer.lock @@ -3466,16 +3466,16 @@ }, { "name": "phpunit/phpunit", - "version": "4.8.4", + "version": "4.8.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "55bf1d6092b0e13a1f26bd5eaffeef3d8ad85ea7" + "reference": "9b7417edaf28059ea63d86be941e6004dbfcc0cc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/55bf1d6092b0e13a1f26bd5eaffeef3d8ad85ea7", - "reference": "55bf1d6092b0e13a1f26bd5eaffeef3d8ad85ea7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9b7417edaf28059ea63d86be941e6004dbfcc0cc", + "reference": "9b7417edaf28059ea63d86be941e6004dbfcc0cc", "shasum": "" }, "require": { @@ -3534,24 +3534,24 @@ "testing", "xunit" ], - "time": "2015-08-15 04:21:23" + "time": "2015-08-19 09:20:57" }, { "name": "phpunit/phpunit-mock-objects", - "version": "2.3.6", + "version": "2.3.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42" + "reference": "5e2645ad49d196e020b85598d7c97e482725786a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/18dfbcb81d05e2296c0bcddd4db96cade75e6f42", - "reference": "18dfbcb81d05e2296c0bcddd4db96cade75e6f42", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5e2645ad49d196e020b85598d7c97e482725786a", + "reference": "5e2645ad49d196e020b85598d7c97e482725786a", "shasum": "" }, "require": { - "doctrine/instantiator": "~1.0,>=1.0.2", + "doctrine/instantiator": "^1.0.2", "php": ">=5.3.3", "phpunit/php-text-template": "~1.2", "sebastian/exporter": "~1.2" @@ -3590,7 +3590,7 @@ "mock", "xunit" ], - "time": "2015-07-10 06:54:24" + "time": "2015-08-19 09:14:08" }, { "name": "sebastian/comparator", diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index dc399b8a..4070a603 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php @@ -101,6 +101,48 @@ class EntryController extends Controller )); } + /** + * Shows all entries for current user. + * + * @param Request $request + * @param int $page + * + * @Route("/all/list/{page}", name="all", defaults={"page" = "1"}) + * + * @return \Symfony\Component\HttpFoundation\Response + */ + public function showAllAction(Request $request, $page) + { + $form = $this->get('form.factory')->create(new EntryFilterType()); + + $filterBuilder = $this->getDoctrine() + ->getRepository('WallabagCoreBundle:Entry') + ->findAllByUser($this->getUser()->getId()); + + if ($request->query->has($form->getName())) { + // manually bind values from the request + $form->submit($request->query->get($form->getName())); + + // build the query from the given form object + $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $filterBuilder); + } + + $pagerAdapter = new DoctrineORMAdapter($filterBuilder->getQuery()); + $entries = new Pagerfanta($pagerAdapter); + + $entries->setMaxPerPage($this->getUser()->getConfig()->getItemsPerPage()); + $entries->setCurrentPage($page); + + return $this->render( + 'WallabagCoreBundle:Entry:entries.html.twig', + array( + 'form' => $form->createView(), + 'entries' => $entries, + 'currentPage' => $page, + ) + ); + } + /** * Shows unread entries for current user. * diff --git a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php index 771daef1..ff51785b 100644 --- a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php @@ -39,7 +39,9 @@ class EntryFilterType extends AbstractType return $filterQuery->createCondition($expression); }, - )); + )) + ->add('isArchived', 'filter_checkbox') + ->add('isStarred', 'filter_checkbox'); } public function getName() diff --git a/src/Wallabag/CoreBundle/Resources/views/base.html.twig b/src/Wallabag/CoreBundle/Resources/views/base.html.twig index ac5d2bf9..3ad776b9 100644 --- a/src/Wallabag/CoreBundle/Resources/views/base.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/base.html.twig @@ -71,7 +71,8 @@
  • {% trans %}unread{% endtrans %}
  • {% trans %}favorites{% endtrans %}
  • {% trans %}archive{% endtrans %}
  • -
  • {% trans %}tags{% endtrans %}
  • +
  • {% trans %}all{% endtrans %}
  • +
  • {% trans %}tags{% endtrans %}
  • {% trans %}save a link{% endtrans %}
  • {% trans %}search{% endtrans %}