1- import { Component } from '@angular/core' ;
2- import { filter , map , shareReplay } from 'rxjs/operators' ;
1+ import { Component , OnInit } from '@angular/core' ;
2+ import { filter , map , take } from 'rxjs/operators' ;
33import { RemoteData } from '../../../core/data/remote-data' ;
44import { Observable } from 'rxjs' ;
55import { ActivatedRoute } from '@angular/router' ;
66import { DSONameService } from '../../../core/breadcrumbs/dso-name.service' ;
7- import { Collection } from '../../../core/shared/collection.model' ;
87import { hasValue } from '../../../shared/empty.util' ;
8+ import { Item } from '../../../core/shared/item.model' ;
99
1010/**
1111 * Component for managing a collection's curation tasks
@@ -14,22 +14,26 @@ import { hasValue } from '../../../shared/empty.util';
1414 selector : 'ds-item-curate' ,
1515 templateUrl : './item-curate.component.html' ,
1616} )
17- export class ItemCurateComponent {
18- dsoRD$ : Observable < RemoteData < Collection > > = this . route . parent . data . pipe (
19- map ( ( data ) => data . dso ) ,
20- shareReplay ( 1 )
21- ) ;
22-
23- itemName$ : Observable < string > = this . dsoRD$ . pipe (
24- filter ( ( rd : RemoteData < Collection > ) => hasValue ( rd ) ) ,
25- map ( ( rd : RemoteData < Collection > ) => {
26- console . log ( rd ) ;
27- return this . dsoNameService . getName ( rd . payload ) ;
28- } )
29- ) ;
17+ export class ItemCurateComponent implements OnInit {
18+ dsoRD$ : Observable < RemoteData < Item > > ;
19+ itemName$ : Observable < string > ;
3020
3121 constructor (
3222 private route : ActivatedRoute ,
3323 private dsoNameService : DSONameService ,
3424 ) { }
25+
26+ ngOnInit ( ) : void {
27+ this . dsoRD$ = this . route . parent . data . pipe (
28+ take ( 1 ) ,
29+ map ( ( data ) => data . dso ) ,
30+ ) ;
31+
32+ this . itemName$ = this . dsoRD$ . pipe (
33+ filter ( ( rd : RemoteData < Item > ) => hasValue ( rd ) ) ,
34+ map ( ( rd : RemoteData < Item > ) => {
35+ return this . dsoNameService . getName ( rd . payload ) ;
36+ } )
37+ ) ;
38+ }
3539}
0 commit comments