diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 75fe1c71b131718ae2b770a4ccdc95c8138b25be..713ba435a641115e0a43178447422c5bfb5786dc 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -822,139 +822,6 @@ export class AppComponent implements OnInit, OnDestroy, Observer { if (itemId) { this.scrollToQuicknav(itemId, "auto"); } - this.loadSessionFile(result.file, result.calculators); - } - } - - public async loadSessionFile(f: File, info?: any) { - // notes merge detection: was there already some notes ? - const existingNotes = Session.getInstance().documentation; - // load - try { - const data = await this.formulaireService.loadSession(f, info); - if (data.hasErrors) { - this.notificationsService.notify(this.intlService.localizeText("ERROR_PROBLEM_LOADING_SESSION"), 3500); - } else { - if (data.loaded && data.loaded.length > 0) { - if (! isDevMode()) { - this.matomoTracker.trackEvent("userAction", "loadSession"); - } - // notes merge detection: was there already some notes ? - const currentNotes = Session.getInstance().documentation; - if (existingNotes !== "" && currentNotes !== existingNotes) { - this.notificationsService.notify(this.intlService.localizeText("WARNING_SESSION_LOAD_NOTES_MERGED"), 3500); - } - // go to calc or diagram depending on what was loaded - if (data.loaded.length > 1) { - this.toDiagram(); - } else { - this.toCalc(data.loaded[0]); - } - } - } - } catch (err) { - this.notificationsService.notify(this.intlService.localizeText("ERROR_LOADING_SESSION"), 3500); - console.error("error loading session - ", err); - // rollback to ensure session is clean - this.doEmptySession(); - } - } - - /** - * Demande au client d'envoyer un email (génère un lien mailto:), pré-rempli - * avec un texte standard, et le contenu de la session au format JSON - */ - public reportBug() { - const recipient = "bug@cassiopee.g-eau.fr"; - const subject = "[ISSUE] " + this.intlService.localizeText("INFO_REPORT_BUG_SUBJECT"); - let body = this.intlService.localizeText("INFO_REPORT_BUG_BODY"); - - // add session description - - // get all forms - const list = []; - for (const c of this._calculators) { - list.push({ - title: c.title, - uid: c.uid, - selected: true - }); - } - let session = this.buildSessionFile(list); - - // compress - session = pako.deflate(session, { to: "string" }); // gzip (zlib) - session = btoa(session); // base64 - - body += session + "\n"; - body = encodeURIComponent(body); - - const mailtoURL = `mailto:${recipient}?subject=${subject}&body=${body}`; - - // temporarily disable tab closing alert, as tab won't be closed for real - this.appSetupService.warnBeforeTabClose = false; - window.location.href = mailtoURL; - this.appSetupService.warnBeforeTabClose = true; - } - - public get revisionInfo(): any { - return { - jalhyd: { - date: jalhydDateRev, - version: jalhydVersion, - }, - nghyd: { - date: nghydDateRev, - version: nghydVersion - } - }; - } - - /** - * sauvegarde du/des formulaires - * @param form formulaire à sélectionner par défaut dans la liste - */ - public saveForm(form?: FormulaireDefinition) { - // liste des formulaires - const list = []; - for (const c of this._calculators) { - const uid = c["uid"]; - const nub = Session.getInstance().findNubByUid(uid); - let required = nub.getTargettedNubs().map((req) => { - return req.uid; - }); - required = required.filter( - (item, index) => required.indexOf(item) === index // deduplicate - ); - list.push({ - "children": nub.getChildren().map((child) => { - return child.uid; - }), - "requires": required, - "selected": form ? (uid === form.uid) : true, - "title": c["title"], - "uid": uid - }); - } - // dialogue de sélection des formulaires à sauver - const dialogRef = this.saveSessionDialog.open( - DialogSaveSessionComponent, - { - data: { - calculators: list - }, - disableClose: false - } - ); - dialogRef.afterClosed().subscribe(result => { - if (result) { - let name = result.filename; - - // ajout extension ".json" - const re = /.+\.json/; - const match = re.exec(name.toLowerCase()); - if (match === null) { - name = name + ".json"; } } @@ -981,22 +848,23 @@ export class AppComponent implements OnInit, OnDestroy, Observer { return runningPlatform; } - /** - * détection de la fermeture de la page/navigateur et demande de confirmation - */ - @HostListener("window:beforeunload", [ "$event" ]) confirmExit($event) { - if ( - this.appSetupService.warnBeforeTabClose - && ! isDevMode() // otherwise prevents dev server to reload app after recompiling - ) { - // affecter une valeur différente de null provoque l'affichage d'un dialogue de confirmation, mais le texte n'est pas affiché - $event.returnValue = "Your data will be lost !"; + /** + * détection de la fermeture de la page/navigateur et demande de confirmation + */ + @HostListener("window:beforeunload", [ "$event" ]) confirmExit($event) { + if ( + this.appSetupService.warnBeforeTabClose + && ! isDevMode() // otherwise prevents dev server to reload app after recompiling + ) { + // affecter une valeur différente de null provoque l'affichage d'un dialogue de confirmation, mais le texte n'est pas affiché + $event.returnValue = "Your data will be lost !"; + } } - @HostListener("keydown", ["$event"]) onKeydown(event: any) { - if (event.which === 38 || event.which === 40) { // up / down arrow - if (event.srcElement.type === "number") { - event.preventDefault(); + @HostListener("keydown", ["$event"]) onKeyDown($event: any) { + if ($event.which === 38 || $event.which === 40) { // up / down arrow + if ($event.srcElement.type === "number") { + $event.preventDefault(); } } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 77599ae82b380285b04b8fe23226a1af837d44c2..1342dd089e8e48efd709e9c0be38422f8c8416b9 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -180,7 +180,6 @@ const appRoutes: Routes = [ enableTracing: false // debugging purposes only } ), - StorageServiceModule, TableModule, KonamiModule ], diff --git a/src/app/components/fixedvar-results/fixed-results.component.ts b/src/app/components/fixedvar-results/fixed-results.component.ts index 30de6df5819ceaf777a8dff997ef4d0864397cf4..8477e6cefc8f389dfa5df1027650a4f06ae428a4 100644 --- a/src/app/components/fixedvar-results/fixed-results.component.ts +++ b/src/app/components/fixedvar-results/fixed-results.component.ts @@ -109,6 +109,7 @@ export class FixedResultsComponent extends ResultsComponentDirective { }); } } + } for (const symbol of this._fixedResults.variablesOrder) { resultFound = false; diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index f378eba7093f3c86186bcaac888ceca88e9587d3..eb1dc8ad519424fda4068d05b1c7d66908e9eea0 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -24,7 +24,7 @@ import { CalculatorResults } from "../../results/calculator-results"; import { ServiceFactory } from "../../services/service-factory"; import { PabTable } from "../elements/pab-table"; import { SelectEntry } from "../elements/select-entry"; -import { PbSchema } from '../elements/pb-schema'; +import { SelectField } from "../elements/select-field"; /** * classe de base pour tous les formulaires