From 68ddb3c390ab2193f15d1c62573ffb53a1e0275d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Grand?= <francois.grand@inrae.fr>
Date: Fri, 9 Sep 2022 14:33:19 +0200
Subject: [PATCH] feat: predams: apply event processing to basin move
 functionnalities

refs #522
---
 .../components/pb-schema/pb-schema.component.ts    |  7 +------
 src/app/services/prebarrage.service.ts             | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/app/components/pb-schema/pb-schema.component.ts b/src/app/components/pb-schema/pb-schema.component.ts
index c335b4083..7ac6b72a7 100644
--- a/src/app/components/pb-schema/pb-schema.component.ts
+++ b/src/app/components/pb-schema/pb-schema.component.ts
@@ -504,6 +504,7 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni
         switch (event.id) {
             case PrebarrageServiceEvents.BASIN_WALL_ADDED:
             case PrebarrageServiceEvents.BASIN_WALL_COPIED:
+            case PrebarrageServiceEvents.MOVE_BASIN:
                 this.clearResults();
                 this.refreshWithSelection(nub.uid);
                 this.calculatorComponent.showPBInputData = true;
@@ -562,9 +563,6 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni
         if (this._selectedItem instanceof PbBassin) {
             this.predamService.moveSelectedBasinUp();
         }
-        this.clearResults();
-        this.refreshWithSelection(this._selectedItem.uid);
-        this.calculatorComponent.showPBInputData = true;
     }
 
     public get uitextMoveBasinUp() {
@@ -583,9 +581,6 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni
         if (this._selectedItem instanceof PbBassin) {
             this.predamService.moveSelectedBasinDown();
         }
-        this.clearResults();
-        this.refreshWithSelection(this._selectedItem.uid);
-        this.calculatorComponent.showPBInputData = true;
     }
 
     public get uitextMoveBasinDown() {
diff --git a/src/app/services/prebarrage.service.ts b/src/app/services/prebarrage.service.ts
index 65e534627..4fadedae0 100644
--- a/src/app/services/prebarrage.service.ts
+++ b/src/app/services/prebarrage.service.ts
@@ -5,7 +5,9 @@ export enum PrebarrageServiceEvents {
     BASIN_WALL_ADDED, // a wall has been added
     BASIN_WALL_COPIED, // a basin or wall has been copied
     BASIN_WALL_REMOVED, // a basin or a wall has been removed
+    MOVE_BASIN, // a basin has been moved up or down
 }
+
 /**
  * service relatif au schéma de prébarrage
  */
@@ -176,6 +178,12 @@ export class PrebarrageService {
     public moveSelectedBasinUp() {
         const uid = this._selectedNub.uid;
         this.moveBasinUp(uid);
+        this._changeEventEmitter.emit(
+            {
+                id: PrebarrageServiceEvents.MOVE_BASIN,
+                data: this._selectedNub
+            }
+        );
     }
 
     /**
@@ -188,6 +196,12 @@ export class PrebarrageService {
     public moveSelectedBasinDown() {
         const uid = this._selectedNub.uid;
         this.moveBasinDown(uid);
+        this._changeEventEmitter.emit(
+            {
+                id: PrebarrageServiceEvents.MOVE_BASIN,
+                data: this._selectedNub
+            }
+        );
     }
 
     /**
-- 
GitLab