diff --git a/e2e/calculator.po.ts b/e2e/calculator.po.ts index 69cc7a7b04f36837903b10a36fcb7f6173faefd7..3c84b64f601583d9ad044c62870ca839fbc6e59e 100644 --- a/e2e/calculator.po.ts +++ b/e2e/calculator.po.ts @@ -26,7 +26,7 @@ export class CalculatorPage { } getSelectById(id: string) { - return element(by.css("mat-select#" + id)); + return element(by.id(id)); } async getSelectValueText(select: ElementFinder) { diff --git a/e2e/load-linked-params.e2e-spec.ts b/e2e/load-linked-params.e2e-spec.ts index 6a1001fc2d74d0ca70933b07e7033c43f4cb4ec9..7bb6efdd283e3e787413742e3b776c3e69156016 100644 --- a/e2e/load-linked-params.e2e-spec.ts +++ b/e2e/load-linked-params.e2e-spec.ts @@ -71,15 +71,15 @@ describe("ngHyd − load session with multiple linked parameters − ", () => { const lo_z2v = await calcPage.getSelectValueText(lo_z2); expect(lo_z2v).toEqual("ZF1 (Macro-rugo.)"); - const lo_l = calcPage.getSelectById("linked_L"); // attention ID non unique, voir nghyd#173 + const lo_l = calcPage.getSelectById("1_linked_L"); const lo_lv = await calcPage.getSelectValueText(lo_l); 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_w = calcPage.getSelectById("2_linked_W"); const lo_wv = await calcPage.getSelectValueText(lo_w); expect(lo_wv).toEqual("W (Ouvrages, ouvrage 2)"); - const lo_cd = calcPage.getSelectById("linked_Cd"); // attention ID non unique, voir nghyd#173 + const lo_cd = calcPage.getSelectById("2_linked_Cd"); const lo_cdv = await calcPage.getSelectValueText(lo_cd); expect(lo_cdv).toEqual("Cd (Ouvrages, ouvrage 1)"); diff --git a/src/app/components/param-computed/param-computed.component.ts b/src/app/components/param-computed/param-computed.component.ts index d15dcbfa4eb0be6c22286699e6588db4fc3cc19a..2abb701ebb7d8deade121b89782691f1fd5a925a 100644 --- a/src/app/components/param-computed/param-computed.component.ts +++ b/src/app/components/param-computed/param-computed.component.ts @@ -1,9 +1,8 @@ import { Component, Input } from "@angular/core"; import { MatDialog } from "@angular/material"; import { NgParameter } from "../../formulaire/ngparam"; -import { ParamCalculability } from "jalhyd"; +import { ParamCalculability, Structure } from "jalhyd"; import { DialogEditParamComputedComponent } from "../dialog-edit-param-computed/dialog-edit-param-computed.component"; -import { I18nService } from "../../services/internationalisation/internationalisation.service"; @Component({ selector: "param-computed", @@ -24,9 +23,12 @@ export class ParamComputedComponent { * id de l'input, utilisé notamment pour les tests */ public get inputId() { - let id = "calc_input-1"; - if (this.param) { - id = "calc_" + this.param.symbol; + let id = "calc_" + this.param.symbol; + // if inside a nested Structure, prefix with Structure position + // to disambiguate + const nub = this.param.paramDefinition.parentNub; + if (nub && nub instanceof Structure) { + id = nub.findPositionInParent() + "_" + id; } return id; } diff --git a/src/app/components/param-link/param-link.component.ts b/src/app/components/param-link/param-link.component.ts index d0510e69b3fb6d3f445bb6ef0dc69a6a53bc462d..7fab3306b2d9ecdd41157b296b9dd75663b931d4 100644 --- a/src/app/components/param-link/param-link.component.ts +++ b/src/app/components/param-link/param-link.component.ts @@ -43,7 +43,14 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { private _formService: FormulaireService; public get selectId() { - return "linked_" + this.param.symbol; + let id = "linked_" + this.param.symbol; + // if inside a nested Structure, prefix with Structure position + // to disambiguate + const nub = this.param.paramDefinition.parentNub; + if (nub && nub instanceof Structure) { + id = nub.findPositionInParent() + "_" + id; + } + return id; } public get isVariable(): boolean { @@ -248,7 +255,6 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { // liste des paramètres liables if (this.param.valueMode === ParamValueMode.LINK) { this._linkableParams = this._formService.getLinkableValues(this.param); - console.log("UPDATED !", this._linkableParams); } else { this._linkableParams = []; } diff --git a/src/app/components/param-values/param-values.component.html b/src/app/components/param-values/param-values.component.html index 171010493d0967599e36da5d580215e4ef64ba36..a34d49e5f49e2755478bfdc567d142d1b99d7269 100644 --- a/src/app/components/param-values/param-values.component.html +++ b/src/app/components/param-values/param-values.component.html @@ -1,6 +1,7 @@ <!-- a fake input bound to nothing, for the sake of UI consistency --> <mat-form-field> - <input matInput disabled class="form-control" type="text" [ngModel]="infoText" [placeholder]="param.title"> + <input matInput disabled class="form-control" type="text" + [id]="inputId" [name]="inputId" [ngModel]="infoText" [placeholder]="param.title"> <button type="button" mat-icon-button class="param-values-more" (click)="openDialog()"> <mat-icon>more_horiz</mat-icon> </button> diff --git a/src/app/components/param-values/param-values.component.ts b/src/app/components/param-values/param-values.component.ts index 95c9e3c71a6a8a95a7399f84c05c1bd35e04644c..27cc698b50f0a0b1ecf478bc682e141069e45a35 100644 --- a/src/app/components/param-values/param-values.component.ts +++ b/src/app/components/param-values/param-values.component.ts @@ -2,7 +2,7 @@ import { Component, Input, AfterViewInit, Output, EventEmitter } from "@angular/ import { NgParameter } from "../../formulaire/ngparam"; import { DialogEditParamValuesComponent } from "../dialog-edit-param-values/dialog-edit-param-values.component"; import { MatDialog } from "@angular/material"; -import { ParamValueMode, Observer } from "jalhyd"; +import { ParamValueMode, Observer, Structure } from "jalhyd"; @Component({ selector: "param-values", @@ -41,6 +41,17 @@ export class ParamValuesComponent implements AfterViewInit, Observer { return NgParameter.preview(this.param.paramDefinition); } + public get inputId() { + let id = "var_" + this.param.symbol; + // if inside a nested Structure, prefix with Structure position + // to disambiguate + const nub = this.param.paramDefinition.parentNub; + if (nub && nub instanceof Structure) { + id = nub.findPositionInParent() + "_" + id; + } + return id; + } + public openDialog() { // modification des valeurs variables this.editValuesDialog.open(