From 7bf4087cd2b3cf64817ab690a18dd20a46b46e74 Mon Sep 17 00:00:00 2001 From: Etienne LOUPIAS <eloupias@grandlyon.com> Date: Fri, 7 Apr 2023 10:43:34 +0200 Subject: [PATCH 1/5] fix(carto): loader not displayed --- src/app/carto/carto.component.html | 1 + src/app/carto/carto.component.ts | 5 +++ .../structure-list.component.html | 34 ++++++++++--------- .../structure-list.component.scss | 2 +- .../structure-list.component.ts | 3 +- 5 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/app/carto/carto.component.html b/src/app/carto/carto.component.html index d8c4b0bb7..94bced40b 100644 --- a/src/app/carto/carto.component.html +++ b/src/app/carto/carto.component.html @@ -7,6 +7,7 @@ class="left-pane" fxLayout="column" [structureList]="structures" + [isLoading]="isLoadingStructures" [selectedStructureList]="structuresSelected" [isOrientation]="isOrientationForm" [location]="currentLocation" diff --git a/src/app/carto/carto.component.ts b/src/app/carto/carto.component.ts index dc992f620..123b0bde1 100644 --- a/src/app/carto/carto.component.ts +++ b/src/app/carto/carto.component.ts @@ -26,6 +26,7 @@ export class CartoComponent implements OnInit { @Output() structureSelection = new EventEmitter<any>(); public structures: Structure[] = []; + public isLoadingStructures: boolean = true; public currentLocation: GeoJson; public displayMarkerId: string; public selectedMarkerId: string; @@ -80,15 +81,18 @@ export class CartoComponent implements OnInit { ); }); } else { + this.isLoadingStructures = true; this.structureService.getStructures(filters).subscribe((structures) => { if (structures) { this.updateStructuresDistance(structures, this.userLongitude, this.userLatitude, false); } else { this.structures = null; } + this.isLoadingStructures = false; }); } } else { + this.isLoadingStructures = true; this.searchedValue = null; this.structureService.getStructures(filters).subscribe((structures) => { if (structures) { @@ -96,6 +100,7 @@ export class CartoComponent implements OnInit { } else { this.structures = null; } + this.isLoadingStructures = false; }); } } diff --git a/src/app/structure-list/structure-list.component.html b/src/app/structure-list/structure-list.component.html index a5c95f9a3..92c330d9e 100644 --- a/src/app/structure-list/structure-list.component.html +++ b/src/app/structure-list/structure-list.component.html @@ -22,22 +22,24 @@ </div> <div id="listCard" class="listCard" role="list" (mouseleave)="mouseLeave()"> - <app-card - *ngFor="let structure of structureList" - class="structure-card" - role="listitem" - [structure]="structure" - [isOrientation]="isOrientation" - [isSelected]="isInPrintList(structure._id)" - (showDetails)="showDetails(structure)" - (keyup.enter)="showDetails(structure)" - (hover)="handleCardHover($event)" - (addToList)="addToList($event)" - /> - <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"> + <div *ngIf="!isLoading"> + <app-card + *ngFor="let structure of structureList" + class="structure-card" + role="listitem" + [structure]="structure" + [isOrientation]="isOrientation" + [isSelected]="isInPrintList(structure._id)" + (showDetails)="showDetails(structure)" + (keyup.enter)="showDetails(structure)" + (hover)="handleCardHover($event)" + (addToList)="addToList($event)" + /> + <p *ngIf="structureList?.length === 0" class="noStructureFound"> + Il n'y a aucune réponse correspondant à votre recherche + </p> + </div> + <div *ngIf="isLoading" class="loader"> <img class="loader-gif" src="/assets/gif/loader_circle.gif" alt /> </div> </div> diff --git a/src/app/structure-list/structure-list.component.scss b/src/app/structure-list/structure-list.component.scss index b08856b47..a3a525ef5 100644 --- a/src/app/structure-list/structure-list.component.scss +++ b/src/app/structure-list/structure-list.component.scss @@ -21,7 +21,7 @@ } } -.listCard > p { +.noStructureFound { margin-left: 1rem; } diff --git a/src/app/structure-list/structure-list.component.ts b/src/app/structure-list/structure-list.component.ts index 26287a5cc..5f0663e35 100644 --- a/src/app/structure-list/structure-list.component.ts +++ b/src/app/structure-list/structure-list.component.ts @@ -15,6 +15,7 @@ import { PrintService } from '../shared/service/print.service'; export class StructureListComponent implements OnChanges, OnInit { @Input() public isOrientation: boolean = false; @Input() public structureList: Structure[]; + @Input() public isLoading = true; @Input() public location: GeoJson; @Input() public selectedStructure: Structure = new Structure(); @Input() public selectedStructureList: Structure[] = []; @@ -26,7 +27,6 @@ export class StructureListComponent implements OnChanges, OnInit { public buttonTypeEnum = ButtonType; public structure: Structure; public printMode = false; - public isLoading = true; constructor( private route: ActivatedRoute, @@ -60,7 +60,6 @@ export class StructureListComponent implements OnChanges, OnInit { } if (changes.structureList) { document.getElementById('listCard').scrollTo(0, 0); - this.isLoading = changes.structureList.firstChange; } } -- GitLab From 8dbae9cdc2275cc4f1e50d684e1ada5b7c0b0c9d Mon Sep 17 00:00:00 2001 From: Etienne LOUPIAS <eloupias@grandlyon.com> Date: Fri, 7 Apr 2023 10:45:53 +0200 Subject: [PATCH 2/5] clean unused code --- src/app/carto/carto.component.html | 1 - src/app/carto/carto.component.ts | 6 ------ src/app/structure-list/structure-list.component.ts | 1 - 3 files changed, 8 deletions(-) diff --git a/src/app/carto/carto.component.html b/src/app/carto/carto.component.html index 94bced40b..e492b6e06 100644 --- a/src/app/carto/carto.component.html +++ b/src/app/carto/carto.component.html @@ -15,7 +15,6 @@ [ngClass]="{ mapPhone: isMapPhone === true }" (displayMapMarkerId)="setMapMarkerId($event)" (selectedMarkerId)="setSelectedMarkerId($event)" - (updatedStructure)="updateStructures($event)" (structureSelected)="selectStructure($event)" /> <div class="btnSwitch"> diff --git a/src/app/carto/carto.component.ts b/src/app/carto/carto.component.ts index 123b0bde1..7ce8e8ecc 100644 --- a/src/app/carto/carto.component.ts +++ b/src/app/carto/carto.component.ts @@ -105,12 +105,6 @@ export class CartoComponent implements OnInit { } } - public updateStructures(s: Structure): void { - this.structures = this.structures.map((structure) => { - return structure._id === s._id ? s : structure; - }); - } - /** * Update structure distance according to user actual position. * @param structures structures data to update diff --git a/src/app/structure-list/structure-list.component.ts b/src/app/structure-list/structure-list.component.ts index 5f0663e35..49569c049 100644 --- a/src/app/structure-list/structure-list.component.ts +++ b/src/app/structure-list/structure-list.component.ts @@ -21,7 +21,6 @@ export class StructureListComponent implements OnChanges, OnInit { @Input() public selectedStructureList: Structure[] = []; @Output() public displayMapMarkerId: EventEmitter<string> = new EventEmitter<string>(); @Output() public selectedMarkerId: EventEmitter<string> = new EventEmitter<string>(); - @Output() public updatedStructure: EventEmitter<Structure> = new EventEmitter<Structure>(); @Output() public structureSelected: EventEmitter<Structure[]> = new EventEmitter<Structure[]>(); public buttonTypeEnum = ButtonType; -- GitLab From d80bd108c3d3b47de52521d85cc96acfddd4581f Mon Sep 17 00:00:00 2001 From: Etienne LOUPIAS <eloupias@grandlyon.com> Date: Thu, 20 Apr 2023 10:05:03 +0200 Subject: [PATCH 3/5] add ng-container --- src/app/structure-list/structure-list.component.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/structure-list/structure-list.component.html b/src/app/structure-list/structure-list.component.html index 92c330d9e..c63724fcc 100644 --- a/src/app/structure-list/structure-list.component.html +++ b/src/app/structure-list/structure-list.component.html @@ -22,7 +22,7 @@ </div> <div id="listCard" class="listCard" role="list" (mouseleave)="mouseLeave()"> - <div *ngIf="!isLoading"> + <ng-container *ngIf="!isLoading"> <app-card *ngFor="let structure of structureList" class="structure-card" @@ -38,7 +38,7 @@ <p *ngIf="structureList?.length === 0" class="noStructureFound"> Il n'y a aucune réponse correspondant à votre recherche </p> - </div> + </ng-container> <div *ngIf="isLoading" class="loader"> <img class="loader-gif" src="/assets/gif/loader_circle.gif" alt /> </div> -- GitLab From 5fead1dca46e72ec9afb6b3d54033cd6a4930596 Mon Sep 17 00:00:00 2001 From: Etienne LOUPIAS <eloupias@grandlyon.com> Date: Thu, 20 Apr 2023 10:14:36 +0200 Subject: [PATCH 4/5] fix null structureList --- src/app/carto/carto.component.ts | 4 ++-- src/app/structure-list/structure-list.component.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/carto/carto.component.ts b/src/app/carto/carto.component.ts index 7ce8e8ecc..01f1063bf 100644 --- a/src/app/carto/carto.component.ts +++ b/src/app/carto/carto.component.ts @@ -86,7 +86,7 @@ export class CartoComponent implements OnInit { if (structures) { this.updateStructuresDistance(structures, this.userLongitude, this.userLatitude, false); } else { - this.structures = null; + this.structures = []; } this.isLoadingStructures = false; }); @@ -98,7 +98,7 @@ export class CartoComponent implements OnInit { if (structures) { this.updateStructuresDistance(structures, this.userLongitude, this.userLatitude); } else { - this.structures = null; + this.structures = []; } this.isLoadingStructures = false; }); diff --git a/src/app/structure-list/structure-list.component.html b/src/app/structure-list/structure-list.component.html index c63724fcc..0824ffde4 100644 --- a/src/app/structure-list/structure-list.component.html +++ b/src/app/structure-list/structure-list.component.html @@ -35,7 +35,7 @@ (hover)="handleCardHover($event)" (addToList)="addToList($event)" /> - <p *ngIf="structureList?.length === 0" class="noStructureFound"> + <p *ngIf="structureList.length === 0" class="noStructureFound"> Il n'y a aucune réponse correspondant à votre recherche </p> </ng-container> -- GitLab From 6e3a05079235f32394ae5f8805800ecce304f3ad Mon Sep 17 00:00:00 2001 From: Etienne LOUPIAS <eloupias@grandlyon.com> Date: Thu, 20 Apr 2023 11:06:55 +0200 Subject: [PATCH 5/5] retour review --- src/app/carto/carto.component.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/carto/carto.component.ts b/src/app/carto/carto.component.ts index 01f1063bf..0571ea605 100644 --- a/src/app/carto/carto.component.ts +++ b/src/app/carto/carto.component.ts @@ -68,6 +68,7 @@ export class CartoComponent implements OnInit { } public getStructures(filters: Filter[]): void { + this.isLoadingStructures = true; const queryString = _.find(filters, { name: 'query' }); if (queryString) { this.searchedValue = queryString.value; @@ -79,9 +80,9 @@ export class CartoComponent implements OnInit { this.currentLocation.geometry.getLon(), this.currentLocation.geometry.getLat() ); + this.isLoadingStructures = false; }); } else { - this.isLoadingStructures = true; this.structureService.getStructures(filters).subscribe((structures) => { if (structures) { this.updateStructuresDistance(structures, this.userLongitude, this.userLatitude, false); @@ -92,7 +93,6 @@ export class CartoComponent implements OnInit { }); } } else { - this.isLoadingStructures = true; this.searchedValue = null; this.structureService.getStructures(filters).subscribe((structures) => { if (structures) { -- GitLab