From 38754800ea0ed5f34dc80fc0ef22f42b9fd0e438 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 10 Apr 2019 16:14:28 +0200 Subject: [PATCH] Fix #176 - Lorsqu'on charge une session, proposer de vider la session existante --- src/app/app.component.ts | 19 +++++++++++++------ .../dialog-load-session.component.html | 6 ++++++ .../dialog-load-session.component.ts | 9 ++++++++- src/locale/messages.en.json | 1 + src/locale/messages.fr.json | 1 + 5 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index e12e52603..43e8c0f2c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -377,16 +377,20 @@ export class AppComponent implements OnInit, OnDestroy, Observer { ); dialogRef.afterClosed().subscribe(result => { if (result) { - for (const c of this._calculators) { - const form = this.formulaireService.getFormulaireFromId(c.uid); - this.formulaireService.requestCloseForm(form.uid); - } - // just to be sure, get rid of any Nub possibly stuck in session without any form attached - Session.getInstance().clearSession(); + this.doEmptySession(); } }); } + public doEmptySession() { + for (const c of this._calculators) { + const form = this.formulaireService.getFormulaireFromId(c.uid); + this.formulaireService.requestCloseForm(form.uid); + } + // just to be sure, get rid of any Nub possibly stuck in session without any form attached + Session.getInstance().clear(); + } + public loadSession() { // création du dialogue de sélection des formulaires à sauver const dialogRef = this.loadSessionDialog.open( @@ -395,6 +399,9 @@ export class AppComponent implements OnInit, OnDestroy, Observer { ); dialogRef.afterClosed().subscribe(result => { if (result) { + if (result.emptySession) { + this.doEmptySession(); + } this.formulaireService.loadSession(result.file, result.calculators); } }); diff --git a/src/app/components/dialog-load-session/dialog-load-session.component.html b/src/app/components/dialog-load-session/dialog-load-session.component.html index 97e2d6e42..5a560987c 100644 --- a/src/app/components/dialog-load-session/dialog-load-session.component.html +++ b/src/app/components/dialog-load-session/dialog-load-session.component.html @@ -43,6 +43,12 @@ </div> </div> + <div class="cb-container"> + <mat-checkbox [(ngModel)]="emptyCurrentSession" [ngModelOptions]="{standalone: true}"> + {{ uitextEmptyCurrentSession }} + </mat-checkbox> + </div> + <div mat-dialog-actions> <button mat-raised-button color="primary" [mat-dialog-close]="false" cdkFocusInitial> {{ uitextCancel }} diff --git a/src/app/components/dialog-load-session/dialog-load-session.component.ts b/src/app/components/dialog-load-session/dialog-load-session.component.ts index b91673e4b..016cac379 100644 --- a/src/app/components/dialog-load-session/dialog-load-session.component.ts +++ b/src/app/components/dialog-load-session/dialog-load-session.component.ts @@ -19,6 +19,8 @@ export class DialogLoadSessionComponent { public dependenciesProblems: any[] = []; + public emptyCurrentSession = false; + constructor( public dialogRef: MatDialogRef<DialogLoadSessionComponent>, private intlService: I18nService, @@ -133,7 +135,8 @@ export class DialogLoadSessionComponent { public loadSession() { this.dialogRef.close({ calculators: this.calculators, - file: this.file + file: this.file, + emptySession: this.emptyCurrentSession }); } @@ -172,4 +175,8 @@ export class DialogLoadSessionComponent { public get uitextFixMissingDependencies() { return this.intlService.localizeText("INFO_DIALOG_FIX_MISSING_DEPENDENCIES"); } + + public get uitextEmptyCurrentSession() { + return this.intlService.localizeText("INFO_DIALOG_EMPTY_CURRENT_SESSION"); + } } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 66c9f9d6b..8f555f490 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -62,6 +62,7 @@ "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_2": "Submerged", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_3": "Zero flow", "INFO_DIALOG_COMPUTED_VALUE_TITLE": "Edit initial value", + "INFO_DIALOG_EMPTY_CURRENT_SESSION": "Empty current session", "INFO_DIALOG_FIX_MISSING_DEPENDENCIES": "Fix missing dependencies", "INFO_DIALOG_LOAD_SESSION_FILENAME": "Choose a file", "INFO_DIALOG_LOAD_SESSION_TITLE": "Load calculator modules", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index c8d611b36..5d719c76a 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -62,6 +62,7 @@ "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_2": "Noyé", "INFO_EXTRARES_ENUM_STRUCTUREFLOWREGIME_3": "Débit nul", "INFO_DIALOG_COMPUTED_VALUE_TITLE": "Modifier la valeur initiale", + "INFO_DIALOG_EMPTY_CURRENT_SESSION": "Vider la session courante", "INFO_DIALOG_FIX_MISSING_DEPENDENCIES": "Résoudre les dépendances", "INFO_DIALOG_LOAD_SESSION_FILENAME": "Choisir un fichier", "INFO_DIALOG_LOAD_SESSION_TITLE": "Charger des modules de calcul", -- GitLab