Skip to content

Commit 2f64564

Browse files
rootroot
authored andcommitted
Creation of a new method so that when a filter is selected a page reload message is announced to the user
1 parent c5f07da commit 2f64564

File tree

5 files changed

+43
-5
lines changed

5 files changed

+43
-5
lines changed

src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[tabIndex]="-1"
33
[routerLink]="[searchLink]"
44
[queryParams]="addQueryParams$ | async"
5-
(click)="filterService.minimizeAll()">
5+
(click)="selectingFilter()">
66
<label class="mb-0 d-flex w-100">
77
<input type="checkbox" [checked]="false" class="my-1 align-self-stretch filter-checkbox"/>
88
<span class="w-100 pl-1 break-facet">

src/app/shared/search/search-filters/search-filter/search-facet-filter-options/search-facet-option/search-facet-option.component.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ import {
1212
Router,
1313
RouterLink,
1414
} from '@angular/router';
15-
import { TranslateModule } from '@ngx-translate/core';
15+
import {
16+
TranslateModule,
17+
TranslateService,
18+
} from '@ngx-translate/core';
1619
import { Observable } from 'rxjs';
1720
import { map } from 'rxjs/operators';
1821

1922
import { PaginationService } from '../../../../../../core/pagination/pagination.service';
20-
import { SearchService } from '../../../../../../core/shared/search/search.service';
2123
import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service';
2224
import { SearchFilterService } from '../../../../../../core/shared/search/search-filter.service';
25+
import { SearchService } from '../../../../../../core/shared/search/search.service';
26+
import { LiveRegionService } from '../../../../../../shared/live-region/live-region.service';
2327
import { currentPath } from '../../../../../utils/route.utils';
2428
import { ShortNumberPipe } from '../../../../../utils/short-number.pipe';
2529
import { FacetValue } from '../../../../models/facet-value.model';
@@ -70,11 +74,18 @@ export class SearchFacetOptionComponent implements OnInit {
7074

7175
paginationId: string;
7276

77+
/**
78+
* Stores selected filters
79+
*/
80+
selectedFilters = new Set();
81+
7382
constructor(protected searchService: SearchService,
7483
protected filterService: SearchFilterService,
7584
protected searchConfigService: SearchConfigurationService,
7685
protected router: Router,
7786
protected paginationService: PaginationService,
87+
protected liveRegionService: LiveRegionService,
88+
private translateService: TranslateService,
7889
) {
7990
}
8091

@@ -119,4 +130,25 @@ export class SearchFacetOptionComponent implements OnInit {
119130
return getFacetValueForType(this.filterValue, this.filterConfig);
120131
}
121132

133+
/**
134+
* Announces to the screen reader that the page will be reloaded, which filter has been selected
135+
* and then implement “filterService.minimizeAll()”
136+
*/
137+
selectingFilter() {
138+
const filterValue = this.filterValue.value;
139+
if (!this.selectedFilters.has(filterValue)) {
140+
this.translateService.get('search-facet-option.update.announcement')
141+
.subscribe(translatedMessage => {
142+
const message = `${translatedMessage} ${filterValue}`;
143+
this.liveRegionService.addMessage(message);
144+
145+
setTimeout(() => {
146+
this.liveRegionService.clear();
147+
}, this.liveRegionService.getMessageTimeOutMs());
148+
this.selectedFilters.add(filterValue);
149+
});
150+
}
151+
this.filterService.minimizeAll();
152+
}
153+
122154
}

src/assets/i18n/en.json5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6763,4 +6763,6 @@
67636763
"register-page.registration.aria.label": "Enter your e-mail address",
67646764

67656765
"forgot-email.form.aria.label": "Enter your e-mail address",
6766+
6767+
"search-facet-option.update.announcement": "The page will be reloaded. selected filter: ",
67666768
}

src/assets/i18n/es.json5

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10192,5 +10192,6 @@
1019210192
// "forgot-email.form.aria.label": "Enter your e-mail address",
1019310193
"forgot-email.form.aria.label": "Introduzca su dirección de correo electrónico",
1019410194

10195-
10196-
}
10195+
// "search-facet-option.update.announcement": "The page will be reloaded. selected filter: ",
10196+
"search-facet-option.update.announcement": "La página será recargada. filtro seleccionado: ",
10197+
}

src/assets/i18n/pt-BR.json5

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10240,4 +10240,7 @@
1024010240

1024110241
// "forgot-email.form.aria.label": "Enter your e-mail address",
1024210242
"forgot-email.form.aria.label": "Digite seu e-mail",
10243+
10244+
// "search-facet-option.update.announcement": "The page will be reloaded. selected filter: ",
10245+
"search-facet-option.update.announcement": "La página será recargada. filtro seleccionado: ",
1024310246
}

0 commit comments

Comments
 (0)