diff --git a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php index 85d1a0610..de95eed96 100644 --- a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php @@ -39,10 +39,21 @@ class EntryFilterType extends AbstractType $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->literal('%'.$value.'%')); return $filterQuery->createCondition($expression); - }, + }, )) ->add('isArchived', 'filter_checkbox') - ->add('isStarred', 'filter_checkbox'); + ->add('isStarred', 'filter_checkbox') + ->add('previewPicture', 'filter_checkbox', array( + 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { + if (false === $values['value']) { + return; + } + + $expression = $filterQuery->getExpr()->isNotNull($field); + + return $filterQuery->createCondition($expression); + }, + )); } public function getName() diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig index 1ecaecc56..89182d98f 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig @@ -70,6 +70,12 @@
+ +
+ {{ form_widget(form.previewPicture) }} + +
+
{{ form_widget(form.isArchived) }} diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index a92835b31..77b578846 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -369,4 +369,17 @@ class EntryControllerTest extends WallabagCoreTestCase $crawler = $client->submit($form); $this->assertCount(2, $crawler->filter('div[class=entry]')); } + + public function testPreviewPictureFilter() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/unread/list'); + $form = $crawler->filter('button[id=submit-filter]')->form(); + $form['entry_filter[previewPicture]']->tick(); + + $crawler = $client->submit($form); + $this->assertCount(1, $crawler->filter('div[class=entry]')); + } }