diff --git a/src/app/core/breadcrumbs/bitstream-breadcrumb.resolver.ts b/src/app/core/breadcrumbs/bitstream-breadcrumb.resolver.ts index 00be49166c..de8da19a41 100644 --- a/src/app/core/breadcrumbs/bitstream-breadcrumb.resolver.ts +++ b/src/app/core/breadcrumbs/bitstream-breadcrumb.resolver.ts @@ -1,10 +1,16 @@ import { Injectable } from '@angular/core'; import { DSOBreadcrumbsService } from './dso-breadcrumbs.service'; -import { DSOBreadcrumbResolver } from './dso-breadcrumb.resolver'; import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; import { Bitstream } from '../shared/bitstream.model'; import { BitstreamDataService } from '../data/bitstream-data.service'; import { BITSTREAM_PAGE_LINKS_TO_FOLLOW } from 'src/app/bitstream-page/bitstream-page.resolver'; +import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; +import { Observable } from 'rxjs'; +import { BreadcrumbConfig } from 'src/app/breadcrumbs/breadcrumb/breadcrumb-config.model'; +import { getFirstCompletedRemoteData, getRemoteDataPayload } from '../shared/operators'; +import { map } from 'rxjs/operators'; +import { hasValue } from 'src/app/shared/empty.util'; +import { DSOBreadcrumbResolver } from './dso-breadcrumb.resolver'; /** * The class that resolves the BreadcrumbConfig object for an Item @@ -17,6 +23,29 @@ export class BitstreamBreadcrumbResolver extends DSOBreadcrumbResolver> { + const uuid = route.params.id; + return this.dataService.findById(uuid, true, false, ...this.followLinks).pipe( + getFirstCompletedRemoteData(), + getRemoteDataPayload(), + map((object: Bitstream) => { + 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; + } + }) + ); + } + /** * Method that returns the follow links to already resolve * The self links defined in this list are expected to be requested somewhere in the near future