Skip to content
Snippets Groups Projects
Commit fe83b315 authored by Etienne LOUPIAS's avatar Etienne LOUPIAS
Browse files

Merge branch '281-loader-non-affichage-sur-la-carto-par-defaut' into 'dev'

Resolve "[Loader] - Non affichage sur la carto par défaut"

See merge request !494
parents b841f175 32f6aa14
No related branches found
No related tags found
2 merge requests!525V2.3.0,!494Resolve "[Loader] - Non affichage sur la carto par défaut"
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
class="left-pane" class="left-pane"
fxLayout="column" fxLayout="column"
[structureList]="structures" [structureList]="structures"
[isLoading]="isLoadingStructures"
[selectedStructureList]="structuresSelected" [selectedStructureList]="structuresSelected"
[isOrientation]="isOrientationForm" [isOrientation]="isOrientationForm"
[location]="currentLocation" [location]="currentLocation"
...@@ -14,7 +15,6 @@ ...@@ -14,7 +15,6 @@
[ngClass]="{ mapPhone: isMapPhone === true }" [ngClass]="{ mapPhone: isMapPhone === true }"
(displayMapMarkerId)="setMapMarkerId($event)" (displayMapMarkerId)="setMapMarkerId($event)"
(selectedMarkerId)="setSelectedMarkerId($event)" (selectedMarkerId)="setSelectedMarkerId($event)"
(updatedStructure)="updateStructures($event)"
(structureSelected)="selectStructure($event)" (structureSelected)="selectStructure($event)"
/> />
<div class="btnSwitch"> <div class="btnSwitch">
......
...@@ -26,6 +26,7 @@ export class CartoComponent implements OnInit { ...@@ -26,6 +26,7 @@ export class CartoComponent implements OnInit {
@Output() structureSelection = new EventEmitter<any>(); @Output() structureSelection = new EventEmitter<any>();
public structures: Structure[] = []; public structures: Structure[] = [];
public isLoadingStructures: boolean = true;
public currentLocation: GeoJson; public currentLocation: GeoJson;
public displayMarkerId: string; public displayMarkerId: string;
public selectedMarkerId: string; public selectedMarkerId: string;
...@@ -67,6 +68,7 @@ export class CartoComponent implements OnInit { ...@@ -67,6 +68,7 @@ export class CartoComponent implements OnInit {
} }
public getStructures(filters: Filter[]): void { public getStructures(filters: Filter[]): void {
this.isLoadingStructures = true;
const queryString = _.find(filters, { name: 'query' }); const queryString = _.find(filters, { name: 'query' });
if (queryString) { if (queryString) {
this.searchedValue = queryString.value; this.searchedValue = queryString.value;
...@@ -78,14 +80,16 @@ export class CartoComponent implements OnInit { ...@@ -78,14 +80,16 @@ export class CartoComponent implements OnInit {
this.currentLocation.geometry.getLon(), this.currentLocation.geometry.getLon(),
this.currentLocation.geometry.getLat() this.currentLocation.geometry.getLat()
); );
this.isLoadingStructures = false;
}); });
} else { } else {
this.structureService.getStructures(filters).subscribe((structures) => { this.structureService.getStructures(filters).subscribe((structures) => {
if (structures) { if (structures) {
this.updateStructuresDistance(structures, this.userLongitude, this.userLatitude, false); this.updateStructuresDistance(structures, this.userLongitude, this.userLatitude, false);
} else { } else {
this.structures = null; this.structures = [];
} }
this.isLoadingStructures = false;
}); });
} }
} else { } else {
...@@ -94,18 +98,13 @@ export class CartoComponent implements OnInit { ...@@ -94,18 +98,13 @@ export class CartoComponent implements OnInit {
if (structures) { if (structures) {
this.updateStructuresDistance(structures, this.userLongitude, this.userLatitude); this.updateStructuresDistance(structures, this.userLongitude, this.userLatitude);
} else { } else {
this.structures = null; this.structures = [];
} }
this.isLoadingStructures = false;
}); });
} }
} }
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. * Update structure distance according to user actual position.
* @param structures structures data to update * @param structures structures data to update
......
...@@ -22,22 +22,24 @@ ...@@ -22,22 +22,24 @@
</div> </div>
<div id="listCard" class="listCard" role="list" (mouseleave)="mouseLeave()"> <div id="listCard" class="listCard" role="list" (mouseleave)="mouseLeave()">
<app-card <ng-container *ngIf="!isLoading">
*ngFor="let structure of structureList" <app-card
class="structure-card" *ngFor="let structure of structureList"
role="listitem" class="structure-card"
[structure]="structure" role="listitem"
[isOrientation]="isOrientation" [structure]="structure"
[isSelected]="isInPrintList(structure._id)" [isOrientation]="isOrientation"
(showDetails)="showDetails(structure)" [isSelected]="isInPrintList(structure._id)"
(keyup.enter)="showDetails(structure)" (showDetails)="showDetails(structure)"
(hover)="handleCardHover($event)" (keyup.enter)="showDetails(structure)"
(addToList)="addToList($event)" (hover)="handleCardHover($event)"
/> (addToList)="addToList($event)"
<p *ngIf="structureList && structureList.length <= 0 && !isLoading"> />
Il n'y a aucune réponse correspondant à votre recherche <p *ngIf="structureList.length === 0" class="noStructureFound">
</p> Il n'y a aucune réponse correspondant à votre recherche
<div *ngIf="structureList && structureList.length <= 0 && isLoading" class="loader"> </p>
</ng-container>
<div *ngIf="isLoading" class="loader">
<img class="loader-gif" src="/assets/gif/loader_circle.gif" alt /> <img class="loader-gif" src="/assets/gif/loader_circle.gif" alt />
</div> </div>
</div> </div>
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
} }
} }
.listCard > p { .noStructureFound {
margin-left: 1rem; margin-left: 1rem;
} }
......
...@@ -15,18 +15,17 @@ import { PrintService } from '../shared/service/print.service'; ...@@ -15,18 +15,17 @@ import { PrintService } from '../shared/service/print.service';
export class StructureListComponent implements OnChanges, OnInit { export class StructureListComponent implements OnChanges, OnInit {
@Input() public isOrientation: boolean = false; @Input() public isOrientation: boolean = false;
@Input() public structureList: Structure[]; @Input() public structureList: Structure[];
@Input() public isLoading = true;
@Input() public location: GeoJson; @Input() public location: GeoJson;
@Input() public selectedStructure: Structure = new Structure(); @Input() public selectedStructure: Structure = new Structure();
@Input() public selectedStructureList: Structure[] = []; @Input() public selectedStructureList: Structure[] = [];
@Output() public displayMapMarkerId: EventEmitter<string> = new EventEmitter<string>(); @Output() public displayMapMarkerId: EventEmitter<string> = new EventEmitter<string>();
@Output() public selectedMarkerId: 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[]>(); @Output() public structureSelected: EventEmitter<Structure[]> = new EventEmitter<Structure[]>();
public buttonTypeEnum = ButtonType; public buttonTypeEnum = ButtonType;
public structure: Structure; public structure: Structure;
public printMode = false; public printMode = false;
public isLoading = true;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
...@@ -60,7 +59,6 @@ export class StructureListComponent implements OnChanges, OnInit { ...@@ -60,7 +59,6 @@ export class StructureListComponent implements OnChanges, OnInit {
} }
if (changes.structureList) { if (changes.structureList) {
document.getElementById('listCard').scrollTo(0, 0); document.getElementById('listCard').scrollTo(0, 0);
this.isLoading = changes.structureList.firstChange;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment