From b923c28daf2e81e3e53cba9dbf4ca16b6f43b8ed Mon Sep 17 00:00:00 2001
From: "francois.grand" <francois.grand@irstea.fr>
Date: Tue, 19 Jun 2018 17:10:48 +0200
Subject: [PATCH] =?UTF-8?q?=20#45=20m=C3=A9thode=20ParallelStructure.getLi?=
 =?UTF-8?q?nkableValues()=20:=20ajout=20d'un=20pr=C3=A9fixe=20num=C3=A9riq?=
 =?UTF-8?q?ue=20sur=20le=20nom=20des=20valeurs=20renvoy=C3=A9es=20pour=20l?=
 =?UTF-8?q?es=20ouvrages=20(par=20ex=200.ZDV)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/nub.ts                          | 14 +++++++++-----
 src/structure/parallel_structure.ts |  9 +++++++--
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/nub.ts b/src/nub.ts
index 83e54f4b..429e70ea 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 7a2d0a9b..77c57101 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;
     }
 }
-- 
GitLab