Skip to content
Snippets Groups Projects
Commit d99fa906 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #12332 TIME 1 confirm before templateEdition

parent be0685a6
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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();
}
......
......@@ -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",
};
......@@ -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",
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment