From f7e19f3cc2d7874e55c9ce2a6ef3277785a0bf78 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Mon, 31 May 2021 20:20:47 +0200 Subject: [PATCH] FEAT #17109 TIME 0:40 add required otp sign position --- lang/fr.json | 3 ++- .../app/indexation/indexation.component.ts | 24 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lang/fr.json b/lang/fr.json index 2a5ca89836..4f8f659a4b 100755 --- a/lang/fr.json +++ b/lang/fr.json @@ -522,6 +522,7 @@ "manage_customizationAdmin": "Personnaliser la page de connexion", "internalUserOtpMsg": "<b>{{user}}</b> sera converti en utilisateur externe, vous ne pourrez plus choisir les autres modes de signature.", "externalUser": "Role externe", - "external": "Externe" + "external": "Externe", + "otpSignaturePositionMandatory": "La position de signature pour les utilisateurs externes est obligatoire." } } diff --git a/src/frontend/app/indexation/indexation.component.ts b/src/frontend/app/indexation/indexation.component.ts index 68a36dd6da..c4ce4ebb2b 100644 --- a/src/frontend/app/indexation/indexation.component.ts +++ b/src/frontend/app/indexation/indexation.component.ts @@ -12,6 +12,7 @@ import { NotificationService } from '../service/notification.service'; import { SignaturesContentService } from '../service/signatures.service'; import { SignaturePositionComponent } from './signature-position/signature-position.component'; import { ActionsService } from '../service/actions.service'; +import { FunctionsService } from '../service/functions.service'; @Component({ templateUrl: 'indexation.component.html', @@ -42,7 +43,8 @@ export class IndexationComponent implements OnInit { public alertController: AlertController, public datePipe: DatePipe, public modalController: ModalController, - public actionsService: ActionsService + public actionsService: ActionsService, + private functionsService: FunctionsService ) { } ngOnInit(): void { } @@ -102,7 +104,7 @@ export class IndexationComponent implements OnInit { const obj: any = await this.appVisaWorkflow.formatData(element); element = obj; }); - } + } resolve(true); }), catchError((err: any) => { @@ -185,6 +187,7 @@ export class IndexationComponent implements OnInit { }).then(async (load: HTMLIonLoadingElement) => { load.present(); const objTosend = this.formatData(data.note); + this.hasEmptyOtpSignaturePosition(); for (let index = 0; index < objTosend.length; index++) { await this.saveDocument(objTosend[index], index); if (objTosend[0].workflow[0].userId === this.authService.user.id) { @@ -379,12 +382,25 @@ export class IndexationComponent implements OnInit { this.notificationService.error('lang.workflowUserstMandatory'); this.menu.open('right-menu'); return false; - } - else if (this.appVisaWorkflow.getCurrentWorkflow().filter((user: any) => user.userId === null && user.noConnector !== undefined).length > 0) { + } else if (this.appVisaWorkflow.getCurrentWorkflow().filter((user: any) => user.userId === null && user.noConnector !== undefined).length > 0) { this.notificationService.error('lang.noConnector'); return false; + } else if (this.hasEmptyOtpSignaturePosition()) { + this.notificationService.error('lang.otpSignaturePositionMandatory'); + return false; } else { return true; } } + + + hasEmptyOtpSignaturePosition() { + const workflow = this.formatData(null)[0].workflow; + + const isSign = /_sign_/g; + + const hasEmptyPosition = workflow.filter((item: any) => item.signaturePositions.length === 0 && !this.functionsService.empty(item.externalInformations) && item.mode.match(isSign) !== null).length > 0; + + return hasEmptyPosition; + } } -- GitLab