Fix formatting

This commit is contained in:
d-buchmann 2025-05-22 15:00:22 +02:00
parent 334a37a9d0
commit 26ee564481
2 changed files with 16 additions and 16 deletions

View file

@ -53,16 +53,16 @@ class SelectAPIController extends AbstractController
#[Route(path: '/tag', name: 'select_tag')] #[Route(path: '/tag', name: 'select_tag')]
public function tag(): Response public function tag(): Response
{ {
$tags = [ $tags = [
'text' => 'test', 'text' => 'test',
'value' => 'test', 'value' => 'test',
]; ];
$this->addEmptyNode($tags); $this->addEmptyNode($tags);
// pseudocode: // pseudocode:
// for each part in selection // for each part in selection
// use TagFilter to find tags // use TagFilter to find tags
// dedupe // dedupe
return $this->json($tags); return $this->json($tags);
#[Route(path: '/category', name: 'select_category')] #[Route(path: '/category', name: 'select_category')]
public function category(): Response public function category(): Response

View file

@ -137,18 +137,18 @@ implode(',', array_map(static fn (PartLot $lot) => $lot->getID(), $part->getPart
$this->denyAccessUnlessGranted('edit', $part); $this->denyAccessUnlessGranted('edit', $part);
switch ($action) { switch ($action) {
case "add_tag": case "add_tag":
$this->denyAccessUnlessGranted('edit', $part); $this->denyAccessUnlessGranted('edit', $part);
$tags = $part->getTags(); $tags = $part->getTags();
$part->setTags($tags . ',' . $target_id); // simple append $part->setTags($tags . ',' . $target_id); // simple append
break; break;
case "remove_tag": case "remove_tag":
$this->denyAccessUnlessGranted('edit', $part); $this->denyAccessUnlessGranted('edit', $part);
$tags = $part->getTags(); $tags = $part->getTags();
$tags = str_replace($target_id, '', $tags); $tags = str_replace($target_id, '', $tags);
// sanitize $tags (remove leading, trailing and double commas) // sanitize $tags (remove leading, trailing and double commas)
$part->setTags($tags); $part->setTags($tags);
break; break;
case 'favorite': case 'favorite':
$this->denyAccessUnlessGranted('change_favorite', $part); $this->denyAccessUnlessGranted('change_favorite', $part);
$part->setFavorite(true); $part->setFavorite(true);