mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-27 20:28:54 +02:00
Added autocomplete for part tags input.
This commit is contained in:
parent
bddd5b758a
commit
7a5a2f65f9
4 changed files with 153 additions and 5 deletions
|
@ -24,6 +24,7 @@ namespace App\Controller;
|
|||
|
||||
|
||||
use App\Services\Attachments\BuiltinAttachmentsFinder;
|
||||
use App\Services\TagFinder;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
@ -47,6 +48,24 @@ class TypeaheadController extends AbstractController
|
|||
$array = $finder->find($query);
|
||||
|
||||
|
||||
$normalizers = [
|
||||
new ObjectNormalizer()
|
||||
];
|
||||
$encoders = [
|
||||
new JsonEncoder()
|
||||
];
|
||||
$serializer = new Serializer($normalizers, $encoders);
|
||||
$data = $serializer->serialize($array, 'json');
|
||||
return new JsonResponse($data, 200, [], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/tags/search/{query}", name="typeahead_tags", requirements={"query"= ".+"})
|
||||
*/
|
||||
public function tags(string $query, TagFinder $finder)
|
||||
{
|
||||
$array = $finder->searchTags($query);
|
||||
|
||||
$normalizers = [
|
||||
new ObjectNormalizer()
|
||||
];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue