From cd68c31ed73329d0ff244e92ce4bd7b9ef5059c2 Mon Sep 17 00:00:00 2001
From: Antonin Coquet <ext.sopra.acoquet@grandlyon.com>
Date: Tue, 13 Apr 2021 17:21:57 +0200
Subject: [PATCH] fix: send query string to structure details components

---
 .../structure-list/components/card/card.component.ts | 12 +++++++++---
 src/app/structure-list/structure-list.component.html |  2 +-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/app/structure-list/components/card/card.component.ts b/src/app/structure-list/components/card/card.component.ts
index 5d2d7dd66..8a1b657e1 100644
--- a/src/app/structure-list/components/card/card.component.ts
+++ b/src/app/structure-list/components/card/card.component.ts
@@ -45,11 +45,17 @@ export class CardComponent implements OnInit {
 
   public cardClicked(): void {
     this.showDetails.emit(this.structure);
+    const queryString = this.route.snapshot.queryParamMap.get('search');
     this.router.navigate([], {
       relativeTo: this.route,
-      queryParams: {
-        id: this.structure._id,
-      },
+      queryParams: queryString
+        ? {
+            id: this.structure._id,
+            search: queryString,
+          }
+        : {
+            id: this.structure._id,
+          },
     });
   }
 
diff --git a/src/app/structure-list/structure-list.component.html b/src/app/structure-list/structure-list.component.html
index 951c2726a..1b39ec645 100644
--- a/src/app/structure-list/structure-list.component.html
+++ b/src/app/structure-list/structure-list.component.html
@@ -16,7 +16,7 @@
   <app-card
     *ngFor="let structure of structuresListChunked"
     [structure]="structure"
-    (showDetails)="showDetails($event)"
+    (showDetails)="showDetails($event, filters)"
     (hover)="handleCardHover($event)"
   ></app-card>
   <p *ngIf="structureList && structureList.length <= 0">Il n'y a aucune réponse correspondant à votre recherche</p>
-- 
GitLab