aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/Filter/EntryFilterType.php15
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig6
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php13
3 files changed, 32 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
index 85d1a061..de95eed9 100644
--- a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
+++ b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
@@ -39,10 +39,21 @@ class EntryFilterType extends AbstractType
39 $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->literal('%'.$value.'%')); 39 $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->literal('%'.$value.'%'));
40 40
41 return $filterQuery->createCondition($expression); 41 return $filterQuery->createCondition($expression);
42 }, 42 },
43 )) 43 ))
44 ->add('isArchived', 'filter_checkbox') 44 ->add('isArchived', 'filter_checkbox')
45 ->add('isStarred', 'filter_checkbox'); 45 ->add('isStarred', 'filter_checkbox')
46 ->add('previewPicture', 'filter_checkbox', array(
47 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
48 if (false === $values['value']) {
49 return;
50 }
51
52 $expression = $filterQuery->getExpr()->isNotNull($field);
53
54 return $filterQuery->createCondition($expression);
55 },
56 ));
46 } 57 }
47 58
48 public function getName() 59 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 1ecaecc5..89182d98 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 @@
70 <div class="col s12"> 70 <div class="col s12">
71 <label>{% trans %}Status{% endtrans %}</label> 71 <label>{% trans %}Status{% endtrans %}</label>
72 </div> 72 </div>
73
74 <div class="input-field col s6">
75 {{ form_widget(form.previewPicture) }}
76 <label for="entry_filter_previewPicture">{% trans %}Has a preview picture{% endtrans %}</label>
77 </div>
78
73 <div class="input-field col s6"> 79 <div class="input-field col s6">
74 {{ form_widget(form.isArchived) }} 80 {{ form_widget(form.isArchived) }}
75 <label for="entry_filter_isArchived">{% trans %}Archived{% endtrans %}</label> 81 <label for="entry_filter_isArchived">{% trans %}Archived{% endtrans %}</label>
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index a92835b3..77b57884 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
369 $crawler = $client->submit($form); 369 $crawler = $client->submit($form);
370 $this->assertCount(2, $crawler->filter('div[class=entry]')); 370 $this->assertCount(2, $crawler->filter('div[class=entry]'));
371 } 371 }
372
373 public function testPreviewPictureFilter()
374 {
375 $this->logInAs('admin');
376 $client = $this->getClient();
377
378 $crawler = $client->request('GET', '/unread/list');
379 $form = $crawler->filter('button[id=submit-filter]')->form();
380 $form['entry_filter[previewPicture]']->tick();
381
382 $crawler = $client->submit($form);
383 $this->assertCount(1, $crawler->filter('div[class=entry]'));
384 }
372} 385}