mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 22:43:03 +00:00

Conflicts: package.json src/app/+search-page/search-filters/search-filters.component.ts src/app/core/auth/auth.effects.ts src/app/core/auth/auth.service.ts src/app/core/auth/server-auth.service.ts src/app/core/data/data.service.ts src/app/header/header.component.spec.ts src/app/shared/auth-nav-menu/auth-nav-menu.component.ts src/app/shared/testing/auth-service-stub.ts yarn.lock
29 lines
1.2 KiB
TypeScript
29 lines
1.2 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/router';
|
|
import { Observable } from 'rxjs';
|
|
import { RemoteData } from '../core/data/remote-data';
|
|
import { getSucceededRemoteData } from '../core/shared/operators';
|
|
import { ItemDataService } from '../core/data/item-data.service';
|
|
import { Item } from '../core/shared/item.model';
|
|
|
|
/**
|
|
* This class represents a resolver that requests a specific item before the route is activated
|
|
*/
|
|
@Injectable()
|
|
export class ItemPageResolver implements Resolve<RemoteData<Item>> {
|
|
constructor(private itemService: ItemDataService) {
|
|
}
|
|
|
|
/**
|
|
* Method for resolving an item based on the parameters in the current route
|
|
* @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot
|
|
* @param {RouterStateSnapshot} state The current RouterStateSnapshot
|
|
* @returns Observable<<RemoteData<Item>> Emits the found item based on the parameters in the current route
|
|
*/
|
|
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<RemoteData<Item>> {
|
|
return this.itemService.findById(route.params.id).pipe(
|
|
getSucceededRemoteData()
|
|
);
|
|
}
|
|
}
|