Skip to content
Snippets Groups Projects
Commit 38754800 authored by mathias.chouet's avatar mathias.chouet
Browse files

Fix #176 - Lorsqu'on charge une session, proposer de vider la session existante

parent e697fb81
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
});
......
......@@ -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 }}
......
......@@ -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");
}
}
......@@ -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",
......
......@@ -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",
......
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