[AAE-4569] Added readOnly property to breadcrumb components (#6636)

* [AAE-4569] Added readOnly property to breadcrumb components

* [AAE-4569] Add method for testing if an anchor element should be used

* [AAE-4569] Add missing return type

* [AAE-4569] Add unit test
This commit is contained in:
Thomas Hunter
2021-02-09 12:57:42 +01:00
committed by GitHub
parent 2071596fe6
commit 0ba2c7dc45
6 changed files with 30 additions and 5 deletions

View File

@@ -92,6 +92,10 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
return !!this.root;
}
/** If true, prevents the user from navigating away from the active node. */
@Input()
readOnly: boolean = false;
/** Emitted when the user clicks on a breadcrumb. */
@Output()
navigate = new EventEmitter<PathElementEntity>();
@@ -178,12 +182,16 @@ export class BreadcrumbComponent implements OnInit, OnChanges, OnDestroy {
return position;
}
breadcrumbItemIsAnchor(lastItem): boolean {
return !this.readOnly && !lastItem;
}
onRoutePathClick(route: PathElementEntity, event?: Event): void {
if (event && event.type === 'click') {
event.preventDefault();
}
if (route) {
if (route && !this.readOnly) {
this.navigate.emit(route);
if (this.target) {