Skip to content
Snippets Groups Projects
Commit 7b3b6729 authored by mathias.chouet's avatar mathias.chouet
Browse files

Fix #173

parent a5608545
No related branches found
No related tags found
No related merge requests found
......@@ -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) {
......
......@@ -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)");
......
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;
}
......
......@@ -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 = [];
}
......
<!-- 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>
......
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment