diff --git a/src/frontend/app/administration/template/template-administration.component.html b/src/frontend/app/administration/template/template-administration.component.html index 92a7b2ae35f3c3a26132a3304de6b7f72916d425..3ac98bad58f9a697f17ac9e21fb5492e90444ec0 100755 --- a/src/frontend/app/administration/template/template-administration.component.html +++ b/src/frontend/app/administration/template/template-administration.component.html @@ -149,7 +149,7 @@ [disabled]="lockFound">{{lang.templateEdition}}</button> <button mat-raised-button color="default" type="button" (click)="$event.stopPropagation();uploadSignFileOffice.click()" - *ngIf="((creationMode && !selectedModelFile) || (!creationMode && !functionsService.empty(template.file.name)))" + *ngIf="((creationMode && !selectedModelFile) || (!creationMode && !functionsService.empty(template.file.name)) && headerService.user.preferences.documentEdition !== 'java')" [disabled]="lockFound">{{lang.importFile}}</button> </div> <iframe *ngIf="templateDocView !== null" [src]="templateDocView" @@ -248,7 +248,7 @@ [disabled]="lockFound">{{lang.templateEdition}}</button> <button mat-raised-button color="default" type="button" (click)="$event.stopPropagation();uploadSignFileOfficeHtml.click()" - *ngIf="!selectedModelFile || !creationMode" + *ngIf="!selectedModelFile || (!creationMode && headerService.user.preferences.documentEdition !== 'java')" [disabled]="lockFound">{{lang.importFile}}</button> </div> <iframe *ngIf="templateDocView !== null" [src]="templateDocView" diff --git a/src/frontend/app/administration/template/template-administration.component.ts b/src/frontend/app/administration/template/template-administration.component.ts index 9ad36672fb3cb1c6fde74229503dfec40f1ea968..af3941003560b09d7b7526d3cd6e2341711697b0 100755 --- a/src/frontend/app/administration/template/template-administration.component.ts +++ b/src/frontend/app/administration/template/template-administration.component.ts @@ -93,7 +93,7 @@ export class TemplateAdministrationComponent implements OnInit, OnDestroy { private route: ActivatedRoute, private router: Router, private notify: NotificationService, - private headerService: HeaderService, + public headerService: HeaderService, public dialog: MatDialog, public appService: AppService, private viewContainerRef: ViewContainerRef, @@ -376,6 +376,24 @@ export class TemplateAdministrationComponent implements OnInit, OnDestroy { } if (this.headerService.user.preferences.documentEdition === 'java') { + // WORKAROUND JAVA MODE DOESNT SUPPORT BASE64 + if (this.creationMode) { + editorOptions.objectId = ''; + editorOptions.objectType = 'templateCreation'; + for (const element of this.defaultTemplatesList) { + if (this.selectedModelFile === element.fileExt + ': ' + element.fileName) { + editorOptions.objectId = element.filePath; + } + } + if (this.functionsService.empty(editorOptions.objectId)) { + alert('Vous ne pouvez pas éditer avec l\'applet Java un document importé.'); + return false; + } + } else { + editorOptions.objectType = 'templateModification'; + editorOptions.objectId = this.template.id; + } + this.launchJavaEditor(editorOptions); } else if (this.headerService.user.preferences.documentEdition === 'onlyoffice') { this.launchOOEditor(editorOptions); @@ -469,7 +487,7 @@ export class TemplateAdministrationComponent implements OnInit, OnDestroy { this.template.file.format = filenameOnTmp.toLowerCase().split('.').pop(); this.template.file.content = data.encodedResource; } - this.templateDocView = data.encodedConvertedResource; + this.templateDocView = this.sanitizer.bypassSecurityTrustResourceUrl('data:application/pdf;base64,' + data.encodedConvertedResource); }) ).subscribe(); }