diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 277a18142..eb72c2624 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -14,11 +14,11 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep; -use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature; use Chill\MainBundle\Form\WorkflowSignatureMetadataType; use Chill\MainBundle\Form\WorkflowStepType; use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository; +use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepSignatureRepository; use Chill\MainBundle\Security\Authorization\EntityWorkflowVoter; use Chill\MainBundle\Security\ChillSecurity; use Chill\MainBundle\Workflow\EntityWorkflowManager; @@ -32,6 +32,7 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Workflow\Registry; @@ -51,6 +52,7 @@ class WorkflowController extends AbstractController private readonly ChillSecurity $security, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, private readonly ClockInterface $clock, + private readonly EntityWorkflowStepSignatureRepository $entityWorkflowStepSignatureRepository, ) {} #[Route(path: '/{_locale}/main/workflow/create', name: 'chill_main_workflow_create')] @@ -374,7 +376,20 @@ class WorkflowController extends AbstractController #[Route(path: '/{_locale}/main/workflow/signature/{signature_id}/metadata', name: 'chill_main_workflow_signature_metadata')] public function addSignatureMetadata(int $signature_id, Request $request): Response { - $signature = $this->entityManager->getRepository(EntityWorkflowStepSignature::class)->find($signature_id); + $signature = $this->entityWorkflowStepSignatureRepository->find($signature_id); + + if (null === $signature) { + throw new NotFoundHttpException('signature not found'); + } + + if ($signature->isSigned()) { + $this->addFlash( + 'notice', + $this->translator->trans('workflow.signature_zone.already_signed_alert') + ); + + return $this->redirectToRoute('chill_main_workflow_show', ['id' => $signature->getStep()->getEntityWorkflow()->getId()]); + } if ($signature->getSigner() instanceof User) { return $this->redirectToRoute('chill_main_workflow_signature_add', ['id' => $signature_id]); diff --git a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStepSignature.php b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStepSignature.php index 46c8bb04d..527ede0ef 100644 --- a/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStepSignature.php +++ b/src/Bundle/ChillMainBundle/Entity/Workflow/EntityWorkflowStepSignature.php @@ -135,4 +135,9 @@ class EntityWorkflowStepSignature implements TrackCreationInterface, TrackUpdate return $this; } + + public function isSigned(): bool + { + return EntityWorkflowSignatureStateEnum::SIGNED == $this->getState(); + } } diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss index 2523ee202..eabc2adc4 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss @@ -31,6 +31,8 @@ // Specific templates @import './scss/notification'; +@import './scss/hover.scss'; + /* * BASE LAYOUT POSITION */ diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/hover.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/hover.scss new file mode 100644 index 000000000..95fe12efc --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/hover.scss @@ -0,0 +1,11 @@ + + +.row.row-hover { + padding: 0.3rem; + + &:hover { + background-color: $gray-100; + border-top: 1px solid $gray-400; + border-bottom: 1px solid $gray-400; + } +} diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss index 5158a826e..d37765e6b 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/scss/record_actions.scss @@ -17,6 +17,10 @@ ul.record_actions { display: inline-block; } + &.slim { + margin-bottom: 0; + } + &.column { flex-direction: column; } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Dev/dev.assets.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Dev/dev.assets.html.twig index 6a7c4edf0..5aafb6635 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Dev/dev.assets.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Dev/dev.assets.html.twig @@ -300,7 +300,96 @@ +
slim
Ajouter slim
enlève la marge inférieure. Permet un meilleur alignement horizontal dans une row
Ajouter .row-hover
sur une class .row
provoque un changement de background au survol
{{ s.stateDate }}
+ {% for s in signatures %} +{{ s.stateDate }}
+ {% endif %} +