Commit 7b3b6729 authored by Mathias Chouet's avatar Mathias Chouet :spaghetti:
Browse files

Fix #173

Showing with 33 additions and 13 deletions
+33 -13
...@@ -26,7 +26,7 @@ export class CalculatorPage { ...@@ -26,7 +26,7 @@ export class CalculatorPage {
} }
getSelectById(id: string) { getSelectById(id: string) {
return element(by.css("mat-select#" + id)); return element(by.id(id));
} }
async getSelectValueText(select: ElementFinder) { async getSelectValueText(select: ElementFinder) {
......
...@@ -71,15 +71,15 @@ describe("ngHyd − load session with multiple linked parameters − ", () => { ...@@ -71,15 +71,15 @@ describe("ngHyd − load session with multiple linked parameters − ", () => {
const lo_z2v = await calcPage.getSelectValueText(lo_z2); const lo_z2v = await calcPage.getSelectValueText(lo_z2);
expect(lo_z2v).toEqual("ZF1 (Macro-rugo.)"); 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); const lo_lv = await calcPage.getSelectValueText(lo_l);
expect(lo_lv).toEqual("L (résultat de Ouvrages)"); 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); const lo_wv = await calcPage.getSelectValueText(lo_w);
expect(lo_wv).toEqual("W (Ouvrages, ouvrage 2)"); 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); const lo_cdv = await calcPage.getSelectValueText(lo_cd);
expect(lo_cdv).toEqual("Cd (Ouvrages, ouvrage 1)"); expect(lo_cdv).toEqual("Cd (Ouvrages, ouvrage 1)");
......
import { Component, Input } from "@angular/core"; import { Component, Input } from "@angular/core";
import { MatDialog } from "@angular/material"; import { MatDialog } from "@angular/material";
import { NgParameter } from "../../formulaire/ngparam"; 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 { DialogEditParamComputedComponent } from "../dialog-edit-param-computed/dialog-edit-param-computed.component";
import { I18nService } from "../../services/internationalisation/internationalisation.service";
@Component({ @Component({
selector: "param-computed", selector: "param-computed",
...@@ -24,9 +23,12 @@ export class ParamComputedComponent { ...@@ -24,9 +23,12 @@ export class ParamComputedComponent {
* id de l'input, utilisé notamment pour les tests * id de l'input, utilisé notamment pour les tests
*/ */
public get inputId() { public get inputId() {
let id = "calc_input-1"; let id = "calc_" + this.param.symbol;
if (this.param) { // if inside a nested Structure, prefix with Structure position
id = "calc_" + this.param.symbol; // to disambiguate
const nub = this.param.paramDefinition.parentNub;
if (nub && nub instanceof Structure) {
id = nub.findPositionInParent() + "_" + id;
} }
return id; return id;
} }
......
...@@ -43,7 +43,14 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { ...@@ -43,7 +43,14 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy {
private _formService: FormulaireService; private _formService: FormulaireService;
public get selectId() { 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 { public get isVariable(): boolean {
...@@ -248,7 +255,6 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy { ...@@ -248,7 +255,6 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy {
// liste des paramètres liables // liste des paramètres liables
if (this.param.valueMode === ParamValueMode.LINK) { if (this.param.valueMode === ParamValueMode.LINK) {
this._linkableParams = this._formService.getLinkableValues(this.param); this._linkableParams = this._formService.getLinkableValues(this.param);
console.log("UPDATED !", this._linkableParams);
} else { } else {
this._linkableParams = []; this._linkableParams = [];
} }
......
<!-- a fake input bound to nothing, for the sake of UI consistency --> <!-- a fake input bound to nothing, for the sake of UI consistency -->
<mat-form-field> <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()"> <button type="button" mat-icon-button class="param-values-more" (click)="openDialog()">
<mat-icon>more_horiz</mat-icon> <mat-icon>more_horiz</mat-icon>
</button> </button>
......
...@@ -2,7 +2,7 @@ import { Component, Input, AfterViewInit, Output, EventEmitter } from "@angular/ ...@@ -2,7 +2,7 @@ import { Component, Input, AfterViewInit, Output, EventEmitter } from "@angular/
import { NgParameter } from "../../formulaire/ngparam"; import { NgParameter } from "../../formulaire/ngparam";
import { DialogEditParamValuesComponent } from "../dialog-edit-param-values/dialog-edit-param-values.component"; import { DialogEditParamValuesComponent } from "../dialog-edit-param-values/dialog-edit-param-values.component";
import { MatDialog } from "@angular/material"; import { MatDialog } from "@angular/material";
import { ParamValueMode, Observer } from "jalhyd"; import { ParamValueMode, Observer, Structure } from "jalhyd";
@Component({ @Component({
selector: "param-values", selector: "param-values",
...@@ -41,6 +41,17 @@ export class ParamValuesComponent implements AfterViewInit, Observer { ...@@ -41,6 +41,17 @@ export class ParamValuesComponent implements AfterViewInit, Observer {
return NgParameter.preview(this.param.paramDefinition); 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() { public openDialog() {
// modification des valeurs variables // modification des valeurs variables
this.editValuesDialog.open( this.editValuesDialog.open(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment