From dfe689d8b29da07a4c046ff50f98b4bf019cd887 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Thu, 5 May 2022 15:29:50 +0200
Subject: [PATCH 1/2] test(e2e): check that an added structure has empty fields
 after the first structure is modified

refs #536
---
 e2e/ouvrages-empty-fields.e2e-spec.ts | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/e2e/ouvrages-empty-fields.e2e-spec.ts b/e2e/ouvrages-empty-fields.e2e-spec.ts
index 6eac089d5..9ee6d8378 100644
--- a/e2e/ouvrages-empty-fields.e2e-spec.ts
+++ b/e2e/ouvrages-empty-fields.e2e-spec.ts
@@ -163,4 +163,23 @@ describe("ngHyd - check that created/cloned structures have empty fields - ", ()
         const emptys = [true, true, true];
         await checkFields(inputIds, emptys);
     });
+
+    it("when a structure is modified (input) and then a structure is added", async () => {
+        await setup();
+
+        // fill 
+        const inp = calcPage.getInputById("0_ZDV");
+        await inp.clear();
+        await inp.sendKeys("1");
+
+        // copy structure
+        const addStruct = calcPage.getAddStructureButton();
+        await addStruct.click();
+        await browser.sleep(200);
+
+        // check empty fields
+        const inputIds = ["1_ZDV", "1_L", "1_W", "1_CdGR"];
+        const emptys = [true, true, true, false];
+        await checkFields(inputIds, emptys);
+    });
 });
-- 
GitLab


From 625b757bbc53879c71cc4f30ec3e42cd24a725a7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Thu, 5 May 2022 16:12:26 +0200
Subject: [PATCH 2/2] fix: added structure field not empty after modifying the
 first one

refs #536
---
 .../fieldset-container/fieldset-container.component.ts        | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/app/components/fieldset-container/fieldset-container.component.ts b/src/app/components/fieldset-container/fieldset-container.component.ts
index d09ee6118..630da2d19 100644
--- a/src/app/components/fieldset-container/fieldset-container.component.ts
+++ b/src/app/components/fieldset-container/fieldset-container.component.ts
@@ -75,15 +75,15 @@ export class FieldsetContainerComponent implements DoCheck, AfterViewInit {
      * dans un nouveau fieldset
      */
     private addSubNub(after: FieldSet, clone: boolean = false) {
-        const prms = after.backupParameters();
+        const prms = clone ? after.backupParameters() : undefined;
         const newFs = this._container.addFromTemplate(0, after.indexAsKid());
         if (clone) {
             // replace in-place to change properties (overkill)
             // @WTF why only those two ?
             newFs.setPropValue("structureType", after.properties.getPropValue("structureType"));
             newFs.setPropValue("loiDebit", after.properties.getPropValue("loiDebit"));
+            newFs.restoreParameters(prms);
         }
-        newFs.restoreParameters(prms);
     }
 
     private onFieldsetListChange() {
-- 
GitLab