X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FForm%2FType%2FEntryFilterType.php;h=bc59c9a1461ac86bb095246b78d1637fa671bf9f;hb=23634d5d842dabcf5d7475e2becb7e127824239e;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..bc59c9a1 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']) { @@ -87,7 +113,6 @@ class EntryFilterType extends AbstractType ]) ->add('language', ChoiceFilterType::class, [ 'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())), - 'choices_as_values' => true, 'label' => 'entry.filters.language_label', ]) ;