Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility in the statistics table #3380

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h2 class="m-1">
<tbody>

<tr>
<td></td>
<th scope="col">{{ objectHeaderLabel }}</th>
<th scope="col"
*ngFor="let header of headers"
class="{{header}}-header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,31 @@ describe('StatisticsTableComponent', () => {
.toEqual('8');
});
});

describe('getObjectHeaderLabel', () => {

it('should return the correct label for TotalVisits', () => {
expect(component.getObjectHeaderLabel('TotalVisits')).toEqual('statistics.table.header.TotalVisits');
});

it('should return the correct label for TotalVisitsPerMonth', () => {
expect(component.getObjectHeaderLabel('TotalVisitsPerMonth')).toEqual('statistics.table.header.TotalVisitsPerMonth');
});

it('should return the correct label for TotalDownloads', () => {
expect(component.getObjectHeaderLabel('TotalDownloads')).toEqual('statistics.table.header.TotalDownloads');
});

it('should return the correct label for TopCities', () => {
expect(component.getObjectHeaderLabel('TopCities')).toEqual('statistics.table.header.TopCities');
});

it('should return the correct label for topCountries', () => {
expect(component.getObjectHeaderLabel('topCountries')).toEqual('statistics.table.header.topCountries');
});

it('should return an empty string for unknown report types', () => {
expect(component.getObjectHeaderLabel('UnknownType')).toEqual('');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export class StatisticsTableComponent implements OnInit {
*/
headers: string[];

/**
* Object header label
*/
objectHeaderLabel: string;

constructor(
protected dsoService: DSpaceObjectDataService,
protected nameService: DSONameService,
Expand All @@ -71,6 +76,7 @@ export class StatisticsTableComponent implements OnInit {
if (this.hasData) {
this.headers = Object.keys(this.report.points[0].values);
}
this.objectHeaderLabel = this.getObjectHeaderLabel(this.report.reportType);
}

/**
Expand All @@ -91,4 +97,25 @@ export class StatisticsTableComponent implements OnInit {
return of(point.label);
}
}

/**
* Defines a dynamic label for the object column
* @param reportType
*/
getObjectHeaderLabel(reportType: string): string {
switch (reportType) {
case 'TotalVisits':
return this.translateService.instant('statistics.table.header.TotalVisits');
case 'TotalVisitsPerMonth':
return this.translateService.instant('statistics.table.header.TotalVisitsPerMonth');
case 'TotalDownloads':
return this.translateService.instant('statistics.table.header.TotalDownloads');
case 'TopCities':
return this.translateService.instant('statistics.table.header.TopCities');
case 'topCountries':
return this.translateService.instant('statistics.table.header.topCountries');
default:
return '';
}
}
}
10 changes: 10 additions & 0 deletions src/assets/i18n/en.json5
Original file line number Diff line number Diff line change
Expand Up @@ -6741,4 +6741,14 @@
"item.page.cc.license.disclaimer": "Except where otherwised noted, this item's license is described as",

"browse.search-form.placeholder": "Search the repository",

"statistics.table.header.TotalVisits": "Object",

"statistics.table.header.TotalVisitsMonth": "Month",

"statistics.table.header.TotalDownloads": "Downloads",

"statistics.table.header.TopCities": "Cities",

"statistics.table.header.topCountries": "Countries",
}
15 changes: 15 additions & 0 deletions src/assets/i18n/es.json5
Original file line number Diff line number Diff line change
Expand Up @@ -8152,5 +8152,20 @@
//"browse.search-form.placeholder": "Search the repository",
"browse.search-form.placeholder": "Buscar en el repositorio",

// "statistics.table.header.TotalVisits": "Object",
"statistics.table.header.TotalVisits": "Objeto",

// "statistics.table.header.TotalVisitsMonth": "Month",
"statistics.table.header.TotalVisitsMonth": "Mes",

// "statistics.table.header.TotalDownloads": "Downloads",
"statistics.table.header.TotalDownloads": "Descargas",

// "statistics.table.header.TopCities": "Cities",
"statistics.table.header.TopCities": "Ciudades",

// "statistics.table.header.topCountries": "Countries",
"statistics.table.header.topCountries": "Países",


}
15 changes: 15 additions & 0 deletions src/assets/i18n/pt-BR.json5
Original file line number Diff line number Diff line change
Expand Up @@ -10249,4 +10249,19 @@

//"browse.search-form.placeholder": "Search the repository",
"browse.search-form.placeholder": "Buscar no repositório",

// "statistics.table.header.TotalVisits": "Object",
"statistics.table.header.TotalVisits": "Objeto",

// "statistics.table.header.TotalVisitsMonth": "Month",
"statistics.table.header.TotalVisitsMonth": "Mês",

// "statistics.table.header.TotalDownloads": "Downloads",
"statistics.table.header.TotalDownloads": "Downloads",

// "statistics.table.header.TopCities": "Cities",
"statistics.table.header.TopCities": "Cidades",

// "statistics.table.header.topCountries": "Countries",
"statistics.table.header.topCountries": "Países",
}
Loading