mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Removed invisible buttons on the CommunityListComponent & fixed content displacement when expanding com/col
This commit is contained in:
@@ -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">
|
||||
@@ -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">
|
||||
@@ -46,10 +49,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>
|
||||
@@ -58,10 +60,9 @@
|
||||
</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>
|
||||
@@ -69,9 +70,9 @@
|
||||
<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) }}
|
||||
@@ -81,10 +82,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>
|
||||
|
@@ -0,0 +1,4 @@
|
||||
::ng-deep .fa-chevron-right::before {
|
||||
display: block;
|
||||
width: 16px;
|
||||
}
|
@@ -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';
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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);
|
||||
});
|
||||
|
@@ -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 {
|
||||
|
||||
|
@@ -1168,6 +1168,10 @@
|
||||
|
||||
"communityList.showMore": "Show More",
|
||||
|
||||
"communityList.expand": "Expand {{ name }}",
|
||||
|
||||
"communityList.collapse": "Collapse {{ name }}",
|
||||
|
||||
"community.create.head": "Create a Community",
|
||||
|
||||
"community.create.notifications.success": "Successfully created the Community",
|
||||
|
Reference in New Issue
Block a user