From e2f07dcb35ce156aa43d4a0d914c45baf07af20b Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Tue, 12 Nov 2019 17:46:07 +0100 Subject: [PATCH] Trigo / SPP : empty results on property change --- .../definition/concrete/form-spp.ts | 39 ++++++++++++------- .../definition/concrete/form-trigo.ts | 9 +---- src/app/services/formulaire.service.ts | 5 +++ 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/app/formulaire/definition/concrete/form-spp.ts b/src/app/formulaire/definition/concrete/form-spp.ts index a58736413..a12a196b6 100644 --- a/src/app/formulaire/definition/concrete/form-spp.ts +++ b/src/app/formulaire/definition/concrete/form-spp.ts @@ -4,30 +4,34 @@ import { FieldSet } from "../../fieldset"; import { FormulaireNode } from "../../formulaire-node"; import { FieldsetContainer } from "../../fieldset-container"; -import { SPP, Nub, Props, Session, YAXN } from "jalhyd"; +import { SPP, Nub, Props, Session, YAXN, IObservable } from "jalhyd"; /** * Formulaire pour "somme / produit de puissances" */ export class FormulaireSPP extends FormulaireBase { - /* constructor() { - super(); - this._formResult = new FormResultPab(this); - - // remove obsolete observer set by super() - this.removeObserver(this._formCompute); - this._formCompute = new FormComputePab(this, (this._formResult as FormResultPab)); - } */ - - /* public get pabNub(): Pab { - return this.currentNub as Pab; - } */ + /** id of select configuring operation */ + private _operationSelectId: string; public get sppNub(): SPP { return this.currentNub as SPP; } + protected parseOptions(json: {}) { + super.parseOptions(json); + this._operationSelectId = this.getOption(json, "operationSelectId"); + } + + public afterParseFieldset(fs: FieldSet) { + if (this._operationSelectId) { + const sel = fs.getFormulaireNodeById(this._operationSelectId); + if (sel) { + fs.properties.addObserver(this); + } + } + } + private createYaxnNub(templ: FieldsetTemplate): Nub { const params = {}; params["calcType"] = templ.calcTypeFromConfig; @@ -129,6 +133,15 @@ export class FormulaireSPP extends FormulaireBase { } else { super.removeFieldset(fs); } } + // interface Observer + + public update(sender: IObservable, data: any) { + super.update(sender, data); + if (data.action === "propertyChange") { + this.reset(); + } + } + private get fieldsetContainer(): FieldsetContainer { const n = this.getFormulaireNodeById("yaxn_container"); if (n === undefined || !(n instanceof FieldsetContainer)) { diff --git a/src/app/formulaire/definition/concrete/form-trigo.ts b/src/app/formulaire/definition/concrete/form-trigo.ts index 510f8b3c9..499d6e03a 100644 --- a/src/app/formulaire/definition/concrete/form-trigo.ts +++ b/src/app/formulaire/definition/concrete/form-trigo.ts @@ -2,7 +2,6 @@ import { IObservable } from "jalhyd"; import { FormulaireBase } from "./form-base"; import { FieldSet } from "../../fieldset"; -import { FormResultFixedVar } from "../form-result-fixedvar"; /** * Formulaire pour les fonctions trigonométriques @@ -41,13 +40,7 @@ export class FormulaireTrigo extends FormulaireBase { public update(sender: IObservable, data: any) { super.update(sender, data); if (data.action === "propertyChange") { - /* if (data.name === "gridType") { - this.reset(); - // Inclined grids have more input fields (OEntH and cIncl) - this.getFieldsetById("fs_grille").updateFields(); - // Alpha and Beta are not always shown - this.getFieldsetById("fs_plan").updateFields(); - } */ + this.reset(); } } } diff --git a/src/app/services/formulaire.service.ts b/src/app/services/formulaire.service.ts index 0391989f5..e0224f8d6 100644 --- a/src/app/services/formulaire.service.ts +++ b/src/app/services/formulaire.service.ts @@ -42,6 +42,7 @@ import { FormulaireBief } from "../formulaire/definition/concrete/form-bief"; import { FormulaireSolveur } from "../formulaire/definition/concrete/form-solveur"; import { AppComponent } from "../app.component"; import { FormulaireSPP } from "../formulaire/definition/concrete/form-spp"; +import { FormulaireTrigo } from "../formulaire/definition/concrete/form-trigo"; @Injectable() export class FormulaireService extends Observable { @@ -344,6 +345,10 @@ export class FormulaireService extends Observable { f = new FormulaireSPP(); break; + case CalculatorType.Trigo: + f = new FormulaireTrigo(); + break; + default: f = new FormulaireBase(); } -- GitLab