diff --git a/src/frontend/app/indexation/indexation.component.ts b/src/frontend/app/indexation/indexation.component.ts index de9784337a53079c6f907f4622e592b778b4fec7..87042436f6ebaa64928c644e7d605a6cda704633 100644 --- a/src/frontend/app/indexation/indexation.component.ts +++ b/src/frontend/app/indexation/indexation.component.ts @@ -378,32 +378,33 @@ export class IndexationComponent implements OnInit { } async signPos(index: number) { - const allUsers: any[] = this.appVisaWorkflow.getCurrentWorkflow(); - const usersWithNoteRole: any[] = this.appVisaWorkflow.getCurrentWorkflow().filter((user: any) => user.role === 'note'); - - if ((allUsers.length === 1 && this.appVisaWorkflow.getCurrentWorkflow()[0].role === 'note') || (allUsers.length === usersWithNoteRole.length)) { - this.notificationService.error('lang.cannotSetSignature'); - } else if (this.appVisaWorkflow.getCurrentWorkflow().length > 0) { - this.appVisaWorkflow.getCurrentWorkflow().forEach((user: any, indexUser: number) => { - if (user.signaturePositions === undefined) { - this.appVisaWorkflow.visaWorkflow[indexUser].signaturePositions = []; - } - }); - const modal = await this.modalController.create({ - component: SignaturePositionComponent, - cssClass: 'custom-alert-fullscreen', - componentProps: { - workflow: this.appVisaWorkflow.getCurrentWorkflow(), - resource: this.filesToUpload[index], - pdfContent: 'data:application/pdf;base64,' + this.filesToUpload[index].content, - docIndex: this.filesToUpload.indexOf(this.filesToUpload[index]) + if (this.appVisaWorkflow.getCurrentWorkflow().length > 0) { + const allUsers: any[] = this.appVisaWorkflow.getCurrentWorkflow(); + const usersWithNoteRole: any[] = this.appVisaWorkflow.getCurrentWorkflow().filter((user: any) => user.role === 'note'); + if ((allUsers.length === 1 && this.appVisaWorkflow.getCurrentWorkflow()[0].role === 'note') || (allUsers.length === usersWithNoteRole.length)) { + this.notificationService.error('lang.cannotSetSignature'); + } else { + this.appVisaWorkflow.getCurrentWorkflow().forEach((user: any, indexUser: number) => { + if (user.signaturePositions === undefined) { + this.appVisaWorkflow.visaWorkflow[indexUser].signaturePositions = []; + } + }); + const modal = await this.modalController.create({ + component: SignaturePositionComponent, + cssClass: 'custom-alert-fullscreen', + componentProps: { + workflow: this.appVisaWorkflow.getCurrentWorkflow(), + resource: this.filesToUpload[index], + pdfContent: 'data:application/pdf;base64,' + this.filesToUpload[index].content, + docIndex: this.filesToUpload.indexOf(this.filesToUpload[index]) + } + }); + await modal.present(); + const { data } = await modal.onWillDismiss(); + if (data !== undefined) { + this.filesToUpload[index].signPos = data; + this.appVisaWorkflow.setPositionsWorkfow(this.filesToUpload, index, data); } - }); - await modal.present(); - const { data } = await modal.onWillDismiss(); - if (data !== undefined) { - this.filesToUpload[index].signPos = data; - this.appVisaWorkflow.setPositionsWorkfow(this.filesToUpload, index, data); } } else { this.notificationService.error('lang.mustSetWorkflowBeforeSignPositions');