From e2b307abf5a0d2801bd414500a9bc599ded292c0 Mon Sep 17 00:00:00 2001 From: rockdrigo Date: Mon, 9 Nov 2026 18:10:58 -0600 Subject: [PATCH] feat(shell): domain menu in the header, as in the deployed dev version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit How: on /indicadores/ 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. --- src/app/app.html | 25 +++++++++++++---- src/app/app.scss | 25 +++++++++++++++++ src/app/app.spec.ts | 11 ++++++++ src/app/app.ts | 14 +++++++++- .../indicadores-navigation.spec.ts | 4 +-- .../indicadores/indicadores-page.html | 8 ------ .../indicadores/indicadores-page.scss | 28 ------------------- .../indicadores/indicadores-page.spec.ts | 8 ++---- .../features/indicadores/indicadores-page.ts | 8 ++---- .../indicadores/indicadores-sections.spec.ts | 6 ++-- 10 files changed, 77 insertions(+), 60 deletions(-) diff --git a/src/app/app.html b/src/app/app.html index b41af08..b9efbea 100644 --- a/src/app/app.html +++ b/src/app/app.html @@ -4,12 +4,25 @@ ISSSTELEON - + @if (activeDomain(); as domain) { + {{ title }} + + + @for (option of otherDomains(); track option) { + {{ domainLabels[option] }} + } + + } @else { + + } diff --git a/src/app/app.scss b/src/app/app.scss index 234d0f1..ba92825 100644 --- a/src/app/app.scss +++ b/src/app/app.scss @@ -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; diff --git a/src/app/app.spec.ts b/src/app/app.spec.ts index f849d1f..e488b2a 100644 --- a/src/app/app.spec.ts +++ b/src/app/app.spec.ts @@ -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(); diff --git a/src/app/app.ts b/src/app/app.ts index b18cd4e..aed86e0 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -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 = { 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), diff --git a/src/app/features/indicadores/indicadores-navigation.spec.ts b/src/app/features/indicadores/indicadores-navigation.spec.ts index 75d9de6..0fd2618 100644 --- a/src/app/features/indicadores/indicadores-navigation.spec.ts +++ b/src/app/features/indicadores/indicadores-navigation.spec.ts @@ -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 () => { diff --git a/src/app/features/indicadores/indicadores-page.html b/src/app/features/indicadores/indicadores-page.html index 8e58d94..da700e0 100644 --- a/src/app/features/indicadores/indicadores-page.html +++ b/src/app/features/indicadores/indicadores-page.html @@ -10,14 +10,6 @@ } @if (!fichaPacienteAbierta()) { - -
@for (section of sections; track section.id) {