From 4086cff6dd2d3cf1791cadd68151cd9d6f39fe58 Mon Sep 17 00:00:00 2001 From: Daniel Palafox Date: Sun, 9 Jul 2023 16:52:02 +0700 Subject: [PATCH 1/2] feature: Add missing aria labels to sort by different types --- .../cdk/panel/panels/panels.component.html | 2 +- .../app-panels-collapse-aria-label.pipe.ts | 2 + .../app-panels-expand-aria-label.pipe.ts | 2 + .../app-panels-sort-by-aria-label.pipe.ts | 94 +++++++++++++++++-- .../properties/shared/shared.en.properties | 33 +++++-- 5 files changed, 120 insertions(+), 13 deletions(-) diff --git a/src/app/cdk/panel/panels/panels.component.html b/src/app/cdk/panel/panels/panels.component.html index 1e5ac1657a..4dc6ff4aef 100644 --- a/src/app/cdk/panel/panels/panels.component.html +++ b/src/app/cdk/panel/panels/panels.component.html @@ -232,7 +232,7 @@

mat-menu-item (click)="sortChange(option)" *ngFor="let option of sortTypes" - [attr.aria-label]="option | appPanelsSortByAriaLabel" + [attr.aria-label]="option | appPanelsSortByAriaLabel: type" > {{ option | sortLabel }} { + switch (type) { + case 'employment': + return $localize`:@@shared.employmentSortTitle:Sort employment by title` + case 'professional-activities': + return $localize`:@@shared.professionalActivitiesSortTitle:Sort professional activities by title` + case 'education': + case 'qualification': + return $localize`:@@shared.educationSortTitle:Sort education and qualifications by title` + case 'distinction': + case 'invited-position': + return $localize`:@@shared.distinctionSortTitle:Sort invited positions and distinction by title` + case 'membership': + case 'service': + return $localize`:@@shared.membershipSortTitle:Sort membership and service by title` + case 'funding': + return $localize`:@@shared.fundingSortTitle:Sort funding by title` + case 'works': + return $localize`:@@shared.worksSortTitle:Sort works by title` + case 'research-resources': + return $localize`:@@shared.researchSortTitle:Sort research resources by title` + } +} + +const getStartDateLabelByType = (type: string): string => { + switch (type) { + case 'employment': + return $localize`:@@shared.employmentSortStart:Sort employment by start date` + case 'professional-activities': + return $localize`:@@shared.professionalActivitiesSortStart:Sort professional activities by start date` + case 'education': + case 'qualification': + return $localize`:@@shared.educationSortStart:Sort education and qualifications by start date` + case 'distinction': + case 'invited-position': + return $localize`:@@shared.distinctionSortStart:Sort invited positions and distinction by start date` + case 'membership': + case 'service': + return $localize`:@@shared.membershipSortStart:Sort membership and service by start date` + } +} + +const getEndDateLabelByType = (type: string): string => { + switch (type) { + case 'employment': + return $localize`:@@shared.employmentSortEnd:Sort employment by end date` + case 'professional-activities': + return $localize`:@@shared.professionalActivitiesSortEnd:Sort professional activities by end date` + case 'education': + case 'qualification': + return $localize`:@@shared.educationSortEnd:Sort education and qualifications by end date` + case 'distinction': + case 'invited-position': + return $localize`:@@shared.distinctionSortEnd:Sort invited positions and distinction by end date` + case 'membership': + case 'service': + return $localize`:@@shared.membershipSortEnd:Sort membership and service by end date` + } +} + +const getTypeLabelByType = (type: string): string => { + switch (type) { + case 'professional-activities': + return $localize`:@@shared.professionalActivitiesSortType:Sort professional activities by type` + case 'funding': + return $localize`:@@shared.fundingSortType:Sort funding by type` + case 'works': + return $localize`:@@shared.worksSortType:Sort works by type` + } +} + +const getDateLabelByType = (type: string): string => { + switch (type) { + case 'funding': + return $localize`:@@shared.fundingSortDate:Sort funding by date` + case 'works': + return $localize`:@@shared.worksSortDate:Sort works by date` + case 'research-resources': + return $localize`:@@shared.researchSortDate:Sort research resources by date` + } +} diff --git a/src/locale/properties/shared/shared.en.properties b/src/locale/properties/shared/shared.en.properties index b38b7b0bea..54b3c80b0a 100644 --- a/src/locale/properties/shared/shared.en.properties +++ b/src/locale/properties/shared/shared.en.properties @@ -600,9 +600,30 @@ share.myOrcidTitle=- My ORCID share.developerTools=Developer tools - ORCID shared.addProfessionalActivity=Add a professional activity shared.sortProfessionalActivities=Sort your professional activities -shared.sortTitle=Sort by title -shared.sortStart=Sort by start date -shared.sortEnd=Sort by end date -shared.sortType=Sort by type -shared.sortDate=Sort by type -shared.sortOrder=Sort by order +shared.professionalActivitiesCollapseAriaLabel=Collapse the professional activities section +shared.professionalActivitiesExpandAriaLabel=Expand the professional activities section +shared.professionalActivitiesSortTitle=Sort professional activities by title +shared.professionalActivitiesSortStart=Sort professional activities by start date +shared.professionalActivitiesSortEnd=Sort professional activities by end date +shared.professionalActivitiesSortType=Sort professional activities by type +shared.employmentSortTitle=Sort employment by title +shared.employmentSortStart=Sort employment by start date +shared.employmentSortEnd=Sort employment by end date +shared.educationSortTitle=Sort education and qualifications by title +shared.educationSortStart=Sort education and qualifications by start date +shared.educationSortEnd=Sort education and qualifications by end date +shared.distinctionSortTitle=Sort invited positions and distinction by title +shared.distinctionSortStart=Sort invited positions and distinction by start date +shared.distinctionSortEnd=Sort invited positions and distinction by end date +shared.membershipSortTitle=Sort membership and service by title +shared.membershipSortStart=Sort membership and service by start date +shared.membershipSortEnd=Sort membership and service by end date +shared.fundingSortTitle=Sort funding by title +shared.fundingSortDate=Sort funding by date +shared.fundingSortType=Sort funding by type +shared.worksSortTitle=Sort works by title +shared.worksSortDate=Sort works by date +shared.worksSortType=Sort works by type +shared.peerReviewsSortOrder=Sort peer reviews by order +shared.researchSortTitle=Sort research resources by title +shared.researchSortDate=Sort research resources by date From 2efafbca40bf73c76187c635edc649d55cb4ca63 Mon Sep 17 00:00:00 2001 From: Daniel Palafox Date: Sun, 9 Jul 2023 16:55:59 +0700 Subject: [PATCH 2/2] fix: Add missing type in pipe --- .../app-panels-sort-by-aria-label.pipe.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/pipes/app-panels-sort-by-aria-label/app-panels-sort-by-aria-label.pipe.ts b/src/app/shared/pipes/app-panels-sort-by-aria-label/app-panels-sort-by-aria-label.pipe.ts index 727dd582ce..a805dd9405 100644 --- a/src/app/shared/pipes/app-panels-sort-by-aria-label/app-panels-sort-by-aria-label.pipe.ts +++ b/src/app/shared/pipes/app-panels-sort-by-aria-label/app-panels-sort-by-aria-label.pipe.ts @@ -5,7 +5,7 @@ import { SortOrderType } from '../../../types/sort' name: 'appPanelsSortByAriaLabel', }) export class AppPanelsSortByAriaLabelPipe implements PipeTransform { - transform(sortBy: SortOrderType): string { + transform(sortBy: SortOrderType, type: string): string { switch (sortBy) { case 'title': return getTitleLabelByType(type);