From 96f0d3247e658ee23a66a19ab3948e31f37beb6c Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Wed, 22 Jul 2020 16:31:13 +0200 Subject: [PATCH] Fix bug in PbCloison parameters display in results table --- .../formulaire/definition/form-prebarrage.ts | 41 +++++++++++++------ src/locale/messages.en.json | 1 + src/locale/messages.fr.json | 1 + 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/app/formulaire/definition/form-prebarrage.ts b/src/app/formulaire/definition/form-prebarrage.ts index f6bc246a7..d791856ac 100644 --- a/src/app/formulaire/definition/form-prebarrage.ts +++ b/src/app/formulaire/definition/form-prebarrage.ts @@ -1,4 +1,4 @@ -import { CalculatorType, PbBassin, PbCloison, IObservable, PreBarrage, VariatedDetails } from "jalhyd"; +import { CalculatorType, PbBassin, PbCloison, IObservable, PreBarrage, VariatedDetails, ParamDefinition } from "jalhyd"; import { FormulaireFixedVar } from "./form-fixedvar"; import { PbSchema } from "../elements/pb-schema"; @@ -235,15 +235,6 @@ export class FormulairePrebarrage extends FormulaireFixedVar { if (computedParam !== undefined) { this.pbResults.cloisonResults.calculatedParameter = computedParam; } - // if some parameter is variating, add id too (trick with PbResultsComponent - for (const s of this._selectedItem.structures) { - for (const p of s.parameterIterator) { - if (p.hasMultipleValues) { - const ngp = this.getParamFromSymbol(p.symbol); - this._pbResults.cloisonResults.addFixedParameter(ngp); - } - } - } // transmission des suffixes de cloisons calculés par l'algo de tri de PbSchemaComponent, // pour le sélecteur de conditions limites const pbs = this.kids[0] as PbSchema; @@ -260,10 +251,34 @@ export class FormulairePrebarrage extends FormulaireFixedVar { } } + /** + * Trouve le Ngparameter correspondant au paramètre "p", parmi tous les + * éléments du formulaire de PbCloison, qui peut contenir plusieurs + * structures ayant des paramètres de même nom + * @param param ParamDefinition + */ + public getCloisonParam(param: ParamDefinition): NgParameter { + for (const p of this.allFormElements) { + if (p instanceof NgParameter) { + if (p.paramDefinition === param) { + return p; + } + } + } + } + public addFixedParameters() { - if (this.wallForm !== undefined) { - for (const p of this.wallForm.getFixedParameters()) { - this._pbResults.cloisonResults.addFixedParameter(p); + if (this._selectedItem !== undefined && this._selectedItem instanceof PbCloison) { + for (const s of this._selectedItem.structures) { + for (const p of s.parameterIterator) { + // if some parameter is variating, add id too (trick with PbResultsComponent) + if (p.visible) { + const ngp = this.getCloisonParam(p); + if (ngp) { + this._pbResults.cloisonResults.addFixedParameter(ngp); + } + } + } } } } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 8e52e8a9f..9f3f67c26 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -344,6 +344,7 @@ "INFO_LIB_STRUCTURE_SEUILTRIANGULAIRE": "Triangular weir", "INFO_LIB_STRUCTURE_SEUILTRIANGULAIRETRUNC": "Truncated triangular weir", "INFO_LIB_STRUCTURE_VANNERECTANGULAIRE": "Rectangular gate", + "INFO_LIB_STRUCTURE_N_COURT": "D", "INFO_LIB_TAU0": "Tractive force", "INFO_LIB_TOR": "Supercritical water line", "INFO_LIB_TOTAL": "Total", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index b15fb7935..e71c1d1a2 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -345,6 +345,7 @@ "INFO_LIB_STRUCTURE_SEUILTRIANGULAIRE": "Seuil triangulaire", "INFO_LIB_STRUCTURE_SEUILTRIANGULAIRETRUNC": "Seuil triangulaire tronqué", "INFO_LIB_STRUCTURE_VANNERECTANGULAIRE": "Vanne rectangulaire", + "INFO_LIB_STRUCTURE_N_COURT": "O", "INFO_LIB_TAU0": "Force tractrice", "INFO_LIB_TOR": "Ligne d'eau torrentielle", "INFO_LIB_TOTAL": "Total", -- GitLab