feat(shell): domain menu in the header, as in the deployed dev version
How: on /indicadores/<domain> routes the App header shows the platform title and a mat-menu button named after the current domain, listing the other two (the same markup and styles as the deployed WebApp's app.html). Other routes (Conectar, Gobernanza) keep the "Análisis de información" breadcrumb. The indicators page drops its own TEA/CaCu/CaMa links, so there is one switcher. Implications: domain switching now depends on the App shell; a page embedded elsewhere has no way to change domain by itself. Specs that asserted the in-page links now assert their absence, and app.spec covers the menu.
This commit is contained in:
+19
-6
@@ -4,12 +4,25 @@
|
||||
<a class="brand" routerLink="/" aria-label="ISSSTELEON, inicio">
|
||||
<img src="assets/branding/isssteleon-logo.png" alt="ISSSTELEON" />
|
||||
</a>
|
||||
<nav class="site-header__nav" aria-label="Secciones">
|
||||
<a class="site-header__section" routerLink="/">Análisis de información</a>
|
||||
@if (breadcrumb(); as crumb) {
|
||||
<span class="site-header__crumb" aria-current="page">› {{ crumb }}</span>
|
||||
}
|
||||
</nav>
|
||||
@if (activeDomain(); as domain) {
|
||||
<span class="platform-title">{{ title }}</span>
|
||||
<button class="domain-selector" mat-button [matMenuTriggerFor]="domainMenu"
|
||||
[attr.aria-label]="'Dominio actual: ' + domainLabels[domain] + '. Cambiar dominio'">
|
||||
{{ domainLabels[domain] }} <span aria-hidden="true">▾</span>
|
||||
</button>
|
||||
<mat-menu #domainMenu="matMenu" aria-label="Cambiar dominio de indicadores">
|
||||
@for (option of otherDomains(); track option) {
|
||||
<a mat-menu-item [routerLink]="['/indicadores', option]">{{ domainLabels[option] }}</a>
|
||||
}
|
||||
</mat-menu>
|
||||
} @else {
|
||||
<nav class="site-header__nav" aria-label="Secciones">
|
||||
<a class="site-header__section" routerLink="/">Análisis de información</a>
|
||||
@if (breadcrumb(); as crumb) {
|
||||
<span class="site-header__crumb" aria-current="page">› {{ crumb }}</span>
|
||||
}
|
||||
</nav>
|
||||
}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
@@ -29,6 +29,31 @@
|
||||
width: clamp(180px, 16vw, 200px);
|
||||
}
|
||||
|
||||
.platform-title {
|
||||
color: var(--color-text);
|
||||
font-family: var(--issste-font-heading);
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
line-height: 1.15;
|
||||
margin-inline-start: var(--issste-space-4);
|
||||
margin-inline-end: auto;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.domain-selector {
|
||||
flex: 0 0 auto;
|
||||
background-color: var(--issste-accent);
|
||||
color: var(--issste-text);
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.domain-selector:hover { background-color: var(--issste-accent); filter: brightness(.94); }
|
||||
.domain-selector:focus-visible { outline: 2px solid var(--issste-text); outline-offset: 2px; }
|
||||
|
||||
@media (max-width: 599px) {
|
||||
.platform-title { font-size: 1.125rem; min-width: 0; }
|
||||
}
|
||||
|
||||
.site-header__nav {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
@@ -30,6 +30,17 @@ describe('App', () => {
|
||||
expect(page.querySelector('.site-footer')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('an indicators page shows the platform title and a menu named after its domain', async () => {
|
||||
// Fails if the header stops naming the domain or offers the current one among the others.
|
||||
const page = await render('/indicadores/cama');
|
||||
expect(page.querySelector('.platform-title')?.textContent).toContain('Plataforma de Indicadores');
|
||||
expect(page.querySelector('.domain-selector')?.textContent).toContain('CaMa');
|
||||
(page.querySelector('.domain-selector') as HTMLButtonElement).click();
|
||||
const options = Array.from(document.querySelectorAll('.mat-mdc-menu-panel a')).map(a => a.textContent?.trim());
|
||||
expect(options).toEqual(['TEA', 'CaCu']);
|
||||
expect(page.querySelector('.site-header__crumb')).toBeNull();
|
||||
});
|
||||
|
||||
it('/conectar opens the full-height workspace (breadcrumb, no footer)', async () => {
|
||||
const page = await render('/conectar');
|
||||
expect(page.querySelector('app-connect-page')).not.toBeNull();
|
||||
|
||||
+13
-1
@@ -1,10 +1,13 @@
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
import { toSignal } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterOutlet } from '@angular/router';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatMenuModule } from '@angular/material/menu';
|
||||
import { filter, map } from 'rxjs';
|
||||
import { Dominio, DOMINIOS } from './features/indicadores/indicadores.models';
|
||||
|
||||
@Component({
|
||||
imports: [RouterLink, RouterOutlet],
|
||||
imports: [RouterLink, RouterOutlet, MatButtonModule, MatMenuModule],
|
||||
selector: 'app-root',
|
||||
styleUrl: './app.scss',
|
||||
templateUrl: './app.html',
|
||||
@@ -13,6 +16,15 @@ export class App {
|
||||
private readonly router = inject(Router);
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
|
||||
protected readonly title = 'Plataforma de Indicadores';
|
||||
protected readonly domainLabels: Record<Dominio, string> = { tea: 'TEA', cacu: 'CaCu', cama: 'CaMa' };
|
||||
private readonly url = toSignal(this.router.events.pipe(
|
||||
filter((event) => event instanceof NavigationEnd), map(event => event.urlAfterRedirects)), { initialValue: this.router.url });
|
||||
// On an indicators page the header names its domain and switches to the others.
|
||||
protected readonly activeDomain = computed(() =>
|
||||
DOMINIOS.find(domain => new RegExp(`^/indicadores/${domain}(?:[/?#]|$)`).test(this.url())));
|
||||
protected readonly otherDomains = computed(() => DOMINIOS.filter(domain => domain !== this.activeDomain()));
|
||||
|
||||
private readonly leafRouteData = toSignal(
|
||||
this.router.events.pipe(
|
||||
filter((event) => event instanceof NavigationEnd),
|
||||
|
||||
@@ -44,8 +44,8 @@ describe('UX-04 navegación Angular', () => {
|
||||
const harness = await setup();
|
||||
await harness.navigateByUrl('/indicadores/' + domain, IndicadoresPage);
|
||||
load(domain, harness); harness.detectChanges();
|
||||
// Our shell keeps the domain nav on the page itself, see indicadores-page.html.
|
||||
expect(harness.routeNativeElement!.querySelectorAll('nav.domain-nav a')).toHaveLength(3);
|
||||
// Domain switching lives in the App header (app.spec.ts); the page must not add a second one.
|
||||
expect(harness.routeNativeElement!.querySelectorAll('nav.domain-nav a')).toHaveLength(0);
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
it('mantiene la ruta, restaura borradores y reconsulta la aplicación entre TEA/CaCu/CaMa', async () => {
|
||||
|
||||
@@ -10,14 +10,6 @@
|
||||
}
|
||||
</header>
|
||||
@if (!fichaPacienteAbierta()) {
|
||||
<!-- Upstream moved domain switching into its own app shell's header (a
|
||||
dropdown in app.ts/app.html); our shell is shared with other workspace
|
||||
sections (Conectar, Gobernanza) so it stays here instead, same as before. -->
|
||||
<nav aria-label="Dominios de indicadores" class="domain-nav">
|
||||
@for (domain of dominios; track domain) {
|
||||
<a mat-button [routerLink]="['/indicadores', domain]" [attr.aria-current]="dominio === domain ? 'page' : null">{{ domainNavLabels[domain] }}</a>
|
||||
}
|
||||
</nav>
|
||||
<div class="section-tabs" [class.dark-theme]="tema === 'oscuro'" role="tablist" [attr.aria-label]="'Secciones de ' + domainLabels[dominio]" (keydown)="sectionKeydown($event)">
|
||||
@for (section of sections; track section.id) {
|
||||
<button type="button" role="tab" [id]="'tab-' + section.id" [attr.aria-controls]="'panel-' + section.id"
|
||||
|
||||
@@ -7,34 +7,6 @@
|
||||
h1 { font: var(--mat-sys-headline-large); font-family: var(--issste-font-heading); font-weight: 700; margin: .65rem 0; }
|
||||
header p { color: var(--mat-sys-on-surface-variant); margin-bottom: 1.5rem; }
|
||||
.domain { color: var(--mat-sys-primary); font: var(--mat-sys-label-large); }
|
||||
// Kept here (not moved to our app shell, see the template comment above the
|
||||
// nav) -- same rules as before upstream relocated its own copy into app.scss.
|
||||
.domain-nav {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--issste-space-2);
|
||||
padding: var(--issste-space-2);
|
||||
justify-content: center;
|
||||
margin: var(--issste-space-4) 0;
|
||||
border-radius: var(--issste-radius);
|
||||
}
|
||||
.domain-nav a {
|
||||
flex: 0 1 6rem;
|
||||
max-width: 10rem;
|
||||
color: var(--issste-text);
|
||||
border: 1px solid var(--issste-border);
|
||||
background: var(--issste-surface);
|
||||
min-height: 44px;
|
||||
border-radius: var(--issste-radius);
|
||||
}
|
||||
.domain-nav a[aria-current='page'] {
|
||||
background: var(--issste-accent);
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
}
|
||||
@media (max-width: 550px) {
|
||||
.domain-nav { gap: var(--issste-space-2); padding-inline: 0; }
|
||||
}
|
||||
.state { padding: 1.25rem; margin: 0; }
|
||||
.section-title { font-family: var(--issste-font-heading); font-size: 1.5rem; line-height: 1.3; margin: 0; overflow-wrap: anywhere; }
|
||||
.section-description { color: var(--issste-text-secondary); margin: var(--issste-space-2) 0 var(--issste-space-4); overflow-wrap: anywhere; }
|
||||
|
||||
@@ -136,13 +136,9 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
|
||||
http.expectNone(() => true);
|
||||
});
|
||||
it('UX-06B mantiene una sola navegación entre dominios, sin duplicar botones', () => {
|
||||
// Our shell has no domain selector of its own (unlike upstream's App),
|
||||
// so the page keeps exactly the one it always had -- not duplicated.
|
||||
// (Needs a render pass first: unlike upstream's trivial "absent" check,
|
||||
// confirming presence requires the template to have actually painted.)
|
||||
// The App header owns the domain menu (app.spec.ts); fails if the page brings back its own links.
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.querySelectorAll('nav.domain-nav')).toHaveLength(1);
|
||||
expect(fixture.nativeElement.querySelectorAll('nav.domain-nav a')).toHaveLength(3);
|
||||
expect(fixture.nativeElement.querySelectorAll('nav.domain-nav')).toHaveLength(0);
|
||||
expect(cards()).toHaveLength(0);
|
||||
// Constructing the page legitimately initializes its domain catalog.
|
||||
const catalogRequest = http.expectOne('/tea/indicadores');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { afterEveryRender, afterNextRender, ChangeDetectorRef, Component, DestroyRef, ElementRef, Injector, inject, computed, signal, viewChild, viewChildren } from '@angular/core';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { ActivatedRoute, RouterLink } from '@angular/router';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
@@ -11,7 +11,7 @@ import { MatIconModule } from '@angular/material/icon';
|
||||
import { MatSelect, MatSelectModule } from '@angular/material/select';
|
||||
import { MatProgressBarModule } from '@angular/material/progress-bar';
|
||||
import { catchError, first, map, of, startWith, Subject, switchMap, takeUntil } from 'rxjs';
|
||||
import { Dominio, DOMINIOS, isDominio, Indicador, Tema } from './indicadores.models';
|
||||
import { Dominio, isDominio, Indicador, Tema } from './indicadores.models';
|
||||
import { vistaEscenario } from './indicadores-eu7-escenario';
|
||||
import { IndicadoresService } from './indicadores.service';
|
||||
import { applyGlobal, domainTypes, GlobalFilterState, IndicadoresMemory, pending, validDraft } from './indicadores-memory';
|
||||
@@ -42,7 +42,7 @@ const HISTORICO_SECTIONS: readonly { id: DashboardSection; label: string }[] = [
|
||||
|
||||
@Component({
|
||||
selector: 'app-indicadores-page',
|
||||
imports: [RouterLink, FormsModule, MatButtonModule, MatCardModule, MatFormFieldModule, MatInputModule, MatIconModule, MatSelectModule, MatProgressBarModule, IndicadorCatalogCard, IndicadorKpiPanel, IndicadorKpiCard, IndicadorPeriodFilters, IndicadoresDefinitions, IndicadoresTracking, IndicadoresHistorico, TeaResumenPeriodo],
|
||||
imports: [FormsModule, MatButtonModule, MatCardModule, MatFormFieldModule, MatInputModule, MatIconModule, MatSelectModule, MatProgressBarModule, IndicadorCatalogCard, IndicadorKpiPanel, IndicadorKpiCard, IndicadorPeriodFilters, IndicadoresDefinitions, IndicadoresTracking, IndicadoresHistorico, TeaResumenPeriodo],
|
||||
templateUrl: './indicadores-page.html',
|
||||
styleUrl: './indicadores-page.scss',
|
||||
})
|
||||
@@ -268,14 +268,12 @@ export class IndicadoresPage {
|
||||
private readonly memory = inject(IndicadoresMemory);
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly route = inject(ActivatedRoute, { optional: true });
|
||||
readonly dominios = DOMINIOS;
|
||||
dominio: Dominio = 'tea';
|
||||
readonly domainLabels: Record<Dominio, string> = { tea: 'TEA', cacu: 'cáncer cervicouterino', cama: 'CaMa' };
|
||||
// At the start of the header line.
|
||||
readonly domainTitles: Record<Dominio, string> = { ...this.domainLabels, cacu: 'Cáncer cervicouterino' };
|
||||
// Short form for the domain-switcher buttons (our shell's own nav, see the
|
||||
// template comment above it) -- `domainLabels`/`domainTitles` are prose-length.
|
||||
readonly domainNavLabels: Record<Dominio, string> = { tea: 'TEA', cacu: 'CaCu', cama: 'CaMa' };
|
||||
readonly kpisByDomain = { ...KPI_BY_DOMAIN, tea: [...KPI_BY_DOMAIN.tea, ...KPI_RESUMEN_TEA] };
|
||||
figureApplied(item: Indicador) { return figureApplied(this.dominio, item.id, this.filters!.applied); }
|
||||
independentPeriods(item: Indicador) { return independentFigurePeriods(this.dominio, item.id); }
|
||||
|
||||
@@ -42,10 +42,8 @@ describe('Secciones compartidas por dominio', () => {
|
||||
expect(tabs.map(t => t.getAttribute('aria-selected'))).toEqual(tabs.map((_, i) => String(i === 0)));
|
||||
const tab = (id: string) => tabs.find(t => t.id === 'tab-' + id)!;
|
||||
expect(root.querySelector('[role="tablist"]')?.getAttribute('aria-label')).toContain(page.domainLabels[domain]);
|
||||
// Upstream moved domain selection to its own App shell; ours keeps it on
|
||||
// the page itself (see indicadores-page.html), since our shell is shared
|
||||
// with other workspace sections.
|
||||
expect(root.querySelector('nav.domain-nav')).not.toBeNull();
|
||||
// The App header switches domains (see app.html); the page has no switcher of its own.
|
||||
expect(root.querySelector('nav.domain-nav')).toBeNull();
|
||||
for (const tab of tabs) {
|
||||
const panel = root.querySelector<HTMLElement>('#' + tab.getAttribute('aria-controls'))!;
|
||||
expect(panel.getAttribute('aria-labelledby')).toBe(tab.id);
|
||||
|
||||
Reference in New Issue
Block a user