From 7bdfc5e445a4780965cf9b84deda8642896d1c60 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Mon, 8 Jul 2019 10:14:05 +0200
Subject: [PATCH] Generate PAB from Cloisons : minimum 2 falls are required

---
 .../dialog-generate-pab/dialog-generate-pab.component.html  | 4 ++--
 .../dialog-generate-pab/dialog-generate-pab.component.ts    | 6 ++++++
 src/locale/messages.en.json                                 | 1 +
 src/locale/messages.fr.json                                 | 1 +
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.html b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.html
index 14202deec..c1161f20c 100644
--- a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.html
+++ b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.html
@@ -25,12 +25,12 @@
     </mat-error>
 
     <mat-form-field>
-      <input matInput required [placeholder]="uitextNBBassins" pattern="^[1-9][0-9]*$"
+      <input matInput required [placeholder]="uitextNBBassins" pattern="^([2-9]|[1-9][0-9]+)$"
       [(ngModel)]="nbBassins" name="nbBassins" #inputNbBassins="ngModel" id="generatePabNbBassins">
     </mat-form-field>
     <mat-error *ngIf="inputNbBassins.invalid && (inputNbBassins.dirty || inputNbBassins.touched)">
         <div *ngIf="inputNbBassins.errors.required || inputNbBassins.errors.pattern">
-            {{ uitextMustBePositive }}
+            {{ uitextMustBeAtLeastTwo }}
         </div>
     </mat-error>
 
diff --git a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts
index a0f55835b..48c7c7972 100644
--- a/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts
+++ b/src/app/components/dialog-generate-pab/dialog-generate-pab.component.ts
@@ -4,6 +4,8 @@ import { Inject, Component } from "@angular/core";
 import { I18nService } from "../../services/internationalisation/internationalisation.service";
 import { FormBuilder } from "@angular/forms";
 
+import { sprintf } from "sprintf-js";
+
 @Component({
     selector: "dialog-generate-pab",
     templateUrl: "dialog-generate-pab.component.html",
@@ -67,6 +69,10 @@ export class DialogGeneratePABComponent {
     return this.intlService.localizeText("ERROR_PARAM_MUST_BE_POSITIVE");
   }
 
+  public get uitextMustBeAtLeastTwo() {
+    return sprintf(this.intlService.localizeText("ERROR_PARAM_MUST_BE_AT_LEAST"), 2);
+  }
+
   public get uitextGeneratePAB() {
       return this.intlService.localizeText("INFO_CALCULATOR_RESULTS_GENERATE_PAB");
   }
diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json
index f51fe3182..f685685d7 100644
--- a/src/locale/messages.en.json
+++ b/src/locale/messages.en.json
@@ -17,6 +17,7 @@
     "ERROR_MINMAXSTEP_STEP": "Value is not in %s",
     "ERROR_NEWTON_DERIVEE_NULLE": "Null function derivative in Newton computation",
     "ERROR_PARAM_MUST_BE_A_NUMBER": "Please type a numeric value",
+    "ERROR_PARAM_MUST_BE_AT_LEAST": "Value must be >= %s",
     "ERROR_PARAM_MUST_BE_POSITIVE": "Please type a positive numeric value",
     "ERROR_PARAM_NULL": "Parameter value must not be NULL",
     "ERROR_PARAMDEF_CALC_UNDEFINED": "calculability of '%symbol%' parameter is undefined",
diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json
index baf4af6ee..03e07508e 100644
--- a/src/locale/messages.fr.json
+++ b/src/locale/messages.fr.json
@@ -17,6 +17,7 @@
     "ERROR_MINMAXSTEP_STEP": "La valeur n'est pas dans %s",
     "ERROR_NEWTON_DERIVEE_NULLE": "Dérivée nulle dans un calcul par la méthode de Newton",
     "ERROR_PARAM_MUST_BE_A_NUMBER": "Veuillez entrer une valeur numérique",
+    "ERROR_PARAM_MUST_BE_AT_LEAST": "La valeur doit être >= %s",
     "ERROR_PARAM_MUST_BE_POSITIVE": "Veuillez entrer une valeur numérique positive",
     "ERROR_PARAM_NULL": "La valeur du paramètre ne peut pas être NULL",
     "ERROR_PARAMDEF_CALC_UNDEFINED": "La calculabilité du paramètre %symbol% n'est pas définie",
-- 
GitLab