Skip to content
Snippets Groups Projects
Commit 7243ed28 authored by Hugo SUBTIL's avatar Hugo SUBTIL
Browse files

fix(carto): display of claimed structures

parent 9861fb9f
No related branches found
No related tags found
3 merge requests!418V2.1.0,!400V2.0,!230V2.0
......@@ -29,7 +29,7 @@
<app-card
*ngFor="let structure of ref.structureList"
[structure]="structure"
[isClaimed]="((structureClaims | async) ?? [])[structure._id]"
[isClaimed]="isAdmin ? structure.isClaimed : true"
(showDetails)="ref.showDetails($event)"
(hover)="ref.handleCardHover($event)"
class="structure-card"
......
......@@ -5,6 +5,7 @@ import { Filter, GeoJson, Structure } from '@gouvfr-anct/mediation-numerique';
import { ButtonType } from '@gouvfr-anct/mediation-numerique/shared';
import * as _ from 'lodash';
import { Observable } from 'rxjs';
import { ProfileService } from '../profile/services/profile.service';
import { AuthService } from '../services/auth.service';
import { GeojsonService } from '../services/geojson.service';
import { StructureService } from '../services/structure.service';
......@@ -29,11 +30,11 @@ export class CartoComponent implements OnInit {
public searchedValue = null;
public buttonTypeEnum = ButtonType;
constructor(
private structureService: StructureService,
private geoJsonService: GeojsonService,
private activatedRoute: ActivatedRoute,
private profileService: ProfileService,
private meta: Meta,
private router: Router,
private authService: AuthService
......@@ -112,9 +113,10 @@ export class CartoComponent implements OnInit {
sortByDistance: boolean = true
): void {
Promise.all(
structures.map((structure) => {
structures.map(async (structure) => {
if (this.geolocation) {
structure = this.getStructurePosition(structure, lon, lat);
structure.isClaimed = await this.isClaimed(structure).toPromise();
}
return structure;
})
......@@ -123,7 +125,6 @@ export class CartoComponent implements OnInit {
structureList = _.sortBy(structureList, ['distance']);
}
this.structures = structureList;
// await this.setClaimIndicators(this.profilService.isAdmin());
});
}
......@@ -221,7 +222,11 @@ export class CartoComponent implements OnInit {
}
}
public isClaimed(structure): Observable<boolean> {
public get isAdmin(): boolean {
return this.profileService.isAdmin();
}
public isClaimed(structure: Structure): Observable<boolean> {
return this.structureService.isClaimed(structure._id, null);
}
}
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