diff options
Diffstat (limited to 'src/Wallabag')
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; | |||
5 | use Symfony\Component\Form\AbstractType; | 5 | use Symfony\Component\Form\AbstractType; |
6 | use Symfony\Component\Form\FormBuilderInterface; | 6 | use Symfony\Component\Form\FormBuilderInterface; |
7 | use Symfony\Component\OptionsResolver\OptionsResolver; | 7 | use Symfony\Component\OptionsResolver\OptionsResolver; |
8 | use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands; | ||
9 | use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface; | ||
8 | 10 | ||
9 | class EntryFilterType extends AbstractType | 11 | class 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 | } |