Add tags input field to action bar

This commit is contained in:
buchmann 2025-10-07 08:21:31 +02:00
parent 858c7a6e0f
commit 74d069f4bd
4 changed files with 55 additions and 27 deletions

View file

@ -78,7 +78,7 @@ class PartListsController extends AbstractController
$errors = [];
$parts = $actionHandler->idStringToArray($ids);
$redirectResponse = $actionHandler->handleAction($action, $parts, $target ? $target : null, $redirect, $errors);
$redirectResponse = $actionHandler->handleAction($action, $parts, $target !== '' ? $target : null, $redirect, $errors);
//Save changes
$this->entityManager->flush();

View file

@ -32,8 +32,8 @@ use App\Entity\Parts\MeasurementUnit;
use App\Entity\Parts\StorageLocation;
use App\Entity\ProjectSystem\Project;
use App\Form\Type\Helper\StructuralEntityChoiceHelper;
use App\Services\Tools\TagFinder;
use App\Services\Trees\NodesListBuilder;
use App\ApiPlatform\Filter\TagFilter;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
@ -50,20 +50,6 @@ class SelectAPIController extends AbstractController
{
}
#[Route(path: '/tag', name: 'select_tag')]
public function tag(): Response
{
$tags = [
'text' => 'test',
'value' => 'test',
];
$this->addEmptyNode($tags);
// pseudocode:
// for each part in selection
// use TagFilter to find tags
// dedupe
return $this->json($tags);
#[Route(path: '/category', name: 'select_category')]
public function category(): Response
{
@ -150,6 +136,27 @@ class SelectAPIController extends AbstractController
return $this->json($nodes);
}
#[Route(path: '/tag', name: 'select_tag')]
public function getResponseForTags(EntityManagerInterface $entityManager): Response
{
$tf = new TagFinder($entityManager, ['min_keyword_length' => 2, 'query_limit' => 250]);
$list = $tf->listTags('__'); // return every tag with at least two characters!
$entries = [];
foreach($list as $d)
{
//if ($entries[$d] === null)
$entries[$d['tags']] = $d['tags'];
}
return $this->json(array_map(static fn($key, $value) => [
'text' => $value,
'value' => $key,
], array_keys($entries), $entries));
}
protected function getResponseForClass(string $class, bool $include_empty = false): Response
{