up demo by what

This commit is contained in:
Tykayn 2025-10-10 17:56:50 +02:00 committed by tykayn
parent 26bfe4ae36
commit 2238380e80
7 changed files with 43 additions and 13 deletions

View file

@ -61,13 +61,13 @@ export class Home implements OnInit, OnDestroy {
// Propriétés pour les filtres
searchText = '';
selectedWhatFilter = 'culture';
selectedWhatFilter = '';
availableWhatTypes: string[] = [];
theme = signal<string | null>(null);
subthemes: Array<{ key: string, label: string, emoji: string }> = [];
activeSubtheme = signal<string | null>(null);
// Option bbox
useBboxFilter = false;
useBboxFilter = true;
currentBbox: { minLng: number, minLat: number, maxLng: number, maxLat: number } | null = null;
// Debounce pour la recherche
private searchDebounceTimer: any = null;
@ -130,7 +130,7 @@ export class Home implements OnInit, OnDestroy {
};
if (overrides.what) {
params.what = overrides.what;
} else if (this.selectedWhatFilter) {
} else if (this.selectedWhatFilter && this.selectedWhatFilter !== '') {
params.what = this.selectedWhatFilter;
}
@ -207,6 +207,11 @@ export class Home implements OnInit, OnDestroy {
this.theme.set(t || null);
this.buildSubthemes();
});
// Ajouter les catégories principales
whatTypes.add('culture');
whatTypes.add('traffic');
this.availableWhatTypes = Array.from(whatTypes).sort();
}
@ -244,9 +249,15 @@ export class Home implements OnInit, OnDestroy {
// Filtre par type d'événement
if (this.selectedWhatFilter) {
filtered = filtered.filter(feature =>
feature?.properties?.what === this.selectedWhatFilter
);
filtered = filtered.filter(feature => {
const what = feature?.properties?.what || '';
// Si c'est une catégorie (culture, traffic), filtrer par préfixe
if (this.selectedWhatFilter === 'culture' || this.selectedWhatFilter === 'traffic') {
return what.startsWith(this.selectedWhatFilter + '.');
}
// Sinon, correspondance exacte
return what === this.selectedWhatFilter;
});
}
this.filteredFeatures = filtered;