From 3e6d764b9b3d5ef4cbe97d4bbd7fb7dff2799f46 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 7 Aug 2024 12:44:34 +0200 Subject: [PATCH 1/8] Replace sign button with signed statement if person/user has signed --- .../Controller/WorkflowController.php | 10 ++++++++-- .../views/Workflow/_signature.html.twig | 16 ++++++++++------ .../ChillMainBundle/translations/messages.fr.yml | 1 + 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 277a18142..9f2196982 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,11 @@ 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->getSigner() instanceof User) { return $this->redirectToRoute('chill_main_workflow_signature_add', ['id' => $signature_id]); diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig index f613b69dd..ddccc6a4c 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig @@ -6,12 +6,16 @@
{{ s.signer|chill_entity_render_box }}
{% endfor %} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 9a90b7fa1..23a77c710 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -531,6 +531,7 @@ workflow: signature_zone: title: Appliquer les signatures électroniques button_sign: Signer + has_signed_statement: 'À signé le %datetime%' metadata: sign_by: 'Signature pour %name%' docType: Type de document From ee6edba2067982a9968709f80a2378ab8e651d29 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 7 Aug 2024 14:18:16 +0200 Subject: [PATCH 2/8] Create isSigned method in EntityWorkflowStepSignature.php Refactorization and ease of use in template and workflow controller --- .../Entity/Workflow/EntityWorkflowStepSignature.php | 5 +++++ .../Resources/views/Workflow/_signature.html.twig | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) 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/views/Workflow/_signature.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig index ddccc6a4c..e439f2268 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig @@ -6,7 +6,7 @@
{{ s.signer|chill_entity_render_box }}
    - {% if s.state.value == 'signed' %} + {% if s.isSigned %}

    {{ 'workflow.signature_zone.has_signed_statement'|trans( { '%datetime%' : s.stateDate|date('j M Y à H:i:s') } ) }}

    {% else %}
  • From 0c797c29970d68dd0ea7b434e7eb4e98827e7696 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 7 Aug 2024 14:18:34 +0200 Subject: [PATCH 3/8] Redirect to workflow show page if document already signed Verify the state of the signature. If isSigned is true, redirection to workflow show page. --- src/Bundle/ChillMainBundle/Controller/WorkflowController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 9f2196982..b9c728eeb 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -382,6 +382,10 @@ class WorkflowController extends AbstractController throw new NotFoundHttpException('signature not found'); } + if ($signature->isSigned()) { + 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]); } From cc8214d52cc9c7de5d5b020e46bc82ec203e5048 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 28 Aug 2024 16:13:26 +0200 Subject: [PATCH 4/8] Add flash message in case signature was already applied --- src/Bundle/ChillMainBundle/Controller/WorkflowController.php | 4 ++++ src/Bundle/ChillMainBundle/translations/messages.fr.yml | 1 + 2 files changed, 5 insertions(+) diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index b9c728eeb..5d78103b8 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -383,6 +383,10 @@ class WorkflowController extends AbstractController } 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()]); } diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 23a77c710..e442f38aa 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -542,6 +542,7 @@ workflow: user signature: Selectionner utilisateur pour signer persons: Usagers user: Utilisateur + already_signed_alert: La signature a déjà été appliquée Subscribe final: Recevoir une notification à l'étape finale From ce781a5b587859b333d11b671e3bc48ca93b3a68 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 28 Aug 2024 16:27:04 +0200 Subject: [PATCH 5/8] Translate datetime object with icu: split date and time Translate datetime within icu format --- src/Bundle/ChillMainBundle/Controller/WorkflowController.php | 1 + .../Resources/views/Workflow/_signature.html.twig | 2 +- .../ChillMainBundle/translations/messages+intl-icu.fr.yaml | 3 +++ src/Bundle/ChillMainBundle/translations/messages.fr.yml | 1 - 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php index 5d78103b8..eb72c2624 100644 --- a/src/Bundle/ChillMainBundle/Controller/WorkflowController.php +++ b/src/Bundle/ChillMainBundle/Controller/WorkflowController.php @@ -387,6 +387,7 @@ class WorkflowController extends AbstractController 'notice', $this->translator->trans('workflow.signature_zone.already_signed_alert') ); + return $this->redirectToRoute('chill_main_workflow_show', ['id' => $signature->getStep()->getEntityWorkflow()->getId()]); } diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig index e439f2268..a2a4129f1 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig @@ -7,7 +7,7 @@
      {% if s.isSigned %} -

      {{ 'workflow.signature_zone.has_signed_statement'|trans( { '%datetime%' : s.stateDate|date('j M Y à H:i:s') } ) }}

      +

      {{ 'workflow.signature_zone.has_signed_statement'|trans({ 'datetime' : s.stateDate }) }}

      {% else %}
    • {{ 'workflow.signature_zone.button_sign'|trans }} diff --git a/src/Bundle/ChillMainBundle/translations/messages+intl-icu.fr.yaml b/src/Bundle/ChillMainBundle/translations/messages+intl-icu.fr.yaml index 96b2edd98..a0753f7a6 100644 --- a/src/Bundle/ChillMainBundle/translations/messages+intl-icu.fr.yaml +++ b/src/Bundle/ChillMainBundle/translations/messages+intl-icu.fr.yaml @@ -45,6 +45,9 @@ workflow: few {# workflows} other {# workflows} } + signature_zone: + has_signed_statement: 'A signé le {datetime, date, short} à {datetime, time, short}' + duration: minute: >- diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index e442f38aa..f6f30bcd0 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -531,7 +531,6 @@ workflow: signature_zone: title: Appliquer les signatures électroniques button_sign: Signer - has_signed_statement: 'À signé le %datetime%' metadata: sign_by: 'Signature pour %name%' docType: Type de document From 71d3aa3969936cb6d98e7702d439d4ada173a238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 4 Sep 2024 17:24:11 +0200 Subject: [PATCH 6/8] Refactor signature rendering logic Reorganized the signature rendering loop for better readability. Moved the row alignment inside the loop and added text alignment for signed statements. Simplified the conditional checks within the loop to enhance code maintainability. --- .../views/Workflow/_signature.html.twig | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig index a2a4129f1..2452411d5 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig @@ -1,24 +1,24 @@

      {{ 'workflow.signature_zone.title'|trans }}

      -
      - {% for s in signatures %} -
      {{ s.signer|chill_entity_render_box }}
      -
      -
        - {% if s.isSigned %} -

        {{ 'workflow.signature_zone.has_signed_statement'|trans({ 'datetime' : s.stateDate }) }}

        - {% else %} -
      • - {{ 'workflow.signature_zone.button_sign'|trans }} - {% if s.state is same as('signed') %} -

        {{ s.stateDate }}

        - {% endif %} -
      • - {% endif %} -
      -
      - {% endfor %} -
      + {% for s in signatures %} +
      +
      {{ s.signer|chill_entity_render_box }}
      +
      + {% if s.isSigned %} +

      {{ 'workflow.signature_zone.has_signed_statement'|trans({ 'datetime' : s.stateDate }) }}

      + {% else %} + + {% endif %} +
      +
      + {% endfor %}
      From 20f2bc6c35e3b2b3d5f46d2dd50ad795ab341d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 4 Sep 2024 17:26:46 +0200 Subject: [PATCH 7/8] Enhance signature display with detailed person information Updated the signature view template to include person details using the '_insert_vue_onthefly.html.twig' template. This change adds more contextual information about the signer, such as their name and status, improving the user experience. --- .../Resources/views/Workflow/_signature.html.twig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig index 2452411d5..a938f9e05 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig @@ -3,7 +3,14 @@
      {% for s in signatures %}
      -
      {{ s.signer|chill_entity_render_box }}
      +
      + {% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { + action: 'show', displayBadge: true, + targetEntity: { name: 'person', id: s.signer.id }, + buttonText: s.signer|chill_entity_render_string, + isDead: s.signer.deathDate is not null + } %} +
      {% if s.isSigned %}

      {{ 'workflow.signature_zone.has_signed_statement'|trans({ 'datetime' : s.stateDate }) }}

      From d0031e82e8eb5e8d6f9610361204a315a9fb17a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 4 Sep 2024 17:55:01 +0200 Subject: [PATCH 8/8] Add hover effect and slim class to dev assets and apply in signature list Introduced a new SCSS file to handle hover effects on rows and added the ability to remove bottom margins with a "slim" class. Updated various twig templates to utilize these new styles for better visual feedback and alignment. --- .../Resources/public/chill/chillmain.scss | 2 + .../Resources/public/chill/scss/hover.scss | 11 +++ .../public/chill/scss/record_actions.scss | 4 + .../Resources/views/Dev/dev.assets.html.twig | 89 +++++++++++++++++++ .../views/Workflow/_signature.html.twig | 6 +- 5 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Resources/public/chill/scss/hover.scss 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

    + +
    +
    +
    + Some text, ul_record_actions sans slim +
    +
    +
      +
    • +
    +
    +
    +
    +
    + Some text, ul_record_actions avec slim +
    +
    +
      +
    • +
    +
    +
    +
    + + + <a class="btn btn-submit">Text</a> Toutes les classes btn-* de bootstrap sont fonctionnelles + +

    Hover

    + +

    Ajouter .row-hover sur une class .row provoque un changement de background au survol

    + +
    +
    + +
    + A signé le 04/09/2024 à 13:55 +
    +
    +
    + +
    + +
    +
    +
    + +
    + A signé le 04/09/2024 à 13:57 +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
+ {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig index a938f9e05..68b6f4274 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Workflow/_signature.html.twig @@ -2,7 +2,7 @@
{% for s in signatures %} -
+
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with { action: 'show', displayBadge: true, @@ -13,9 +13,9 @@
{% if s.isSigned %} -

{{ 'workflow.signature_zone.has_signed_statement'|trans({ 'datetime' : s.stateDate }) }}

+ {{ 'workflow.signature_zone.has_signed_statement'|trans({ 'datetime' : s.stateDate }) }} {% else %} -