From fd23607a471987e1f8c0053a9aa2b269d011c11a Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Tue, 17 Nov 2020 18:46:22 +0100 Subject: [PATCH] FIX #15461 TIME 0:15 add notif error unsign --- .../app/signature-book.component.html | 4 +- .../app/signature-book.component.scss | 21 ++-- src/frontend/app/signature-book.component.ts | 97 ++++++++++++------- src/frontend/lang/lang-en.ts | 1 + src/frontend/lang/lang-fr.ts | 1 + src/frontend/lang/lang-nl.ts | 1 + 6 files changed, 77 insertions(+), 48 deletions(-) diff --git a/src/frontend/app/signature-book.component.html b/src/frontend/app/signature-book.component.html index 7b3eb26ea79..25f2cc44646 100755 --- a/src/frontend/app/signature-book.component.html +++ b/src/frontend/app/signature-book.component.html @@ -256,8 +256,7 @@ [ngClass]="[signatureBook.attachments[rightSelectedThumbnail].status == 'SIGN' ? 'signed' : '']" [ngStyle]="{'box-shadow': signatureBook.listinstance.requested_signature ? 'inset 0px 0px 5px 0px red' : 'inset 0px 0px 5px 0px #656565;'}"> <span - *ngIf="signatureBook.attachments[rightSelectedThumbnail].status != 'SIGN' && signatureBook.signatures[0]" - style="cursor: pointer"> + *ngIf="signatureBook.attachments[rightSelectedThumbnail].status != 'SIGN' && signatureBook.signatures[0]"> <span *ngIf="!loadingSign"> <img *ngFor="let signature of signatureBook.signatures; let i = index" src="../../rest/users/{{signature.user_serial_id}}/signatures/{{signature.id}}/content" @@ -274,6 +273,7 @@ </span> </div> </div> + <app-attachments-list *ngIf="showAttachmentPanel" #appAttachmentsList [resId]="resId" [target]="'process'" (reloadBadgeAttachments)="refreshAttachments()" (afterActionAttachment)="refreshAttachments()"> diff --git a/src/frontend/app/signature-book.component.scss b/src/frontend/app/signature-book.component.scss index 0c9e83a9652..165a38055c5 100755 --- a/src/frontend/app/signature-book.component.scss +++ b/src/frontend/app/signature-book.component.scss @@ -364,10 +364,6 @@ height: 100px; } -.pjSign { - cursor: pointer; -} - .pjDetails label { font-weight: bold; cursor: inherit; @@ -935,20 +931,22 @@ img:hover.panelSelectedThumbnail { } .pjSign img { + cursor: pointer; border: solid 2px white; height: 30px; - width: 50px; - -webkit-transition: height 0.5s; + width: auto; + min-width: 60px; + -webkit-transition: all 0.5s; /* Safari */ - transition: height 0.5s; + transition: all 0.5s; } .pjSign:hover img { height: 60px; width: auto; - -webkit-transition: height 0.5s; + -webkit-transition: all 0.5s; /* Safari */ - transition: height 0.5s; + transition: all 0.5s; } .pjSign:hover img:hover { @@ -956,6 +954,9 @@ img:hover.panelSelectedThumbnail { } .pjSign:hover { + display: flex; + white-space: pre; + overflow: hidden !important; width: 95%; -webkit-transition: width 0.5s; /* Safari */ @@ -1110,4 +1111,4 @@ img:hover.panelSelectedThumbnail { margin-top: 2px; color: black; font-weight: normal; -} \ No newline at end of file +} diff --git a/src/frontend/app/signature-book.component.ts b/src/frontend/app/signature-book.component.ts index 42a16905e43..f28bee12f3a 100755 --- a/src/frontend/app/signature-book.component.ts +++ b/src/frontend/app/signature-book.component.ts @@ -422,46 +422,71 @@ export class SignatureBookComponent implements OnInit, OnDestroy { unsignFile(attachment: any) { if (attachment.isResource) { - this.http.put('../../rest/resources/' + attachment.res_id + '/unsign', {}) - .subscribe(() => { - this.appDocumentViewer.loadRessource(attachment.res_id, 'maintDocument'); - this.rightViewerLink += '?tsp=' + Math.floor(Math.random() * 100); - this.signatureBook.attachments[this.rightSelectedThumbnail].status = 'A_TRA'; - - if (this.signatureBook.resList.length > 0) { - this.signatureBook.resList[this.signatureBook.resListIndex].allSigned = false; - } - if (this.headerTab === 'visaCircuit') { - this.changeSignatureBookLeftContent('document'); - setTimeout(() => { - this.changeSignatureBookLeftContent('visaCircuit'); - }, 0); - } - }); + this.unSignMainDocument(attachment); } else { - this.http.put('../../rest/attachments/' + attachment.res_id + '/unsign', {}) - .subscribe(() => { - this.appDocumentViewer.loadRessource(attachment.res_id, 'attachment'); - this.rightViewerLink = '../../rest/attachments/' + attachment.res_id + '/content'; - this.signatureBook.attachments[this.rightSelectedThumbnail].viewerLink = this.rightViewerLink; - this.signatureBook.attachments[this.rightSelectedThumbnail].status = 'A_TRA'; - this.signatureBook.attachments[this.rightSelectedThumbnail].idToDl = attachment.res_id; - this.signatureBook.attachments[this.rightSelectedThumbnail].signed = false; - this.signatureBook.attachments[this.rightSelectedThumbnail].viewerId = attachment.res_id; - if (this.signatureBook.resList.length > 0) { - this.signatureBook.resList[this.signatureBook.resListIndex].allSigned = false; - } - if (this.headerTab === 'visaCircuit') { - this.changeSignatureBookLeftContent('document'); - setTimeout(() => { - this.changeSignatureBookLeftContent('visaCircuit'); - }, 0); - } - - }); + this.unSignAttachment(attachment); } } + unSignMainDocument(attachment: any) { + this.http.put(`../../rest/resources/${attachment.res_id}/unsign`, {}).pipe( + tap(() => { + this.appDocumentViewer.loadRessource(attachment.res_id, 'maintDocument'); + this.rightViewerLink += '?tsp=' + Math.floor(Math.random() * 100); + this.signatureBook.attachments[this.rightSelectedThumbnail].status = 'A_TRA'; + + if (this.signatureBook.resList.length > 0) { + this.signatureBook.resList[this.signatureBook.resListIndex].allSigned = false; + } + if (this.headerTab === 'visaCircuit') { + this.changeSignatureBookLeftContent('document'); + setTimeout(() => { + this.changeSignatureBookLeftContent('visaCircuit'); + }, 0); + } + }), + catchError((err: any) => { + if (err.status === 403) { + this.notify.error(this.lang.youCannotUnsign); + } else { + this.notify.handleSoftErrors(err); + } + return of(false); + }) + ).subscribe(); + } + + unSignAttachment(attachment: any) { + this.http.put('../../rest/attachments/' + attachment.res_id + '/unsign', {}).pipe( + tap(() => { + this.appDocumentViewer.loadRessource(attachment.res_id, 'attachment'); + this.rightViewerLink = '../rest/attachments/' + attachment.res_id + '/content'; + this.signatureBook.attachments[this.rightSelectedThumbnail].viewerLink = this.rightViewerLink; + this.signatureBook.attachments[this.rightSelectedThumbnail].status = 'A_TRA'; + this.signatureBook.attachments[this.rightSelectedThumbnail].idToDl = attachment.res_id; + this.signatureBook.attachments[this.rightSelectedThumbnail].signed = false; + this.signatureBook.attachments[this.rightSelectedThumbnail].viewerId = attachment.res_id; + if (this.signatureBook.resList.length > 0) { + this.signatureBook.resList[this.signatureBook.resListIndex].allSigned = false; + } + if (this.headerTab === 'visaCircuit') { + this.changeSignatureBookLeftContent('document'); + setTimeout(() => { + this.changeSignatureBookLeftContent('visaCircuit'); + }, 0); + } + }), + catchError((err: any) => { + if (err.status === 403) { + this.notify.error(this.lang.youCannotUnsign); + } else { + this.notify.handleSoftErrors(err); + } + return of(false); + }) + ).subscribe(); + } + backToBasket() { const path = '/basketList/users/' + this.userId + '/groups/' + this.groupId + '/baskets/' + this.basketId; this.router.navigate([path]); diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index 6d2fb1e9e10..e528d54effc 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1740,4 +1740,5 @@ export const LANG_EN = { "indexingModelReplaceToDelete": "To delete this model you have to replace it by another.", "indexingModelFieldsReset": "The following fields are not in the selected model and will be reset for all mails : ", "indexingModelReassign": "Reassign indexing model", + "youCannotUnsign": "You do not have the right to <b>unsign</b> this document. You must be the person who signed this document." }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index a50a244300e..052a29d6855 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1742,4 +1742,5 @@ export const LANG_FR = { "indexingModelReplaceToDelete": "Pour le supprimer vous devez le remplacer par un autre modèle.", "indexingModelFieldsReset": "Les champs suivants ne sont pas dans le modèle sélectionné et seront réinitialisés pour tous les courriers : ", "indexingModelReassign": "Réaffectation du modèle d'enregistrement", + "youCannotUnsign" : "Vous n'avez pas le droit de <b>dé-signer</b> ce document. Vous devez ếtre la personne qui a signé ce document." }; diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index 41268ad38f5..47a31b91b22 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -1723,4 +1723,5 @@ export const LANG_NL = { "indexingModelReplaceToDelete": "Pour le supprimer vous devez le remplacer par un autre modèle.__TO_TRANSLATE", "indexingModelFieldsReset": "Les champs suivants ne sont pas dans le modèle sélectionné et seront réinitialisés pour tous les courriers : __TO_TRANSLATE", "indexingModelReassign": "Réaffectation du modèle d'enregistrement__TO_TRANSLATE", + "youCannotUnsign": "Vous n'avez pas le droit de <b>dé-signer</b> ce document. Vous devez ếtre la personne qui a signé ce document.__TO_TRANSLATE" }; -- GitLab