From 1d45b5bf98ed83720db65af548aae4cd134db3d9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois?= <francois.grand@irstea.fr>
Date: Thu, 25 Jan 2018 06:50:54 +0100
Subject: [PATCH] =?UTF-8?q?classe=20GenericInputComponent=20:=20factorisat?=
 =?UTF-8?q?ion=20de=20code=20(m=C3=A9thode=20updateAndValidateUI)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../generic-input/generic-input.component.ts    | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/app/components/generic-input/generic-input.component.ts b/src/app/components/generic-input/generic-input.component.ts
index 2077a6bbb..70a31ad94 100644
--- a/src/app/components/generic-input/generic-input.component.ts
+++ b/src/app/components/generic-input/generic-input.component.ts
@@ -148,14 +148,19 @@ export abstract class GenericInputComponent extends BaseComponent {
         this.validateModel();
     }
 
-    public set model(v: any) {
-        this.setAndValidateModel(v);
-
-        // MAJ UI
+    /**
+     * MAJ et validation de l'UI
+     */
+    protected updateAndValidateUI() {
         this._uiValue = this.modelToUI(this.getModelValue());
         this.validateUI();
     }
 
+    public set model(v: any) {
+        this.setAndValidateModel(v);
+        this.updateAndValidateUI();
+    }
+
     private get uiValue() {
         return this._uiValue;
     }
@@ -175,8 +180,8 @@ export abstract class GenericInputComponent extends BaseComponent {
      * @see BaseComponent
      */
     protected afterFirstViewChecked() {
-        this._uiValue = this.modelToUI(this.getModelValue());
-        this.validate();
+        this.updateAndValidateUI();
+        this.validateModel();
     }
 
     /**
-- 
GitLab