diff --git a/e2e/solveur.e2e-spec.ts b/e2e/solveur.e2e-spec.ts index 73d5e0d54d223b9ca11a0b0f3adac91ddb41a009..a542f32ba20103af9ac8f1e42e886e1df209998e 100644 --- a/e2e/solveur.e2e-spec.ts +++ b/e2e/solveur.e2e-spec.ts @@ -170,4 +170,20 @@ describe("Solveur - ", () => { // check "search parameter" value has not changed expect(await calcPage.getSelectValueText(sel)).toEqual(selText); }); + + it("check solver searched parameter is set to 'bottom slope'", async () => { + // open "canal critical slope" example + const examples = await element.all(by.css("#examples-list .load-example")); + await examples[3].click(); + await browser.sleep(500); + + // select solver tab + await navbar.clickCalculatorTab(2); + await browser.sleep(500); + + // check selected searched parameter text + const sel = calcPage.getSelectById("select_searched_param"); + const selText = await calcPage.getSelectValueText(sel); + expect(selText).toEqual("If - Pente du fond (Sec. param.)"); + }); }); diff --git a/src/app/formulaire/elements/select-field-custom.ts b/src/app/formulaire/elements/select-field-custom.ts index 1b7ddc7105ebcdc51e7f45e274a2cb55367a05a0..5c395281e5840ac070e79ad385bf96e4f806e4f2 100644 --- a/src/app/formulaire/elements/select-field-custom.ts +++ b/src/app/formulaire/elements/select-field-custom.ts @@ -3,7 +3,7 @@ import { ServiceFactory } from "../../services/service-factory"; import { SelectField } from "./select-field"; import { decodeHtml, arraysAreEqual } from "../../util"; -import { FishSpecies, Session, Solveur, FishPass, CalculatorType, Verificateur, Nub, PbCloison, PreBarrage } from "jalhyd"; +import { FishSpecies, Session, Solveur, FishPass, CalculatorType, Verificateur, Nub, PbCloison, PreBarrage, acSection } from "jalhyd"; import { sprintf } from "sprintf-js"; @@ -30,7 +30,15 @@ export class SelectFieldCustom extends SelectField { case "solveur_searched": // Solveur, paramètre recherché (à faire varier) const sp = (nub as Solveur).searchedParameter; if (sp !== undefined) { - this.setValueFromId(this._entriesBaseId + sp.nubUid + "_" + sp.symbol); + let parentNubUid; + const parentNub = sp.getParentComputeNode(false); + if (parentNub instanceof acSection) { + parentNubUid = parentNub.uid; + } + else { + parentNubUid = sp.nubUid + } + this.setValueFromId(this._entriesBaseId + parentNubUid + "_" + sp.symbol); } break; @@ -225,7 +233,7 @@ export class SelectFieldCustom extends SelectField { // default to first available entry if any if (this._entries.length > 0) { if (this._multiple) { - this.setValue([ this._entries[0] ]); + this.setValue([this._entries[0]]); } else { this.setValue(this._entries[0]); } @@ -265,10 +273,10 @@ export class SelectFieldCustom extends SelectField { } else { // keep previously selected entry(ies) if possible if (pse) { - if (! Array.isArray(pse) && pse.id) { + if (!Array.isArray(pse) && pse.id) { this.setValueFromId(pse.id); } else if (Array.isArray(pse) && pse.length > 0) { - this.setValueFromId(pse.map((e) => e.id )); + this.setValueFromId(pse.map((e) => e.id)); } else { this.setDefaultValue(); } @@ -287,16 +295,16 @@ export class SelectFieldCustom extends SelectField { this._selectedEntry = v; // if value changed const valueChanged = ( - ! previousSelectedEntry + !previousSelectedEntry || ( - ! Array.isArray(previousSelectedEntry) - && ! Array.isArray(v) + !Array.isArray(previousSelectedEntry) + && !Array.isArray(v) && previousSelectedEntry.id !== v.id ) || ( Array.isArray(previousSelectedEntry) && Array.isArray(v) - && ! arraysAreEqual(previousSelectedEntry, v, "id", true) + && !arraysAreEqual(previousSelectedEntry, v, "id", true) ) ); if (valueChanged) { @@ -327,7 +335,7 @@ export class SelectFieldCustom extends SelectField { } } } - if (! found) { + if (!found) { this.setDefaultValue(); } }