diff --git a/src/Controller/AutocompleteGroupController.php b/src/Controller/AutocompleteGroupController.php index 9af12dd7..3858d82a 100644 --- a/src/Controller/AutocompleteGroupController.php +++ b/src/Controller/AutocompleteGroupController.php @@ -33,6 +33,10 @@ public function index(Request $request, BookRepository $bookRepository, string $ $exactmatch = false; $json = ['results' => []]; + + if ($type !== 'authors' && $query === '' && $request->get('create', true) !== true) { + $json['results'][] = ['value' => 'no_'.$type, 'text' => '[No '.$type.' defined]']; + } foreach ($group as $item) { if (!str_contains(strtolower($item['item']), strtolower($query))) { continue; @@ -42,9 +46,7 @@ public function index(Request $request, BookRepository $bookRepository, string $ } $json['results'][] = ['value' => $item['item'], 'text' => $item['item']]; } - if (($type !== 'authors') && $query === '' && $request->get('create', true) !== true) { - $json['results'][] = ['value' => 'no_'.$type, 'text' => '[No '.$type.' defined]']; - } + if (!$exactmatch && strlen($query) > 2 && $request->get('create', true) === true) { $json['results'][] = ['value' => $query, 'text' => 'New: '.$query]; } diff --git a/src/Form/BookFilterType.php b/src/Form/BookFilterType.php index 7cd02467..a674dd47 100644 --- a/src/Form/BookFilterType.php +++ b/src/Form/BookFilterType.php @@ -32,7 +32,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder->add('serieIndexGTE', Type\SearchType::class, [ 'required' => false, - 'mapped'=>false, + 'mapped' => false, 'target_callback' => function (QueryBuilder $qb, ?string $searchValue): void { if ($searchValue !== null) { $qb->andWhere('book.serieIndex >= :indexGTE'); @@ -43,7 +43,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $builder->add('serieIndexLTE', Type\SearchType::class, [ 'required' => false, - 'mapped'=>false, + 'mapped' => false, 'target_callback' => function (QueryBuilder $qb, ?string $searchValue): void { if ($searchValue !== null) { @@ -246,6 +246,26 @@ public function buildForm(FormBuilderInterface $builder, array $options): void }, ]); + $builder->add('picture', Type\ChoiceType::class, [ + 'choices' => [ + 'Any' => '', + 'Has picture' => 'with', + 'No picture' => 'without', + ], + 'required' => false, + 'mapped' => false, + 'target_callback' => function (QueryBuilder $qb, ?string $readValue): void { + switch ($readValue) { + case 'with': + $qb->andWhere('book.imageFilename is not null'); + break; + case 'without': + $qb->andWhere('book.imageFilename is null'); + break; + } + }, + ]); + $builder->add('orderBy', Type\ChoiceType::class, [ 'choices' => [ 'title' => 'title', diff --git a/src/Service/FilteredBookUrlGenerator.php b/src/Service/FilteredBookUrlGenerator.php index e69dab00..75e0f04e 100644 --- a/src/Service/FilteredBookUrlGenerator.php +++ b/src/Service/FilteredBookUrlGenerator.php @@ -16,6 +16,7 @@ class FilteredBookUrlGenerator 'serie' => '', 'publisher' => '', 'read' => '', + 'picture' => '', 'favorite' => '', 'verified' => '', 'orderBy' => 'title', diff --git a/templates/default/index.html.twig b/templates/default/index.html.twig index 4fcd6335..e6b3ffa3 100644 --- a/templates/default/index.html.twig +++ b/templates/default/index.html.twig @@ -29,12 +29,15 @@
-
+
{{ form_row(form.authorsNot) }}
-
+
{{ form_row(form.tags) }}
+
+ {{ form_row(form.picture) }} +
{{ form_row(form.favorite) }}