diff --git a/src/frontend/app/administration/template/template-administration.component.html b/src/frontend/app/administration/template/template-administration.component.html index e54566ea3c289078a63a812e8d5bbf37d65f3ade..f990d97afeff5ad4d31f3987e7f45261402d9459 100755 --- a/src/frontend/app/administration/template/template-administration.component.html +++ b/src/frontend/app/administration/template/template-administration.component.html @@ -26,12 +26,12 @@ </div> </div> <div class="container" [class.fullContainer]="appService.getViewMode()"> - <div class="container-content"> + <div class="container-content" style="padding: 10px 10px 0px 10px;"> <div *ngIf="loading" style="display:flex;height:100%;"> <mat-spinner style="margin:auto;"></mat-spinner> </div> - <mat-card *ngIf="!loading" class="card-app-content"> - <form class="form-horizontal" (ngSubmit)="onSubmit()" #templatesFormUp="ngForm"> + <mat-card *ngIf="!loading" class="card-app-content" style="display: contents;"> + <form style="display: contents;" class="form-horizontal" (ngSubmit)="onSubmit()" #templatesFormUp="ngForm"> <div class="col-sm-12"> <div class="form-group"> <div class="col-sm-12"> @@ -124,8 +124,7 @@ [(ngModel)]="selectedModelFile" [required]="template.target!='acknowledgementReceipt'"> <mat-optgroup label="{{lang.loadedFile}} :"> - <mat-option class="selectFile" - (click)="uploadSignFileOffice.click()" + <mat-option class="selectFile" (click)="uploadSignFileOffice.click()" [value]="template.file.name"> <mat-icon class="fa fa-paperclip" color="primary" style="height:auto;"></mat-icon> @@ -220,15 +219,15 @@ <mat-select id="template_style" [disabled]="!creationMode && template.file.paper.name !== null" name="template_style" title="{{lang.defaultTemplate}}" - placeholder="{{lang.chosenModel}}" - [(ngModel)]="selectedModelFile" + placeholder="{{lang.chosenModel}}" [(ngModel)]="selectedModelFile" [required]="template.target!='acknowledgementReceipt'"> <mat-optgroup label="{{lang.loadedFile}} :"> - <mat-option - (click)="uploadSignFileOfficeHtml.click()" - style="text-align: center;" [value]="template.file.paper.name"> + <mat-option (click)="uploadSignFileOfficeHtml.click()" + style="text-align: center;" + [value]="template.file.paper.name"> <mat-icon class="fa fa-paperclip" color="primary" - style="height:auto;"></mat-icon> {{!functionsService.empty(template.file.paper) && !functionsService.empty(template.file.paper.name) ? template.file.paper.name : lang.importFile}} + style="height:auto;"></mat-icon> + {{!functionsService.empty(template.file.paper) && !functionsService.empty(template.file.paper.name) ? template.file.paper.name : lang.importFile}} </mat-option> </mat-optgroup> <ng-container *ngFor="let extension of extensionModels"> @@ -258,11 +257,9 @@ </mat-tab-group> </div> </div> - <div class="form-group"> - <div class="col-sm-12" style="text-align:center;"> - <button mat-raised-button color="primary" type="submit" - [disabled]="!templatesFormUp.form.valid || lockFound">{{lang.save}}</button> - </div> + <div class="col-sm-12" style="background: white;position:sticky;bottom:0px; text-align:center;"> + <button mat-raised-button color="primary" type="submit" + [disabled]="!templatesFormUp.form.valid || lockFound">{{lang.save}}</button> </div> </form> </mat-card> diff --git a/src/frontend/app/administration/template/template-administration.component.ts b/src/frontend/app/administration/template/template-administration.component.ts index c44201ba03c0086de298064ed07b3e051ffabcfb..685bdabee00f8601614cd625759b6eb3f69020b7 100755 --- a/src/frontend/app/administration/template/template-administration.component.ts +++ b/src/frontend/app/administration/template/template-administration.component.ts @@ -142,12 +142,14 @@ export class TemplateAdministrationComponent implements OnInit, OnDestroy { } else if (this.template.type === 'OFFICE') { this.template.file.format = data.template.template_file_name.split('.').pop(); this.template.file.name = data.template.template_file_name; + this.getViewTemplateContent(); } else if (this.template.target === 'acknowledgementReceipt') { if (!this.functionsService.empty(data.template.template_file_name)) { this.template.file.paper.format = data.template.template_file_name.split('.').pop(); } this.template.file.paper.name = data.template.template_file_name; this.template.file.electronic.content = data.template.template_content; + this.getViewTemplateContent(); } this.headerService.setHeader(this.lang.templateModification, this.template.template_label); @@ -160,6 +162,18 @@ export class TemplateAdministrationComponent implements OnInit, OnDestroy { }); } + getViewTemplateContent() { + this.http.get(`../rest/templates/${this.template.id}/content`).pipe( + tap((data: any) => { + this.templateDocView = this.sanitizer.bypassSecurityTrustResourceUrl('data:application/pdf;base64,' + data.encodedDocument); + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } + initMce(selectorId: string) { setTimeout(() => { tinymce.remove('textarea'); @@ -420,7 +434,6 @@ export class TemplateAdministrationComponent implements OnInit, OnDestroy { } getViewTemplateFile() { - this.http.post('../rest/convertedFile/encodedFile', { encodedFile: this.template.target === 'acknowledgementReceipt' ? this.template.file.paper.content : this.template.file.content, format: this.template.target === 'acknowledgementReceipt' ? this.template.file.paper.format : this.template.file.format }).pipe( tap((data: any) => { this.templateDocView = this.sanitizer.bypassSecurityTrustResourceUrl('data:application/pdf;base64,' + data.encodedResource); @@ -430,7 +443,6 @@ export class TemplateAdministrationComponent implements OnInit, OnDestroy { return of(false); }) ).subscribe(); - } checkLockFile(id: string, extension: string) {