Skip to content

Commit

Permalink
Merge pull request #2717 from alexandrevryghem/fix-accessibility-issu…
Browse files Browse the repository at this point in the history
…es_contribute-main

Fix accessibility issues (part 2)
  • Loading branch information
tdonohue authored Jan 31, 2024
2 parents 5b9a98a + ca24713 commit 85369aa
Show file tree
Hide file tree
Showing 66 changed files with 363 additions and 265 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<div class="container">
<h1>{{ 'admin.access-control.bulk-access.title' | translate }}</h1>
<ds-bulk-access-browse [listId]="listId"></ds-bulk-access-browse>
<div class="clearfix mb-3"></div>
<ds-bulk-access-settings #dsBulkSettings ></ds-bulk-access-settings>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="container">
<h2 id="header">{{'admin.batch-import.page.header' | translate}}</h2>
<h1 id="header">{{'admin.batch-import.page.header' | translate}}</h1>
<p>{{'admin.batch-import.page.help' | translate}}</p>
<p *ngIf="dso">
selected collection: <b>{{getDspaceObjectName()}}</b>&nbsp;
Expand Down Expand Up @@ -28,7 +28,7 @@ <h2 id="header">{{'admin.batch-import.page.header' | translate}}</h2>
<small class="form-text text-muted">
{{'admin.batch-import.page.toggle.help' | translate}}
</small>


