Skip to content

Commit

Permalink
add categories to assistant
Browse files Browse the repository at this point in the history
  • Loading branch information
KaydenLiss committed Jul 4, 2023
1 parent 425f9a1 commit 259edcb
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 24 deletions.
37 changes: 25 additions & 12 deletions config/assistant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 6 additions & 0 deletions src/Form/Type/VVTDatenkategorieType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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'
]);
;
}

Expand Down
54 changes: 43 additions & 11 deletions src/Service/AssistantService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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';
Expand All @@ -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'];
Expand All @@ -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),
Expand All @@ -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);
Expand Down Expand Up @@ -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;

Expand All @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
}
}
1 change: 0 additions & 1 deletion templates/vvt_datenkategorie/_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

<div>
{{ form_widget(form) }}
<button class="btn btn-success btn-block btn waves-effect waves-light">{{ button_label|default('Speichern') }}</button>
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions translations/assistant/assistant.de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ assistant:
start: Assistent Starten
finished: Der Assistent ist fertig und alle Elemente wurden erfolgreich angelegt. Du kannst ihn neu starten, um weitere Verarbeitungstätigkeiten zu dokumentieren.
aborted: Der Assistent wurde abgebrochen. Bereits angelegte Elemente wurden gespeichert.
category:
processing:
title: Datenkategorie für Auftragsverarbeitung
info: Welche Datenkategorie/Löschfrist soll für die zur Auftragsverarbeitung zugehörigen Verarbeitstätigkeit gelten? Dieser Punkt kann übersprungen werden falls die Verarbeitungstätigkeit bereits existiert.
transfer:
title: Datenkategorie für Datenweitergabe
info: Welche Datenkategorie/Löschfrist soll für die zur Datenweitergabe zugehörigen Verarbeitstätigkeit gelten? Dieser Punkt kann übersprungen werden falls die Verarbeitungstätigkeit bereits existiert.
contact:
source:
title: Eingangskontakt
Expand Down Expand Up @@ -36,12 +43,14 @@ software:
info: Wird für die Datenweitergabe Software verwendet? Wenn keine Software verwendet wird, kann dieser Schritt übersprungen werden.
new:
word: Neu
category: Neue Kategorie
contact: Neuer Kontakt
transfer: Neue Datenweitergabe
processing: Neue Auftragsverarbeitung
procedure: Neue Verarbeitungstätigkeit
software: Neue Software
select:
category: Datenkategorie wählen
contact: Kontakt wählen
procedure: Verarbeitungstätigkeit wählen
software: Software wählen

0 comments on commit 259edcb

Please sign in to comment.