diff --git a/config/assistant.yaml b/config/assistant.yaml index b515c146..81243dab 100644 --- a/config/assistant.yaml +++ b/config/assistant.yaml @@ -6,48 +6,61 @@ steps: newTitle: 'new.software' skip: true 1: + type: 'App\Form\Type\VVTDatenkategorieType' + title: 'category.processing.title' + info: 'category.processing.info' + newTitle: 'new.category' + skip: true + 2: type: 'App\Form\Type\VVTType' title: 'procedure.processing.title' info: 'procedure.processing.info' newTitle: 'new.procedure' software: 0 - 2: + category: 1 + 3: type: 'App\Form\Type\KontaktType' title: 'contact.source.title' info: 'contact.source.info' newTitle: 'new.contact' - 3: + 4: type: 'App\Form\Type\DatenweitergabeType' title: 'processing.title' info: 'processing.info' newTitle: 'new.processing' transferType: 2 software: 0 - procedure: 1 - contact: 2 - 4: + procedure: 2 + contact: 3 + 5: type: 'App\Form\Type\SoftwareType' title: 'software.transfer.title' info: 'software.transfer.info' newTitle: 'new.software' skip: true - 5: + 6: + type: 'App\Form\Type\VVTDatenkategorieType' + title: 'category.transfer.title' + info: 'category.transfer.info' + newTitle: 'new.category' + skip: true + 7: type: 'App\Form\Type\VVTType' title: 'procedure.transfer.title' info: 'procedure.transfer.info' newTitle: 'new.procedure' - software: 4 - 6: + software: 5 + 8: type: 'App\Form\Type\KontaktType' title: 'contact.dest.title' info: 'contact.dest.info' newTitle: 'new.contact' - 7: + 9: type: 'App\Form\Type\DatenweitergabeType' title: 'transfer.title' info: 'transfer.info' newTitle: 'new.transfer' transferType: 1 - software: 4 - procedure: 5 - contact: 6 + software: 5 + procedure: 7 + contact: 8 diff --git a/src/Form/Type/VVTDatenkategorieType.php b/src/Form/Type/VVTDatenkategorieType.php index b63a65fb..23a849bf 100644 --- a/src/Form/Type/VVTDatenkategorieType.php +++ b/src/Form/Type/VVTDatenkategorieType.php @@ -10,6 +10,7 @@ use App\Entity\VVTDatenkategorie; use Symfony\Bridge\Doctrine\Form\Type\EntityType; +use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\AbstractType; @@ -35,6 +36,11 @@ public function buildForm(FormBuilderInterface $builder, array $options): void 'translation_domain' => 'form', 'help' => 'dataTypesHelp' ]) + ->add('save', SubmitType::class, [ + 'attr' => array('class' => 'btn btn-success btn-block btn waves-effect waves-light'), + 'label' => 'save', + 'translation_domain' => 'form' + ]); ; } diff --git a/src/Service/AssistantService.php b/src/Service/AssistantService.php index 22200a1a..5a2ddbda 100644 --- a/src/Service/AssistantService.php +++ b/src/Service/AssistantService.php @@ -10,13 +10,16 @@ use App\Entity\Team; use App\Entity\User; use App\Entity\VVT; +use App\Entity\VVTDatenkategorie; use App\Form\Type\DatenweitergabeType; use App\Form\Type\KontaktType; use App\Form\Type\SoftwareType; +use App\Form\Type\VVTDatenkategorieType; use App\Form\Type\VVTType; use App\Repository\DatenweitergabeRepository; use App\Repository\KontakteRepository; use App\Repository\SoftwareRepository; +use App\Repository\VVTDatenkategorieRepository; use App\Repository\VVTRepository; use Doctrine\Common\Collections\ArrayCollection; use Symfony\Component\Config\FileLocator; @@ -31,6 +34,7 @@ class AssistantService const PROPERTY_TITLE = 'title'; const PROPERTY_INFO = 'info'; const PROPERTY_NEW = 'newTitle'; + const PROPERTY_CATEGORY = 'category'; const PROPERTY_CONTACT = 'contact'; const PROPERTY_PROCEDURE = 'procedure'; const PROPERTY_SOFTWARE = 'software'; @@ -39,16 +43,18 @@ class AssistantService private array $steps = []; - public function __construct(private readonly RequestStack $requestStack, - private readonly DatenweitergabeService $dataTransferService, - private readonly SoftwareService $softwareService, - private readonly VVTService $vvtService, - private readonly KontakteRepository $contactRepository, - private readonly SoftwareRepository $softwareRepository, - private readonly DatenweitergabeRepository $datenweitergabeRepository, - private readonly VVTRepository $vvtRepository, - private readonly TranslatorInterface $translator, - private readonly FormFactoryInterface $formBuilder + public function __construct(private readonly RequestStack $requestStack, + private readonly VVTDatenkategorieService $categoryService, + private readonly DatenweitergabeService $dataTransferService, + private readonly SoftwareService $softwareService, + private readonly VVTService $vvtService, + private readonly KontakteRepository $contactRepository, + private readonly SoftwareRepository $softwareRepository, + private readonly DatenweitergabeRepository $datenweitergabeRepository, + private readonly VVTDatenkategorieRepository $categoryRepository, + private readonly VVTRepository $vvtRepository, + private readonly TranslatorInterface $translator, + private readonly FormFactoryInterface $formBuilder ) { $configDirectories = [__DIR__.'/../../config']; @@ -74,6 +80,7 @@ public function getPropertyForStep(int $step, string $key): int|string|bool|Kont if (array_key_exists($step, $this->steps) && array_key_exists($key, $this->steps[$step])) { $value = $this->steps[$step][$key]; return match($key) { + self::PROPERTY_CATEGORY => $this->getCategoriesFromStep($value), self::PROPERTY_CONTACT => $this->getContactFromStep($value), self::PROPERTY_PROCEDURE => $this->getProcedureFromStep($value), self::PROPERTY_SOFTWARE => $this->getSoftwareFromStep($value), @@ -95,6 +102,19 @@ private function getSingleFromSessionForStep(int $step): ?string { $array = $this->getArrayFromSessionForStep(step: $step); return $array ? strval($array[0]) : null; } + private function getCategoriesFromStep(int $step): ArrayCollection { + $categoryIds = $this->getArrayFromSessionForStep($step); + $categoryArray = new ArrayCollection(); + if (is_array($categoryIds)) { + for ($i = 0; $i < count($categoryIds); $i++) { + $category = $this->categoryRepository->find($categoryIds[$i]); + if ($category) { + $categoryArray->add($category); + } + } + } + return $categoryArray; + } private function getContactFromStep(int $step): ?Kontakte { $contactId = $this->getSingleFromSessionForStep($step); @@ -149,7 +169,7 @@ public function clear(): void { } } - public function createElementForStep(int $step, User $user, Team $team): Software|Kontakte|VVT|Datenweitergabe|null + public function createElementForStep(int $step, User $user, Team $team): Software|Kontakte|VVT|Datenweitergabe|VVTDatenkategorie|null { $item = null; @@ -162,6 +182,9 @@ public function createElementForStep(int $step, User $user, Team $team): Softwar $item->setTeam($team); $item->setActiv(1); break; + case VVTDatenKategorieType::class: + $item = $this->categoryService->newVVTDatenkategorie(team: $team, user: $user); + break; case DatenweitergabeType::class: // if a datenweitergabe already exists for this step, use that instead $item = $this->getDatenweitergabeFromStep($step); @@ -206,6 +229,11 @@ public function getSelectDataForStep(int $step, Team $team): array { $select['items'] = $this->vvtRepository->findActiveByTeam($team); $select['multiple'] = true; break; + case VVTDatenkategorieType::class: + $select['selected'] = $this->getArrayFromSessionForStep($step); + $select['label'] = $this->translator->trans(id: 'select.category', domain: 'assistant'); + $select['items'] = $this->categoryRepository->findByTeam($team); + $select['multiple'] = true; } return $select; } @@ -231,8 +259,12 @@ private function addDependenciesToDatenweitergabe(Datenweitergabe $item, $step): private function addDependenciesToProcedure(VVT $procedure, $step): void { $softwareArray = $this->getPropertyForStep(step: $step, key: self::PROPERTY_SOFTWARE); + $categoryArray = $this->getPropertyForStep(step: $step, key: self::PROPERTY_CATEGORY); foreach($softwareArray as $software) { $procedure->addSoftware($software); } + foreach ($categoryArray as $category) { + $procedure->addKategorien($category); + } } } diff --git a/templates/vvt_datenkategorie/_form.html.twig b/templates/vvt_datenkategorie/_form.html.twig index 417a4a8a..99f591fd 100644 --- a/templates/vvt_datenkategorie/_form.html.twig +++ b/templates/vvt_datenkategorie/_form.html.twig @@ -29,7 +29,6 @@