-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #236 from H2-invent/feature/dsfa_table
Create index page with table for DSFA
- Loading branch information
Showing
15 changed files
with
207 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use App\Entity\Team; | ||
use App\Form\Type\VvtDsfaType; | ||
use App\Repository\VVTDsfaRepository; | ||
use App\Repository\VVTRepository; | ||
use App\Service\AssignService; | ||
use App\Service\CurrentTeamService; | ||
use App\Service\SecurityService; | ||
use App\Service\VVTService; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Symfony\Component\Validator\Validator\ValidatorInterface; | ||
use Symfony\Contracts\Translation\TranslatorInterface; | ||
|
||
class DsfaController extends BaseController | ||
{ | ||
public function __construct( | ||
private TranslatorInterface $translator, | ||
private VVTDsfaRepository $repo, | ||
private VVTRepository $VVTRepository, | ||
private EntityManagerInterface $em, | ||
private CurrentTeamService $currentTeamService, | ||
private VVTService $VVTService, | ||
private SecurityService $securityService) | ||
{ | ||
} | ||
|
||
#[Route('/dsfa', name: 'dsfa')] | ||
public function index(): Response | ||
{ | ||
return $this->render('dsfa/index.html.twig', [ | ||
'title' => $this->translator->trans(id: 'dataProtectionImpactAssessment.word_plural', domain: 'vvt'), | ||
'dsfas' => $this->repo->findAllByTeam($this->getTeam()), | ||
]); | ||
} | ||
|
||
#[Route(path: '/dsfa/new', name: 'dsfa_new')] | ||
public function new(ValidatorInterface $validator, Request $request): Response | ||
{ | ||
$team = $this->getTeam(); | ||
$vvt = $this->VVTRepository->find($request->get('vvt')); | ||
if ($this->securityService->teamDataCheck($vvt, $team) === false) { | ||
return $this->redirectToRoute('vvt'); | ||
} | ||
|
||
$dsfa = $this->VVTService->newDsfa($team, $this->getUser(), $vvt); | ||
$form = $this->createForm(VvtDsfaType::class,$dsfa ); | ||
$form->handleRequest($request); | ||
$errors = array(); | ||
|
||
if ($form->isSubmitted() && $form->isValid()) { | ||
$dsfa = $form->getData(); | ||
$errors = $validator->validate($dsfa); | ||
if (count($errors) == 0) { | ||
$this->em->persist($dsfa); | ||
$this->em->flush(); | ||
$this->addSuccessMessage($this->translator->trans(id: 'dsfa.created', domain: 'vvt')); | ||
|
||
return $this->redirectToRoute('vvt_edit', [ | ||
'id' => $dsfa->getVvt()->getId(), | ||
]); | ||
} | ||
} | ||
|
||
return $this->render('dsfa/edit.html.twig', [ | ||
'form' => $form->createView(), | ||
'errors' => $errors, | ||
'title' => $this->translator->trans(id: 'dataPrivacyFollowUpEstimation.create', domain: 'vvt'), | ||
'dsfa' => $dsfa, | ||
'activ' => $dsfa->getActiv(), | ||
]); | ||
} | ||
|
||
#[Route(path: '/dsfa/edit', name: 'dsfa_edit')] | ||
public function edit(ValidatorInterface $validator, Request $request, AssignService $assignService): Response | ||
{ | ||
$team = $this->getTeam(); | ||
$dsfa = $this->repo->find($request->get('dsfa')); | ||
|
||
if ($this->securityService->teamDataCheck($dsfa->getVvt(), $team) === false) { | ||
return $this->redirectToRoute('vvt'); | ||
} | ||
|
||
$newDsfa = $this->VVTService->cloneDsfa($dsfa, $this->getUser()); | ||
$form = $this->createForm(VvtDsfaType::class, $newDsfa); | ||
$form->handleRequest($request); | ||
$assign = $assignService->createForm($dsfa, $team); | ||
$errors = array(); | ||
|
||
if ($form->isSubmitted() && $form->isValid() && $dsfa->getActiv() && !$dsfa->getVvt()->getApproved()) { | ||
$dsfa->setActiv(false); | ||
$newDsfa = $form->getData(); | ||
$errors = $validator->validate($newDsfa); | ||
|
||
if (count($errors) == 0) { | ||
$this->em->persist($newDsfa); | ||
$this->em->persist($dsfa); | ||
$this->em->flush(); | ||
$this->addSuccessMessage($this->translator->trans(id: 'save.successful', domain: 'general')); | ||
|
||
return $this->redirectToRoute('dsfa_edit', [ | ||
'dsfa' => $newDsfa->getId(), | ||
]); | ||
} | ||
} | ||
|
||
$this->setBackButton($this->generateUrl('vvt_edit', ['id' => $dsfa->getVvt()->getId()])); | ||
|
||
return $this->render('dsfa/edit.html.twig', [ | ||
'form' => $form->createView(), | ||
'assignForm' => $assign->createView(), | ||
'errors' => $errors, | ||
'title' => $this->translator->trans(id: 'dataPrivacyFollowUpEstimation.edit', domain: 'vvt'), | ||
'dsfa' => $dsfa, | ||
'activ' => $dsfa->getActiv(), | ||
]); | ||
} | ||
|
||
private function getTeam(): ?Team | ||
{ | ||
return $this->currentTeamService->getTeamFromSession($this->getUser()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
templates/vvt/__dsfaHistory.html.twig → templates/dsfa/__history.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
{% trans_default_domain 'vvt' %} | ||
<li> | ||
<a href="{{ path('vvt_dsfa_edit',{'dsfa':p.id}) }}"> | ||
<a href="{{ path('dsfa_edit',{'dsfa':p.id}) }}"> | ||
{{ p.createdAt|date('d.m.Y h:m') }} -- id: {{ p.id }} -- {% trans from 'general' %}createdBy{% endtrans %}: {{ p.user.email }} | ||
{% if not p.dsb %} --<span>{% trans %}dsbReviewMissing{% endtrans %}</span>{% endif %} | ||
{% if not p.ergebnis %} -- <span>{% trans %}resultMissing{% endtrans %}</span>{% endif %} | ||
</a> | ||
</li> | ||
{% if p.previous %} | ||
{{ include('vvt/__dsfaHistory.html.twig', {'p':p.previous}) }} | ||
{{ include('dsfa/__history.html.twig', {'p':p.previous}) }} | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{% extends 'base.html.twig' %} | ||
|
||
{% block title %} | ||
{{ title }} | ||
{% endblock %} | ||
|
||
{% set fullWidthLayout = true %} | ||
|
||
{% block body %} | ||
<table id="data-table" class="dataTable"> | ||
<thead> | ||
<tr> | ||
<th scope="col">#</th> | ||
<th scope="col">VVT</th> | ||
<th scope="col">{% trans from 'general' %}state{% endtrans %}</th> | ||
<th scope="col">{% trans from 'general' %}appoved{% endtrans %}</th> | ||
<th scope="col">{% trans from 'general' %}date{% endtrans %}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for dsfa in dsfas %} | ||
<tr data-href='{{ path('dsfa_edit',{'dsfa':dsfa.id}) }}'> | ||
<td>{{ dsfa.vvt.nummer }}</td> | ||
<td>{{ dsfa.vvt.name }}</td> | ||
<td>{{ dsfa.vvt.approved ? 'approved'|trans : dsfa.vvt.status.name }}</td> | ||
<td>{{ dsfa.vvt.approved ? 'yes'|trans : 'no'|trans }}</td> | ||
<td>{{ dsfa.createdAt|date('d.m.Y H:i:s') }}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
{% endblock %} |
Oops, something went wrong.