Newer
Older
arrValues.push({
id: arrType.id,
label: arrType.label,
title: arrType.label,
disabled: true,
isTitle: true,
color: '#135f7f'
});
data.templates.filter((template: any) => template.attachmentType === arrType.id).forEach((template: any) => {
arrValues.push({
id: template.id,
label: ' ' + template.label,
title: template.exists ? template.label : this.translate.instant('lang.fileDoesNotExists'),
extension: template.extension,
disabled: !template.exists,
});
});
});
this.listTemplates = arrValues;
})
).subscribe();
}
closeEditor() {
this.templateListForm.reset();
this.editInProgress = false;
this.isDocModified = false;
setEditor() {
if (this.headerService.user.preferences.documentEdition === 'java') {
this.editor.mode = 'java';
this.editor.async = true;
} else if (this.headerService.user.preferences.documentEdition === 'onlyoffice') {
this.editor.mode = 'onlyoffice';
this.editor.async = false;
} else if (this.headerService.user.preferences.documentEdition === 'collaboraonline') {
this.editor.mode = 'collaboraOnline';
this.editor.async = false;
this.loading = true;
Guillaume Heurtier
committed
return new Promise((resolve) => {
Guillaume Heurtier
committed
this.getFile().pipe(
map((data: any) => {
const formatdatas = {
encodedFile: data.content,
format: data.format,
resId: this.resId
Guillaume Heurtier
committed
};
return formatdatas;
}),
exhaustMap((data) => this.http.put(`../rest/resources/${this.resId}?onlyDocument=true`, data)),
tap(() => {
this.closeEditor();
this.loadRessource(this.resId);
resolve(true);
}),
finalize(() => this.loading = false),
Guillaume Heurtier
committed
catchError((err: any) => {
this.notify.handleSoftErrors(err);
resolve(false);
return of(false);
})
).subscribe();
});
}
loadTmpDocument(base64Content: string, format: string) {
return new Promise((resolve, reject) => {
this.http.post(`../rest/convertedFile/encodedFile`, { format: format, encodedFile: base64Content }).pipe(
tap((data: any) => {
console.log(data);
this.file = {
name: 'maarch',
format: format,
type: 'application/pdf',
contentMode: 'base64',
content: base64Content,
src: this.base64ToArrayBuffer(data.encodedResource)
};
}),
// exhaustMap((data) => this.http.post(`../rest/convertedFile/encodedFile`, data.content)),
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
catchError((err: any) => {
this.notify.handleSoftErrors(err);
resolve(false);
return of(false);
})
).subscribe();
});
}
saveTmpDocument() {
return new Promise((resolve, reject) => {
this.getFile().pipe(
tap((data: any) => {
this.file = {
name: 'maarch',
format: data.format,
type: 'application/pdf',
contentMode: 'base64',
content: data.content,
src: null
};
}),
exhaustMap((data) => this.http.post(`../rest/convertedFile/encodedFile`, { format: data.format, encodedFile: data.content })),
tap((data: any) => {
this.file.src = this.base64ToArrayBuffer(data.encodedResource);
this.closeEditor();
resolve(true);
}),
catchError((err: any) => {
this.notify.handleSoftErrors(err);
resolve(false);
return of(false);
})
).subscribe();
});
openResourceVersion(version: number, type: string) {
const title = type !== 'PDF' ? this.translate.instant('lang.' + type + '_version') : `${this.translate.instant('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();
}
this.dialogRef = this.dialog.open(ConfirmComponent, { panelClass: 'maarch-modal', autoFocus: false, disableClose: true, data: { title: this.translate.instant('lang.UNSIGN'), msg: this.translate.instant('lang.confirmAction') } });
this.dialogRef.afterClosed().pipe(
filter((data: string) => data === 'ok'),
exhaustMap(() => this.http.put(`../rest/resources/${this.resId}/unsign`, {})),
this.notify.success(this.translate.instant('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' } });
}