Skip to content

Commit

Permalink
Fix for DSpace#1602 Insufficient collection information when submitti…
Browse files Browse the repository at this point in the history
…ng an article.
  • Loading branch information
im-shubham-vish committed Aug 16, 2024
1 parent 1efa886 commit 938fa11
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<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>
</ds-truncatable-part>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import {
find,
map,
switchMap,
} from 'rxjs/operators';

import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
Expand Down Expand Up @@ -65,7 +66,7 @@ export class SidebarSearchListElementComponent<T extends SearchResult<K>, K exte
ngOnInit(): void {
super.ngOnInit();
if (hasValue(this.dso)) {
this.parentTitle$ = this.getParentTitle();
this.parentTitle$ = this.getHierarchicalName();
this.description = this.getDescription();
}
}
Expand All @@ -88,6 +89,33 @@ export class SidebarSearchListElementComponent<T extends SearchResult<K>, K exte
}),
);
}

getHierarchicalName(): Observable<string> {
return this.getParentTitle().pipe(
switchMap((parentTitle: string) => {
return this.getParent().pipe(
switchMap((parentRD: RemoteData<DSpaceObject>) => {
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
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;
}

0 comments on commit 938fa11

Please sign in to comment.