diff --git a/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.html b/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.html index 040f528768d..a8f7cfb5dc5 100644 --- a/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.html +++ b/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.html @@ -1,6 +1,6 @@ - +
+ [innerHTML]="(hierarchicalTitle$ && hierarchicalTitle$ | async) ? (hierarchicalTitle$ | async) : ('home.breadcrumbs' | translate)">
, K exte */ parentTitle$: Observable; + /** + * Observable for the hierarchical title i.e community > subcommunity > collection + */ + hierarchicalTitle$: Observable; + /** * A description to display below the title */ @@ -69,6 +76,7 @@ export class SidebarSearchListElementComponent, K exte super.ngOnInit(); if (hasValue(this.dso)) { this.parentTitle$ = this.getParentTitle(); + this.hierarchicalTitle$ = this.getHierarchicalName(); this.description = this.getDescription(); } } @@ -92,6 +100,38 @@ export class SidebarSearchListElementComponent, K exte ); } + /** + * Get the title of the object's parent + * keep on Retrieving recursively the parent by using the object's parent link and retrieving its 'dc.title' metadata + * and build a heirarchical name by concating the parent's names + */ + getHierarchicalName(): Observable { + return this.getParent().pipe( + switchMap((parentRD: RemoteData) => { + if (hasValue(parentRD) && hasValue(parentRD.payload)) { + const parentName$: string = this.dsoNameService.getName(parentRD.payload); + if (parentName$) { + return this.createInstanceFromDSpaceObject(parentRD.payload).getHierarchicalName().pipe( + map((ancestorName: string) => ancestorName ? `${ancestorName} > ${parentName$}` : parentName$), + ); + } + return observableOf(''); + } + return observableOf(''); + }), + catchError(() => observableOf('')), + ); + } + + /** + * Utility method to create an instance of the current class from a DSpaceObject + */ + private createInstanceFromDSpaceObject(dso: DSpaceObject): this { + const instance = Object.create(this); + instance.dso = dso; + return instance; + } + /** * Get the parent of the object */ diff --git a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss index e045b197d28..5602606a5c2 100644 --- a/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss +++ b/src/app/shared/truncatable/truncatable-part/truncatable-part.component.scss @@ -9,3 +9,8 @@ .removeFaded.content::after { display: none; } + +.content { + white-space: normal; + overflow: visible; +}