diff --git a/e2e/load-linked-params.e2e-spec.ts b/e2e/load-linked-params.e2e-spec.ts index cd0b97a4c5d99b0eb3d40802c5f2cc1d62c0ee6d..56f84364aade223b1b5dc7668fce26da822c81ff 100644 --- a/e2e/load-linked-params.e2e-spec.ts +++ b/e2e/load-linked-params.e2e-spec.ts @@ -35,7 +35,7 @@ describe("ngHyd − load session with multiple linked parameters", () => { await sidenav.loadSessionFile("./session-liens-spaghetti.json"); await browser.sleep(500); - expect(await navbar.getAllCalculatorTabs().count()).toBe(4); + expect(await navbar.getAllCalculatorTabs().count()).toBe(5); // 1. check Section paramétrée await navbar.clickCalculatorTab(0); @@ -51,11 +51,11 @@ describe("ngHyd − load session with multiple linked parameters", () => { // check target params values const mr_b = calcPage.getSelectById("linked_B"); const mr_bv = await calcPage.getSelectValueText(mr_b); - expect(mr_bv).toEqual("L (résultat de Ouvrages, ouvrage 1)"); + expect(mr_bv).toEqual("L (résultat de Ouvrages)"); const mr_q = calcPage.getSelectById("linked_Q"); const mr_qv = await calcPage.getSelectValueText(mr_q); - expect(mr_qv).toEqual("Q (résultat de R. uniforme)"); + expect(mr_qv).toEqual("Q (R. uniforme)"); // 3. check Lois d'ouvrages await navbar.clickCalculatorTab(2); @@ -67,7 +67,7 @@ describe("ngHyd − load session with multiple linked parameters", () => { const lo_l = calcPage.getSelectById("linked_L"); // attention ID non unique, voir nghyd#173 const lo_lv = await calcPage.getSelectValueText(lo_l); - expect(lo_lv).toEqual("L (résultat de Ouvrages, ouvrage 1)"); + expect(lo_lv).toEqual("L (résultat de Ouvrages)"); const lo_w = calcPage.getSelectById("linked_W"); // attention ID non unique, voir nghyd#173 const lo_wv = await calcPage.getSelectValueText(lo_w); @@ -81,9 +81,17 @@ describe("ngHyd − load session with multiple linked parameters", () => { await navbar.clickCalculatorTab(3); // check target params values - const lo_y = calcPage.getSelectById("linked_Y"); - const lo_yv = await calcPage.getSelectValueText(lo_y); - expect(lo_yv).toEqual("Yt (Sec. param., résultat complémentaire)"); + const lo_q = calcPage.getSelectById("linked_Q"); + const lo_qv = await calcPage.getSelectValueText(lo_q); + expect(lo_qv).toEqual("CvQT (Déver. dénoyés, résultat complémentaire)"); + + // 5. check Déver. dénoyés + await navbar.clickCalculatorTab(4); + + // check target params values + const lo_br = calcPage.getSelectById("linked_BR"); + const lo_brv = await calcPage.getSelectValueText(lo_br); + expect(lo_brv).toEqual("LargeurBerge (Sec. param.)"); }); }); diff --git a/e2e/session-liens-spaghetti.json b/e2e/session-liens-spaghetti.json index bbccd213b330929dd8221f650604f979c1bbd64b..87b17d2a13cc46819f2620f39cf5ba412304773f 100644 --- a/e2e/session-liens-spaghetti.json +++ b/e2e/session-liens-spaghetti.json @@ -77,7 +77,7 @@ { "symbol": "B", "mode": "LINK", - "targetNub": "cjdyYW", + "targetNub": "ZW9icn", "targetParam": "L" }, { @@ -186,7 +186,7 @@ { "symbol": "L", "mode": "LINK", - "targetNub": "cjdyYW", + "targetNub": "ZW9icn", "targetParam": "L" }, { @@ -276,7 +276,9 @@ }, { "symbol": "Q", - "mode": "CALCUL" + "mode": "LINK", + "targetNub": "NGlpMn", + "targetParam": "CvQT" }, { "symbol": "If", @@ -292,14 +294,77 @@ }, { "symbol": "Y", + "mode": "SINGLE", + "value": 0.8 + }, + { + "symbol": "LargeurBerge", + "mode": "CALCUL" + } + ] + }, + { + "uid": "NGlpMn", + "props": { + "calcType": 9, + "nodeType": 0 + }, + "meta": { + "title": "Déver. dénoyés" + }, + "structures": [ + { + "uid": "M29rcW", + "props": { + "calcType": 7, + "nodeType": 5, + "structureType": 0, + "loiDebit": 7 + }, + "parameters": [ + { + "symbol": "ZDV", + "mode": "SINGLE", + "value": 100 + }, + { + "symbol": "L", + "mode": "SINGLE", + "value": 2 + }, + { + "symbol": "Cd", + "mode": "SINGLE", + "value": 0.4 + } + ] + } + ], + "parameters": [ + { + "symbol": "Pr", + "mode": "SINGLE", + "value": 0.0001 + }, + { + "symbol": "Q", + "mode": "CALCUL" + }, + { + "symbol": "Z1", + "mode": "SINGLE", + "value": 102 + }, + { + "symbol": "BR", "mode": "LINK", "targetNub": "OW9rd3", - "targetParam": "Yt" + "targetParam": "LargeurBerge" }, { - "symbol": "LargeurBerge", + "symbol": "ZR", "mode": "SINGLE", - "value": 2.5 + "value": 99 } ] } diff --git a/src/app/formulaire/definition/form-compute-parallel-structures.ts b/src/app/formulaire/definition/form-compute-parallel-structures.ts index 9daa4cbd6cf61b2db18eb0e1173ee28dfc3ed49d..580a52f08184d797601a6b247e15c8f27d60de35 100644 --- a/src/app/formulaire/definition/form-compute-parallel-structures.ts +++ b/src/app/formulaire/definition/form-compute-parallel-structures.ts @@ -1,4 +1,4 @@ -import { ComputeNode, ParallelStructure } from "jalhyd"; +import { ComputeNode, ParallelStructure, Structure } from "jalhyd"; import { FormComputeFixedVar } from "./form-compute-fixedvar"; import { FormResultFixedVar } from "./form-result-fixedvar"; @@ -38,15 +38,19 @@ export class FormComputeParallelStructures extends FormComputeFixedVar { } /** - * construit un identifiant de type "n.X" avec "n" l'index de l'ouvrage auquel appartient le paramètre et "X" son symbole + * construit un identifiant de type { uid: "abcdef", symbol: "X" } + * avec "abcdef" l'index de l'ouvrage et "X" son paramètre */ - protected getParameterRefid(p: NgParameter) { - const [fsc, fs, i] = this.structureParents(p); - if (i === -1) { + protected getParameterRefid(p: NgParameter): any { + const nub = p.paramDefinition.parentComputeNode; + if (nub instanceof Structure) { + return { + uid: nub.uid, + symbol: p.symbol + }; + } else { return super.getParameterRefid(p); } - - return `${i}.${p.symbol}`; } protected setParameterValue(node: ComputeNode, p: NgParameter, val: number) { diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts index e34b286f2ad2ba92e824467f8b17df273cc87c94..e1d9f5433a88176548ee9c053157780103abd20b 100644 --- a/src/app/formulaire/definition/form-definition.ts +++ b/src/app/formulaire/definition/form-definition.ts @@ -162,7 +162,7 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs * @param uid id à rechercher */ public hasNubId(uid: string): boolean { - return this._currentNub.uid === uid; + return (this._currentNub && this._currentNub.uid === uid); } public moveFieldsetUp(fs: FieldSet) { diff --git a/src/app/services/formulaire/formulaire.service.ts b/src/app/services/formulaire/formulaire.service.ts index fe3e0bfe647b01192068444a2a8d6b39475d793c..c9d21d2d340e33bb1826ce329eadd97095be58e8 100644 --- a/src/app/services/formulaire/formulaire.service.ts +++ b/src/app/services/formulaire/formulaire.service.ts @@ -617,15 +617,17 @@ export class FormulaireService extends Observable { for (const dn of dependingNubs) { if (! visited.includes(dn.uid)) { const form = this.getFormulaireFromNubId(dn.uid); - const hadResults = form.hasResults; - // form might not have a result, but still have another form depending on it ! - form.resetResults(visited); - if (hadResults) { - if (notify) { - this.notificationsService.notify( - this.intlService.localizeText("INFO_SNACKBAR_RESULTS_INVALIDATED") + " " + form.calculatorName, - 2000 - ); + if (form) { + const hadResults = form.hasResults; + // form might not have a result, but still have another form depending on it ! + form.resetResults(visited); + if (hadResults) { + if (notify) { + this.notificationsService.notify( + this.intlService.localizeText("INFO_SNACKBAR_RESULTS_INVALIDATED") + " " + form.calculatorName, + 2000 + ); + } } } }