diff --git a/src/nub.ts b/src/nub.ts index 83e54f4be62b7aee89414b48f7006c614a1f6107..429e70ea43003d17c9812d4f70a774fe15aa47da 100644 --- a/src/nub.ts +++ b/src/nub.ts @@ -254,12 +254,16 @@ export abstract class Nub extends ComputeNode implements IReferencedNub { // return res; // } + private addPrefix(str: string, prefix: string) { + return prefix === undefined ? str : `${prefix}${str}`; + } + /** * liste des valeurs (paramètre, résultat, résultat complémentaire) liables à un paramètre * @param src objet qui sert de clé de recherche des paramètres liables, de type INamedObject | string * @returns tableau d'objets de la forme { "name":string, "value":NamedIterableValues, "nub":Nub}, nub=Nub d'origine de la "value" */ - public getLinkableValues(src: any): any[] { + public getLinkableValues(src: any, prefix?: string): any[] { const res: any[] = []; const isStr = typeof (src) === "string"; @@ -279,12 +283,12 @@ export abstract class Nub extends ComputeNode implements IReferencedNub { case "Z1": case "Z2": if (p.symbol === "Z1" || p.symbol === "Z2") - res.push({ "name": p.symbol, "value": p, "nub": this }); + res.push({ "name": this.addPrefix(p.symbol, prefix), "value": p, "nub": this }); break; default: if (p.symbol === name) - res.push({ "name": name, "value": p, "nub": this }); + res.push({ "name": this.addPrefix(p.symbol, prefix), "value": p, "nub": this }); } } } @@ -292,13 +296,13 @@ export abstract class Nub extends ComputeNode implements IReferencedNub { // résultat if (this._result !== undefined) { if (this._result.name === name) - res.push({ "name": `${name}.`, "value": this._result, "nub": this }); + res.push({ "name": this.addPrefix(`${name}.`, prefix), "value": this._result, "nub": this }); // résultats complémentaires const erIter = this._result.getIterableExtraResults(name) if (erIter !== undefined) - res.push({ "name": `${this._result.name}.${name}`, "value": erIter, "nub": this }); + res.push({ "name": this.addPrefix(`${this._result.name}.${name}`, prefix), "value": erIter, "nub": this }); } return res; diff --git a/src/structure/parallel_structure.ts b/src/structure/parallel_structure.ts index 7a2d0a9b2c5bb8f8eb964da8a89f6253dfe9bd3b..77c571014c60186edc24533e4b5288b5f2c19914 100644 --- a/src/structure/parallel_structure.ts +++ b/src/structure/parallel_structure.ts @@ -301,8 +301,13 @@ export class ParallelStructure extends Nub { */ public getLinkableValues(src: any): any[] { let res = super.getLinkableValues(src); - for (const s of this.structures) - res = res.concat(s.getLinkableValues(src)); + + let i = 0; + for (const s of this.structures) { + const l = s.getLinkableValues(src, `${i}.`); + res = res.concat(l); + i++; + } return res; } }