From 7f206e034e0301f7ad59906ac7b049a9d4646f8f Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Fri, 24 May 2019 17:38:05 +0200
Subject: [PATCH] =?UTF-8?q?Modale=20de=20param=C3=A8tre=20vari=C3=A9:=20d?=
 =?UTF-8?q?=C3=A9lection=20de=20la=20strat=C3=A9gie=20d'extension?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../dialog-edit-param-values.component.html   |  9 +++++++
 .../dialog-edit-param-values.component.ts     | 27 ++++++++++++++++++-
 .../param-field-line.component.ts             |  2 +-
 src/locale/messages.en.json                   |  3 +++
 src/locale/messages.fr.json                   |  3 +++
 5 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.html b/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.html
index 8fbe604a5..43f8a3a0f 100644
--- a/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.html
+++ b/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.html
@@ -105,6 +105,15 @@
         </form>
     </div>
 
+    <mat-form-field>
+      <mat-select [placeholder]="uitextExtensionStrategy" [(value)]="selectedExtensionStrategy"
+        data-testid="variable-extension-strategy-select">
+          <mat-option *ngFor="let e of extensionStrategies" [value]="e.value">
+              {{ e.label }}
+          </mat-option>
+      </mat-select>
+    </mat-form-field>
+
   </div>
 
   <div mat-dialog-content *ngIf="viewChart">
diff --git a/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts b/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts
index 5bc041da5..803de5b0b 100644
--- a/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts
+++ b/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts
@@ -3,7 +3,7 @@ import { Inject, Component, OnInit } from "@angular/core";
 import { FormBuilder, FormGroup, Validators } from "@angular/forms";
 import { I18nService } from "../../services/internationalisation/internationalisation.service";
 import { NgParameter } from "../../formulaire/ngparam";
-import { ParamValueMode } from "jalhyd";
+import { ParamValueMode, ExtensionStrategy } from "jalhyd";
 import { sprintf } from "sprintf-js";
 import { ApplicationSetupService } from "../../services/app-setup/app-setup.service";
 
@@ -23,6 +23,9 @@ export class DialogEditParamValuesComponent implements OnInit {
     /** available decimal separators */
     public decimalSeparators: { label: string; value: string; }[];
 
+    /** available extension strategies */
+    public extensionStrategies: { value: ExtensionStrategy; label: string; }[];
+
     /** current decimal separator */
     public decimalSeparator: string;
 
@@ -76,6 +79,16 @@ export class DialogEditParamValuesComponent implements OnInit {
             }
         ];
         this.decimalSeparator = this.decimalSeparators[0].value;
+        this.extensionStrategies = [
+            {
+                value: ExtensionStrategy.REPEAT_LAST,
+                label: this.intlService.localizeText("INFO_PARAMFIELD_PARAMVARIER_EXT_STRATEGY_REPEAT_LAST")
+            },
+            {
+                value: ExtensionStrategy.RECYCLE,
+                label: this.intlService.localizeText("INFO_PARAMFIELD_PARAMVARIER_EXT_STRATEGY_RECYCLE")
+            }
+        ];
 
         // chart configuration
         const nDigits = this.appSetupService.displayDigits;
@@ -171,6 +184,14 @@ export class DialogEditParamValuesComponent implements OnInit {
         this.param.valueMode = v;
     }
 
+    public get selectedExtensionStrategy() {
+        return this.param.paramDefinition.extensionStrategy;
+    }
+
+    public set selectedExtensionStrategy(es) {
+        this.param.paramDefinition.extensionStrategy = es;
+    }
+
     public get isMinMax() {
         return this.param.valueMode === ParamValueMode.MINMAX;
     }
@@ -412,6 +433,10 @@ export class DialogEditParamValuesComponent implements OnInit {
         return this.intlService.localizeText("INFO_PARAMFIELD_PARAMVARIER_IMPORT_FICHIER");
     }
 
+    public get uitextExtensionStrategy() {
+        return this.intlService.localizeText("INFO_PARAMFIELD_PARAMVARIER_EXT_STRATEGY");
+    }
+
     public ngOnInit() {
         this.initVariableValues();
     }
diff --git a/src/app/components/param-field-line/param-field-line.component.ts b/src/app/components/param-field-line/param-field-line.component.ts
index df956b33a..5b105c01f 100644
--- a/src/app/components/param-field-line/param-field-line.component.ts
+++ b/src/app/components/param-field-line/param-field-line.component.ts
@@ -197,7 +197,7 @@ export class ParamFieldLineComponent implements OnChanges {
         let ret = true;
         if (this.param.paramDefinition.isCalculated) {
             const nub = this.param.paramDefinition.parentNub;
-            const p = nub.findFirstSingleParameter(this.param.paramDefinition);
+            const p = nub.findFirstCalculableParameter(this.param.paramDefinition);
             ret = (p !== undefined);
         }
         return ret;
diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json
index b521d5451..32364c098 100644
--- a/src/locale/messages.en.json
+++ b/src/locale/messages.en.json
@@ -212,6 +212,9 @@
     "INFO_PARAMFIELD_PARAMFIXE": "Fixed",
     "INFO_PARAMFIELD_PARAMLIE_LABEL": "Linked parameter",
     "INFO_PARAMFIELD_PARAMLIE": "Link",
+    "INFO_PARAMFIELD_PARAMVARIER_EXT_STRATEGY": "Values list extension strategy",
+    "INFO_PARAMFIELD_PARAMVARIER_EXT_STRATEGY_REPEAT_LAST": "Repeat last value",
+    "INFO_PARAMFIELD_PARAMVARIER_EXT_STRATEGY_RECYCLE": "Recycle values",
     "INFO_PARAMFIELD_PARAMVARIER_IMPORT_FICHIER": "Import file",
     "INFO_PARAMFIELD_PARAMVARIER_MINMAXSTEP": "min: %s, max: %s, step: %s",
     "INFO_PARAMFIELD_PARAMVARIER_MODE": "Mode",
diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json
index efa2d9ba8..7228186b3 100644
--- a/src/locale/messages.fr.json
+++ b/src/locale/messages.fr.json
@@ -212,6 +212,9 @@
     "INFO_PARAMFIELD_PARAMFIXE": "fixé",
     "INFO_PARAMFIELD_PARAMLIE_LABEL": "Paramètre lié",
     "INFO_PARAMFIELD_PARAMLIE": "lié",
+    "INFO_PARAMFIELD_PARAMVARIER_EXT_STRATEGY": "Stratégie d'extension de la liste de valeurs",
+    "INFO_PARAMFIELD_PARAMVARIER_EXT_STRATEGY_REPEAT_LAST": "Répéter la dernière valeur",
+    "INFO_PARAMFIELD_PARAMVARIER_EXT_STRATEGY_RECYCLE": "Réutiliser les valeurs",
     "INFO_PARAMFIELD_PARAMVARIER_IMPORT_FICHIER": "Importer un fichier",
     "INFO_PARAMFIELD_PARAMVARIER_MINMAXSTEP": "min : %s, max : %s, pas : %s",
     "INFO_PARAMFIELD_PARAMVARIER_MODE": "Mode",
-- 
GitLab