From cdfb93668abfa08a2c0aefad6d86f55679cb2047 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 11 Apr 2019 11:19:14 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20#173=20-=20pr=C3=A9fixage=20des=20ID=20de?= =?UTF-8?q?s=20input=20de=20structures=20par=20la=20position=20de=20la=20s?= =?UTF-8?q?tructure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generic-input/generic-input.component.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/components/generic-input/generic-input.component.ts b/src/app/components/generic-input/generic-input.component.ts index 0b8b3f09b..e75f2ed18 100644 --- a/src/app/components/generic-input/generic-input.component.ts +++ b/src/app/components/generic-input/generic-input.component.ts @@ -1,7 +1,7 @@ import { Input, Output, EventEmitter, ChangeDetectorRef, OnChanges, ViewChild } from "@angular/core"; import { NgModel } from "@angular/forms"; import { BaseComponent } from "../base/base.component"; -import { isNumeric } from "jalhyd"; +import { isNumeric, Structure } from "jalhyd"; import { FormulaireDefinition } from "../../formulaire/definition/form-definition"; import { NgParameter } from "../../formulaire/ngparam"; import { I18nService } from "../../services/internationalisation/internationalisation.service"; @@ -37,11 +37,18 @@ export abstract class GenericInputComponent extends BaseComponent implements OnC * id de l'input, utilisé notamment pour les tests */ public get inputId() { - let id = "input-1"; + let id = "error-in-inputId"; if (this._model) { // unique input id based on parameter symbol if (this._model instanceof NgParameter) { - id = (this._model as NgParameter).symbol; + const param = this._model as NgParameter; + id = param.symbol; + // if inside a nested Structure, prefix with Structure position + // to disambiguate + const nub = param.paramDefinition.parentNub; + if (nub && nub instanceof Structure) { + id = nub.findPositionInParent() + "_" + id; + } } } return id; -- GitLab