feat(indicadores): "Fijar indicador" only from five indicators, like the search

How: the catalog card gets a `fijable` input and shows its pin button only when
it is true; the page passes searchVisible(), so the button appears with the
search, from MIN_BUSQUEDA (5) indicators in Resumen. Below that, saved pins are
ignored when ordering the cards, so a pin from a longer catalog can't reorder
cards that offer no way to unpin.

Implications: cáncer de mama (three charts) has no pin buttons; CaCu and TEA
keep them. Pins stay saved and come back if the domain grows past the threshold.
This commit is contained in:
rockdrigo
2026-11-09 20:37:49 -06:00
parent 612a11fa6f
commit 502fc969f0
4 changed files with 14 additions and 7 deletions
@@ -34,11 +34,13 @@ import { IndicadorConteosPareados } from './indicador-conteos-pareados';
<h2 [id]="titleId" tabindex="-1">{{ indicador.titulo }}</h2>
</div>
</header>
<button class="pin-toggle" mat-button type="button" [attr.aria-pressed]="pinned"
[attr.aria-label]="(pinned ? 'Desfijar indicador' : 'Fijar indicador') + ', ' + indicador.titulo"
(click)="pinChanged.emit()">
<mat-icon aria-hidden="true">push_pin</mat-icon>{{ pinned ? 'Desfijar indicador' : 'Fijar indicador' }}
</button>
@if (fijable) {
<button class="pin-toggle" mat-button type="button" [attr.aria-pressed]="pinned"
[attr.aria-label]="(pinned ? 'Desfijar indicador' : 'Fijar indicador') + ', ' + indicador.titulo"
(click)="pinChanged.emit()">
<mat-icon aria-hidden="true">push_pin</mat-icon>{{ pinned ? 'Desfijar indicador' : 'Fijar indicador' }}
</button>
}
<div class="catalog-content" [id]="contentId" [attr.aria-labelledby]="titleId">
@if (isEu7) {
<div #visibilityRegion class="eu7-region">
@@ -154,6 +156,8 @@ export class IndicadorCatalogCard implements OnChanges, OnDestroy {
@Input({ required: true }) applied!: GlobalApplied;
@Input() independentPeriods = false;
@Input() pinned = false;
// Pinning reorders a long grid; with a few cards there is nothing to bring forward.
@Input() fijable = true;
@Input() visualProfile: FigureVisualProfile = READABLE_VISUAL_PROFILE;
readonly pinChanged = output<void>();
@ViewChild('visibilityRegion') visibilityRegion?: ElementRef<HTMLElement>;
@@ -112,7 +112,7 @@
<div class="catalog-grid">
@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)" />
[pinned]="isPinned(item)" [fijable]="searchVisible()" (pinChanged)="togglePinned(item)" />
}
</div>
}
@@ -132,7 +132,8 @@ describe('UX-06E.D.3.A catálogo permanentemente desplegado', () => {
expect(header.querySelector('h2')?.textContent).toBe(title);
expect(header.querySelector('.card-identity button')).toBeNull();
expect(header.querySelector('button')).toBeNull();
expect(fixture.nativeElement.querySelector('.pin-toggle').getAttribute('aria-label')).toContain(title);
// Two cards: no pin button (it shows from MIN_BUSQUEDA indicators, see indicadores-pinning.spec.ts).
expect(fixture.nativeElement.querySelector('.pin-toggle')).toBeNull();
http.expectNone(() => true);
});
it('UX-06B mantiene una sola navegación entre dominios, sin duplicar botones', () => {
@@ -331,6 +331,8 @@ export class IndicadoresPage {
readonly searchResults = computed(() => {
const selected = new Set(this.selectedIndicators());
const items = this.catalogOrder().filter(item => selected.has(item.id));
// Below MIN_BUSQUEDA there are no pin buttons, so saved pins don't reorder the cards either.
if (!this.searchVisible()) return { items };
return { items: [...items.filter(item => this.isPinned(item)), ...items.filter(item => !this.isPinned(item))] };
});
readonly catalogLoading = signal(true);