Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #1602 Insufficient collection information when submitting an article #3327

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ds-truncatable-part [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'" [showToggle]="false">
<ds-truncatable-part [background]="isCurrent() ? 'primary' : 'default'" [showToggle]="false">
<div [ngClass]="isCurrent() ? 'text-light' : 'text-body'"
[innerHTML]="(parentTitle$ && parentTitle$ | async) ? (parentTitle$ | async) : ('home.breadcrumbs' | translate)"></div>
[innerHTML]="(hierarchicalTitle$ && hierarchicalTitle$ | async) ? (hierarchicalTitle$ | async) : ('home.breadcrumbs' | translate)"></div>
</ds-truncatable-part>
<ds-truncatable-part [maxLines]="1" [background]="isCurrent() ? 'primary' : 'default'" [showToggle]="false">
<div class="font-weight-bold"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
of as observableOf,
} from 'rxjs';
import {
catchError,
find,
map,
switchMap,
} from 'rxjs/operators';

import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
Expand Down Expand Up @@ -50,6 +52,11 @@
*/
parentTitle$: Observable<string>;

/**
* Observable for the hierarchical title i.e community > subcommunity > collection
*/
hierarchicalTitle$: Observable<string>;

/**
* A description to display below the title
*/
Expand All @@ -69,6 +76,7 @@
super.ngOnInit();
if (hasValue(this.dso)) {
this.parentTitle$ = this.getParentTitle();
this.hierarchicalTitle$ = this.getHierarchicalName();
this.description = this.getDescription();
}
}
Expand All @@ -92,6 +100,38 @@
);
}

/**
* 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<string> {
return this.getParent().pipe(
switchMap((parentRD: RemoteData<DSpaceObject>) => {
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('');

Check warning on line 118 in src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts#L118

Added line #L118 was not covered by tests
}
return observableOf('');

Check warning on line 120 in src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts

View check run for this annotation

Codecov / codecov/patch

src/app/shared/object-list/sidebar-search-list-element/sidebar-search-list-element.component.ts#L120

Added line #L120 was not covered by tests
}),
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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@
.removeFaded.content::after {
display: none;
}

.content {
white-space: normal;
overflow: visible;
}
Loading