Commit 28dd22b3 authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FIX #18927 TIME 0:15 send resource with signed attachment if exists

parent 4a57db1e
...@@ -104,6 +104,8 @@ export class MailEditorComponent implements OnInit, OnDestroy { ...@@ -104,6 +104,8 @@ export class MailEditorComponent implements OnInit, OnDestroy {
summarySheetUnits: any = []; summarySheetUnits: any = [];
signedAttachId: number = null;
constructor( constructor(
public http: HttpClient, public http: HttpClient,
public translate: TranslateService, public translate: TranslateService,
...@@ -988,9 +990,14 @@ export class MailEditorComponent implements OnInit, OnDestroy { ...@@ -988,9 +990,14 @@ export class MailEditorComponent implements OnInit, OnDestroy {
}; };
} }
openEmailAttach(type: string, attach: any): void { async openEmailAttach(type: string, attach: any): Promise<void> {
this.signedAttachId = null;
if (type === 'attachments') { if (type === 'attachments') {
this.http.get(`../rest/attachments/${attach.id}/content?mode=base64`).pipe( if (attach.status === 'SIGN') {
this.signedAttachId = attach.id;
await this.getSignedAttachment(this.signedAttachId);
}
this.http.get(`../rest/attachments/${this.signedAttachId !== null ? this.signedAttachId : attach.id}/content?mode=base64`).pipe(
tap((data: any) => { tap((data: any) => {
this.dialog.open(DocumentViewerModalComponent, { autoFocus: false, panelClass: 'maarch-full-height-modal', data: { title: `${attach.label}`, base64: data.encodedDocument, filename: data.filename } }); this.dialog.open(DocumentViewerModalComponent, { autoFocus: false, panelClass: 'maarch-full-height-modal', data: { title: `${attach.label}`, base64: data.encodedDocument, filename: data.filename } });
}), }),
...@@ -1030,4 +1037,20 @@ export class MailEditorComponent implements OnInit, OnDestroy { ...@@ -1030,4 +1037,20 @@ export class MailEditorComponent implements OnInit, OnDestroy {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2); return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join('')); }).join(''));
} }
getSignedAttachment(id: number) {
this.signedAttachId = null;
return new Promise((resolve) => {
this.http.get(`../rest/attachments/${id}`).pipe(
tap((data: any) => {
this.signedAttachId = id + data.relation;
resolve(true);
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
return of(false);
})
).subscribe();
})
}
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment