mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
74053: fix issue #865
This commit is contained in:
@@ -4,11 +4,12 @@ import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/r
|
||||
import { DSOBreadcrumbsService } from './dso-breadcrumbs.service';
|
||||
import { DataService } from '../data/data.service';
|
||||
import { getRemoteDataPayload, getSucceededRemoteData } from '../shared/operators';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { filter, find, map, take } from 'rxjs/operators';
|
||||
import { Observable } from 'rxjs';
|
||||
import { DSpaceObject } from '../shared/dspace-object.model';
|
||||
import { ChildHALResource } from '../shared/child-hal-resource.model';
|
||||
import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model';
|
||||
import { hasValue } from '../../shared/empty.util';
|
||||
|
||||
/**
|
||||
* The class that resolves the BreadcrumbConfig object for a DSpaceObject
|
||||
@@ -29,12 +30,17 @@ export abstract class DSOBreadcrumbResolver<T extends ChildHALResource & DSpaceO
|
||||
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<BreadcrumbConfig<T>> {
|
||||
const uuid = route.params.id;
|
||||
return this.dataService.findById(uuid, ...this.followLinks).pipe(
|
||||
getSucceededRemoteData(),
|
||||
filter((rd) => hasValue(rd.error) || hasValue(rd.payload)),
|
||||
take(1),
|
||||
getRemoteDataPayload(),
|
||||
map((object: T) => {
|
||||
if (hasValue(object)) {
|
||||
const fullPath = state.url;
|
||||
const url = fullPath.substr(0, fullPath.indexOf(uuid)) + uuid;
|
||||
return {provider: this.breadcrumbService, key: object, url: url};
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user