From 499e9b7a5362b9f5b012c94d96d6fb569d88e611 Mon Sep 17 00:00:00 2001 From: "hamza.hramchi" <hamza.hramchi@xelians.fr> Date: Thu, 14 Jan 2021 18:25:57 +0100 Subject: [PATCH] FEAT #15550 TIME 0:30 fix duplicate signatures --- .../app/document/document.component.ts | 1 + .../app/signatures/signatures.component.ts | 39 ++++++++++++++----- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/frontend/app/document/document.component.ts b/src/frontend/app/document/document.component.ts index a12cffddb8..fddbab21ec 100755 --- a/src/frontend/app/document/document.component.ts +++ b/src/frontend/app/document/document.component.ts @@ -251,6 +251,7 @@ export class DocumentComponent implements OnInit { cssClass: 'my-custom-class', componentProps: { currentWorflow: this.mainDocument.workflow.filter((line: { current: boolean; }) => line.current === true)[0], + posCurrentUser: this.mainDocument.workflow.indexOf(this.mainDocument.workflow.filter((item: { current: boolean; }) => item.current === true)[0]) } }); await modal.present(); diff --git a/src/frontend/app/signatures/signatures.component.ts b/src/frontend/app/signatures/signatures.component.ts index 284469edcf..788c2dc7a9 100755 --- a/src/frontend/app/signatures/signatures.component.ts +++ b/src/frontend/app/signatures/signatures.component.ts @@ -19,6 +19,7 @@ import { SignaturePadPageComponent } from '../pad/pad.component'; export class SignaturesComponent implements OnInit { @Input() currentWorflow: any; + @Input() posCurrentUser: number; loading: boolean = true; scrolling: boolean = false; @@ -127,22 +128,42 @@ export class SignaturesComponent implements OnInit { signature.positionX = signPosCurrentPage[0].positionX; signature.positionY = signPosCurrentPage[0].positionY; this.storeSignature(signature, this.signaturesService.currentPage); + } + let signaturePos = signPosOtherPage.filter((item: any) => item.sequence === this.posCurrentUser); + if (signaturePos.length > 0) { + signaturePos.forEach((element: { positionX: any; positionY: any; page: number; }) => { + signature.positionX = element.positionX; + signature.positionY = element.positionY; + this.storeSignature(signature, element.page); + }); + } else { + signPosOtherPage.forEach((element: { positionX: any; positionY: any; page: number; }) => { + signature.positionX = element.positionX; + signature.positionY = element.positionY; + this.storeSignature(signature, element.page); + }); } - this.currentWorflow.signaturePositions.forEach((element: { positionX: any; positionY: any; page: number; }) => { - signature.positionX = element.positionX; - signature.positionY = element.positionY; - this.storeSignature(signature, element.page); - }); + if (this.currentWorflow.signaturePositions.length === 1) { this.notificationService.success('lang.signatureInDocAddedAlt'); } else { - this.translate.get('lang.signaturesInDocAdded', { 0: this.currentWorflow.signaturePositions.map((item: any) => item.page) }).subscribe((res: string) => { - this.notificationService.success(res); - }); + if (signaturePos.length > 0) { + this.translate.get('lang.signaturesInDocAdded', { 0: signaturePos.map((item: any) => item.page) }).subscribe((res: string) => { + this.notificationService.success(res); + }); + } else { + this.translate.get('lang.signaturesInDocAdded', { 0: this.currentWorflow.signaturePositions.map((item: any) => item.page) }).subscribe((res: string) => { + this.notificationService.success(res); + }); + } } if (signPosCurrentPage.length === 0 && signPosOtherPage.length > 0) { - this.modalController.dismiss({ redirectPage: signPosOtherPage[0].page }); + if (signaturePos.length > 0) { + this.modalController.dismiss({ redirectPage: signaturePos[0].page }); + } else { + this.modalController.dismiss({ redirectPage: this.currentWorflow.signaturePositions[0].page }); + } } else { this.modalController.dismiss('success'); } -- GitLab