Skip to content

Commit

Permalink
feature: Add missing aria labels to sort by different types
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielPalafox committed Jul 9, 2023
1 parent 06dda31 commit 4086cff
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/app/cdk/panel/panels/panels.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ <h3 class="activity-header orc-font-body-large">
mat-menu-item
(click)="sortChange(option)"
*ngFor="let option of sortTypes"
[attr.aria-label]="option | appPanelsSortByAriaLabel"
[attr.aria-label]="option | appPanelsSortByAriaLabel: type"
>
{{ option | sortLabel }}
<mat-icon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export class AppPanelsCollapseAriaLabelPipe implements PipeTransform {
transform(panelType: any, args?: any, panelTitle?: any): string {
if (panelType === 'employment') {
return $localize`:@@shared.employmentCollapseAriaLabel:Collapse the Employment section`
} else if (panelType === 'professional-activities') {
return $localize`:@@shared.professionalActivitiesCollapseAriaLabel:Collapse the professional activities section`
} else if (panelType === 'education' || panelType === 'qualification') {
return $localize`:@@shared.educationQualificationCollapseAriaLabel:Collapse the Education and qualifications section`
} else if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export class AppPanelsExpandAriaLabelPipe implements PipeTransform {
transform(panelType: any, args?: any, panelTitle?: any): string {
if (panelType === 'employment') {
return $localize`:@@shared.employmentExpandAriaLabel:Expand the Employment section`
} else if (panelType === 'professional-activities') {
return $localize`:@@shared.professionalActivitiesExpandAriaLabel:Expand the professional activities section`
} else if (panelType === 'education' || panelType === 'qualification') {
return $localize`:@@shared.educationQualificationExpandAriaLabel:Expand the Education and qualifications section`
} else if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,99 @@ export class AppPanelsSortByAriaLabelPipe implements PipeTransform {
transform(sortBy: SortOrderType): string {
switch (sortBy) {
case 'title':
return $localize`:@@shared.sortTitle:Sort by title`
return getTitleLabelByType(type);
case 'start':
return $localize`:@@shared.sortStart:Sort by start date`
return getStartDateLabelByType(type);
case 'end':
return $localize`:@@shared.sortEnd:Sort by end date`
return getEndDateLabelByType(type);
case 'date':
return $localize`:@@shared.sortDate:Sort by type`
return getDateLabelByType(type);
case 'type':
return $localize`:@@shared.sortType:Sort by type`
return getTypeLabelByType(type);
case 'order':
return $localize`:@@shared.sortOrder:Sort by order`
return $localize`:@@shared.peerReviewsSortOrder:Sort peer reviews by order`
}
}
}

const getTitleLabelByType = (type: string): string => {
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`
}
}
33 changes: 27 additions & 6 deletions src/locale/properties/shared/shared.en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4086cff

Please sign in to comment.