|
5 | 5 | import { Observable } from 'rxjs'; |
6 | 6 | import { map } from 'rxjs/operators'; |
7 | 7 |
|
| 8 | +import { getDSORoute } from '../../app-routing-paths'; |
8 | 9 | import { BreadcrumbConfig } from '../../breadcrumbs/breadcrumb/breadcrumb-config.model'; |
9 | 10 | import { hasValue } from '../../shared/empty.util'; |
10 | 11 | import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; |
@@ -32,15 +33,34 @@ export const DSOBreadcrumbResolver: (route: ActivatedRouteSnapshot, state: Route |
32 | 33 | dataService: IdentifiableDataService<DSpaceObject>, |
33 | 34 | ...linksToFollow: FollowLinkConfig<DSpaceObject>[] |
34 | 35 | ): Observable<BreadcrumbConfig<DSpaceObject>> => { |
35 | | - const uuid = route.params.id; |
| 36 | + return DSOBreadcrumbResolverByUuid(route, state, route.params.id, breadcrumbService, dataService, ...linksToFollow); |
| 37 | +}; |
| 38 | + |
| 39 | +/** |
| 40 | + * Method for resolving a breadcrumb config object with the given UUID |
| 41 | + * |
| 42 | + * @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot |
| 43 | + * @param {RouterStateSnapshot} state The current RouterStateSnapshot |
| 44 | + * @param {String} uuid The uuid of the DSO object |
| 45 | + * @param {DSOBreadcrumbsService} breadcrumbService |
| 46 | + * @param {IdentifiableDataService} dataService |
| 47 | + * @param linksToFollow |
| 48 | + * @returns BreadcrumbConfig object |
| 49 | + */ |
| 50 | +export const DSOBreadcrumbResolverByUuid: (route: ActivatedRouteSnapshot, state: RouterStateSnapshot, uuid: string, breadcrumbService: DSOBreadcrumbsService, dataService: IdentifiableDataService<DSpaceObject>, ...linksToFollow: FollowLinkConfig<DSpaceObject>[]) => Observable<BreadcrumbConfig<DSpaceObject>> = ( |
| 51 | + route: ActivatedRouteSnapshot, |
| 52 | + state: RouterStateSnapshot, |
| 53 | + uuid: string, |
| 54 | + breadcrumbService: DSOBreadcrumbsService, |
| 55 | + dataService: IdentifiableDataService<DSpaceObject>, |
| 56 | + ...linksToFollow: FollowLinkConfig<DSpaceObject>[] |
| 57 | +): Observable<BreadcrumbConfig<DSpaceObject>> => { |
36 | 58 | return dataService.findById(uuid, true, false, ...linksToFollow).pipe( |
37 | 59 | getFirstCompletedRemoteData(), |
38 | 60 | getRemoteDataPayload(), |
39 | 61 | map((object: DSpaceObject) => { |
40 | 62 | if (hasValue(object)) { |
41 | | - const fullPath = state.url; |
42 | | - const url = (fullPath.substring(0, fullPath.indexOf(uuid))).concat(uuid); |
43 | | - return { provider: breadcrumbService, key: object, url: url }; |
| 63 | + return { provider: breadcrumbService, key: object, url: getDSORoute(object) }; |
44 | 64 | } else { |
45 | 65 | return undefined; |
46 | 66 | } |
|
0 commit comments