CaCu route chart: a card of its own, last in the clinical section, following the general filter

It was a loose section above the cards. It is now a card like the cytology pair, as wide as the grid and last, and it
takes the general filter's interval (semester or month) and, when the filter names periods, opens on the newest one it
publishes; another filter drops the period picked inside the card.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-22 04:13:54 -06:00
parent 0f0f85db39
commit ddb203857f
6 changed files with 52 additions and 10 deletions
@@ -1,5 +1,5 @@
<section class="route" aria-label="Días desde la toma de muestra hasta cada evento de la ruta del tamizaje">
<h3 class="figure-title">Tiempos de la ruta del tamizaje</h3>
<mat-card class="route" aria-label="Días desde la toma de muestra hasta cada evento de la ruta del tamizaje">
<header><div class="card-identity"><h2 class="figure-title">Tiempos de la ruta del tamizaje</h2></div></header>
@switch (status()) {
@case ('deferred') { <p role="status">La vista se cargará al acercarse a esta región.</p> }
@case ('loading') { <mat-progress-bar mode="indeterminate" aria-label="Cargando los tiempos de la ruta del tamizaje" /><p role="status">Cargando los tiempos de la ruta…</p> }
@@ -34,4 +34,4 @@
</div>
</details>
}
</section>
</mat-card>
@@ -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; }
@@ -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');
});
});
@@ -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<Dominio>();
readonly tema = input.required<Tema>();
/** The general filter's interval (semester or month) and, when it names periods, those periods. */
readonly tipo = input<TipoPeriodo>('semestre');
readonly periodos = input<readonly string[] | undefined>(undefined);
/** The measures load once the region is visible. */
readonly visible = input(true);
@@ -34,12 +37,19 @@ export class IndicadorScreeningRoute {
private readonly payloads = signal<Record<string, IndicadorDatos> | 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<string, IndicadorDatos>) {
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());
}
@@ -112,13 +112,16 @@
<span>Incluye el periodo y los indicadores seleccionados. Elige «Guardar como PDF» en el cuadro de impresión.</span>
</div>
}
@if (screeningRouteAvailable) { <app-indicador-screening-route [dominio]="dominio" [tema]="tema" /> }
<div class="catalog-grid">
@if (histopatologiaPendiente) { <app-indicador-histopatologia-pendiente /> }
@for (item of searchResults().items; track cardIdentity(item)) {
<app-indicador-catalog-card [id]="cardElementId(item)" [dominio]="dominio" [indicador]="item" [tema]="tema" [applied]="figureApplied(item)" [independentPeriods]="independentPeriods(item)"
[pinned]="isPinned(item)" (pinChanged)="togglePinned(item)" />
}
@if (screeningRouteAvailable && filters; as general) {
<app-indicador-screening-route [dominio]="dominio" [tema]="tema" [tipo]="general.applied.tipo"
[periodos]="general.applied.selection.mode === 'explicit' ? general.applied.selection.periodos : undefined" />
}
</div>
}
</section>
@@ -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))]);