From c57d1f6e2d517b63c9de01bac90de5c330ed05ac Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Fri, 4 Dec 2020 19:12:02 +0100 Subject: [PATCH] FIX #15570 TIME 1 add control no doc in indexation + fix undefined resId visa model --- .../send-signature-book-action.component.html | 6 +++--- .../send-signature-book-action.component.ts | 19 +++++++++++++++---- .../app/visa/visa-workflow.component.ts | 4 +++- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.html b/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.html index 59b4fd7bed5..dd57b42a399 100644 --- a/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.html +++ b/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.html @@ -38,10 +38,10 @@ </li> </ul> </div> - <app-visa-workflow *ngIf="data.resIds.length <= 1 || (!noResourceToProcess && data.resIds.length > 1)" + <app-visa-workflow *ngIf="!noResourceToProcess" [adminMode]="true" #appVisaWorkflow> </app-visa-workflow> - <div style="padding-top: 10px;"> + <div *ngIf="!noResourceToProcess" style="padding-top: 10px;"> <app-note-editor #noteEditor [resIds]="data.resIds"></app-note-editor> </div> </mat-sidenav-content> @@ -58,4 +58,4 @@ (click)="onSubmit()">{{lang.validate}}</button> <button mat-raised-button mat-button [disabled]="loading" [mat-dialog-close]="">{{lang.cancel}}</button> </div> -</div> \ No newline at end of file +</div> diff --git a/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.ts b/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.ts index 31c734e8abe..3cc33e87b91 100644 --- a/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.ts +++ b/src/frontend/app/actions/visa-send-signature-book-action/send-signature-book-action.component.ts @@ -29,7 +29,7 @@ export class SendSignatureBookActionComponent implements AfterViewInit { } }; - @ViewChild('noteEditor', { static: true }) noteEditor: NoteEditorComponent; + @ViewChild('noteEditor', { static: false }) noteEditor: NoteEditorComponent; @ViewChild('appVisaWorkflow', { static: false }) appVisaWorkflow: VisaWorkflowComponent; constructor( @@ -40,8 +40,19 @@ export class SendSignatureBookActionComponent implements AfterViewInit { public functions: FunctionsService) { } async ngAfterViewInit(): Promise<void> { - if (this.data.resIds.length === 0 && !this.functions.empty(this.data.resource.destination)) { - await this.appVisaWorkflow.loadListModel(this.data.resource.destination); + if (this.data.resIds.length === 0) { + if (this.data.resource.encodedFile === null) { + this.noResourceToProcess = true; + this.resourcesError = [ + { + alt_identifier : this.lang.currentIndexingMail, + reason : 'noDocumentToSend' + } + ]; + } else if (!this.functions.empty(this.data.resource.destination)) { + this.noResourceToProcess = false; + await this.appVisaWorkflow.loadListModel(this.data.resource.destination); + } this.loading = false; } else if (this.data.resIds.length > 0) { await this.checkSignatureBook(); @@ -157,7 +168,7 @@ export class SendSignatureBookActionComponent implements AfterViewInit { this.http.put(this.data.indexActionRoute, { resource: resId, note: this.noteEditor.getNote() }).pipe( tap((data: any) => { if (!data) { - this.dialogRef.close('success'); + this.dialogRef.close(this.data.resIds); } if (data && data.errors != null) { this.notify.error(data.errors); diff --git a/src/frontend/app/visa/visa-workflow.component.ts b/src/frontend/app/visa/visa-workflow.component.ts index fe6d0564710..0c2e8d73ad4 100644 --- a/src/frontend/app/visa/visa-workflow.component.ts +++ b/src/frontend/app/visa/visa-workflow.component.ts @@ -170,7 +170,7 @@ export class VisaWorkflowComponent implements OnInit { } async loadVisaModelList() { - if (this.resId !== null) { + if (!this.functions.empty(this.resId)) { await this.loadDefaultModel(); } @@ -424,6 +424,7 @@ export class VisaWorkflowComponent implements OnInit { }), catchError((err: any) => { this.notify.handleSoftErrors(err); + resolve(false); return of(false); }) ).subscribe(); @@ -442,6 +443,7 @@ export class VisaWorkflowComponent implements OnInit { }), catchError((err: any) => { this.notify.handleSoftErrors(err); + resolve(false); return of(false); }) ).subscribe(); -- GitLab