From 435fe3aa5c53776bef43fa41272942a9d8d0fe3b Mon Sep 17 00:00:00 2001 From: Jean-Pascal <jean-pascal.aubry@inrae.fr> Date: Fri, 15 Dec 2023 15:19:52 +0000 Subject: [PATCH] fix: create custom class for macrorugo formulaire to reset results in macrorugoremous when a property is updated Refs #609 --- .../calculator.component.ts | 3 +- .../formulaire/definition/form-macrorugo.ts | 50 +++++++++++++++++++ src/app/services/formulaire.service.ts | 6 +++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/app/formulaire/definition/form-macrorugo.ts diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts index 735bc0f5e..8aec6d7b5 100644 --- a/src/app/components/generic-calculator/calculator.component.ts +++ b/src/app/components/generic-calculator/calculator.component.ts @@ -1274,9 +1274,10 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe } public async generateBackwaterInPAM() { + console.log("generateBackwaterInPAM") const f: FormulaireDefinition = await this.formulaireService.createFormulaire(CalculatorType.MacrorugoRemous); const mrr = (f.currentNub as MacrorugoRemous); - // mrr.setPropValue(MacrorugoRemous._nubMacroRugo, this.formulaire.currentNub.uid); + mrr.setPropValue("nubMacroRugo", this.formulaire.currentNub.uid); mrr.syncSectionMacroRugo(); this.router.navigate(["/calculator", f.uid]); } diff --git a/src/app/formulaire/definition/form-macrorugo.ts b/src/app/formulaire/definition/form-macrorugo.ts new file mode 100644 index 000000000..591a26310 --- /dev/null +++ b/src/app/formulaire/definition/form-macrorugo.ts @@ -0,0 +1,50 @@ +import { RemousResults } from "app/results/remous-results"; +import { acSection, CourbeRemous, CourbeRemousParams, MacroRugo, MacrorugoRemous, Props, Result, Session } from "jalhyd"; +import { IObservable, MacrorugoRemousParams, Nub, Observer, Verificateur} from "jalhyd/build/internal_modules"; +import { FormulaireFixedVar } from "./form-fixedvar"; +import { SelectField } from "../elements/select/select-field"; +import { FallbackRegistry } from "@angular-devkit/core/src/experimental/jobs"; +import { FormulaireDefinition } from "./form-definition"; +import { FormulaireService } from "app/services/formulaire.service"; +import { ServiceFactory } from "app/services/service-factory"; +import { log } from "console"; +import { OnInit, DoCheck, AfterViewChecked, OnDestroy } from "@angular/core"; + +export class FormulaireMacrorugo extends FormulaireFixedVar { + + + /** résultats de courbes de remous */ + + constructor() { + super(); + this.updateCalcResults(); + } + + protected updateCalcResults() { + console.log(console.log("vurrent", this._currentNub)) + for (const n of Session.getInstance().getAllNubs()) { + if(n instanceof MacroRugo) { + console.log(n) + } + let pamRemous: MacrorugoRemous + if (n instanceof MacrorugoRemous) { + pamRemous = n; + console.log(pamRemous) + if (pamRemous !== undefined && this._currentNub !== undefined) { + const form = ServiceFactory.formulaireService.getFormulaireFromNubId(pamRemous.uid); + console.log(form) + form.reset() + } + } + } + } + protected reaffectResultComponents() { + // const ver: MacroRugo = (this.currentNub as MacroRugo); + this.updateCalcResults(); + } + + public resetFormResults() { + // this._verificateurResults.reset(); + this.updateCalcResults(); + } +} diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index 9078a93ab..1eb8e7571 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -60,6 +60,7 @@ import { ServiceFactory } from "./service-factory"; import { FormulairePressureLoss } from "app/formulaire/definition/form-pressureloss"; import { getNubResultUnit } from "jalhyd"; import { FormulaireMacrorugoRemous } from "app/formulaire/definition/form-macrorugo-remous"; +import { FormulaireMacrorugo } from "app/formulaire/definition/form-macrorugo"; @Injectable() export class FormulaireService extends Observable { @@ -349,6 +350,11 @@ export class FormulaireService extends Observable { f = new FormulaireMacrorugoRemous(); break; + + case CalculatorType.MacroRugo: + f = new FormulaireMacrorugo(); + break; + default: f = new FormulaireFixedVar(); } -- GitLab