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) {