Merge branch '301-has-signed-statement' into 'signature-app-master'

Adjust behavior when signature in signed state

See merge request Chill-Projet/chill-bundles!717
This commit is contained in:
Julien Fastré 2024-09-05 14:50:05 +00:00
commit bf1af1aaad
9 changed files with 157 additions and 16 deletions

View File

@ -14,11 +14,11 @@ namespace Chill\MainBundle\Controller;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Workflow\EntityWorkflow; use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep; use Chill\MainBundle\Entity\Workflow\EntityWorkflowStep;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
use Chill\MainBundle\Form\WorkflowSignatureMetadataType; use Chill\MainBundle\Form\WorkflowSignatureMetadataType;
use Chill\MainBundle\Form\WorkflowStepType; use Chill\MainBundle\Form\WorkflowStepType;
use Chill\MainBundle\Pagination\PaginatorFactory; use Chill\MainBundle\Pagination\PaginatorFactory;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository; use Chill\MainBundle\Repository\Workflow\EntityWorkflowRepository;
use Chill\MainBundle\Repository\Workflow\EntityWorkflowStepSignatureRepository;
use Chill\MainBundle\Security\Authorization\EntityWorkflowVoter; use Chill\MainBundle\Security\Authorization\EntityWorkflowVoter;
use Chill\MainBundle\Security\ChillSecurity; use Chill\MainBundle\Security\ChillSecurity;
use Chill\MainBundle\Workflow\EntityWorkflowManager; use Chill\MainBundle\Workflow\EntityWorkflowManager;
@ -32,6 +32,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Validator\Validator\ValidatorInterface;
use Symfony\Component\Workflow\Registry; use Symfony\Component\Workflow\Registry;
@ -51,6 +52,7 @@ class WorkflowController extends AbstractController
private readonly ChillSecurity $security, private readonly ChillSecurity $security,
private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry,
private readonly ClockInterface $clock, private readonly ClockInterface $clock,
private readonly EntityWorkflowStepSignatureRepository $entityWorkflowStepSignatureRepository,
) {} ) {}
#[Route(path: '/{_locale}/main/workflow/create', name: 'chill_main_workflow_create')] #[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')] #[Route(path: '/{_locale}/main/workflow/signature/{signature_id}/metadata', name: 'chill_main_workflow_signature_metadata')]
public function addSignatureMetadata(int $signature_id, Request $request): Response 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) { if ($signature->getSigner() instanceof User) {
return $this->redirectToRoute('chill_main_workflow_signature_add', ['id' => $signature_id]); return $this->redirectToRoute('chill_main_workflow_signature_add', ['id' => $signature_id]);

View File

@ -135,4 +135,9 @@ class EntityWorkflowStepSignature implements TrackCreationInterface, TrackUpdate
return $this; return $this;
} }
public function isSigned(): bool
{
return EntityWorkflowSignatureStateEnum::SIGNED == $this->getState();
}
} }

View File

@ -31,6 +31,8 @@
// Specific templates // Specific templates
@import './scss/notification'; @import './scss/notification';
@import './scss/hover.scss';
/* /*
* BASE LAYOUT POSITION * BASE LAYOUT POSITION
*/ */

View File

@ -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;
}
}

View File

@ -17,6 +17,10 @@ ul.record_actions {
display: inline-block; display: inline-block;
} }
&.slim {
margin-bottom: 0;
}
&.column { &.column {
flex-direction: column; flex-direction: column;
} }

View File

