From dea0a38d7481f4fd7d34d3a461ac56cd503606c0 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Thu, 19 Dec 2019 15:07:34 +0100
Subject: [PATCH] FEAT #11158 TIME 0:40 fix format in edit attachment

---
 .../attachments-page/attachment-page.component.html           | 4 ++--
 .../attachments/attachments-page/attachment-page.component.ts | 2 +-
 src/frontend/app/viewer/document-viewer.component.ts          | 3 ++-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/frontend/app/attachments/attachments-page/attachment-page.component.html b/src/frontend/app/attachments/attachments-page/attachment-page.component.html
index be640b7d94c..98075b0f803 100644
--- a/src/frontend/app/attachments/attachments-page/attachment-page.component.html
+++ b/src/frontend/app/attachments/attachments-page/attachment-page.component.html
@@ -196,7 +196,7 @@
                         </ng-template>
                         <app-document-viewer #appAttachmentViewer style="height:100%;width:100%;" [editMode]="editMode"
                             [resId]="data.resId" [resIdMaster]="attachment['resIdMaster'].value" [mode]="'attachment'"
-                            [attachType]="attachment['type'].value" [infoPanel]="snavLeft"
+                            [format]="attachment['format'].value" [attachType]="attachment['type'].value" [infoPanel]="snavLeft"
                             (triggerEvent)="setDatasViewer($event)"
                             [title]="attachment.chrono.value + ' - ' + attachment.title.value">
                         </app-document-viewer>
@@ -205,7 +205,7 @@
                         *ngFor="let version of versions">
                         <ng-template matTabContent>
                             <app-document-viewer #appDocumentViewer style="height:100%;width:100%;" [editMode]="false"
-                                [resId]="version.resId" [mode]="'attachment'"
+                                [resId]="version.resId" [mode]="'attachment'" [format]="attachment['format'].value"
                                 [title]="attachment.chrono.value + ' - ' + attachment.title.value + ' (' + version.relation + ')'">
                             </app-document-viewer>
                         </ng-template>
diff --git a/src/frontend/app/attachments/attachments-page/attachment-page.component.ts b/src/frontend/app/attachments/attachments-page/attachment-page.component.ts
index dfcfba96c28..1d958d41827 100644
--- a/src/frontend/app/attachments/attachments-page/attachment-page.component.ts
+++ b/src/frontend/app/attachments/attachments-page/attachment-page.component.ts
@@ -98,7 +98,7 @@ export class AttachmentPageComponent implements OnInit {
                     validationDate: new FormControl({ value: data.validationDate !== null ? new Date(data.validationDate) : null, disabled: !this.editMode }),
                     signedResponse: new FormControl({ value: data.signedResponse, disabled: false }),
                     encodedFile: new FormControl({ value: '_CURRENT_FILE', disabled: !this.editMode }, [Validators.required]),
-                    format: new FormControl({ value: '', disabled: true }, [Validators.required])
+                    format: new FormControl({ value: data.format, disabled: true }, [Validators.required])
                 };
 
                 this.versions = data.versions;
diff --git a/src/frontend/app/viewer/document-viewer.component.ts b/src/frontend/app/viewer/document-viewer.component.ts
index 34e4aa20368..39640939c25 100644
--- a/src/frontend/app/viewer/document-viewer.component.ts
+++ b/src/frontend/app/viewer/document-viewer.component.ts
@@ -67,6 +67,7 @@ export class DocumentViewerComponent implements OnInit {
     @Input('title') title: string = '';
     @Input('mode') mode: string = 'mainDocument';
     @Input('attachType') attachType: string = null;
+    @Input('format') format: string = null;
 
     @Output('triggerEvent') triggerEvent = new EventEmitter<string>();
     
@@ -605,7 +606,7 @@ export class DocumentViewerComponent implements OnInit {
             this.http.post('../../rest/jnlp', this.editor.options).pipe(
                 tap((data: any) => {
                     window.location.href = '../../rest/jnlp/' + data.generatedJnlp;
-                    this.checkLockFile(data.jnlpUniqueId, 'odt');
+                    this.checkLockFile(data.jnlpUniqueId, this.format);
                 })
             ).subscribe();
         }
-- 
GitLab