diff --git a/lang/fr.json b/lang/fr.json index 2a5ca89836f664bdf80b3f6d4a3ffaaa7e40b94c..4f8f659a4b44b406946439a6ef75ae771cd857ab 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 68a36dd6da16565512fbced41a63312ac49cab6a..c4ce4ebb2bd4a72dcc08595d1f603b7e567d21b8 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; + } }