From e8f15b79dcc3c364ec64d3744c94200730be8bd5 Mon Sep 17 00:00:00 2001
From: Hamza HRAMCHI <hamza.hramchi@xelians.fr>
Date: Wed, 9 Feb 2022 17:17:04 +0100
Subject: [PATCH] FIX #15943 TIME 1:10 delete signatures after refusal action +
 not being able to annotate when the document is certified + wording

---
 lang/en.json                                  |  5 ++-
 lang/fr.json                                  |  5 ++-
 .../app/document/document.component.ts        | 39 +++++++++++++------
 src/frontend/app/search/search.component.scss |  6 +++
 src/frontend/app/search/search.component.ts   |  3 +-
 .../app/signatures/signatures.component.html  |  4 +-
 6 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/lang/en.json b/lang/en.json
index 62ebd4fcc9..5ca16125b8 100755
--- a/lang/en.json
+++ b/lang/en.json
@@ -406,7 +406,7 @@
         "loadingMoreData": "Load more data ...",
         "validateDocumentWarning": "You are about to validate this document!",
         "certifiedDocument": "Certified document",
-        "certifiedDocumentMsg": "The document was signed by digital certificate, you cannot affix a stamp.",
+        "certifiedDocumentMsg": "The document was signed by digital certificate, you cannot affix a stamp or annotate the document.",
         "errorUserSignType": "Signers without a certificate must be present before signers with a certificate.",
         "fortifyReadException": "Error when communicating with Fortify",
         "docaposteSignatureDisabled": "The docaposteSignature parameter is not activated",
@@ -627,6 +627,7 @@
         "notificationTemplateTable": "<table style=\"border: 1pt solid #000000; width: 582px; height: 77px;\" border=\"1\" frame=\"box\" cellspacing=\"1\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: small;\"><strong>Objet</strong></span></td>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: small;\"><strong>Liens</strong></span></td>\n</tr>\n{{rows}}\n</tbody>\n</table>",
         "notificationTemplateRow": "<tr>\n<td><span style=\"font-family: arial,helvetica,sans-serif; font-size: small;\">{{object}}</span></td>\n<td><span style=\"font-family: arial,helvetica,sans-serif;\"><a href=\"{{link}}\">Voir</a></span></td>\n</tr>",
         "azure_samlConnection": "Azure SAML",
-        "cannotSetSignature": "You cannot pre-position a signature for a user with the annotator role"
+        "cannotSetSignature": "You cannot pre-position a signature for a user with the annotator role",
+        "resumeOriginalDoc": "The return document action resumes the original document"
     }
 }
\ No newline at end of file
diff --git a/lang/fr.json b/lang/fr.json
index f09d81e94f..57432f289a 100755
--- a/lang/fr.json
+++ b/lang/fr.json
@@ -417,7 +417,7 @@
 		"loadingMoreData": "Charger plus de données ...",
 		"validateDocumentWarning": "Vous êtes sur le point de valider ce document !",
 		"certifiedDocument": "Document certifié",
-		"certifiedDocumentMsg": "Le document a été signé par certificat numérique, vous ne pouvez pas apposer de griffe.",
+		"certifiedDocumentMsg": "Le document a été signé par certificat numérique, vous ne pouvez pas apposer de griffe ou annoter le document.",
 		"errorUserSignType": "Les signataires sans certificat doivent être présent avant les signataires avec certificat.",
 		"fortifyReadException": "Erreur lors de la communication avec Fortify",
 		"certifiedDocumentMsg2": "Document certifié ! Les annotations sur le document ne seront pas prise en compte !",
@@ -626,6 +626,7 @@
 		"originaleize": "Taille originale",
 		"scalingDocWith": "{{value}} % de la largeur du document",
 		"azure_samlConnection": "Azure SAML",
-		"cannotSetSignature": "Vous ne pouvez pas pré-positionner une signature pour un utilisateur ave le rôle annotateur"
+		"cannotSetSignature": "Vous ne pouvez pas pré-positionner une signature pour un utilisateur ave le rôle annotateur",
+		"resumeOriginalDoc": "L'action renvoi de document reprend le document original"
 	}
 }
diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts
index be3e24ba1f..010bda5eda 100755
--- a/src/frontend/app/document/document.component.ts
+++ b/src/frontend/app/document/document.component.ts
@@ -276,17 +276,33 @@ export class DocumentComponent implements OnInit {
     }
 
     async openNoteEditor() {
-        const modal = await this.modalController.create({
-            component: DocumentNotePadComponent,
-            cssClass: 'fullscreen',
-            componentProps: {
-                precentScrollLeft: this.posX,
-                precentScrollTop: this.posY,
-                content: this.docList[this.currentDoc].imgContent[this.pageNum]
-            }
-        });
-        await modal.present();
-        const { data } = await modal.onWillDismiss();
+        if (this.mainDocument.isCertified && this.userMode === 'note') {
+            this.signaturesService.stampLock = true;
+            const modal = await this.modalController.create({
+                component: SignaturesComponent,
+                cssClass: 'my-custom-class',
+                componentProps: {
+                    currentWorflow: this.mainDocument.workflow.filter((line: { current: boolean }) => line.current === true)[0],
+                    content: this.fileContent
+                }
+            });
+            await modal.present();
+            const { data } = await modal.onWillDismiss().finally(() => {
+                this.signaturesService.stampLock = false;
+            });
+        } else {
+            const modal = await this.modalController.create({
+                component: DocumentNotePadComponent,
+                cssClass: 'fullscreen',
+                componentProps: {
+                    precentScrollLeft: this.posX,
+                    precentScrollTop: this.posY,
+                    content: this.docList[this.currentDoc].imgContent[this.pageNum]
+                }
+            });
+            await modal.present();
+            const { data } = await modal.onWillDismiss();
+        }
     }
 
     scrollToElem() {
@@ -618,6 +634,7 @@ export class DocumentComponent implements OnInit {
                 {
                     text: this.translate.instant('lang.reject'),
                     handler: async (data: any) => {
+                        this.signaturesService.signaturesContent = [];
                         const idsToProcess = await this.actionsService.checkGroupMail(this.mainDocument, 'reject');
 
                         const res = await this.signatureMethodService.launchDefaultMode(data.paragraph, idsToProcess);
diff --git a/src/frontend/app/search/search.component.scss b/src/frontend/app/search/search.component.scss
index 4e408fdead..f67c7e0cb0 100644
--- a/src/frontend/app/search/search.component.scss
+++ b/src/frontend/app/search/search.component.scss
@@ -67,4 +67,10 @@
         height: auto;
         display: inline-block;
     }
+}
+
+::ng-deep.action-sheet-sub-title.sc-ion-action-sheet-md {
+    color: gray;
+    font-size: 12px;
+    opacity: 0.9;
 }
\ No newline at end of file
diff --git a/src/frontend/app/search/search.component.ts b/src/frontend/app/search/search.component.ts
index 2a1d4298aa..01369e214b 100644
--- a/src/frontend/app/search/search.component.ts
+++ b/src/frontend/app/search/search.component.ts
@@ -229,7 +229,8 @@ export class SearchComponent implements OnInit {
             }
         });
         const actionSheet = await this.actionSheetController.create({
-            header: this.translate.instant('lang.actions') + (item.reference !== null ? ' - ' + item.reference : ''),
+            header: this.translate.instant('lang.actions') + (item.reference !== null ? ' - ' + item.reference : '') + '\n' + 'TEST',
+            subHeader: this.translate.instant('lang.resumeOriginalDoc'),
             buttons: buttons
         });
         await actionSheet.present();
diff --git a/src/frontend/app/signatures/signatures.component.html b/src/frontend/app/signatures/signatures.component.html
index 6c7e6ab927..09292f42a2 100755
--- a/src/frontend/app/signatures/signatures.component.html
+++ b/src/frontend/app/signatures/signatures.component.html
@@ -1,6 +1,6 @@
 <ion-header [translucent]="true">
     <ion-toolbar color="primary">
-        <ion-title>{{'lang.signatures' | translate}} <small class="secondary" *ngIf="signPosMode">{{this.currentWorflow.signaturePositions.length}} {{'lang.prePositionings' | translate}}</small></ion-title>
+        <ion-title>{{!signaturesService.stampLock ? 'lang.signatures' : 'lang.certifiedDocument' | translate}} <small class="secondary" *ngIf="signPosMode">{{this.currentWorflow.signaturePositions.length}} {{'lang.prePositionings' | translate}}</small></ion-title>
         <ion-buttons slot="end">
             <ion-button (click)="dismissModal()">
                 <ion-icon slot="icon-only" name="close-outline"></ion-icon>
@@ -8,7 +8,7 @@
         </ion-buttons>
     </ion-toolbar>
 </ion-header>
-<ion-content (wheel)="scroll($event)">
+<ion-content (wheel)="!signaturesService.stampLock ? scroll($event): null">
     <ng-container *ngIf="!signaturesService.stampLock; else elseCertified">
         <ion-slides *ngIf="!loading" pager="true" [options]="slideOpts" #slides>
             <ion-slide *ngFor="let slide of signaturesList" style="display: grid;grid-template-columns: repeat(2, 1fr);">
-- 
GitLab