Chore: Visual fix.
This commit is contained in:
@@ -39,6 +39,13 @@ describe('Exportación: botones', () => {
|
||||
const boton = (root: HTMLElement, texto: string) => [...root.querySelectorAll('button')].find(b => b.textContent!.includes(texto)) as HTMLButtonElement | undefined;
|
||||
const esperar = async () => { for (let i = 0; i < 20; i++) { await fixture.whenStable(); await new Promise(r => setTimeout(r, 10)); fixture.detectChanges(); } };
|
||||
|
||||
// Fails if the buttons stop being a bare group (the title row of the table holds them) or bring back their own block.
|
||||
it('has no block of its own: only the buttons, and messages after them', () => {
|
||||
const root = montar();
|
||||
expect(root.querySelector('h3, section')).toBeNull();
|
||||
expect(root.firstElementChild!.classList.contains('actions')).toBe(true);
|
||||
});
|
||||
|
||||
// Fails if the button stops being available for a query that fits the limit.
|
||||
it('enables the spreadsheet export for a query within the limit', () => {
|
||||
expect(boton(montar(), 'Excel')!.disabled).toBe(false);
|
||||
|
||||
@@ -19,30 +19,29 @@ const FORMAT_LABEL: Record<ExportFormat, string> = { xlsx: 'Excel (.xlsx)', pdf:
|
||||
selector: 'app-seguimiento-exportar',
|
||||
imports: [DecimalPipe],
|
||||
template: `
|
||||
<section aria-labelledby="exportar-titulo">
|
||||
<h3 id="exportar-titulo">Exportar resultados</h3>
|
||||
<p class="hint">Se exportan los {{ total() | number }} registros de la consulta mostrada, no solo la página visible.</p>
|
||||
<div class="actions">
|
||||
@for (formato of formatos; track formato) {
|
||||
<button type="button" [disabled]="!available(formato)" (click)="exportar(formato)">Exportar {{ label[formato] }}</button>
|
||||
}
|
||||
@if (estado() === 'working') { <button type="button" (click)="cancelar()">Cancelar</button> }
|
||||
</div>
|
||||
<div class="actions" role="group" aria-label="Exportar resultados"
|
||||
[attr.title]="'Se exportan los ' + (total() | number) + ' registros de la consulta mostrada, no solo la página visible.'">
|
||||
@for (formato of formatos; track formato) {
|
||||
@if (total() > limits[formato]) {
|
||||
<p class="hint">{{ label[formato] }} admite hasta {{ limits[formato] | number }} registros; la consulta tiene {{ total() | number }}. Acota los filtros para exportar.</p>
|
||||
}
|
||||
<button type="button" [disabled]="!available(formato)" (click)="exportar(formato)">Exportar {{ label[formato] }}</button>
|
||||
}
|
||||
@if (estado() === 'working') { <p role="status">{{ progressText() }}</p> }
|
||||
@if (estado() === 'error') { <p role="alert">{{ mensaje() }}</p> }
|
||||
@if (listo()) { <p role="status">{{ listo() }}</p> }
|
||||
</section>
|
||||
@if (estado() === 'working') { <button type="button" (click)="cancelar()">Cancelar</button> }
|
||||
</div>
|
||||
@for (formato of formatos; track formato) {
|
||||
@if (total() > limits[formato]) {
|
||||
<p class="message hint">{{ label[formato] }} admite hasta {{ limits[formato] | number }} registros; la consulta tiene {{ total() | number }}. Acota los filtros para exportar.</p>
|
||||
}
|
||||
}
|
||||
@if (estado() === 'working') { <p class="message" role="status">{{ progressText() }}</p> }
|
||||
@if (estado() === 'error') { <p class="message" role="alert">{{ mensaje() }}</p> }
|
||||
@if (listo()) { <p class="message" role="status">{{ listo() }}</p> }
|
||||
`,
|
||||
// The host takes no box of its own: the buttons sit in the title row that holds it, and each message
|
||||
// takes a full line below that row.
|
||||
styles: `
|
||||
:host { display: block; margin-top: 1.5rem; }
|
||||
h3 { margin: 0 0 .5rem; font-size: 1rem; }
|
||||
.hint { color: var(--issste-text-secondary); margin: .25rem 0; }
|
||||
.actions { display: flex; flex-wrap: wrap; gap: 1rem; margin: .5rem 0; }
|
||||
:host { display: contents; }
|
||||
.message { flex: 0 0 100%; margin: 0; }
|
||||
.hint { color: var(--issste-text-secondary); }
|
||||
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .75rem; margin-inline-start: auto; }
|
||||
button { color: inherit; background: var(--issste-surface); border: 1px solid var(--issste-border); border-radius: 4px;
|
||||
padding: .6rem 1rem; min-height: 44px; box-sizing: border-box; font: inherit; cursor: pointer; }
|
||||
button:disabled { opacity: .5; cursor: default; }
|
||||
|
||||
@@ -38,6 +38,10 @@ export class IndicadorConteosPareados implements OnChanges, OnDestroy {
|
||||
private subscription?: Subscription;
|
||||
private key = '';
|
||||
private loaded = false;
|
||||
// On a narrow screen the donut's long label gives way to a legend under it.
|
||||
private readonly estrecha = typeof matchMedia === 'function' ? matchMedia('(max-width: 520px)') : undefined;
|
||||
private readonly alCambiarAncho = () => { if (this.model) this.draw(); };
|
||||
constructor() { this.estrecha?.addEventListener('change', this.alCambiarAncho); }
|
||||
|
||||
get model(): ModeloConteos | undefined { return this.pages[this.periodIndex]; }
|
||||
get total() { return this.model ? totalExamenes(this.model) : null; }
|
||||
@@ -107,9 +111,9 @@ export class IndicadorConteosPareados implements OnChanges, OnDestroy {
|
||||
private draw() {
|
||||
const m = this.model;
|
||||
if (!m) return;
|
||||
this.donutFigure = donaConteos(m, this.par, this.tema);
|
||||
this.donutFigure = donaConteos(m, this.par, this.tema, this.estrecha?.matches ?? false);
|
||||
this.barsFigure = barrasConteos(m, this.par, this.tema);
|
||||
this.changeDetector.markForCheck();
|
||||
}
|
||||
ngOnDestroy() { this.subscription?.unsubscribe(); }
|
||||
ngOnDestroy() { this.subscription?.unsubscribe(); this.estrecha?.removeEventListener('change', this.alCambiarAncho); }
|
||||
}
|
||||
|
||||
@@ -91,6 +91,49 @@ describe('Conteos pareados de CaMa: lo que se puede sumar', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Conteos pareados de CaMa: etiquetas de la dona', () => {
|
||||
type Figura = { data: Record<string, any>[]; layout: { annotations: Record<string, any>[]; margin: Record<string, number>; showlegend: boolean } };
|
||||
const dona = (compacta = false) => donaConteos(modelo(examenes(LAB_E), pacientes(LAB_P)), PAR, 'claro', compacta) as unknown as Figura;
|
||||
|
||||
// Fails if the long label of the 4 without subcategory goes back inside the ring (where it is cut), loses its
|
||||
// percentage or its guide line, or if the short labels or the centre total change.
|
||||
it('2025-S2: la etiqueta larga sale del anillo, horizontal y con línea guía; las cortas y el total se conservan', () => {
|
||||
const f = dona(), t = f.data[0], llamada = f.layout.annotations[1];
|
||||
expect(t['text'][0]).toBe('');
|
||||
expect(t['text'][1]).toBe('');
|
||||
expect(t['text'][4]).toMatch(/^BI-RADS 5<br>54[.,]5 %$/);
|
||||
expect(t['values']).toEqual([15, 0, 0, 0, 18, 0]);
|
||||
expect(f.layout.annotations[0]['text']).toBe('<b>33</b><br>mastografías');
|
||||
expect(f.layout.annotations).toHaveLength(2);
|
||||
expect(llamada['text']).toBe('BI-RADS 4<br>(sin subcategoría)<br>45.5 %');
|
||||
// A guide line: an arrow without head from the label to a point inside the slice, and no text rotation.
|
||||
expect(llamada['showarrow']).toBe(true);
|
||||
expect(llamada['arrowhead']).toBe(0);
|
||||
expect(llamada['textangle']).toBeUndefined();
|
||||
});
|
||||
|
||||
// Fails if the label can reach the neighbouring chart: its side must keep a margin, and it sits on the side of its slice.
|
||||
it('reserva espacio del lado de la etiqueta y la coloca del lado de su segmento', () => {
|
||||
const f = dona(), llamada = f.layout.annotations[1];
|
||||
// The slice is 45 % of a clockwise ring: its middle points right, so label and margin are on the right.
|
||||
expect(llamada['xanchor']).toBe('left');
|
||||
expect(llamada['ax']).toBeGreaterThan(0);
|
||||
expect(f.layout.margin['r']).toBeGreaterThanOrEqual(110);
|
||||
expect(f.layout.margin['l']).toBeLessThan(20);
|
||||
expect(f.layout.showlegend).toBe(false);
|
||||
});
|
||||
|
||||
// Fails if a narrow screen keeps a label that needs side room instead of moving to a legend under the donut.
|
||||
it('en pantalla estrecha no hay llamada: la dona usa una leyenda debajo', () => {
|
||||
const f = dona(true);
|
||||
expect(f.layout.annotations).toHaveLength(1);
|
||||
expect(f.layout.showlegend).toBe(true);
|
||||
expect((f.layout as Record<string, any>)['legend']['orientation']).toBe('h');
|
||||
expect(f.layout.margin['r']).toBeLessThan(20);
|
||||
expect(f.data[0]['values']).toEqual([15, 0, 0, 0, 18, 0]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Conteos pareados de CaMa: lo que no se calcula', () => {
|
||||
it('no hay razón de mastografías por paciente en la figura ni en el modelo', () => {
|
||||
// Fails if a "≈ x por paciente" annotation comes back: exams of a category include those of patients whose
|
||||
|
||||
@@ -44,6 +44,8 @@ export const esSocioConteos = (dominio: Dominio, id: string, ids: readonly strin
|
||||
const ETIQUETA_RESPALDO: Readonly<Record<string, string>> = { B4: 'BI-RADS 4 (sin subcategoría)' };
|
||||
const COLOR_RESPALDO: Readonly<Record<string, string>> = { B4: '#E9C08C' };
|
||||
const COLOR_NEUTRO = '#8A9199';
|
||||
// Labels longer than «BI-RADS 4A» do not fit inside the ring.
|
||||
const LARGO_ETIQUETA_INTERIOR = 12;
|
||||
|
||||
export interface CategoriaConteo { id: string; etiqueta: string; color: string; n: number | null; }
|
||||
export interface FilaConteo { id: string; etiqueta: string; pacientes: number | null; examenes: number | null; }
|
||||
@@ -102,19 +104,49 @@ export function modelosConteos(par: ParConteos, examenes: IndicadorDatos, pacien
|
||||
}
|
||||
export const totalExamenes = (m: ModeloConteos) => sumar(m.examenes.map(c => c.n));
|
||||
|
||||
/** Exams by category around their total; nothing is drawn when a cell is unknown. */
|
||||
export function donaConteos(m: ModeloConteos, par: ParConteos, tema: Tema): PlotlyFigure {
|
||||
// Geometry the callouts rely on. The ring is height-bound (a 400 px figure with a 10 px margin above and below and
|
||||
// the pie over 90 % of that height), so its radius does not depend on the width of the card.
|
||||
const ALTO_DONA = 400, MARGEN_VERTICAL = 10, RADIO_DONA = Math.round((ALTO_DONA - 2 * MARGEN_VERTICAL) * .9 / 2);
|
||||
const MARGEN_ROTULO = 120, SALIDA_ROTULO = 28;
|
||||
|
||||
/**
|
||||
* Exams by category around their total; nothing is drawn when a cell is unknown. A long label does not fit in the
|
||||
* ring: it is drawn outside, horizontal and on two lines, joined to its slice by a guide line, on the side of the
|
||||
* slice with room reserved for it so it never reaches the neighbouring chart. On a narrow card (`compacta`) the
|
||||
* callouts give way to a legend under the donut.
|
||||
*/
|
||||
export function donaConteos(m: ModeloConteos, par: ParConteos, tema: Tema, compacta = false): PlotlyFigure {
|
||||
const total = totalExamenes(m);
|
||||
if (!total) return { data: [], layout: {} };
|
||||
const p = c2Theme(tema), n = m.examenes.map(c => c.n!);
|
||||
const larga = (i: number) => m.examenes[i].etiqueta.length > LARGO_ETIQUETA_INTERIOR && n[i] > 0;
|
||||
const porcentaje = (i: number) => percentNumber(100 * n[i] / total) + ' %';
|
||||
const dibujadas = (i: number) => !larga(i) && n[i] / total >= .05;
|
||||
// Each long label is a callout whose guide line ends inside its slice.
|
||||
let antes = 0;
|
||||
const llamadas = n.flatMap((v, i) => {
|
||||
const angulo = 2 * Math.PI * (antes + v / 2) / total;
|
||||
antes += v;
|
||||
if (compacta || !larga(i)) return [];
|
||||
const seno = Math.sin(angulo), coseno = Math.cos(angulo), dentro = Math.round(RADIO_DONA * .8), fuera = RADIO_DONA + SALIDA_ROTULO - dentro;
|
||||
const etiqueta = escapar(m.examenes[i].etiqueta), corte = etiqueta.indexOf(' (');
|
||||
return [{ x: .5, y: .5, xref: 'paper', yref: 'paper', xshift: Math.round(dentro * seno), yshift: Math.round(dentro * coseno),
|
||||
ax: Math.round(fuera * seno), ay: Math.round(-fuera * coseno), axref: 'pixel', ayref: 'pixel', showarrow: true, arrowhead: 0, arrowwidth: 1, arrowcolor: p.text,
|
||||
text: (corte > 0 ? etiqueta.slice(0, corte) + '<br>' + etiqueta.slice(corte + 1) : etiqueta) + '<br>' + porcentaje(i),
|
||||
align: seno >= 0 ? 'left' : 'right', xanchor: seno >= 0 ? 'left' : 'right', yanchor: 'middle', font: { size: 12, color: p.text }, lado: seno >= 0 ? 'r' : 'l' }];
|
||||
});
|
||||
const lado = (l: string) => llamadas.some(a => a.lado === l) ? MARGEN_ROTULO : 10;
|
||||
return { data: [{ type: 'pie', hole: .6, sort: false, direction: 'clockwise', values: n, labels: m.examenes.map(c => escapar(c.etiqueta)),
|
||||
marker: { colors: m.examenes.map(c => c.color), line: { color: p.background, width: 2 } }, textinfo: 'text', textposition: 'inside',
|
||||
text: n.map((v, i) => v / total < .05 ? '' : escapar(m.examenes[i].etiqueta) + '<br>' + percentNumber(100 * v / total) + ' %'),
|
||||
text: n.map((_, i) => dibujadas(i) ? escapar(m.examenes[i].etiqueta) + '<br>' + porcentaje(i) : ''),
|
||||
domain: { x: [0, 1], y: [.05, .95] },
|
||||
customdata: n.map(v => [miles(v), percentNumber(100 * v / total)]),
|
||||
hovertemplate: `%{label}<br>%{customdata[0]} ${par.unidades.examenes}, %{customdata[1]} %<extra></extra>` }],
|
||||
layout: { autosize: true, height: 400, showlegend: false, margin: { t: 10, l: 10, r: 10, b: 10 }, paper_bgcolor: p.background, font: { color: p.text },
|
||||
layout: { autosize: true, height: compacta ? ALTO_DONA + 40 : ALTO_DONA, showlegend: compacta, paper_bgcolor: p.background, font: { color: p.text },
|
||||
margin: { t: MARGEN_VERTICAL, b: compacta ? 70 : MARGEN_VERTICAL, l: lado('l'), r: lado('r') },
|
||||
...(compacta ? { legend: { orientation: 'h', x: .5, xanchor: 'center', y: -.02, yanchor: 'top', font: { size: 12 } } } : {}),
|
||||
annotations: [{ x: .5, y: .5, xref: 'paper', yref: 'paper', showarrow: false, font: { size: 18, color: p.text },
|
||||
text: `<b>${miles(total)}</b><br>${par.unidades.examenes}` }] }, config: { displayModeBar: false } };
|
||||
text: `<b>${miles(total)}</b><br>${par.unidades.examenes}` }, ...llamadas.map(({ lado: _lado, ...a }) => a)] }, config: { displayModeBar: false } };
|
||||
}
|
||||
|
||||
/** Per BI-RADS family: patients (in their most severe category) next to exams. No ratio between them is drawn. */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<p>Consulta individual de seguimiento de {{ dominio === 'cama' ? domainLabels.cama : 'cáncer cervicouterino' }}</p>
|
||||
} @else {
|
||||
@if (dominio !== 'cama') { <span class="domain">{{ domainTitles[dominio] }}, investigación</span> }
|
||||
<h1 id="dashboard-title">{{ dominio === 'cama' ? 'Cáncer de mama' : 'Indicadores' }}</h1>
|
||||
<h1 id="dashboard-title">{{ dominio === 'cama' ? 'Sistema TNM de clasificación tumoral' : 'Indicadores' }}</h1>
|
||||
<p>Explora los indicadores de {{ domainLabels[dominio] }}.</p>
|
||||
}
|
||||
</header>
|
||||
|
||||
@@ -33,6 +33,15 @@ describe('Seguimiento de CaMa: ficha del paciente', () => {
|
||||
const enlace = (n = 0) => root().querySelectorAll<HTMLButtonElement>('.patient-link')[n];
|
||||
const ficha = () => root().querySelector('app-cama-patient-card');
|
||||
|
||||
// Fails if the export buttons leave the title row or come back under the table.
|
||||
it('has the export buttons in the row of the section title, and nothing after the pagination', () => {
|
||||
const row = root().querySelector('.title-row')!;
|
||||
expect(row.querySelector('h2')!.textContent).toContain('Seguimiento de');
|
||||
expect([...row.querySelectorAll('button')].map(b => b.textContent!.trim())).toEqual(['Exportar Excel (.xlsx)', 'Exportar PDF']);
|
||||
expect(root().querySelector('nav')!.nextElementSibling).toBeNull();
|
||||
expect(root().textContent).not.toContain('Exportar resultados');
|
||||
});
|
||||
|
||||
// Fails if the identifier stops being a control, which leaves the record reachable only by mouse.
|
||||
it('draws each identifier as a button named after the patient', () => {
|
||||
expect(root().querySelectorAll('.patient-link')).toHaveLength(5);
|
||||
@@ -104,7 +113,7 @@ describe('Seguimiento: ficha de CaMa y cambio de dominio', () => {
|
||||
(fixture.nativeElement as HTMLElement).querySelector<HTMLButtonElement>('.patient-link')!.click();
|
||||
await fixture.whenStable(); fixture.detectChanges();
|
||||
expect(abierta).toEqual([true]);
|
||||
expect((fixture.nativeElement as HTMLElement).querySelector('h2')!.hidden).toBe(true);
|
||||
expect((fixture.nativeElement as HTMLElement).querySelector('.title-row')!.closest('[hidden]')).not.toBeNull();
|
||||
fixture.componentRef.setInput('dominio', 'tea'); fixture.detectChanges();
|
||||
expect(abierta).toEqual([true, false]);
|
||||
http.verify(); fixture.destroy();
|
||||
|
||||
@@ -28,6 +28,12 @@ interface Borrador { corte?: string; meses: 1 | 3 | 6 | 12; page_size: number; f
|
||||
<app-cama-patient-card [summary]="patient" (back)="cerrarFicha()" />
|
||||
}
|
||||
<div [hidden]="!!ficha()">
|
||||
<div class="title-row">
|
||||
<h2>Seguimiento de {{ domainLabel }}</h2>
|
||||
@if (data(); as respuesta) {
|
||||
<app-seguimiento-exportar [dominio]="dominio" [respuesta]="respuesta" [habilitado]="estado() === 'ready'" />
|
||||
}
|
||||
</div>
|
||||
<form (ngSubmit)="aplicar()">
|
||||
<label>Fecha de corte <input name="corte" type="date" [(ngModel)]="draft.corte" /></label>
|
||||
<label>Ventana de meses <select name="meses" [(ngModel)]="draft.meses">
|
||||
@@ -75,13 +81,14 @@ interface Borrador { corte?: string; meses: 1 | 3 | 6 | 12; page_size: number; f
|
||||
<span>Página {{ respuesta.paginacion.page }} de {{ respuesta.paginacion.total_pages }}, {{ respuesta.paginacion.total_items }} registros</span>
|
||||
<button type="button" [disabled]="respuesta.paginacion.page >= respuesta.paginacion.total_pages || estado() === 'loading'" (click)="ir(respuesta.paginacion.page + 1)">Siguiente</button>
|
||||
</nav>
|
||||
<app-seguimiento-exportar [dominio]="dominio" [respuesta]="respuesta" [habilitado]="estado() === 'ready'" />
|
||||
}
|
||||
</div>
|
||||
`,
|
||||
styles: `
|
||||
:host { display: block; min-width: 0; }
|
||||
p { color: var(--issste-text-secondary); }
|
||||
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: 1rem; }
|
||||
.title-row h2 { margin: 0; margin-inline-end: auto; }
|
||||
form { display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; margin-bottom: 1rem; }
|
||||
label { display: flex; flex-direction: column; gap: .5rem; max-width: 100%; }
|
||||
input, select, button { color: inherit; background: var(--issste-surface); border: 1px solid var(--issste-border); border-radius: 4px;
|
||||
@@ -105,6 +112,8 @@ interface Borrador { corte?: string; meses: 1 | 3 | 6 | 12; page_size: number; f
|
||||
export class IndicadoresSeguimientoTabla implements OnChanges {
|
||||
@Input({ required: true }) dominio!: Dominio;
|
||||
@Input() active = false;
|
||||
/** Domain name for the section title, which sits in the same row as the export buttons. */
|
||||
@Input() domainLabel = '';
|
||||
private readonly service = inject(SeguimientoTablaService);
|
||||
private readonly injector = inject(Injector);
|
||||
/** Tells the page that an individual record replaced the list, so it can retitle itself. */
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
(registroAgregado)="pacienteDetalle.agregarRegistro($event)" (volver)="volverASeguimiento()" />
|
||||
}
|
||||
<div [hidden]="pacienteDetalle.estado().tipo !== 'cerrado'">
|
||||
<h2 [hidden]="camaFichaAbierta()">Seguimiento de {{ domainLabel }}</h2>
|
||||
@if (dominio !== 'cama') { <h2>Seguimiento de {{ domainLabel }}</h2> }
|
||||
@if (dominio === 'cama') {
|
||||
<app-seguimiento-tabla [dominio]="dominio" [active]="active" (fichaAbierta)="cambiaFichaCama($event)" />
|
||||
<app-seguimiento-tabla [dominio]="dominio" [domainLabel]="domainLabel" [active]="active" (fichaAbierta)="cambiaFichaCama($event)" />
|
||||
} @else if (dominio !== 'cacu') {
|
||||
<p>El seguimiento aún no está disponible.</p>
|
||||
<div class="tracking-table" role="region" aria-label="Estructura prevista de seguimiento" tabindex="0">
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
@let p = summary();
|
||||
<button class="back-button" mat-stroked-button type="button" (click)="back.emit()"><mat-icon aria-hidden="true">arrow_back</mat-icon><span>Regresar</span></button>
|
||||
<div class="toolbar">
|
||||
<button class="back-button" mat-stroked-button type="button" (click)="back.emit()"><mat-icon aria-hidden="true">arrow_back</mat-icon><span>Regresar</span></button>
|
||||
<button class="export-button" mat-stroked-button type="button" [disabled]="generating()" (click)="exportPdf()"><mat-icon aria-hidden="true">picture_as_pdf</mat-icon><span>Exportar ficha PDF</span></button>
|
||||
@if (generating()) { <p class="toolbar-message" role="status">Generando PDF…</p> }
|
||||
@if (failed()) { <p class="toolbar-message" role="alert">No se pudo generar el PDF. Intenta nuevamente.</p> }
|
||||
</div>
|
||||
<header>
|
||||
<h2 #title tabindex="-1">Paciente {{ p.pseudonymId }}</h2>
|
||||
<p>Fecha de corte: {{ p.cutoff }}.</p>
|
||||
<button mat-stroked-button type="button" [disabled]="generating()" (click)="exportPdf()"><mat-icon aria-hidden="true">picture_as_pdf</mat-icon><span>Exportar ficha PDF</span></button>
|
||||
@if (generating()) { <p role="status">Generando PDF…</p> }
|
||||
@if (failed()) { <p role="alert">No se pudo generar el PDF. Intenta nuevamente.</p> }
|
||||
<dl class="summary">
|
||||
<div><dt>Identificador seudónimo</dt><dd>{{ p.pseudonymId }}</dd></div>
|
||||
<div><dt>Grupo de edad</dt><dd>{{ p.ageGroup ?? notAvailable }}</dd></div>
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
header { margin-block: 1.5rem; }
|
||||
h2 { margin-block: .5rem 1rem; font-size: 1.65rem; }
|
||||
h3 { margin-block: 0 1rem; font-size: 1.2rem; }
|
||||
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; }
|
||||
.toolbar-message { flex: 0 0 100%; margin: 0; }
|
||||
.export-button { margin-inline-start: auto; }
|
||||
.back-button { display: inline-flex; align-items: center; gap: .35rem; min-height: 40px; padding-inline: .65rem; }
|
||||
.back-button mat-icon { width: 1.15rem; height: 1.15rem; font-size: 1.15rem; }
|
||||
.availability { margin-block: .75rem; color: var(--issste-text-secondary); }
|
||||
|
||||
@@ -106,6 +106,18 @@ describe('Ficha CaMa: componente', () => {
|
||||
vi.restoreAllMocks();
|
||||
}, 30000);
|
||||
|
||||
// Fails if the two buttons leave the row above the title: back on the left, the PDF export on the right.
|
||||
it('puts "Regresar" first and "Exportar ficha PDF" last in one row above the identifier', () => {
|
||||
montar(toCamaPatientSummary(complete(), '2026-10-20')!);
|
||||
const row = root().querySelector('.toolbar')!;
|
||||
const buttons = [...row.querySelectorAll('button')];
|
||||
expect(buttons).toHaveLength(2);
|
||||
expect(buttons[0].textContent).toContain('Regresar');
|
||||
expect(buttons[1].textContent).toContain('Exportar ficha PDF');
|
||||
expect(row.compareDocumentPosition(root().querySelector('h2')!) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
||||
expect(root().querySelector('header')!.querySelector('button')).toBeNull();
|
||||
});
|
||||
|
||||
// Fails if the back button stops telling the list to return.
|
||||
it('emits back when "Regresar" is pressed', () => {
|
||||
montar(toCamaPatientSummary(complete(), '2026-10-20')!);
|
||||
|
||||
Reference in New Issue
Block a user