From 6e4909e1d7a636be1c9d1e4d51296cbf4b8fdf47 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Thu, 8 Sep 2022 15:15:23 +0200
Subject: [PATCH] fix: predams: wring name in snackbar when copying/adding a
 basin

refs #522
---
 jalhyd_branch                                                 | 2 +-
 .../components/fixedvar-results/fixed-results.component.ts    | 4 ++--
 src/app/components/generic-input/generic-input.component.ts   | 2 +-
 src/app/components/param-computed/param-computed.component.ts | 2 +-
 src/app/components/param-link/param-link.component.ts         | 2 +-
 src/app/components/param-values/param-values.component.ts     | 2 +-
 src/app/services/internationalisation.service.ts              | 3 +--
 7 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/jalhyd_branch b/jalhyd_branch
index 094bda298..337ba388f 100644
--- a/jalhyd_branch
+++ b/jalhyd_branch
@@ -1 +1 @@
-316-courbe-de-remous-et-bief-remonter-une-erreur-quand-le-pas-de-discretisation-est-superieur-la
+320-prebarrages-regroupement-de-la-saisie-des-bassins
diff --git a/src/app/components/fixedvar-results/fixed-results.component.ts b/src/app/components/fixedvar-results/fixed-results.component.ts
index 7fb67ea7f..ae76c3e19 100644
--- a/src/app/components/fixedvar-results/fixed-results.component.ts
+++ b/src/app/components/fixedvar-results/fixed-results.component.ts
@@ -95,7 +95,7 @@ export class FixedResultsComponent extends ResultsComponentDirective {
                     let label = this.formattedLabel(fp);
                     const nub = fp.paramDefinition.parentNub;
                     // add child type and position before label
-                    if (nub && nub.parent && nub.parent.childrenType) {
+                    if (nub && nub.parent && nub.intlType) {
                         const pos = nub.findPositionInParent();
                         // label = this.intlService.localizeText("INFO_OUVRAGE") + " n°" + (pos + 1) + ": " + label;
                         const cn = capitalize(this.intlService.childName(nub));
@@ -198,7 +198,7 @@ export class FixedResultsComponent extends ResultsComponentDirective {
             let label = this.formattedLabel(fp);
             const nub = fp.paramDefinition.parentNub;
             // add child type and position before label
-            if (nub && nub.parent && nub.parent.childrenType) {
+            if (nub && nub.parent && nub.intlType) {
                 const pos = nub.findPositionInParent();
                 const cn = capitalize(this.intlService.childName(nub));
                 label = sprintf(this.intlService.localizeText("INFO_STUFF_N"), cn)
diff --git a/src/app/components/generic-input/generic-input.component.ts b/src/app/components/generic-input/generic-input.component.ts
index 3154a308f..d95168143 100644
--- a/src/app/components/generic-input/generic-input.component.ts
+++ b/src/app/components/generic-input/generic-input.component.ts
@@ -36,7 +36,7 @@ export abstract class GenericInputComponentDirective implements OnChanges {
                 id = param.symbol;
                 // if inside a child Nub, prefix with child position to disambiguate
                 const nub = param.paramDefinition.parentNub;
-                if (nub && nub.parent && nub.parent.childrenType) {
+                if (nub && nub.parent && nub.intlType) {
                     id = nub.findPositionInParent() + "_" + id;
                 }
             }
diff --git a/src/app/components/param-computed/param-computed.component.ts b/src/app/components/param-computed/param-computed.component.ts
index 5525dcf7a..85d6f4070 100644
--- a/src/app/components/param-computed/param-computed.component.ts
+++ b/src/app/components/param-computed/param-computed.component.ts
@@ -32,7 +32,7 @@ export class ParamComputedComponent {
         let id = "calc_" + this.param.symbol;
         // if inside a child Nub, prefix with child position to disambiguate
         const nub = this.param.paramDefinition.parentNub;
-        if (nub && nub.parent && nub.parent.childrenType) {
+        if (nub && nub.parent && nub.intlType) {
             id = nub.findPositionInParent() + "_" + id;
         }
         return id;
diff --git a/src/app/components/param-link/param-link.component.ts b/src/app/components/param-link/param-link.component.ts
index 2571d9ec7..8e03ffeb2 100644
--- a/src/app/components/param-link/param-link.component.ts
+++ b/src/app/components/param-link/param-link.component.ts
@@ -40,7 +40,7 @@ export class ParamLinkComponent implements OnChanges, Observer, OnDestroy {
         let id = "linked_" + this.param.symbol;
         // if inside a child Nub, prefix with child position to disambiguate
         const nub = this.param.paramDefinition.parentNub;
-        if (nub && nub.parent && nub.parent.childrenType) {
+        if (nub && nub.parent && nub.intlType) {
             id = nub.findPositionInParent() + "_" + id;
         }
         return id;
diff --git a/src/app/components/param-values/param-values.component.ts b/src/app/components/param-values/param-values.component.ts
index eeb36a21d..8f3959026 100644
--- a/src/app/components/param-values/param-values.component.ts
+++ b/src/app/components/param-values/param-values.component.ts
@@ -47,7 +47,7 @@ export class ParamValuesComponent implements AfterViewInit, Observer {
         let id = "var_" + this.param.symbol;
         // if inside a child Nub, prefix with child position to disambiguate
         const nub = this.param.paramDefinition.parentNub;
-        if (nub && nub.parent && nub.parent.childrenType) {
+        if (nub && nub.parent && nub.intlType) {
             id = nub.findPositionInParent() + "_" + id;
         }
         return id;
diff --git a/src/app/services/internationalisation.service.ts b/src/app/services/internationalisation.service.ts
index 4b8f545f6..7dddda2a9 100644
--- a/src/app/services/internationalisation.service.ts
+++ b/src/app/services/internationalisation.service.ts
@@ -334,8 +334,7 @@ export class I18nService extends Observable implements Observer {
      * @param short if true, will return short name
      */
     public childName(nub: Nub, plural: boolean = false, short: boolean = false) {
-        const type: string = nub.parent.childrenType;
-        let k = "INFO_CHILD_TYPE_" + type.toUpperCase();
+        let k = "INFO_CHILD_TYPE_" + nub.intlType.toUpperCase();
         if (short) {
             k += "_SHORT";
         } else if (plural) {
-- 
GitLab