From 1a835d4e27ce68bd17e3d3c237abc1ee8858f2a9 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Fri, 24 May 2019 10:07:55 +0200
Subject: [PATCH] Fixed bug in CalcSerie() for SectionParametree

---
 src/nub.ts                        | 31 +++++++++++++++++++------------
 src/section/section_parametree.ts |  6 ++++++
 2 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/src/nub.ts b/src/nub.ts
index 22aa2f40..21463a8c 100644
--- a/src/nub.ts
+++ b/src/nub.ts
@@ -339,17 +339,9 @@ export abstract class Nub extends ComputeNode implements IObservable {
         }
 
         // find calculated parameter
-        let computedSymbol: any;
-        if (sDonnee) {
-            computedSymbol = sDonnee;
-        } else {
-            if (this.calculatedParam === undefined) {
-                throw new Error(`CalcSerie() : aucun paramètre à calculer`);
-            }
-            computedSymbol = this.calculatedParamDescriptor;
-        }
+        const computedSymbol = this.findCalculatedParameter(sDonnee);
 
-        if (rInit === undefined) {
+        if (rInit === undefined && this.calculatedParam) {
             rInit = this.calculatedParam.v;
         }
 
@@ -436,8 +428,10 @@ export abstract class Nub extends ComputeNode implements IObservable {
             this.progress = 100;
         }
 
-        const realSymbol = (typeof computedSymbol === "string") ? computedSymbol : computedSymbol.symbol;
-        this._result.name = realSymbol;
+        if (computedSymbol !== undefined) {
+            const realSymbol = (typeof computedSymbol === "string") ? computedSymbol : computedSymbol.symbol;
+            this._result.name = realSymbol;
+        }
 
         this.notifyResultUpdated();
 
@@ -1141,6 +1135,19 @@ export abstract class Nub extends ComputeNode implements IObservable {
         this._observable.notifyObservers(data, sender);
     }
 
+    protected findCalculatedParameter(sDonnee: any): any {
+        let computedSymbol: any;
+        if (sDonnee) {
+            computedSymbol = sDonnee;
+        } else {
+            if (this.calculatedParam === undefined) {
+                throw new Error(`CalcSerie() : aucun paramètre à calculer`);
+            }
+            computedSymbol = this.calculatedParamDescriptor;
+        }
+        return computedSymbol;
+    }
+
     protected doCalc(computedSymbol?: any, rInit?: number) {
         return this.Calc(computedSymbol, rInit);
     }
diff --git a/src/section/section_parametree.ts b/src/section/section_parametree.ts
index a943d060..4a7da8dd 100644
--- a/src/section/section_parametree.ts
+++ b/src/section/section_parametree.ts
@@ -137,6 +137,12 @@ export class SectionParametree extends SectionNub {
         return this._result;
     }
 
+    // calculated param is always "Y"
+    protected findCalculatedParameter(sDonnee: any): any {
+        return undefined;
+    }
+
+    // calculated param is always "Y"
     protected doCalc(computedSymbol?: any, rInit?: number) {
         return this.Calc();
     }
-- 
GitLab