X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FForm%2FType%2FEntryFilterType.php;h=f3f848e9a6db0f667e5e80a0e9b308192a1dfc86;hb=5ecdfcd041767c9e3244a92bb0a6cc3c3f80fea3;hp=dcdb3ab72965b3bbcea8920e4384c8d39d342988;hpb=4094ea47712efbe58624ff74daeb1f77c9b0edcf;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index dcdb3ab7..f3f848e9 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php @@ -35,6 +35,20 @@ class EntryFilterType extends AbstractType { $builder ->add('readingTime', NumberRangeFilterType::class, [ + 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { + $value = $values['value']; + + if (null === $value['left_number'][0] || null === $value['right_number'][0]) { + return; + } + + $min = (int) ($value['left_number'][0] * $this->user->getConfig()->getReadingSpeed()); + $max = (int) ($value['right_number'][0] * $this->user->getConfig()->getReadingSpeed()); + + $expression = $filterQuery->getExpr()->between($field, $min, $max); + + return $filterQuery->createCondition($expression); + }, 'label' => 'entry.filters.reading_time.label', ]) ->add('createdAt', DateRangeFilterType::class, [ @@ -73,6 +87,18 @@ class EntryFilterType extends AbstractType ->add('isStarred', CheckboxFilterType::class, [ 'label' => 'entry.filters.starred_label', ]) + ->add('isUnread', CheckboxFilterType::class, [ + 'label' => 'entry.filters.unread_label', + 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { + if (false === $values['value']) { + return; + } + + $expression = $filterQuery->getExpr()->eq('e.isArchived', 'false'); + + return $filterQuery->createCondition($expression); + }, + ]) ->add('previewPicture', CheckboxFilterType::class, [ 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { if (false === $values['value']) {