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:
@@ -34,11 +34,13 @@ import { IndicadorConteosPareados } from './indicador-conteos-pareados';
|
|||||||
<h2 [id]="titleId" tabindex="-1">{{ indicador.titulo }}</h2>
|
<h2 [id]="titleId" tabindex="-1">{{ indicador.titulo }}</h2>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
@if (fijable) {
|
||||||
<button class="pin-toggle" mat-button type="button" [attr.aria-pressed]="pinned"
|
<button class="pin-toggle" mat-button type="button" [attr.aria-pressed]="pinned"
|
||||||
[attr.aria-label]="(pinned ? 'Desfijar indicador' : 'Fijar indicador') + ', ' + indicador.titulo"
|
[attr.aria-label]="(pinned ? 'Desfijar indicador' : 'Fijar indicador') + ', ' + indicador.titulo"
|
||||||
(click)="pinChanged.emit()">
|
(click)="pinChanged.emit()">
|
||||||
<mat-icon aria-hidden="true">push_pin</mat-icon>{{ pinned ? 'Desfijar indicador' : 'Fijar indicador' }}
|
<mat-icon aria-hidden="true">push_pin</mat-icon>{{ pinned ? 'Desfijar indicador' : 'Fijar indicador' }}
|
||||||
</button>
|
</button>
|
||||||
|
}
|
||||||
<div class="catalog-content" [id]="contentId" [attr.aria-labelledby]="titleId">
|
<div class="catalog-content" [id]="contentId" [attr.aria-labelledby]="titleId">
|
||||||
@if (isEu7) {
|
@if (isEu7) {
|
||||||
<div #visibilityRegion class="eu7-region">
|
<div #visibilityRegion class="eu7-region">
|
||||||
@@ -154,6 +156,8 @@ export class IndicadorCatalogCard implements OnChanges, OnDestroy {
|
|||||||
@Input({ required: true }) applied!: GlobalApplied;
|
@Input({ required: true }) applied!: GlobalApplied;
|
||||||
@Input() independentPeriods = false;
|
@Input() independentPeriods = false;
|
||||||
@Input() pinned = 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;
|
@Input() visualProfile: FigureVisualProfile = READABLE_VISUAL_PROFILE;
|
||||||
readonly pinChanged = output<void>();
|
readonly pinChanged = output<void>();
|
||||||
@ViewChild('visibilityRegion') visibilityRegion?: ElementRef<HTMLElement>;
|
@ViewChild('visibilityRegion') visibilityRegion?: ElementRef<HTMLElement>;
|
||||||
|
|||||||
@@ -112,7 +112,7 @@
|
|||||||
<div class="catalog-grid">
|
<div class="catalog-grid">
|
||||||
@for (item of searchResults().items; track cardIdentity(item)) {
|
@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)"
|
<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>
|
</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('h2')?.textContent).toBe(title);
|
||||||
expect(header.querySelector('.card-identity button')).toBeNull();
|
expect(header.querySelector('.card-identity button')).toBeNull();
|
||||||
expect(header.querySelector('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);
|
http.expectNone(() => true);
|
||||||
});
|
});
|
||||||
it('UX-06B mantiene una sola navegación entre dominios, sin duplicar botones', () => {
|
it('UX-06B mantiene una sola navegación entre dominios, sin duplicar botones', () => {
|
||||||
|
|||||||
@@ -331,6 +331,8 @@ export class IndicadoresPage {
|
|||||||
readonly searchResults = computed(() => {
|
readonly searchResults = computed(() => {
|
||||||
const selected = new Set(this.selectedIndicators());
|
const selected = new Set(this.selectedIndicators());
|
||||||
const items = this.catalogOrder().filter(item => selected.has(item.id));
|
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))] };
|
return { items: [...items.filter(item => this.isPinned(item)), ...items.filter(item => !this.isPinned(item))] };
|
||||||
});
|
});
|
||||||
readonly catalogLoading = signal(true);
|
readonly catalogLoading = signal(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user