From 0ef697ef98e5e3867637f4e3208ecd5ccf28e7e9 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Mon, 31 Oct 2022 15:44:31 +0100
Subject: [PATCH] fix: wording and loader

---
 src/app/annuaire/annuaire.component.ts                  | 6 +++++-
 src/app/annuaire/result-list/result-list.component.html | 8 +++++++-
 src/app/structure-list/structure-list.component.html    | 7 ++++++-
 src/app/structure-list/structure-list.component.ts      | 2 ++
 4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/app/annuaire/annuaire.component.ts b/src/app/annuaire/annuaire.component.ts
index 69872baf5..41c073128 100644
--- a/src/app/annuaire/annuaire.component.ts
+++ b/src/app/annuaire/annuaire.component.ts
@@ -1,4 +1,4 @@
-import { Component, OnInit } from '@angular/core';
+import { Component } from '@angular/core';
 import { UserAnnuary } from '../models/user.model';
 import { AuthService } from '../services/auth.service';
 import { SearchService } from '../structure-list/services/search.service';
@@ -18,6 +18,10 @@ export class AnnuaireComponent {
   public nextPage: number = 1;
   public filterActive: boolean = false;
 
+  ngOnInit(): void {
+    this.getUsers({ queryParam: '', page: 1, jobFilters: [], employerFilters: [] });
+  }
+
   public getUsers(params: SearchQuery): void {
     if (this.userIsLoggedIn()) {
       this.searchService.annuaireSearchQuery = params;
diff --git a/src/app/annuaire/result-list/result-list.component.html b/src/app/annuaire/result-list/result-list.component.html
index 1582d326c..268fe8c9a 100644
--- a/src/app/annuaire/result-list/result-list.component.html
+++ b/src/app/annuaire/result-list/result-list.component.html
@@ -47,7 +47,13 @@
 
 <div class="results unlogged" *ngIf="!isLogged">
   <img src="../../assets/ico/annuaire-unlogged.svg" alt="Illustration annuaire" />
-  <div class="users">{{ totalUserResult }} utilisateurs sont présents dans l'annuaire Rés'in</div>
+  <div class="users" [ngPlural]="totalUserResult">
+    <ng-template ngPluralCase="0">Aucun utilisateur n'est présent dans l'annuaire Rés'in</ng-template>
+    <ng-template ngPluralCase="1">1 utilisateur est présent dans l'annuaire Rés'in</ng-template>
+    <ng-template ngPluralCase="other"
+      >{{ totalUserResult }} utilisateurs sont présents dans l'annuaire Rés'in</ng-template
+    >
+  </div>
   <div class="access">
     Pour accéder à l’annuaire de Rés’in et contacter les utilisateurs,<br />
     veuillez vous connecter ou vous créer un compte.
diff --git a/src/app/structure-list/structure-list.component.html b/src/app/structure-list/structure-list.component.html
index 2d00d0c39..b69c38836 100644
--- a/src/app/structure-list/structure-list.component.html
+++ b/src/app/structure-list/structure-list.component.html
@@ -29,6 +29,11 @@
       (hover)="handleCardHover($event)"
       class="structure-card"
     ></app-card>
-    <p *ngIf="structureList && structureList.length <= 0">Il n'y a aucune réponse correspondant à votre recherche</p>
+    <p *ngIf="structureList && structureList.length <= 0 && !isLoading">
+      Il n'y a aucune réponse correspondant à votre recherche
+    </p>
+    <div *ngIf="structureList && structureList.length <= 0 && isLoading" class="loader">
+      <img class="loader-gif" src="/assets/gif/loader_circle.gif" alt />
+    </div>
   </div>
 </div>
diff --git a/src/app/structure-list/structure-list.component.ts b/src/app/structure-list/structure-list.component.ts
index 196e29e75..a3ee50fa7 100644
--- a/src/app/structure-list/structure-list.component.ts
+++ b/src/app/structure-list/structure-list.component.ts
@@ -23,6 +23,7 @@ export class StructureListComponent implements OnChanges, OnInit {
   public buttonTypeEnum = ButtonType;
   public structure: Structure;
   public printMode = false;
+  public isLoading = true;
 
   constructor(
     private route: ActivatedRoute,
@@ -62,6 +63,7 @@ export class StructureListComponent implements OnChanges, OnInit {
     }
     if (changes.structureList) {
       document.getElementById('listCard').scrollTo(0, 0);
+      this.isLoading = changes.structureList.firstChange;
     }
   }
 
-- 
GitLab