Merge pull request #1418 from wallabag/v2-previewpicture-filter

filter for entries with previewPicture
This commit is contained in:
Jeremy Benoist 2015-09-13 10:14:42 +02:00
commit 40f59b219b
3 changed files with 32 additions and 2 deletions

View file

@ -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()

View file

@ -70,6 +70,12 @@
<div class="col s12">
<label>{% trans %}Status{% endtrans %}</label>
</div>
<div class="input-field col s6">
{{ form_widget(form.previewPicture) }}
<label for="entry_filter_previewPicture">{% trans %}Has a preview picture{% endtrans %}</label>
</div>
<div class="input-field col s6">
{{ form_widget(form.isArchived) }}
<label for="entry_filter_isArchived">{% trans %}Archived{% endtrans %}</label>

View file

@ -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]'));
}
}