feat: filtro todos seleccionado por default #3

Merged
EidanThen merged 1 commits from dev into main 2026-09-01 16:13:37 +00:00
@@ -51,7 +51,7 @@ export class RouteOverviewMapComponent implements OnInit, OnDestroy, AfterViewIn
usuarios: { id: string; nombre: string }[] = [];
dias: string[] = [];
selectedUsuarioId: string | null = null;
selectedUsuarioId: string = 'Todos';
selectedDia: string = 'Todos';
selectedRouteDetail: RouteAssignedResponse | null = null;
@@ -112,11 +112,12 @@ export class RouteOverviewMapComponent implements OnInit, OnDestroy, AfterViewIn
this.allRoutes = [...routes];
this.usuarios = this.routeState.getUsuariosUnicos();
this.dias = this.routeState.getDiasUnicos();
// Init from queryParams default (Todos)
// Start each map load with the complete planning selected by default.
const qp = this.activatedRoute.snapshot.queryParams;
if (qp['usuario_id']) this.selectedUsuarioId = String(qp['usuario_id']);
else if (!this.selectedUsuarioId && this.usuarios.length) this.selectedUsuarioId = 'Todos';
if (qp['dia']) this.selectedDia = String(qp['dia']);
if (qp['pdv_id']) {
this.selectedUsuarioId = 'Todos';
this.selectedDia = 'Todos';
}
// If focus pdv provided, auto-select detail after map loads
this.applyFilter();
this.cdr.detectChanges();
@@ -135,20 +136,6 @@ export class RouteOverviewMapComponent implements OnInit, OnDestroy, AfterViewIn
// React to queryParams changes
this.subs.push(
this.activatedRoute.queryParams.subscribe(qp => {
let changed = false;
if (qp['usuario_id'] && String(qp['usuario_id']) !== this.selectedUsuarioId) {
this.selectedUsuarioId = String(qp['usuario_id']);
changed = true;
}
if (qp['dia'] && qp['dia'] !== this.selectedDia) {
this.selectedDia = String(qp['dia']);
changed = true;
}
if (changed) {
this.applyFilter();
if (this.map) this.renderFiltered();
this.cdr.detectChanges();
}
// Focus a specific route if pdv_id passed
if (qp['pdv_id'] && this.filteredRoutes.length) {
const found = this.filteredRoutes.find(r => String(r.json.pdv_id) === String(qp['pdv_id']));