Skip to content
Snippets Groups Projects
document-viewer.component.ts 39.9 KiB
Newer Older
  • Learn to ignore specific revisions
  • 
        openResourceVersion(version: number, type: string) {
    
            const title = type !== 'PDF' ? this.lang[type + '_version'] : `${this.lang.version} ${version}`;
    
            // TO SHOW ORIGINAL DOC (because autoload signed doc)
            type = type === 'SIGN' ? 'PDF' : type;
    
            this.http.get(`../../rest/resources/${this.resId}/content/${version}?type=${type}`).pipe(
                tap((data: any) => {
    
    
                    this.dialog.open(DocumentViewerModalComponent, { autoFocus: false, panelClass: 'maarch-full-height-modal', data: { title: `${title}`, base64: data.encodedDocument } });
    
                }),
                catchError((err: any) => {
                    this.notify.handleSoftErrors(err);
                    return of(false);
                })
            ).subscribe();
        }
    
    
        unsignMainDocument() {
    
            this.dialogRef = this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: this.lang.UNSIGN, msg: this.lang.confirmAction } });
    
    
            this.dialogRef.afterClosed().pipe(
                filter((data: string) => data === 'ok'),
                exhaustMap(() => this.http.put(`../../rest/resources/${this.resId}/unsign`, {})),
                tap(() => {
                    this.notify.success(this.lang.documentUnsigned);
                    this.loadRessource(this.resId);
                }),
                catchError((err: any) => {
                    this.notify.handleErrors(err);
                    return of(false);
                })
            ).subscribe();
        }
    
    
        isEditorLoaded() {
            if (this.isEditingTemplate()) {
                return this.isEditingTemplate() && this.isDocModified;
            } else {
                return true;
            }
        }
    
    
        openMaarchParapheurWorkflow() {
            this.dialog.open(VisaWorkflowModalComponent, { panelClass: 'maarch-modal', data: { id: this.resId, type: 'resource' } });
        }