aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorJeremy Benoist <j0k3r@users.noreply.github.com>2015-08-19 14:33:46 +0200
committerJeremy Benoist <j0k3r@users.noreply.github.com>2015-08-19 14:33:46 +0200
commit7b2d33689338386b331a9a370eb6b9d8576f0cbb (patch)
tree80dcb197a59534f231354455a4a7913bea029392 /src
parentb71ebd9af90458a4631e987676e3ee3d84c16f9e (diff)
parent443cecd2d895a7e257a051ea65c6822fdce73b07 (diff)
downloadwallabag-7b2d33689338386b331a9a370eb6b9d8576f0cbb.tar.gz
wallabag-7b2d33689338386b331a9a370eb6b9d8576f0cbb.tar.zst
wallabag-7b2d33689338386b331a9a370eb6b9d8576f0cbb.zip
Merge pull request #1342 from wallabag/v2-domain-filter
fix #981: add filter on domain name
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Filter/EntryFilterType.php15
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig8
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php24
3 files changed, 45 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
index 2fa2f8a0..d1057fb5 100644
--- a/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
+++ b/src/Wallabag/CoreBundle/Filter/EntryFilterType.php
@@ -5,6 +5,8 @@ namespace Wallabag\CoreBundle\Filter;
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface; 6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\OptionsResolver\OptionsResolver; 7use Symfony\Component\OptionsResolver\OptionsResolver;
8use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands;
9use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
8 10
9class EntryFilterType extends AbstractType 11class EntryFilterType extends AbstractType
10{ 12{
@@ -24,7 +26,18 @@ class EntryFilterType extends AbstractType
24 'placeholder' => 'dd/mm/yyyy'), 26 'placeholder' => 'dd/mm/yyyy'),
25 'format' => 'dd/MM/yyyy', 27 'format' => 'dd/MM/yyyy',
26 'widget' => 'single_text' 28 'widget' => 'single_text'
27 ))); 29 )))
30 ->add('domainName', 'filter_text', array(
31 'apply_filter' => function (QueryInterface $filterQuery, $field, $values)
32 {
33 $value = $values['value'];
34 if (strlen($value) <= 3 || empty($value)) {
35 return null;
36 }
37 $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->literal('%'.$value.'%'));
38 return $filterQuery->createCondition($expression);
39 }
40 ));
28 } 41 }
29 42
30 public function getName() 43 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 41ce9eee..67061e4c 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
@@ -77,8 +77,16 @@
77 <label for="entry_filter_readingTime_right_number">{% trans %}to{% endtrans %}</label> 77 <label for="entry_filter_readingTime_right_number">{% trans %}to{% endtrans %}</label>
78 </div> 78 </div>
79 79
80
80 <div class="col s12"> 81 <div class="col s12">
82
81 <label>{% trans %}Create at{% endtrans %}</label> 83 <label>{% trans %}Create at{% endtrans %}</label>
84
85 <label>{% trans %}Domain name{% endtrans %}</label>
86 </div>
87 <div class="input-field col s6">
88 {{ form_widget(form.domainName, {'type': 'text'}) }}
89 <label for="entry_filter_domainName">{% trans %}www.website.com{% endtrans %}</label>
82 </div> 90 </div>
83 91
84 <div class="input-field col s6"> 92 <div class="input-field col s6">
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 87c16415..8d013ec0 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -293,7 +293,6 @@ class EntryControllerTest extends WallabagCoreTestCase
293 { 293 {
294 $this->logInAs('admin'); 294 $this->logInAs('admin');
295 $client = $this->getClient(); 295 $client = $this->getClient();
296
297 $crawler = $client->request('GET', '/config'); 296 $crawler = $client->request('GET', '/config');
298 297
299 $form = $crawler->filter('button[id=config_save]')->form(); 298 $form = $crawler->filter('button[id=config_save]')->form();
@@ -310,4 +309,27 @@ class EntryControllerTest extends WallabagCoreTestCase
310 309
311 $this->assertContains($parameters, $client->getResponse()->getContent()); 310 $this->assertContains($parameters, $client->getResponse()->getContent());
312 } 311 }
312
313 public function testFilterOnDomainName()
314 {
315 $this->logInAs('admin');
316 $client = $this->getClient();
317
318 $crawler = $client->request('GET', '/unread/list');
319 $form = $crawler->filter('button[id=submit-filter]')->form();
320 $data = array(
321 'entry_filter[domainName]' => 'monde'
322 );
323
324 $crawler = $client->submit($form, $data);
325 $this->assertCount(1, $crawler->filter('div[class=entry]'));
326
327 $form = $crawler->filter('button[id=submit-filter]')->form();
328 $data = array(
329 'entry_filter[domainName]' => 'wallabag'
330 );
331
332 $crawler = $client->submit($form, $data);
333 $this->assertCount(0, $crawler->filter('div[class=entry]'));
334 }
313} 335}