<ds-file-dropzone-no-uploader
*ngIf="isUpload"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1 id="header" class="border-bottom pb-2">{{'admin.registries.bitstream-formats
<table id="formats" class="table table-striped table-hover">
<thead>
<tr>
<th scope="col" [attr.aria-label]="'admin.registries.bitstream-formats.select' | translate"></th>
<th scope="col"><span class="sr-only">{{'admin.registries.bitstream-formats.table.selected' | translate}}</span></th>
<th scope="col">{{'admin.registries.bitstream-formats.table.id' | translate}}</th>
<th scope="col">{{'admin.registries.bitstream-formats.table.name' | translate}}</th>
<th scope="col">{{'admin.registries.bitstream-formats.table.mimetype' | translate}}</th>
Expand All @@ -35,6 +35,7 @@ <h1 id="header" class="border-bottom pb-2">{{'admin.registries.bitstream-formats
[checked]="isSelected(bitstreamFormat) | async"
(change)="selectBitStreamFormat(bitstreamFormat, $event)"
>
<span class="sr-only">{{'admin.registries.bitstream-formats.select' | translate}}}</span>
</label>
</td>
<td><a [routerLink]="['/admin/registries/bitstream-formats', bitstreamFormat.id, 'edit']">{{bitstreamFormat.id}}</a></td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="metadata-registry row">
<div class="col-12">

<h2 id="header" class="border-bottom pb-2">{{'admin.registries.metadata.head' | translate}}</h2>
<h1 id="header" class="border-bottom pb-2">{{'admin.registries.metadata.head' | translate}}</h1>

<p id="description" class="pb-2">{{'admin.registries.metadata.description' | translate}}</p>

Expand All @@ -19,7 +19,7 @@ <h2 id="header" class="border-bottom pb-2">{{'admin.registries.metadata.head' |
<table id="metadata-schemas" class="table table-striped table-hover">
<thead>
<tr>
<th scope="col"></th>
<th scope="col"><span class="sr-only">{{'admin.registries.metadata.schemas.table.selected' | translate}}</span></th>
<th scope="col">{{'admin.registries.metadata.schemas.table.id' | translate}}</th>
<th scope="col">{{'admin.registries.metadata.schemas.table.namespace' | translate}}</th>
<th scope="col">{{'admin.registries.metadata.schemas.table.name' | translate}}</th>
Expand All @@ -34,6 +34,7 @@ <h2 id="header" class="border-bottom pb-2">{{'admin.registries.metadata.head' |
[checked]="isSelected(schema) | async"
(change)="selectMetadataSchema(schema, $event)"
>
<span class="sr-only">{{((isSelected(schema) | async) ? 'admin.registries.metadata.schemas.deselect' : 'admin.registries.metadata.schemas.select') | translate}}</span>
</label>
</td>
<td class="selectable-row" (click)="editSchema(schema)"><a [routerLink]="[schema.prefix]">{{schema.id}}</a></td>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div *ngIf="registryService.getActiveMetadataSchema() | async; then editheader; else createHeader"></div>

<ng-template #createHeader>
<h4>{{messagePrefix + '.create' | translate}}</h4>
<h2>{{messagePrefix + '.create' | translate}}</h2>
</ng-template>

<ng-template #editheader>
<h4>{{messagePrefix + '.edit' | translate}}</h4>
<h2>{{messagePrefix + '.edit' | translate}}</h2>
</ng-template>

<ds-form [formId]="formId"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div *ngIf="registryService.getActiveMetadataField() | async; then editheader; else createHeader"></div>

<ng-template #createHeader>
<h4>{{messagePrefix + '.create' | translate}}</h4>
<h2>{{messagePrefix + '.create' | translate}}</h2>
</ng-template>

<ng-template #editheader>
<h4>{{messagePrefix + '.edit' | translate}}</h4>
<h2>{{messagePrefix + '.edit' | translate}}</h2>
</ng-template>

<ds-form [formId]="formId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<div class="metadata-schema row">
<div class="col-12" *ngVar="(metadataSchema$ | async) as schema">

<h2 id="header" class="border-bottom pb-2">{{'admin.registries.schema.head' | translate}}: "{{schema?.prefix}}"</h2>
<h1 id="header" class="border-bottom pb-2">{{'admin.registries.schema.head' | translate}}: "{{schema?.prefix}}"</h1>

<p id="description" class="pb-2">{{'admin.registries.schema.description' | translate:{ namespace: schema?.namespace } }}</p>

<ds-metadata-field-form
[metadataSchema]="schema"
(submitForm)="forceUpdateFields()"></ds-metadata-field-form>

<h3>{{'admin.registries.schema.fields.head' | translate}}</h3>
<h2>{{'admin.registries.schema.fields.head' | translate}}</h2>

<ng-container *ngVar="(metadataFields$ | async)?.payload as fields">
<ds-pagination
Expand All @@ -24,7 +24,7 @@ <h3>{{'admin.registries.schema.fields.head' | translate}}</h3>
<table id="metadata-fields" class="table table-striped table-hover">
<thead>
<tr>
<th></th>
<th><span class="sr-only">{{'admin.registries.schema.fields.table.selected' | translate}}</span></th>
<th scope="col">{{'admin.registries.schema.fields.table.id' | translate}}</th>
<th scope="col">{{'admin.registries.schema.fields.table.field' | translate}}</th>
<th scope="col">{{'admin.registries.schema.fields.table.scopenote' | translate}}</th>
Expand All @@ -33,12 +33,11 @@ <h3>{{'admin.registries.schema.fields.head' | translate}}</h3>
<tbody>
<tr *ngFor="let field of fields?.page"
[ngClass]="{'table-primary' : isActive(field) | async}">
<td>
<label class="mb-0">
<input type="checkbox"
[checked]="isSelected(field) | async"
(change)="selectMetadataField(field, $event)">
</label>
<td *ngVar="(isSelected(field) | async) as selected">
<input type="checkbox"
[attr.aria-label]="(selected ? 'admin.registries.schema.fields.deselect' : 'admin.registries.schema.fields.select') | translate"
[checked]="selected"
(change)="selectMetadataField(field, $event)">
</td>
<td class="selectable-row" (click)="editField(field)">{{field.id}}</td>
<td class="selectable-row" (click)="editField(field)">{{schema?.prefix}}.{{field.element}}{{field.qualifier ? '.' + field.qualifier : ''}}</td>
Expand Down
2 changes: 1 addition & 1 deletion src/app/collection-page/collection-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<!-- Collection logo -->
<ds-comcol-page-logo *ngIf="logoRD$"
[logo]="(logoRD$ | async)?.payload"
[alternateText]="'Collection Logo'">
[alternateText]="'collection.logo' | translate">
</ds-comcol-page-logo>

<!-- Handle -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<div class="container-fluid mb-2" *ngVar="(itemTemplateRD$ | async) as itemTemplateRD">
<label>{{ 'collection.edit.template.label' | translate}}</label>
<span class="d-inline-block mb-2">{{ 'collection.edit.template.label' | translate}}</span>
<div class="button-row space-children-mr">
<button *ngIf="!itemTemplateRD?.payload" class="btn btn-success" (click)="addItemTemplate()">
<i class="fas fa-plus"></i>
<i class="fas fa-plus" aria-hidden="true"></i>
<span class="d-none d-sm-inline">&nbsp;{{"collection.edit.template.add-button" | translate}}</span>
</button>
<button *ngIf="itemTemplateRD?.payload" class="btn btn-danger" (click)="deleteItemTemplate()">
<i class="fas fa-trash-alt"></i>
<i class="fas fa-trash-alt" aria-hidden="true"></i>
<span class="d-none d-sm-inline">&nbsp;{{"collection.edit.template.delete-button" | translate}}</span>
</button>
<button *ngIf="itemTemplateRD?.payload" class="btn btn-primary"
[routerLink]="'/collections/' + (dsoRD$ | async)?.payload.uuid + '/itemtemplate'">
<i class="fas fa-edit"></i>
<i class="fas fa-edit" aria-hidden="true"></i>
<span class="d-none d-sm-inline">&nbsp;{{"collection.edit.template.edit-button" | translate}}</span>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<cdk-tree-node *cdkTreeNodeDef="let node; when: isShowMore" cdkTreeNodePadding
class="example-tree-node show-more-node">
<div class="btn-group">
<button type="button" class="btn btn-default" cdkTreeNodeToggle>
<span class="fa fa-chevron-right invisible" aria-hidden="true"></span>
</button>
<span aria-hidden="true" class="btn btn-default invisible" cdkTreeNodeToggle>
<span class="fa fa-chevron-right"></span>
</span>
<div class="align-middle pt-2">
<button *ngIf="!(dataSource.loading$ | async)" (click)="getNextPage(node)"
class="btn btn-outline-primary btn-sm" role="button">
Expand All @@ -24,15 +24,18 @@
<cdk-tree-node *cdkTreeNodeDef="let node; when: hasChild" cdkTreeNodePadding
class="example-tree-node expandable-node">
<div class="btn-group">
<button type="button" class="btn btn-default" cdkTreeNodeToggle
[title]="'toggle ' + dsoNameService.getName(node.payload)"
[attr.aria-label]="'toggle ' + dsoNameService.getName(node.payload)"
<button *ngIf="hasChild(null, node) | async" type="button" class="btn btn-default" cdkTreeNodeToggle
[attr.aria-label]="(node.isExpanded ? 'communityList.collapse' : 'communityList.expand') | translate:{ name: dsoNameService.getName(node.payload) }"
(click)="toggleExpanded(node)"
[ngClass]="(hasChild(null, node)| async) ? 'visible' : 'invisible'"
[attr.data-test]="(hasChild(null, node)| async) ? 'expand-button' : ''">
data-test="expand-button">
<span class="{{node.isExpanded ? 'fa fa-chevron-down' : 'fa fa-chevron-right'}}"
aria-hidden="true"></span>
<span class="sr-only">{{ (node.isExpanded ? 'communityList.collapse' : 'communityList.expand') | translate:{ name: dsoNameService.getName(node.payload) } }}</span>
</button>
<!--Don't render the button when non-expandable otherwise it's still accessible, instead render this placeholder-->
<span *ngIf="!(hasChild(null, node) | async)" aria-hidden="true" class="btn btn-default invisible">
<span class="fa fa-chevron-right"></span>
</span>
<div class="d-flex flex-row">
<span class="align-middle pt-2 lead">
<a [routerLink]="node.route" class="lead">{{ dsoNameService.getName(node.payload) }}</a>
Expand All @@ -44,10 +47,9 @@
<ds-truncatable [id]="node.id">
<div class="text-muted" cdkTreeNodePadding>
<div class="d-flex" *ngIf="node.payload.shortDescription">
<button type="button" class="btn btn-default invisible">
<span class="{{node.isExpanded ? 'fa fa-chevron-down' : 'fa fa-chevron-right'}}"
aria-hidden="true"></span>
</button>
<span aria-hidden="true" class="btn btn-default invisible">
<span class="fa fa-chevron-right"></span>
</span>
<ds-truncatable-part [id]="node.id" [minLines]="3">
<span>{{node.payload.shortDescription}}</span>
</ds-truncatable-part>
Expand All @@ -56,31 +58,29 @@
</ds-truncatable>
<div class="d-flex" *ngIf="node===loadingNode && dataSource.loading$ | async"
cdkTreeNodePadding>
<button type="button" class="btn btn-default invisible">
<span class="{{node.isExpanded ? 'fa fa-chevron-down' : 'fa fa-chevron-right'}}"
aria-hidden="true"></span>
</button>
<span aria-hidden="true" class="btn btn-default invisible">
<span class="fa fa-chevron-right"></span>
</span>
<ds-themed-loading class="ds-themed-loading"></ds-themed-loading>
</div>
</cdk-tree-node>
<!-- This is the tree node template for leaf nodes (collections and (sub)coms without children) -->
<cdk-tree-node *cdkTreeNodeDef="let node; when: !(hasChild && isShowMore)" cdkTreeNodePadding
class="example-tree-node childless-node">
<div class="btn-group">
<button type="button" class="btn btn-default" cdkTreeNodeToggle>
<span class="fa fa-chevron-right invisible" aria-hidden="true"></span>
</button>
<span aria-hidden="true" class="btn btn-default invisible" cdkTreeNodeToggle>
<span class="fa fa-chevron-right"></span>
</span>
<h6 class="align-middle pt-2">
<a [routerLink]="node.route" class="lead">{{ dsoNameService.getName(node.payload) }}</a>
</h6>
</div>
<ds-truncatable [id]="node.id">
<div class="text-muted" cdkTreeNodePadding>
<div class="d-flex" *ngIf="node.payload.shortDescription">
<button type="button" class="btn btn-default invisible">
<span class="{{node.isExpanded ? 'fa fa-chevron-down' : 'fa fa-chevron-right'}}"
aria-hidden="true"></span>
</button>
<span aria-hidden="true" class="btn btn-default invisible">
<span class="fa fa-chevron-right"></span>
</span>
<ds-truncatable-part [id]="node.id" [minLines]="3">
<span>{{node.payload.shortDescription}}</span>
</ds-truncatable-part>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
::ng-deep .fa-chevron-right::before {
display: block;
width: 16px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { CommunityListService, showMoreFlatNode, toFlatNode } from '../community
import { CdkTreeModule } from '@angular/cdk/tree';
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CUSTOM_ELEMENTS_SCHEMA, DebugElement } from '@angular/core';
import { RouterTestingModule } from '@angular/router/testing';
import { Community } from '../../core/shared/community.model';
import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils';
Expand Down Expand Up @@ -300,12 +300,14 @@ describe('CommunityListComponent', () => {

describe('second top community node is expanded and has more children (collections) than page size of collection', () => {
describe('children of second top com are added (page-limited pageSize 2)', () => {
let allNodes;
let allNodes: DebugElement[];
beforeEach(fakeAsync(() => {
const chevronExpand = fixture.debugElement.queryAll(By.css('.expandable-node button'));
const chevronExpandSpan = fixture.debugElement.queryAll(By.css('.expandable-node button span'));
if (chevronExpandSpan[1].nativeElement.classList.contains('fa-chevron-right')) {
chevronExpand[1].nativeElement.click();
const toggleButtons: DebugElement[] = fixture.debugElement.queryAll(By.css('.expandable-node button'));
const toggleButtonText: DebugElement = toggleButtons[1].query(By.css('span'));
expect(toggleButtonText).not.toBeNull();

if (toggleButtonText.nativeElement.classList.contains('fa-chevron-right')) {
toggleButtons[1].nativeElement.click();
tick();
fixture.detectChanges();
}
Expand All @@ -315,17 +317,18 @@ describe('CommunityListComponent', () => {
allNodes = [...expandableNodesFound, ...childlessNodesFound];
}));
it('tree contains 2 (page-limited) top com, 2 (page-limited) coll of 2nd top com, a show more for those page-limited coll and show more for page-limited top com', () => {
mockTopFlatnodesUnexpanded.slice(0, 2).map((topFlatnode: FlatNode) => {
expect(allNodes.find((foundEl) => {
return (foundEl.nativeElement.textContent.trim() === topFlatnode.name);
})).toBeTruthy();
});
mockCollectionsPage1.map((coll) => {
expect(allNodes.find((foundEl) => {
return (foundEl.nativeElement.textContent.trim() === coll.name);
})).toBeTruthy();
});
const allNodeNames: string[] = allNodes.map((node: DebugElement) => node.nativeElement.innerText.trim());
expect(allNodes.length).toEqual(4);
const flatNodes: string[] = mockTopFlatnodesUnexpanded.slice(0, 2).map((flatNode: FlatNode) => flatNode.name);
for (const flatNode of flatNodes) {
expect(allNodeNames).toContain(flatNode);
}
expect(flatNodes.length).toBe(2);
const page1CollectionNames: string[] = mockCollectionsPage1.map((collection: Collection) => collection.name);
for (const collectionName of page1CollectionNames) {
expect(allNodeNames).toContain(collectionName);
}
expect(page1CollectionNames.length).toBe(2);
const showMoreEl = fixture.debugElement.queryAll(By.css('.show-more-node'));
expect(showMoreEl.length).toEqual(2);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { DSONameService } from '../../core/breadcrumbs/dso-name.service';
@Component({
selector: 'ds-community-list',
templateUrl: './community-list.component.html',
styleUrls: ['./community-list.component.scss'],
})
export class CommunityListComponent implements OnInit, OnDestroy {

Expand Down
2 changes: 1 addition & 1 deletion src/app/community-page/community-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- Community name -->
<ds-comcol-page-header [name]="dsoNameService.getName(communityPayload)"></ds-comcol-page-header>
<!-- Community logo -->
<ds-comcol-page-logo *ngIf="logoRD$" [logo]="(logoRD$ | async)?.payload" [alternateText]="'Community Logo'">
<ds-comcol-page-logo *ngIf="logoRD$" [logo]="(logoRD$ | async)?.payload" [alternateText]="'community.logo' | translate">
</ds-comcol-page-logo>
<!-- Handle -->
<ds-themed-comcol-page-handle [content]="communityPayload.handle" [title]="'community.page.handle'">
Expand Down
Loading

0 comments on commit 85369aa

Please sign in to comment.