@ -300,7 +300,96 @@
</ul> </ul>
</div> </div>
<h3><code>slim</code></h3>
<p>Ajouter <code>slim</code> enlève la marge inférieure. Permet un meilleur alignement horizontal dans une <code>row</code></p>
<div class="container">
<div class="row row-hover">
<div class="col-8">
Some text, ul_record_actions sans slim
</div>
<div class="col-4">
<ul class="record_actions">
<li><button class="btn">Some action</button></li>
</ul>
</div>
</div>
<div class="row row-hover">
<div class="col-8">
Some text, ul_record_actions avec slim
</div>
<div class="col-4">
<ul class="record_actions slim">
<li><button class="btn">Some action</button></li>
</ul>
</div>
</div>
</div>
<xmp><a class="btn btn-submit">Text</a></xmp> <xmp><a class="btn btn-submit">Text</a></xmp>
Toutes les classes btn-* de bootstrap sont fonctionnelles Toutes les classes btn-* de bootstrap sont fonctionnelles
<h2>Hover</h2>
<p>Ajouter <code>.row-hover</code> sur une class <code>.row</code> provoque un changement de background au survol</p>
<div class="container">
<div class="row row-hover align-items-center">
<div class="col-sm-12 col-md-8">
<span class="onthefly-container" data-target-name="person" data-target-id="329" data-action="show" data-button-text="Fatoumata Binta DIALLO (33 ans)" data-display-badge="true" data-v-app=""><a data-v-0c1a1125=""><span data-v-0c1a1125="" class="chill-entity entity-person badge-person">Fatoumata Binta DIALLO (33 ans)<!--v-if--></span></a><!--teleport start--><!--teleport end--></span>
</div>
<div class="col-sm-12 col-md-4">
<span class="text-end">A signé le 04/09/2024 à 13:55</span>
</div>
</div>
<div class="row row-hover align-items-center">
<div class="col-sm-12 col-md-8">
<span class="onthefly-container" data-target-name="person" data-target-id="330" data-action="show" data-button-text="Abdoulaye DIALLO (9 ans)" data-display-badge="true" data-v-app=""><a data-v-0c1a1125=""><span data-v-0c1a1125="" class="chill-entity entity-person badge-person">Abdoulaye DIALLO (9 ans)<!--v-if--></span></a><!--teleport start--><!--teleport end--></span>
</div>
<div class="col-sm-12 col-md-4">
<ul class="record_actions">
<li>
<a class="btn btn-misc" href="/fr/main/workflow/signature/6/metadata?returnPath=/fr/main/workflow/15/show"><i class="fa fa-pencil-square-o"></i> Signer</a>
</li>
</ul>
</div>
</div>
<div class="row row-hover align-items-center">
<div class="col-sm-12 col-md-8">
<span class="onthefly-container" data-target-name="person" data-target-id="332" data-action="show" data-button-text="Mohamed DIALLO (44 ans)" data-display-badge="true" data-v-app=""><a data-v-0c1a1125=""><span data-v-0c1a1125="" class="chill-entity entity-person badge-person">Mohamed DIALLO (44 ans)<!--v-if--></span></a><!--teleport start--><!--teleport end--></span>
</div>
<div class="col-sm-12 col-md-4">
<span class="text-end">A signé le 04/09/2024 à 13:57</span>
</div>
</div>
<div class="row row-hover align-items-center">
<div class="col-sm-12 col-md-8">
<span class="onthefly-container" data-target-name="person" data-target-id="333" data-action="show" data-button-text="Fatou DIALLO (37 ans)" data-display-badge="true" data-v-app=""><a data-v-0c1a1125=""><span data-v-0c1a1125="" class="chill-entity entity-person badge-person">Fatou DIALLO (37 ans)<!--v-if--></span></a><!--teleport start--><!--teleport end--></span>
</div>
<div class="col-sm-12 col-md-4">
<ul class="record_actions">
<li>
<a class="btn btn-misc" href="/fr/main/workflow/signature/8/metadata?returnPath=/fr/main/workflow/15/show"><i class="fa fa-pencil-square-o"></i> Signer</a>
</li>
</ul>
</div>
</div>
<div class="row row-hover align-items-center">
<div class="col-sm-12 col-md-8">
<span class="onthefly-container" data-target-name="person" data-target-id="334" data-action="show" data-button-text="Fanta DIALLO (7 ans)" data-display-badge="true" data-v-app=""><a data-v-0c1a1125=""><span data-v-0c1a1125="" class="chill-entity entity-person badge-person">Fanta DIALLO (7 ans)<!--v-if--></span></a><!--teleport start--><!--teleport end--></span>
</div>
<div class="col-sm-12 col-md-4">
<ul class="record_actions">
<li>
<a class="btn btn-misc" href="/fr/main/workflow/signature/9/metadata?returnPath=/fr/main/workflow/15/show"><i class="fa fa-pencil-square-o"></i> Signer</a>
</li>
</ul>
</div>
</div>
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -1,20 +1,31 @@
<h2>{{ 'workflow.signature_zone.title'|trans }}</h2> <h2>{{ 'workflow.signature_zone.title'|trans }}</h2>
<div class="container"> <div class="container">
<div class="row align-items-center"> {% for s in signatures %}
{% for s in signatures %} <div class="row row-hover align-items-center">
<div class="col-sm-12 col-md-8"><span>{{ s.signer|chill_entity_render_box }}</span></div> <div class="col-sm-12 col-md-8">
<div class="col-sm-12 col-md-4"> {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
<ul class="record_actions"> action: 'show', displayBadge: true,
<li> targetEntity: { name: 'person', id: s.signer.id },
<a class="btn btn-misc" href="{{ chill_path_add_return_path('chill_main_workflow_signature_metadata', { 'signature_id': s.id}) }}"><i class="fa fa-pencil-square-o"></i> {{ 'workflow.signature_zone.button_sign'|trans }}</a> buttonText: s.signer|chill_entity_render_string,
{% if s.state is same as('signed') %} isDead: s.signer.deathDate is not null
<p class="updatedBy">{{ s.stateDate }}</p> } %}
</div>
<div class="col-sm-12 col-md-4">
{% if s.isSigned %}
<span class="text-end">{{ 'workflow.signature_zone.has_signed_statement'|trans({ 'datetime' : s.stateDate }) }}</span>
{% else %}
<ul class="record_actions slim">
<li>
<a class="btn btn-misc" href="{{ chill_path_add_return_path('chill_main_workflow_signature_metadata', { 'signature_id': s.id}) }}"><i class="fa fa-pencil-square-o"></i> {{ 'workflow.signature_zone.button_sign'|trans }}</a>
{% if s.state is same as('signed') %}
<p class="updatedBy">{{ s.stateDate }}</p>
{% endif %}
</li>
</ul>
{% endif %} {% endif %}
</li> </div>
</ul> </div>
</div> {% endfor %}
{% endfor %}
</div>
</div> </div>

View File

@ -45,6 +45,9 @@ workflow:
few {# workflows} few {# workflows}
other {# workflows} other {# workflows}
} }
signature_zone:
has_signed_statement: 'A signé le {datetime, date, short} à {datetime, time, short}'
duration: duration:
minute: >- minute: >-

View File

@ -541,6 +541,7 @@ workflow:
user signature: Selectionner utilisateur pour signer user signature: Selectionner utilisateur pour signer
persons: Usagers persons: Usagers
user: Utilisateur user: Utilisateur
already_signed_alert: La signature a déjà été appliquée
Subscribe final: Recevoir une notification à l'étape finale Subscribe final: Recevoir une notification à l'étape finale