Commit b923c28d authored by Grand Francois's avatar Grand Francois
Browse files

#45 méthode ParallelStructure.getLinkableValues() : ajout d'un préfixe...

 #45 méthode ParallelStructure.getLinkableValues() : ajout d'un préfixe numérique sur le nom des valeurs renvoyées pour les ouvrages (par ex 0.ZDV)
Showing with 16 additions and 7 deletions
+16 -7
......@@ -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;
......
......@@ -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;
}
}
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