mirror of
https://github.com/wallabag/wallabag.git
synced 2025-09-30 19:22:12 +00:00
Merge 5981cfb8b8
into cf30c39d2f
This commit is contained in:
commit
e9f136c284
5 changed files with 58 additions and 3 deletions
|
@ -627,6 +627,16 @@ class EntryController extends AbstractController
|
||||||
$currentEntryId = $request->attributes->getInt('id');
|
$currentEntryId = $request->attributes->getInt('id');
|
||||||
|
|
||||||
$formOptions = [];
|
$formOptions = [];
|
||||||
|
$direction = 'desc';
|
||||||
|
$sortBy = null;
|
||||||
|
|
||||||
|
if (null !== $request->get('entry_filter') && null !== $request->get('entry_filter')['sortType'] && '' !== $request->get('entry_filter')['sortType']) {
|
||||||
|
$direction = (null !== $request->get('entry_filter')['sortOrder'] && \in_array($request->get('entry_filter')['sortOrder'], ['asc', 'desc'], true)) ? $request->get('entry_filter')['sortOrder'] : 'desc';
|
||||||
|
|
||||||
|
if (\in_array($request->get('entry_filter')['sortType'], ['id','title','createdAt', 'url', 'readingTime'], true)) {
|
||||||
|
$sortBy = $request->get('entry_filter')['sortType'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case 'search':
|
case 'search':
|
||||||
|
@ -654,7 +664,7 @@ class EntryController extends AbstractController
|
||||||
$qb = $this->entryRepository->getBuilderForSameDomainByUser($this->getUser()->getId(), $currentEntryId);
|
$qb = $this->entryRepository->getBuilderForSameDomainByUser($this->getUser()->getId(), $currentEntryId);
|
||||||
break;
|
break;
|
||||||
case 'all':
|
case 'all':
|
||||||
$qb = $this->entryRepository->getBuilderForAllByUser($this->getUser()->getId());
|
$qb = $this->entryRepository->getBuilderForAllByUser($this->getUser()->getId(), $sortBy, $direction);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException(\sprintf('Type "%s" is not implemented.', $type));
|
throw new \InvalidArgumentException(\sprintf('Type "%s" is not implemented.', $type));
|
||||||
|
|
|
@ -205,6 +205,24 @@ class EntryFilterType extends AbstractType
|
||||||
'choices' => array_flip($this->repository->findDistinctLanguageByUser($user->getId())),
|
'choices' => array_flip($this->repository->findDistinctLanguageByUser($user->getId())),
|
||||||
'label' => 'entry.filters.language_label',
|
'label' => 'entry.filters.language_label',
|
||||||
])
|
])
|
||||||
|
->add('sortOrder', ChoiceFilterType::class, [
|
||||||
|
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { },
|
||||||
|
'choices' => [
|
||||||
|
'entry.sort.ascending' => 'asc',
|
||||||
|
'entry.sort.descending' => 'desc',
|
||||||
|
],
|
||||||
|
'label' => 'entry.sort.order_label',
|
||||||
|
])
|
||||||
|
->add('sortType', ChoiceFilterType::class, [
|
||||||
|
'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { },
|
||||||
|
'choices' => [
|
||||||
|
'entry.sort.by.creation_date' => 'createdAt',
|
||||||
|
'entry.sort.by.title' => 'title',
|
||||||
|
'entry.sort.by.url' => 'url',
|
||||||
|
'entry.sort.by.reading_time' => 'readingTime',
|
||||||
|
],
|
||||||
|
'label' => 'entry.sort.status_label',
|
||||||
|
])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,10 +30,11 @@ class EntryRepository extends ServiceEntityRepository
|
||||||
*
|
*
|
||||||
* @return QueryBuilder
|
* @return QueryBuilder
|
||||||
*/
|
*/
|
||||||
public function getBuilderForAllByUser($userId)
|
public function getBuilderForAllByUser($userId, $sortBy = 'createdAt', $direction = 'desc')
|
||||||
{
|
{
|
||||||
|
$sortBy = $sortBy ?: 'createdAt';
|
||||||
return $this
|
return $this
|
||||||
->getSortedQueryBuilderByUser($userId)
|
->getSortedQueryBuilderByUser($userId, $sortBy, $direction)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,6 +276,22 @@
|
||||||
<label for="entry_filter_createdAt_right_date" class="active">{{ 'entry.filters.created_at.to'|trans }}</label>
|
<label for="entry_filter_createdAt_right_date" class="active">{{ 'entry.filters.created_at.to'|trans }}</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="col s6">
|
||||||
|
{{ form_label(form.sortType) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col s6">
|
||||||
|
{{ form_label(form.sortOrder) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col s6">
|
||||||
|
{{ form_widget(form.sortType) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col s6">
|
||||||
|
{{ form_widget(form.sortOrder) }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="col s6">
|
<div class="col s6">
|
||||||
<button type="reset" class="center waves-effect waves-green btn-flat">{{ 'entry.filters.action.clear'|trans }}</button>
|
<button type="reset" class="center waves-effect waves-green btn-flat">{{ 'entry.filters.action.clear'|trans }}</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -237,6 +237,16 @@ entry:
|
||||||
untagged: Untagged entries
|
untagged: Untagged entries
|
||||||
all: All entries
|
all: All entries
|
||||||
same_domain: Same domain
|
same_domain: Same domain
|
||||||
|
sort:
|
||||||
|
status_label: Sort by
|
||||||
|
order_label: Order
|
||||||
|
by:
|
||||||
|
creation_date: Creation date
|
||||||
|
title: Title
|
||||||
|
url: URL
|
||||||
|
reading_time: Reading time
|
||||||
|
ascending: Ascending
|
||||||
|
descending: Descending
|
||||||
list:
|
list:
|
||||||
number_on_the_page: '{0} There are no entries.|{1} There is one entry.|]1,Inf[ There are %count% entries.'
|
number_on_the_page: '{0} There are no entries.|{1} There is one entry.|]1,Inf[ There are %count% entries.'
|
||||||
reading_time: estimated reading time
|
reading_time: estimated reading time
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue