From 938fa116051d5e397be06ef89b5ad8b6f036ef1f Mon Sep 17 00:00:00 2001 From: im-shubham-vish Date: Fri, 16 Aug 2024 12:34:48 +0530 Subject: [PATCH 1/5] Fix for #1602 Insufficient collection information when submitting an article. --- ...sidebar-search-list-element.component.html | 2 +- .../sidebar-search-list-element.component.ts | 30 ++++++++++++++++++- .../truncatable-part.component.scss | 5 ++++ 3 files changed, 35 insertions(+), 2 deletions(-) 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..e96753167d0 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,4 +1,4 @@ - +
diff --git a/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts b/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts index c262dee2594..bfeabd53472 100644 --- a/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts +++ b/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts @@ -12,6 +12,7 @@ import { import { find, map, + switchMap, } from 'rxjs/operators'; import { DSONameService } from '../../../core/breadcrumbs/dso-name.service'; @@ -65,7 +66,7 @@ export class SidebarSearchListElementComponent, K exte ngOnInit(): void { super.ngOnInit(); if (hasValue(this.dso)) { - this.parentTitle$ = this.getParentTitle(); + this.parentTitle$ = this.getHierarchicalName(); this.description = this.getDescription(); } } @@ -88,6 +89,33 @@ export class SidebarSearchListElementComponent, K exte }), ); } + + getHierarchicalName(): Observable { + return this.getParentTitle().pipe( + switchMap((parentTitle: string) => { + return this.getParent().pipe( + switchMap((parentRD: RemoteData) => { + if (hasValue(parentRD) && hasValue(parentRD.payload)) { + const parentInstance = this.createInstanceFromDSpaceObject(parentRD.payload); + return parentInstance.getHierarchicalName().pipe( + map((ancestorName: string) => ancestorName ? `${ancestorName} > ${parentTitle}` : parentTitle) + ); + } + return observableOf(parentTitle); + }) + ); + }) + ); + } + + /** + * 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; +} From da206d4669cf9077261feb150a33d69f942a33d7 Mon Sep 17 00:00:00 2001 From: im-shubham-vish Date: Fri, 13 Sep 2024 12:56:20 +0530 Subject: [PATCH 2/5] Fix for #1602 Insufficient collection information when submitting an article --- .../sidebar-search-list-element.component.ts | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts b/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts index c607d114edb..20847d3c75d 100644 --- a/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts +++ b/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts @@ -92,25 +92,25 @@ export class SidebarSearchListElementComponent, K exte }), ); } - + getHierarchicalName(): Observable { return this.getParentTitle().pipe( switchMap((parentTitle: string) => { - return this.getParent().pipe( - switchMap((parentRD: RemoteData) => { - if (hasValue(parentRD) && hasValue(parentRD.payload)) { - const parentInstance = this.createInstanceFromDSpaceObject(parentRD.payload); - return parentInstance.getHierarchicalName().pipe( - map((ancestorName: string) => ancestorName ? `${ancestorName} > ${parentTitle}` : parentTitle) - ); - } - return observableOf(parentTitle); - }) - ); - }) + return this.getParent().pipe( + switchMap((parentRD: RemoteData) => { + if (hasValue(parentRD) && hasValue(parentRD.payload)) { + const parentInstance = this.createInstanceFromDSpaceObject(parentRD.payload); + return parentInstance.getHierarchicalName().pipe( + map((ancestorName: string) => ancestorName ? `${ancestorName} > ${parentTitle}` : parentTitle), + ); + } + return observableOf(parentTitle); + }), + ); + }), ); } - + /** * Utility method to create an instance of the current class from a DSpaceObject */ From ecfa42bb760f9a6398564f3c74e4565844e5c94b Mon Sep 17 00:00:00 2001 From: im-shubham-vish Date: Fri, 20 Sep 2024 18:13:28 +0530 Subject: [PATCH 3/5] fix for 1602 Insufficient collection information when submitting an article --- ...sidebar-search-list-element.component.html | 2 +- .../sidebar-search-list-element.component.ts | 40 ++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) 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 e96753167d0..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,7 +75,8 @@ export class SidebarSearchListElementComponent, K exte ngOnInit(): void { super.ngOnInit(); if (hasValue(this.dso)) { - this.parentTitle$ = this.getHierarchicalName(); + this.parentTitle$ = this.getParentTitle(); + this.hierarchicalTitle$ = this.getHierarchicalName(); this.description = this.getDescription(); } } @@ -93,21 +100,26 @@ 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.getParentTitle().pipe( - switchMap((parentTitle: string) => { - return this.getParent().pipe( - switchMap((parentRD: RemoteData) => { - if (hasValue(parentRD) && hasValue(parentRD.payload)) { - const parentInstance = this.createInstanceFromDSpaceObject(parentRD.payload); - return parentInstance.getHierarchicalName().pipe( - map((ancestorName: string) => ancestorName ? `${ancestorName} > ${parentTitle}` : parentTitle), - ); - } - return observableOf(parentTitle); - }), - ); + 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('')), ); } From eeca811ecf21b4251a5a232d21cf50d6020aa109 Mon Sep 17 00:00:00 2001 From: im-shubham-vish Date: Sat, 19 Oct 2024 17:57:34 +0530 Subject: [PATCH 4/5] Fix for #1602 Insufficient collection information when submitting an article (removed no longer going to be use parentTitle var) --- ...ebar-search-list-element.component.spec.ts | 28 +++++++++++++++++- ...ebar-search-list-element.component.spec.ts | 29 ++++++++++++++++++- ...ebar-search-list-element.component.spec.ts | 29 ++++++++++++++++++- ...ebar-search-list-element.component.spec.ts | 29 ++++++++++++++++++- ...ebar-search-list-element.component.spec.ts | 8 ++--- .../sidebar-search-list-element.component.ts | 18 ------------ 6 files changed, 115 insertions(+), 26 deletions(-) diff --git a/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-issue/journal-issue-sidebar-search-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-issue/journal-issue-sidebar-search-list-element.component.spec.ts index 5cf06fdeade..643c5348c25 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-issue/journal-issue-sidebar-search-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-issue/journal-issue-sidebar-search-list-element.component.spec.ts @@ -1,3 +1,6 @@ +import { DSpaceObject } from 'src/app/core/shared/dspace-object.model'; +import { followLink } from 'src/app/shared/utils/follow-link-config.model'; + import { Collection } from '../../../../../core/shared/collection.model'; import { Item } from '../../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; @@ -36,7 +39,30 @@ const parent = Object.assign(new Collection(), { ], }, }); +function getExpectedHierarchicalTitle(parentObj: DSpaceObject, obj: ItemSearchResult): string { + let titles: string[] = [obj.indexableObject.metadata['dc.title'][0].value]; + let currentParent: DSpaceObject = parentObj; + + while (currentParent) { + titles.unshift(currentParent.metadata['dc.title'][0].value); + currentParent = this.getParent(); + } + + return titles.join(' > '); +} + +function getParent(): DSpaceObject { + if (this.dso && typeof this.dso.getParentLinkKey === 'function') { + const parentLinkKey = this.dso.getParentLinkKey(); + const parentObj = this.linkService.resolveLink(this.dso, followLink(parentLinkKey))[parentLinkKey]; + if (parentObj && parentObj.payload) { + return parentObj.payload; + } + } + return undefined; +} +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); describe('JournalIssueSidebarSearchListElementComponent', - createSidebarSearchListElementTests(JournalIssueSidebarSearchListElementComponent, object, parent, 'parent title', 'title', '5 - 7'), + createSidebarSearchListElementTests(JournalIssueSidebarSearchListElementComponent, object, parent, expectedHierarchicalTitle, 'title', '5 - 7'), ); diff --git a/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal/journal-sidebar-search-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal/journal-sidebar-search-list-element.component.spec.ts index a7c2af3806f..cf537b8743b 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal/journal-sidebar-search-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal/journal-sidebar-search-list-element.component.spec.ts @@ -1,3 +1,6 @@ +import { DSpaceObject } from 'src/app/core/shared/dspace-object.model'; +import { followLink } from 'src/app/shared/utils/follow-link-config.model'; + import { Collection } from '../../../../../core/shared/collection.model'; import { Item } from '../../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; @@ -35,6 +38,30 @@ const parent = Object.assign(new Collection(), { }, }); +function getExpectedHierarchicalTitle(parentObj: DSpaceObject, obj: ItemSearchResult): string { + let titles: string[] = [obj.indexableObject.metadata['dc.title'][0].value]; + let currentParent: DSpaceObject = parentObj; + + while (currentParent) { + titles.unshift(currentParent.metadata['dc.title'][0].value); + currentParent = this.getParent(); + } + + return titles.join(' > '); +} + +function getParent(): DSpaceObject { + if (this.dso && typeof this.dso.getParentLinkKey === 'function') { + const parentLinkKey = this.dso.getParentLinkKey(); + const parentObj = this.linkService.resolveLink(this.dso, followLink(parentLinkKey))[parentLinkKey]; + if (parentObj && parentObj.payload) { + return parentObj.payload; + } + } + return undefined; +} +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); + describe('JournalSidebarSearchListElementComponent', - createSidebarSearchListElementTests(JournalSidebarSearchListElementComponent, object, parent, 'parent title', 'title', '1234, 5678'), + createSidebarSearchListElementTests(JournalSidebarSearchListElementComponent, object, parent, expectedHierarchicalTitle, 'title', '1234, 5678'), ); diff --git a/src/app/shared/object-list/sidebar-search-list-element/collection/collection-sidebar-search-list-element.component.spec.ts b/src/app/shared/object-list/sidebar-search-list-element/collection/collection-sidebar-search-list-element.component.spec.ts index 5b0e07ba232..c0f6d98f798 100644 --- a/src/app/shared/object-list/sidebar-search-list-element/collection/collection-sidebar-search-list-element.component.spec.ts +++ b/src/app/shared/object-list/sidebar-search-list-element/collection/collection-sidebar-search-list-element.component.spec.ts @@ -1,3 +1,6 @@ +import { DSpaceObject } from 'src/app/core/shared/dspace-object.model'; +import { followLink } from 'src/app/shared/utils/follow-link-config.model'; + import { Collection } from '../../../../core/shared/collection.model'; import { Community } from '../../../../core/shared/community.model'; import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model'; @@ -32,6 +35,30 @@ const parent = Object.assign(new Community(), { }, }); +function getExpectedHierarchicalTitle(parentObj: DSpaceObject, obj: CollectionSearchResult): string { + let titles: string[] = [obj.indexableObject.metadata['dc.title'][0].value]; + let currentParent: DSpaceObject = parentObj; + + while (currentParent) { + titles.unshift(currentParent.metadata['dc.title'][0].value); + currentParent = this.getParent(); + } + + return titles.join(' > '); +} + +function getParent(): DSpaceObject { + if (this.dso && typeof this.dso.getParentLinkKey === 'function') { + const parentLinkKey = this.dso.getParentLinkKey(); + const parentObj = this.linkService.resolveLink(this.dso, followLink(parentLinkKey))[parentLinkKey]; + if (parentObj && parentObj.payload) { + return parentObj.payload; + } + } + return undefined; +} +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); + describe('CollectionSidebarSearchListElementComponent', - createSidebarSearchListElementTests(CollectionSidebarSearchListElementComponent, object, parent, 'parent title', 'title', 'description'), + createSidebarSearchListElementTests(CollectionSidebarSearchListElementComponent, object, parent, expectedHierarchicalTitle, 'title', 'description'), ); diff --git a/src/app/shared/object-list/sidebar-search-list-element/community/community-sidebar-search-list-element.component.spec.ts b/src/app/shared/object-list/sidebar-search-list-element/community/community-sidebar-search-list-element.component.spec.ts index f3114feda4e..17af62a7e05 100644 --- a/src/app/shared/object-list/sidebar-search-list-element/community/community-sidebar-search-list-element.component.spec.ts +++ b/src/app/shared/object-list/sidebar-search-list-element/community/community-sidebar-search-list-element.component.spec.ts @@ -1,3 +1,6 @@ +import { DSpaceObject } from 'src/app/core/shared/dspace-object.model'; +import { followLink } from 'src/app/shared/utils/follow-link-config.model'; + import { Community } from '../../../../core/shared/community.model'; import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; import { createSidebarSearchListElementTests } from '../sidebar-search-list-element.component.spec'; @@ -31,6 +34,30 @@ const parent = Object.assign(new Community(), { }, }); +function getExpectedHierarchicalTitle(parentObj: DSpaceObject, obj: CommunitySearchResult): string { + let titles: string[] = [obj.indexableObject.metadata['dc.title'][0].value]; + let currentParent: DSpaceObject = parentObj; + + while (currentParent) { + titles.unshift(currentParent.metadata['dc.title'][0].value); + currentParent = this.getParent(); + } + + return titles.join(' > '); +} + +function getParent(): DSpaceObject { + if (this.dso && typeof this.dso.getParentLinkKey === 'function') { + const parentLinkKey = this.dso.getParentLinkKey(); + const parentObj = this.linkService.resolveLink(this.dso, followLink(parentLinkKey))[parentLinkKey]; + if (parentObj && parentObj.payload) { + return parentObj.payload; + } + } + return undefined; +} +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); + describe('CommunitySidebarSearchListElementComponent', - createSidebarSearchListElementTests(CommunitySidebarSearchListElementComponent, object, parent, 'parent title', 'title', 'description'), + createSidebarSearchListElementTests(CommunitySidebarSearchListElementComponent, object, parent, expectedHierarchicalTitle, 'title', 'description'), ); diff --git a/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.spec.ts b/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.spec.ts index 22bf7fd52cc..75fb83430d3 100644 --- a/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.spec.ts +++ b/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.spec.ts @@ -22,7 +22,7 @@ export function createSidebarSearchListElementTests( componentClass: any, object: SearchResult, parent: DSpaceObject, - expectedParentTitle: string, + expectedHierarchicalTitle: string, expectedTitle: string, expectedDescription: string, extraProviders: any[] = [], @@ -59,9 +59,9 @@ export function createSidebarSearchListElementTests( fixture.detectChanges(); }); - it('should contain the correct parent title', (done) => { - component.parentTitle$.subscribe((title) => { - expect(title).toEqual(expectedParentTitle); + it('should contain the correct hierarchical title', (done) => { + component.hierarchicalTitle$.subscribe((title) => { + expect(title).toEqual(expectedHierarchicalTitle); done(); }); }); diff --git a/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts b/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts index 085a5b08631..54f3fe419f9 100644 --- a/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts +++ b/src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts @@ -47,11 +47,6 @@ import { SearchResultListElementComponent } from '../search-result-list-element/ * component by overriding the relevant methods of this component */ export class SidebarSearchListElementComponent, K extends DSpaceObject> extends SearchResultListElementComponent implements OnInit { - /** - * Observable for the title of the parent object (displayed above the object's title) - */ - parentTitle$: Observable; - /** * Observable for the hierarchical title i.e community > subcommunity > collection */ @@ -75,7 +70,6 @@ export class SidebarSearchListElementComponent, K exte ngOnInit(): void { super.ngOnInit(); if (hasValue(this.dso)) { - this.parentTitle$ = this.getParentTitle(); this.hierarchicalTitle$ = this.getHierarchicalName(); this.description = this.getDescription(); } @@ -88,18 +82,6 @@ export class SidebarSearchListElementComponent, K exte return this.context === Context.SideBarSearchModalCurrent; } - /** - * Get the title of the object's parent - * Retrieve the parent by using the object's parent link and retrieving its 'dc.title' metadata - */ - getParentTitle(): Observable { - return this.getParent().pipe( - map((parentRD: RemoteData) => { - return hasValue(parentRD) && hasValue(parentRD.payload) ? this.dsoNameService.getName(parentRD.payload) : undefined; - }), - ); - } - /** * 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 From be7cec4085e20d75fb1da0557c8da5e1cc751473 Mon Sep 17 00:00:00 2001 From: im-shubham-vish Date: Tue, 22 Oct 2024 13:20:40 +0530 Subject: [PATCH 5/5] Fix for #1602 Insufficient collection information when submitting an article(removed no longer use variable parentTitle) --- ...ebar-search-list-element.component.spec.ts | 73 +++++++++++++------ ...ebar-search-list-element.component.spec.ts | 54 +++++++++++++- ...ebar-search-list-element.component.spec.ts | 69 ++++++++++++------ ...ebar-search-list-element.component.spec.ts | 54 +++++++++++++- ...ebar-search-list-element.component.spec.ts | 55 +++++++++++++- ...ebar-search-list-element.component.spec.ts | 54 +++++++++++++- ...ebar-search-list-element.component.spec.ts | 66 +++++++++++------ ...ebar-search-list-element.component.spec.ts | 66 +++++++++++------ ...ebar-search-list-element.component.spec.ts | 54 +++++++++++++- 9 files changed, 439 insertions(+), 106 deletions(-) diff --git a/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-issue/journal-issue-sidebar-search-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-issue/journal-issue-sidebar-search-list-element.component.spec.ts index 643c5348c25..dc692644bda 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-issue/journal-issue-sidebar-search-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-issue/journal-issue-sidebar-search-list-element.component.spec.ts @@ -1,5 +1,11 @@ -import { DSpaceObject } from 'src/app/core/shared/dspace-object.model'; -import { followLink } from 'src/app/shared/utils/follow-link-config.model'; +import { + catchError, + Observable, + of, + switchMap, +} from 'rxjs'; +import { RemoteData } from 'src/app/core/data/remote-data'; +import { Community } from 'src/app/core/shared/community.model'; import { Collection } from '../../../../../core/shared/collection.model'; import { Item } from '../../../../../core/shared/item.model'; @@ -39,30 +45,53 @@ const parent = Object.assign(new Collection(), { ], }, }); -function getExpectedHierarchicalTitle(parentObj: DSpaceObject, obj: ItemSearchResult): string { - let titles: string[] = [obj.indexableObject.metadata['dc.title'][0].value]; - let currentParent: DSpaceObject = parentObj; - while (currentParent) { - titles.unshift(currentParent.metadata['dc.title'][0].value); - currentParent = this.getParent(); +function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable { + let titles: string[] = []; + if (obj.indexableObject.metadata['dc.title']) { + titles = [obj.indexableObject.metadata['dc.title'][0].value]; } + let currentParent: Collection = parentObj; - return titles.join(' > '); -} + const fetchParentTitles = (currParent: Collection | Community): Observable => { + if (!currParent) { + return of([]); + } -function getParent(): DSpaceObject { - if (this.dso && typeof this.dso.getParentLinkKey === 'function') { - const parentLinkKey = this.dso.getParentLinkKey(); - const parentObj = this.linkService.resolveLink(this.dso, followLink(parentLinkKey))[parentLinkKey]; - if (parentObj && parentObj.payload) { - return parentObj.payload; + if (currParent.parentCommunity) { + return currParent.parentCommunity.pipe( + switchMap((remoteData: RemoteData) => { + if (remoteData.hasSucceeded && remoteData.payload) { + const parentTitle = remoteData.payload.name; + titles.unshift(parentTitle); + return fetchParentTitles(remoteData.payload); + } + return of([]); + }), + catchError(() => of([])), + ); + } else { + return of([]); } - } - return undefined; + }; + + return fetchParentTitles(currentParent).pipe( + switchMap(() => titles.join(' > ')), + ); } -const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); -describe('JournalIssueSidebarSearchListElementComponent', - createSidebarSearchListElementTests(JournalIssueSidebarSearchListElementComponent, object, parent, expectedHierarchicalTitle, 'title', '5 - 7'), -); +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); +if (expectedHierarchicalTitle) { + expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => { + describe('JournalIssueSidebarSearchListElementComponent', () => { + createSidebarSearchListElementTests( + JournalIssueSidebarSearchListElementComponent, + object, + parent, + hierarchicalTitle, + 'title', + '1234, 5678', + ); + }); + }); +} diff --git a/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-volume/journal-volume-sidebar-search-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-volume/journal-volume-sidebar-search-list-element.component.spec.ts index 16f13945337..aa4e3a6d2be 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-volume/journal-volume-sidebar-search-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal-volume/journal-volume-sidebar-search-list-element.component.spec.ts @@ -1,3 +1,12 @@ +import { + catchError, + Observable, + of, + switchMap, +} from 'rxjs'; +import { RemoteData } from 'src/app/core/data/remote-data'; +import { Community } from 'src/app/core/shared/community.model'; + import { Collection } from '../../../../../core/shared/collection.model'; import { Item } from '../../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; @@ -40,6 +49,45 @@ const parent = Object.assign(new Collection(), { }, }); -describe('JournalVolumeSidebarSearchListElementComponent', - createSidebarSearchListElementTests(JournalVolumeSidebarSearchListElementComponent, object, parent, 'parent title', 'title', 'journal title (1) (2)'), -); +function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable { + let titles: string[] = []; + if (obj.indexableObject.metadata['dc.title']) { + titles = [obj.indexableObject.metadata['dc.title'][0].value]; + } + let currentParent: Collection = parentObj; + + const fetchParentTitles = (currParent: Collection | Community): Observable => { + if (!currParent) { + return of([]); + } + + if (currParent.parentCommunity) { + return currParent.parentCommunity.pipe( + switchMap((remoteData: RemoteData) => { + if (remoteData.hasSucceeded && remoteData.payload) { + const parentTitle = remoteData.payload.name; + titles.unshift(parentTitle); + return fetchParentTitles(remoteData.payload); + } + return of([]); + }), + catchError(() => of([])), + ); + } else { + return of([]); + } + }; + + return fetchParentTitles(currentParent).pipe( + switchMap(() => titles.join(' > ')), + ); +} + +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); +if (expectedHierarchicalTitle) { + expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => { + describe('JournalVolumeSidebarSearchListElementComponent', () => { + createSidebarSearchListElementTests(JournalVolumeSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', 'journal title (1) (2)'); + }); + }); +} diff --git a/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal/journal-sidebar-search-list-element.component.spec.ts b/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal/journal-sidebar-search-list-element.component.spec.ts index cf537b8743b..8b73d728b34 100644 --- a/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal/journal-sidebar-search-list-element.component.spec.ts +++ b/src/app/entity-groups/journal-entities/item-list-elements/sidebar-search-list-elements/journal/journal-sidebar-search-list-element.component.spec.ts @@ -1,5 +1,12 @@ -import { DSpaceObject } from 'src/app/core/shared/dspace-object.model'; -import { followLink } from 'src/app/shared/utils/follow-link-config.model'; +import { + catchError, + map, + Observable, + of, + switchMap, +} from 'rxjs'; +import { RemoteData } from 'src/app/core/data/remote-data'; +import { Community } from 'src/app/core/shared/community.model'; import { Collection } from '../../../../../core/shared/collection.model'; import { Item } from '../../../../../core/shared/item.model'; @@ -38,30 +45,48 @@ const parent = Object.assign(new Collection(), { }, }); -function getExpectedHierarchicalTitle(parentObj: DSpaceObject, obj: ItemSearchResult): string { - let titles: string[] = [obj.indexableObject.metadata['dc.title'][0].value]; - let currentParent: DSpaceObject = parentObj; - - while (currentParent) { - titles.unshift(currentParent.metadata['dc.title'][0].value); - currentParent = this.getParent(); +function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable { + let titles: string[] = []; + if (obj.indexableObject.metadata['dc.title']) { + titles = [obj.indexableObject.metadata['dc.title'][0].value]; } + let currentParent: Collection = parentObj; - return titles.join(' > '); -} + const fetchParentTitles = (currParent: Collection | Community): Observable => { + if (!currParent) { + return of([]); + } -function getParent(): DSpaceObject { - if (this.dso && typeof this.dso.getParentLinkKey === 'function') { - const parentLinkKey = this.dso.getParentLinkKey(); - const parentObj = this.linkService.resolveLink(this.dso, followLink(parentLinkKey))[parentLinkKey]; - if (parentObj && parentObj.payload) { - return parentObj.payload; + if (currParent.parentCommunity) { + return currParent.parentCommunity.pipe( + switchMap((remoteData: RemoteData) => { + if (remoteData.hasSucceeded && remoteData.payload) { + const parentTitle = remoteData.payload.name; + titles.unshift(parentTitle); + if (remoteData.payload) { + return fetchParentTitles(remoteData.payload); + } + } + return of([]); + }), + catchError(() => of([])), + map(() => titles), + ); } + }; + + if (fetchParentTitles(currentParent)) { + return fetchParentTitles(currentParent).pipe( + map(() => titles.join(' > ')), + ); } - return undefined; } -const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); -describe('JournalSidebarSearchListElementComponent', - createSidebarSearchListElementTests(JournalSidebarSearchListElementComponent, object, parent, expectedHierarchicalTitle, 'title', '1234, 5678'), -); +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); +if (expectedHierarchicalTitle) { + expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => { + describe('JournalSidebarSearchListElementComponent', () => { + createSidebarSearchListElementTests(JournalSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', '1234, 5678'); + }); + }); +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/org-unit/org-unit-sidebar-search-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/org-unit/org-unit-sidebar-search-list-element.component.spec.ts index 4d3f27f6ef4..352687de2d5 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/org-unit/org-unit-sidebar-search-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/org-unit/org-unit-sidebar-search-list-element.component.spec.ts @@ -1,3 +1,12 @@ +import { + catchError, + Observable, + of, + switchMap, +} from 'rxjs'; +import { RemoteData } from 'src/app/core/data/remote-data'; +import { Community } from 'src/app/core/shared/community.model'; + import { Collection } from '../../../../../core/shared/collection.model'; import { Item } from '../../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; @@ -37,6 +46,45 @@ const parent = Object.assign(new Collection(), { }, }); -describe('OrgUnitSidebarSearchListElementComponent', - createSidebarSearchListElementTests(OrgUnitSidebarSearchListElementComponent, object, parent, 'parent title', 'title', 'description'), -); +function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable { + let titles: string[] = []; + if (obj.indexableObject.metadata['dc.title']) { + titles = [obj.indexableObject.metadata['dc.title'][0].value]; + } + let currentParent: Collection = parentObj; + + const fetchParentTitles = (currParent: Collection | Community): Observable => { + if (!currParent) { + return of([]); + } + + if (currParent.parentCommunity) { + return currParent.parentCommunity.pipe( + switchMap((remoteData: RemoteData) => { + if (remoteData.hasSucceeded && remoteData.payload) { + const parentTitle = remoteData.payload.name; + titles.unshift(parentTitle); + return fetchParentTitles(remoteData.payload); + } + return of([]); + }), + catchError(() => of([])), + ); + } else { + return of([]); + } + }; + + return fetchParentTitles(currentParent).pipe( + switchMap(() => titles.join(' > ')), + ); +} + +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); +if (expectedHierarchicalTitle) { + expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => { + describe('OrgUnitSidebarSearchListElementComponent', () => { + createSidebarSearchListElementTests(OrgUnitSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', 'description'); + }); + }); +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/person/person-sidebar-search-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/person/person-sidebar-search-list-element.component.spec.ts index 6e614c58114..9ba619637bd 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/person/person-sidebar-search-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/person/person-sidebar-search-list-element.component.spec.ts @@ -1,3 +1,12 @@ +import { + catchError, + Observable, + of, + switchMap, +} from 'rxjs'; +import { RemoteData } from 'src/app/core/data/remote-data'; +import { Community } from 'src/app/core/shared/community.model'; + import { Collection } from '../../../../../core/shared/collection.model'; import { Item } from '../../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; @@ -42,7 +51,45 @@ const parent = Object.assign(new Collection(), { }, }); -describe('PersonSidebarSearchListElementComponent', - createSidebarSearchListElementTests(PersonSidebarSearchListElementComponent, object, parent, 'parent title', 'family name, given name', 'job title', [ - ]), -); +function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable { + let titles: string[] = []; + if (obj.indexableObject.metadata['dc.title']) { + titles = [obj.indexableObject.metadata['dc.title'][0].value]; + } + let currentParent: Collection = parentObj; + + const fetchParentTitles = (currParent: Collection | Community): Observable => { + if (!currParent) { + return of([]); + } + + if (currParent.parentCommunity) { + return currParent.parentCommunity.pipe( + switchMap((remoteData: RemoteData) => { + if (remoteData.hasSucceeded && remoteData.payload) { + const parentTitle = remoteData.payload.name; + titles.unshift(parentTitle); + return fetchParentTitles(remoteData.payload); + } + return of([]); + }), + catchError(() => of([])), + ); + } else { + return of([]); + } + }; + + return fetchParentTitles(currentParent).pipe( + switchMap(() => titles.join(' > ')), + ); +} + +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); +if (expectedHierarchicalTitle) { + expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => { + describe('PersonSidebarSearchListElementComponent', () => { + createSidebarSearchListElementTests(PersonSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'family name,given name', 'job title', []); + }); + }); +} diff --git a/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/project/project-sidebar-search-list-element.component.spec.ts b/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/project/project-sidebar-search-list-element.component.spec.ts index a7be69965fc..becb8842a41 100644 --- a/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/project/project-sidebar-search-list-element.component.spec.ts +++ b/src/app/entity-groups/research-entities/item-list-elements/sidebar-search-list-elements/project/project-sidebar-search-list-element.component.spec.ts @@ -1,3 +1,12 @@ +import { + catchError, + Observable, + of, + switchMap, +} from 'rxjs'; +import { RemoteData } from 'src/app/core/data/remote-data'; +import { Community } from 'src/app/core/shared/community.model'; + import { Collection } from '../../../../../core/shared/collection.model'; import { Item } from '../../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model'; @@ -27,6 +36,45 @@ const parent = Object.assign(new Collection(), { }, }); -describe('ProjectSidebarSearchListElementComponent', - createSidebarSearchListElementTests(ProjectSidebarSearchListElementComponent, object, parent, 'parent title', 'title', undefined), -); +function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable { + let titles: string[] = []; + if (obj.indexableObject.metadata['dc.title']) { + titles = [obj.indexableObject.metadata['dc.title'][0].value]; + } + let currentParent: Collection = parentObj; + + const fetchParentTitles = (currParent: Collection | Community): Observable => { + if (!currParent) { + return of([]); + } + + if (currParent.parentCommunity) { + return currParent.parentCommunity.pipe( + switchMap((remoteData: RemoteData) => { + if (remoteData.hasSucceeded && remoteData.payload) { + const parentTitle = remoteData.payload.name; + titles.unshift(parentTitle); + return fetchParentTitles(remoteData.payload); + } + return of([]); + }), + catchError(() => of([])), + ); + } else { + return of([]); + } + }; + + return fetchParentTitles(currentParent).pipe( + switchMap(() => titles.join(' > ')), + ); +} + +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); +if (expectedHierarchicalTitle) { + expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => { + describe('ProjectSidebarSearchListElementComponent', () => { + createSidebarSearchListElementTests(ProjectSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', undefined); + }); + }); +} diff --git a/src/app/shared/object-list/sidebar-search-list-element/collection/collection-sidebar-search-list-element.component.spec.ts b/src/app/shared/object-list/sidebar-search-list-element/collection/collection-sidebar-search-list-element.component.spec.ts index c0f6d98f798..1109b32621e 100644 --- a/src/app/shared/object-list/sidebar-search-list-element/collection/collection-sidebar-search-list-element.component.spec.ts +++ b/src/app/shared/object-list/sidebar-search-list-element/collection/collection-sidebar-search-list-element.component.spec.ts @@ -1,5 +1,10 @@ -import { DSpaceObject } from 'src/app/core/shared/dspace-object.model'; -import { followLink } from 'src/app/shared/utils/follow-link-config.model'; +import { + catchError, + Observable, + of, + switchMap, +} from 'rxjs'; +import { RemoteData } from 'src/app/core/data/remote-data'; import { Collection } from '../../../../core/shared/collection.model'; import { Community } from '../../../../core/shared/community.model'; @@ -35,30 +40,45 @@ const parent = Object.assign(new Community(), { }, }); -function getExpectedHierarchicalTitle(parentObj: DSpaceObject, obj: CollectionSearchResult): string { - let titles: string[] = [obj.indexableObject.metadata['dc.title'][0].value]; - let currentParent: DSpaceObject = parentObj; - - while (currentParent) { - titles.unshift(currentParent.metadata['dc.title'][0].value); - currentParent = this.getParent(); +function getExpectedHierarchicalTitle(parentObj: Community, obj: CollectionSearchResult): Observable { + let titles: string[] = []; + if (obj.indexableObject.metadata['dc.title']) { + titles = [obj.indexableObject.metadata['dc.title'][0].value]; } + let currentParent: Community = parentObj; - return titles.join(' > '); -} + const fetchParentTitles = (currParent: Collection | Community): Observable => { + if (!currParent) { + return of([]); + } -function getParent(): DSpaceObject { - if (this.dso && typeof this.dso.getParentLinkKey === 'function') { - const parentLinkKey = this.dso.getParentLinkKey(); - const parentObj = this.linkService.resolveLink(this.dso, followLink(parentLinkKey))[parentLinkKey]; - if (parentObj && parentObj.payload) { - return parentObj.payload; + if (currParent.parentCommunity) { + return currParent.parentCommunity.pipe( + switchMap((remoteData: RemoteData) => { + if (remoteData.hasSucceeded && remoteData.payload) { + const parentTitle = remoteData.payload.name; + titles.unshift(parentTitle); + return fetchParentTitles(remoteData.payload); + } + return of([]); + }), + catchError(() => of([])), + ); + } else { + return of([]); } - } - return undefined; + }; + + return fetchParentTitles(currentParent).pipe( + switchMap(() => titles.join(' > ')), + ); } -const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); -describe('CollectionSidebarSearchListElementComponent', - createSidebarSearchListElementTests(CollectionSidebarSearchListElementComponent, object, parent, expectedHierarchicalTitle, 'title', 'description'), -); +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); +if (expectedHierarchicalTitle) { + expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => { + describe('CollectionSidebarSearchListElementComponent', () => { + createSidebarSearchListElementTests(CollectionSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', 'description'); + }); + }); +} diff --git a/src/app/shared/object-list/sidebar-search-list-element/community/community-sidebar-search-list-element.component.spec.ts b/src/app/shared/object-list/sidebar-search-list-element/community/community-sidebar-search-list-element.component.spec.ts index 17af62a7e05..626081ca7f6 100644 --- a/src/app/shared/object-list/sidebar-search-list-element/community/community-sidebar-search-list-element.component.spec.ts +++ b/src/app/shared/object-list/sidebar-search-list-element/community/community-sidebar-search-list-element.component.spec.ts @@ -1,5 +1,10 @@ -import { DSpaceObject } from 'src/app/core/shared/dspace-object.model'; -import { followLink } from 'src/app/shared/utils/follow-link-config.model'; +import { + catchError, + Observable, + of, + switchMap, +} from 'rxjs'; +import { RemoteData } from 'src/app/core/data/remote-data'; import { Community } from '../../../../core/shared/community.model'; import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model'; @@ -34,30 +39,45 @@ const parent = Object.assign(new Community(), { }, }); -function getExpectedHierarchicalTitle(parentObj: DSpaceObject, obj: CommunitySearchResult): string { - let titles: string[] = [obj.indexableObject.metadata['dc.title'][0].value]; - let currentParent: DSpaceObject = parentObj; - - while (currentParent) { - titles.unshift(currentParent.metadata['dc.title'][0].value); - currentParent = this.getParent(); +function getExpectedHierarchicalTitle(parentObj: Community, obj: CommunitySearchResult): Observable { + let titles: string[] = []; + if (obj.indexableObject.metadata['dc.title']) { + titles = [obj.indexableObject.metadata['dc.title'][0].value]; } + let currentParent: Community = parentObj; - return titles.join(' > '); -} + const fetchParentTitles = (currParent: Community): Observable => { + if (!currParent) { + return of([]); + } -function getParent(): DSpaceObject { - if (this.dso && typeof this.dso.getParentLinkKey === 'function') { - const parentLinkKey = this.dso.getParentLinkKey(); - const parentObj = this.linkService.resolveLink(this.dso, followLink(parentLinkKey))[parentLinkKey]; - if (parentObj && parentObj.payload) { - return parentObj.payload; + if (currParent.parentCommunity) { + return currParent.parentCommunity.pipe( + switchMap((remoteData: RemoteData) => { + if (remoteData.hasSucceeded && remoteData.payload) { + const parentTitle = remoteData.payload.name; + titles.unshift(parentTitle); + return fetchParentTitles(remoteData.payload); + } + return of([]); + }), + catchError(() => of([])), + ); + } else { + return of([]); } - } - return undefined; + }; + + return fetchParentTitles(currentParent).pipe( + switchMap(() => titles.join(' > ')), + ); } -const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); -describe('CommunitySidebarSearchListElementComponent', - createSidebarSearchListElementTests(CommunitySidebarSearchListElementComponent, object, parent, expectedHierarchicalTitle, 'title', 'description'), -); +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); +if (expectedHierarchicalTitle) { + expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => { + describe('CommunitySidebarSearchListElementComponent', () => { + createSidebarSearchListElementTests(CommunitySidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', 'description'); + }); + }); +} diff --git a/src/app/shared/object-list/sidebar-search-list-element/item-types/publication/publication-sidebar-search-list-element.component.spec.ts b/src/app/shared/object-list/sidebar-search-list-element/item-types/publication/publication-sidebar-search-list-element.component.spec.ts index d078d8e1c5b..d7f9e38dec4 100644 --- a/src/app/shared/object-list/sidebar-search-list-element/item-types/publication/publication-sidebar-search-list-element.component.spec.ts +++ b/src/app/shared/object-list/sidebar-search-list-element/item-types/publication/publication-sidebar-search-list-element.component.spec.ts @@ -1,3 +1,12 @@ +import { + catchError, + Observable, + of, + switchMap, +} from 'rxjs'; +import { RemoteData } from 'src/app/core/data/remote-data'; +import { Community } from 'src/app/core/shared/community.model'; + import { Collection } from '../../../../../core/shared/collection.model'; import { Item } from '../../../../../core/shared/item.model'; import { ItemSearchResult } from '../../../../object-collection/shared/item-search-result.model'; @@ -42,6 +51,45 @@ const parent = Object.assign(new Collection(), { }, }); -describe('PublicationSidebarSearchListElementComponent', - createSidebarSearchListElementTests(PublicationSidebarSearchListElementComponent, object, parent, 'parent title', 'title', '(publisher, date) author'), -); +function getExpectedHierarchicalTitle(parentObj: Collection, obj: ItemSearchResult): Observable { + let titles: string[] = []; + if (obj.indexableObject.metadata['dc.title']) { + titles = [obj.indexableObject.metadata['dc.title'][0].value]; + } + let currentParent: Collection = parentObj; + + const fetchParentTitles = (currParent: Collection | Community): Observable => { + if (!currParent) { + return of([]); + } + + if (currParent.parentCommunity) { + return currParent.parentCommunity.pipe( + switchMap((remoteData: RemoteData) => { + if (remoteData.hasSucceeded && remoteData.payload) { + const parentTitle = remoteData.payload.name; + titles.unshift(parentTitle); + return fetchParentTitles(remoteData.payload); + } + return of([]); + }), + catchError(() => of([])), + ); + } else { + return of([]); + } + }; + + return fetchParentTitles(currentParent).pipe( + switchMap(() => titles.join(' > ')), + ); +} + +const expectedHierarchicalTitle = getExpectedHierarchicalTitle(parent, object); +if (expectedHierarchicalTitle) { + expectedHierarchicalTitle.subscribe((hierarchicalTitle: string) => { + describe('PublicationSidebarSearchListElementComponent', () => { + createSidebarSearchListElementTests(PublicationSidebarSearchListElementComponent, object, parent, hierarchicalTitle, 'title', '(publisher, date) author'); + }); + }); +}