diff --git a/src/app/features/indicadores/indicador-screening-route.html b/src/app/features/indicadores/indicador-screening-route.html index 37dffda..4c4610b 100644 --- a/src/app/features/indicadores/indicador-screening-route.html +++ b/src/app/features/indicadores/indicador-screening-route.html @@ -1,5 +1,5 @@ -
-

Tiempos de la ruta del tamizaje

+ +

Tiempos de la ruta del tamizaje

@switch (status()) { @case ('deferred') {

La vista se cargará al acercarse a esta región.

} @case ('loading') {

Cargando los tiempos de la ruta…

} @@ -34,4 +34,4 @@ } -
+ diff --git a/src/app/features/indicadores/indicador-screening-route.scss b/src/app/features/indicadores/indicador-screening-route.scss index fdeeaf6..577d5fb 100644 --- a/src/app/features/indicadores/indicador-screening-route.scss +++ b/src/app/features/indicadores/indicador-screening-route.scss @@ -1,7 +1,8 @@ -:host { display: block; min-width: 0; } -.route { min-width: 0; padding-top: var(--issste-space-3); } -p, h3, summary { overflow-wrap: anywhere; } -h3 { font-size: 1rem; line-height: 1.5; } +// A card of its own, as wide as the grid like the pair of cards above it. +:host { display: block; min-width: 0; grid-column: 1 / -1; } +.route { min-width: 0; margin: 0; } +.figure-title { margin: 0; font-size: 1.25rem; } +p, h2, summary { overflow-wrap: anywhere; } .controls { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: center; margin-block: .75rem; } app-plotly-chart { --plot-height: 360px; } summary { cursor: pointer; padding-block: .75rem; } diff --git a/src/app/features/indicadores/indicador-screening-route.spec.ts b/src/app/features/indicadores/indicador-screening-route.spec.ts index 7a804b5..e06a843 100644 --- a/src/app/features/indicadores/indicador-screening-route.spec.ts +++ b/src/app/features/indicadores/indicador-screening-route.spec.ts @@ -109,4 +109,20 @@ describe('Ruta del tamizaje: componente', () => { expect(charts()).toHaveLength(0); expect(f.nativeElement.querySelector('[role=alert]')).not.toBeNull(); }); + it('es una tarjeta con su encabezado y abre en el periodo del filtro general; otro filtro suelta el periodo elegido adentro', () => { + // Fails if the chart is not a card of its own, ignores the periods of the general filter, or keeps a period picked + // inside it after the filter changed. + f.componentRef.setInput('periodos', ['2025-S1']); + f.detectChanges(); responder(); + expect(f.nativeElement.querySelector('mat-card h2')?.textContent).toContain('Tiempos de la ruta del tamizaje'); + expect(f.componentInstance.model()?.period).toBe('2025-S1'); + f.componentInstance.selectPeriod('2025-S2'); + expect(f.componentInstance.model()?.period).toBe('2025-S2'); + f.componentRef.setInput('periodos', ['2025-S2']); f.detectChanges(); + expect(f.componentInstance.requestedPeriod()).toBeUndefined(); + expect(f.componentInstance.model()?.period).toBe('2025-S2'); + // A period the route does not publish falls back to the newest that has data. + f.componentRef.setInput('periodos', ['2019-S1']); f.detectChanges(); + expect(f.componentInstance.model()?.period).toBe('2025-S2'); + }); }); diff --git a/src/app/features/indicadores/indicador-screening-route.ts b/src/app/features/indicadores/indicador-screening-route.ts index c1d66fe..44f3a70 100644 --- a/src/app/features/indicadores/indicador-screening-route.ts +++ b/src/app/features/indicadores/indicador-screening-route.ts @@ -3,6 +3,7 @@ import { HttpErrorResponse } from '@angular/common/http'; import { forkJoin, Subscription, timeout, TimeoutError } from 'rxjs'; import { MatButtonModule } from '@angular/material/button'; import { MatButtonToggleModule } from '@angular/material/button-toggle'; +import { MatCardModule } from '@angular/material/card'; import { MatFormFieldModule } from '@angular/material/form-field'; import { MatProgressBarModule } from '@angular/material/progress-bar'; import { MatSelectModule } from '@angular/material/select'; @@ -16,14 +17,16 @@ import { ROUTE_IDS, RouteIncompatible, RouteView, routeCellText, routeFigure, ro /** Days along the screening route, from the sample to each event, as horizontal bars: cumulative or step by step. */ @Component({ selector: 'app-indicador-screening-route', - imports: [MatButtonModule, MatButtonToggleModule, MatFormFieldModule, MatProgressBarModule, MatSelectModule, PlotlyChart], + imports: [MatButtonModule, MatButtonToggleModule, MatCardModule, MatFormFieldModule, MatProgressBarModule, MatSelectModule, PlotlyChart], templateUrl: './indicador-screening-route.html', styleUrl: './indicador-screening-route.scss', }) export class IndicadorScreeningRoute { readonly dominio = input.required(); readonly tema = input.required(); + /** The general filter's interval (semester or month) and, when it names periods, those periods. */ readonly tipo = input('semestre'); + readonly periodos = input(undefined); /** The measures load once the region is visible. */ readonly visible = input(true); @@ -34,12 +37,19 @@ export class IndicadorScreeningRoute { private readonly payloads = signal | undefined>(undefined); readonly model = computed(() => { const data = this.payloads(); - return data ? routeModel(data, this.tipo(), this.requestedPeriod()) : undefined; + return data ? routeModel(data, this.tipo(), this.requestedPeriod() ?? this.periodoDelFiltro(data)) : undefined; }); readonly figure = computed(() => { const model = this.model(); return model && routeHasData(model) ? routeFigure(model, this.view(), this.tema()) : undefined; }); + // The newest period of the general filter that the route publishes; the chart shows one period at a time. + private periodoDelFiltro(data: Record) { + const pedidos = this.periodos(); + if (!pedidos?.length) return undefined; + const publicados = new Set(ROUTE_IDS.flatMap(id => data[id].periodos)); + return [...pedidos].sort().reverse().find(p => publicados.has(p)); + } readonly periodLabel = etiquetaPeriodo; readonly cellText = routeCellText; @@ -52,6 +62,8 @@ export class IndicadorScreeningRoute { if (!this.visible()) { this.status.set('deferred'); return; } untracked(() => this.load(dominio, tipo)); }); + // Another general filter is another question: the period picked inside the card no longer holds. + effect(() => { this.tipo(); this.periodos(); untracked(() => this.requestedPeriod.set(undefined)); }); inject(DestroyRef).onDestroy(() => this.subscription?.unsubscribe()); } diff --git a/src/app/features/indicadores/indicadores-page.html b/src/app/features/indicadores/indicadores-page.html index 7961ceb..16ad1b0 100644 --- a/src/app/features/indicadores/indicadores-page.html +++ b/src/app/features/indicadores/indicadores-page.html @@ -112,13 +112,16 @@ Incluye el periodo y los indicadores seleccionados. Elige «Guardar como PDF» en el cuadro de impresión. } - @if (screeningRouteAvailable) { }
@if (histopatologiaPendiente) { } @for (item of searchResults().items; track cardIdentity(item)) { } + @if (screeningRouteAvailable && filters; as general) { + + }
} diff --git a/src/app/features/indicadores/indicadores-screening-route-page.spec.ts b/src/app/features/indicadores/indicadores-screening-route-page.spec.ts index 959845a..b940c8d 100644 --- a/src/app/features/indicadores/indicadores-screening-route-page.spec.ts +++ b/src/app/features/indicadores/indicadores-screening-route-page.spec.ts @@ -7,6 +7,7 @@ import { HttpTestingController, provideHttpClientTesting } from '@angular/common import { By } from '@angular/platform-browser'; import { provideRouter } from '@angular/router'; import { IndicadorCatalogCard } from './indicador-catalog-card'; +import { IndicadorScreeningRoute } from './indicador-screening-route'; import { IndicadoresPage } from './indicadores-page'; import { IndicadoresMemory } from './indicadores-memory'; import { Dominio } from './indicadores.models'; @@ -43,6 +44,15 @@ describe('Ruta del tamizaje: página de CaCu', () => { for (const id of [...ROUTE_IDS, ...CACU_SIN_TARJETA]) expect(ids).not.toContain(id); expect(ids).toEqual(['cacu_eu7', 'cacu_confirmacion_citologia']); }); + it('la ruta es la última de la sección clínica, en su tarjeta y con el intervalo del filtro general', () => { + // Fails if the chart is not the last card of the grid, is not inside a card, or does not follow the general filter's interval. + abrir('cacu', [item('cacu_eu7', 'C2'), item('cacu_confirmacion_citologia', 'C2'), ...ROUTE_IDS.map(id => item(id))]); + const grid = fixture.nativeElement.querySelector('.catalog-grid') as HTMLElement; + expect(grid.lastElementChild?.tagName).toBe('APP-INDICADOR-SCREENING-ROUTE'); + expect(grid.lastElementChild?.querySelector('mat-card h2')?.textContent).toContain('Tiempos de la ruta del tamizaje'); + const ruta = fixture.debugElement.query(By.directive(IndicadorScreeningRoute)).componentInstance as IndicadorScreeningRoute; + expect(ruta.tipo()).toBe(fixture.componentInstance.filters!.applied.tipo); + }); it('con la ruta, la franja de oportunidad conserva sus tarjetas: solo se retiran las de la sección clínica', () => { // Fails if the opportunity strip loses a card when the route chart appears. abrir('cacu', [item('cacu_eu7', 'C2'), ...ROUTE_IDS.map(id => item(id))]);