Skip to content
Snippets Groups Projects
Commit 971cf0eb authored by Lotte Hofstede's avatar Lotte Hofstede
Browse files

Merge branch 'entity-page-change-fix' into entities-or2018

parents 01ab627a 8ab6eb6e
No related branches found
No related tags found
No related merge requests found
<div class="container" *ngVar="(itemRDObs | async) as itemRD">
<div class="item-page" *ngIf="itemRD?.hasSucceeded" @fadeInOut>
<div class="item-page" *ngIf="(itemRDObs | async)?.hasSucceeded" @fadeInOut>
<div *ngIf="itemRD?.payload as item">
<ds-entity-type-switcher [object]="item" [viewMode]="ElementViewMode.Full"></ds-entity-type-switcher>
<ds-entity-type-switcher [object]="(itemRDObs | async)?.payload" [viewMode]="ElementViewMode.Full"></ds-entity-type-switcher>
</div>
</div>
<ds-error *ngIf="itemRD?.hasFailed" message="{{'error.item' | translate}}"></ds-error>
<ds-loading *ngIf="itemRD?.isLoading" message="{{'loading.item' | translate}}"></ds-loading>
<ds-error *ngIf="(itemRDObs | async)?.hasFailed" message="{{'error.item' | translate}}"></ds-error>
<ds-loading *ngIf="(itemRDObs | async)?.isLoading" message="{{'loading.item' | translate}}"></ds-loading>
</div>
......@@ -14,6 +14,7 @@ import { fadeInOut } from '../../shared/animations/fade';
import { hasValue } from '../../shared/empty.util';
import * as viewMode from '../../shared/view-mode';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Subscription } from 'rxjs/Subscription';
/**
* This component renders a simple item page.
......@@ -31,11 +32,11 @@ export class ItemPageComponent implements OnInit {
id: number;
private sub: any;
private sub: Subscription;
private itemSub: Subscription;
thumbnailObs: Observable<Bitstream>;
itemRDObs?: BehaviorSubject<RemoteData<Item>> = new BehaviorSubject(new RemoteData(true, true, false, null, null));
itemRDObs: BehaviorSubject<RemoteData<Item>> = new BehaviorSubject(new RemoteData(true, true, undefined, null, null));
ElementViewMode = viewMode.ElementViewMode;
......@@ -43,9 +44,7 @@ export class ItemPageComponent implements OnInit {
private route: ActivatedRoute,
private items: ItemDataService,
private metadataService: MetadataService,
) {
}
) { }
ngOnInit(): void {
this.sub = this.route.params.subscribe((params) => {
......@@ -56,7 +55,10 @@ export class ItemPageComponent implements OnInit {
initialize(params) {
this.id = +params.id;
this.items.findById(params.id).filter((rd) => hasValue(rd.payload)).first().subscribe((item) => this.itemRDObs.next(item));
if (hasValue(this.itemSub)) {
this.itemSub.unsubscribe();
}
this.itemSub = this.items.findById(params.id).subscribe((item) => this.itemRDObs.next(item));
this.metadataService.processRemoteData(this.itemRDObs);
this.thumbnailObs = this.itemRDObs
.map((rd: RemoteData<Item>) => rd.payload)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment