mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
78 lines
2.3 KiB
TypeScript
78 lines
2.3 KiB
TypeScript
import { filter, map } from 'rxjs/operators';
|
|
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
|
|
import { ActivatedRoute, Data, Router } from '@angular/router';
|
|
|
|
import { Observable , BehaviorSubject } from 'rxjs';
|
|
|
|
import { ItemPageComponent } from '../simple/item-page.component';
|
|
import { MetadataMap } from '../../core/shared/metadata.models';
|
|
import { ItemDataService } from '../../core/data/item-data.service';
|
|
|
|
import { RemoteData } from '../../core/data/remote-data';
|
|
import { Item } from '../../core/shared/item.model';
|
|
|
|
import { fadeInOut } from '../../shared/animations/fade';
|
|
import { hasValue } from '../../shared/empty.util';
|
|
import { AuthService } from '../../core/auth/auth.service';
|
|
import { Location } from '@angular/common';
|
|
|
|
|
|
/**
|
|
* This component renders a full item page.
|
|
* The route parameter 'id' is used to request the item it represents.
|
|
*/
|
|
|
|
@Component({
|
|
selector: 'ds-full-item-page',
|
|
styleUrls: ['./full-item-page.component.scss'],
|
|
templateUrl: './full-item-page.component.html',
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
animations: [fadeInOut]
|
|
})
|
|
export class FullItemPageComponent extends ItemPageComponent implements OnInit, OnDestroy {
|
|
|
|
itemRD$: BehaviorSubject<RemoteData<Item>>;
|
|
|
|
metadata$: Observable<MetadataMap>;
|
|
|
|
/**
|
|
* True when the itemRD has been originated from its workflowitem, false otherwise.
|
|
*/
|
|
fromWfi = false;
|
|
|
|
subs = [];
|
|
|
|
constructor(protected route: ActivatedRoute,
|
|
router: Router,
|
|
items: ItemDataService,
|
|
authService: AuthService,
|
|
private _location: Location) {
|
|
super(route, router, items, authService);
|
|
}
|
|
|
|
/*** AoT inheritance fix, will hopefully be resolved in the near future **/
|
|
ngOnInit(): void {
|
|
super.ngOnInit();
|
|
this.metadata$ = this.itemRD$.pipe(
|
|
map((rd: RemoteData<Item>) => rd.payload),
|
|
filter((item: Item) => hasValue(item)),
|
|
map((item: Item) => item.metadata),);
|
|
|
|
this.subs.push(this.route.data.subscribe((data: Data) => {
|
|
this.fromWfi = hasValue(data.wfi);
|
|
})
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Navigate back in browser history.
|
|
*/
|
|
back() {
|
|
this._location.back();
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe());
|
|
}
|
|
}
|