diff --git a/src/frontend/app/viewer/document-viewer.component.html b/src/frontend/app/viewer/document-viewer.component.html index cc89aef579f9196bc8f59dbcd16cf2b56a4caaeb..32c6cec2853aa97ca97f027ea5dbb603ca7ebcf5 100644 --- a/src/frontend/app/viewer/document-viewer.component.html +++ b/src/frontend/app/viewer/document-viewer.component.html @@ -30,6 +30,7 @@ <div style="margin-right:20px;align-items: center;justify-content: center;text-align: center;display: flex;"> <plugin-select-search #templateList *ngIf="listTemplates.length > 0" [label]="lang.chooseModel" [placeholderLabel]="lang.chooseModel" [datas]="listTemplates" [class]="'input-form-filled'" + [formControlSelect]="templateListForm" (afterSelected)="editTemplate($event)" style="width: 240px;text-align: left;font-weight:normal;font-size: 13px;"> </plugin-select-search> </div> diff --git a/src/frontend/app/viewer/document-viewer.component.ts b/src/frontend/app/viewer/document-viewer.component.ts index 7657e030317413199e2f8f91a9f78729495080c4..0d1fc986a95bce6b8c22a5b0ef50e04bebd94a14 100644 --- a/src/frontend/app/viewer/document-viewer.component.ts +++ b/src/frontend/app/viewer/document-viewer.component.ts @@ -12,6 +12,7 @@ import { AlertComponent } from '../../plugins/modal/alert.component'; import { SortPipe } from '../../plugins/sorting.pipe'; import { templateVisitAll } from '@angular/compiler'; import { PluginSelectSearchComponent } from '../../plugins/select-search/select-search.component'; +import { FormControl } from '@angular/forms'; @Component({ @@ -55,6 +56,8 @@ export class DocumentViewerComponent implements OnInit { listTemplates: any[] = []; + templateListForm = new FormControl(); + @Input('resId') resId: number = null; @Input('infoPanel') infoPanel: MatSidenav = null; @Input('editMode') editMode: boolean = false; @@ -491,19 +494,35 @@ export class DocumentViewerComponent implements OnInit { } editTemplate(templateId: number) { - this.refreshDatas.emit(); - const template = this.listTemplates.filter(template => template.id === templateId)[0]; - this.editInProgress = true; - const jnlp: any = { - objectType: 'resourceCreation', - objectId: template.id, - cookie: document.cookie, - data: this.resourceDatas, - }; - this.http.post('../../rest/jnlp', jnlp).pipe( - tap((data: any) => { - window.location.href = '../../rest/jnlp/' + data.generatedJnlp; - this.checkLockFile(data.jnlpUniqueId, template); + this.dialogRef = this.dialog.open(ConfirmComponent, { autoFocus: false, disableClose: true, data: { title: this.lang.templateEdition, msg: this.lang.editionAttachmentConfirm } }); + + this.dialogRef.afterClosed().pipe( + tap((data: string) => { + if (data !== 'ok') { + this.templateListForm.reset(); + } + }), + filter((data: string) => data === 'ok'), + tap(() => { + this.refreshDatas.emit(); + const template = this.listTemplates.filter(template => template.id === templateId)[0]; + this.editInProgress = true; + const jnlp: any = { + objectType: 'resourceCreation', + objectId: template.id, + cookie: document.cookie, + data: this.resourceDatas, + }; + this.http.post('../../rest/jnlp', jnlp).pipe( + tap((data: any) => { + window.location.href = '../../rest/jnlp/' + data.generatedJnlp; + this.checkLockFile(data.jnlpUniqueId, template); + }) + ).subscribe(); + }), + catchError((err: any) => { + this.notify.handleErrors(err); + return of(false); }) ).subscribe(); } diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index 841263b67c68b714382f26ac9f51497006b899f9..91cc699139d81b6e80ab9d944fc5369b8e38da5e 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -1287,4 +1287,5 @@ export const LANG_EN = { "attachmentUpdated" : "Attachment updated", "signedVersionDeleted" : "Signed version deleted", "newVersionAdded" : "New version added", + "editionAttachmentConfirm" : "All merge variables will be replaced taking into account what you entered in the form on the left. <br> <br> Only <b> chrono number </b> ([res_letterbox.alt_identifier]) will be replaced after mail registration", }; diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index cf4ac40e8f519380e1926d375e57508269793057..eab376f4b3d2881a05ca5bd20c4a5e7383d2b214 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -1324,4 +1324,5 @@ export const LANG_FR = { "attachmentUpdated" : "Pièce jointe modifiée", "signedVersionDeleted" : "Version signée supprimée", "newVersionAdded" : "Nouvelle version créée", + "editionAttachmentConfirm" : "Toutes les variables de fusion seront remplacées en prenant en compte ce que vous avez saisie dans le formulaire à gauche. <br><br>Seul le <b>numéro chrono</b> ([res_letterbox.alt_identifier]) sera remplacée après l'enregistrement du courrier", };