1- import { Component } from '@angular/core' ;
1+ import { Component , OnInit } from '@angular/core' ;
22import { Collection } from '../../../core/shared/collection.model' ;
33import { ObjectSelectComponent } from '../object-select/object-select.component' ;
4- import { isNotEmpty } from '../../empty.util' ;
5- import { ObjectSelectService } from '../object-select.service' ;
6- import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service' ;
7- import { DSONameService } from '../../../core/breadcrumbs/dso-name.service' ;
4+ import { isNotEmpty , hasValueOperator } from '../../empty.util' ;
5+ import { Observable } from 'rxjs' ;
6+ import { DSpaceObjectSelect } from '../object-select.model' ;
7+ import { getAllSucceededRemoteDataPayload } from '../../../core/shared/operators' ;
8+ import { map } from 'rxjs/operators' ;
9+ import { PaginatedList } from '../../../core/data/paginated-list.model' ;
10+ import { getCollectionPageRoute } from '../../../collection-page/collection-page-routing-paths' ;
811
912@Component ( {
1013 selector : 'ds-collection-select' ,
@@ -15,21 +18,29 @@ import { DSONameService } from '../../../core/breadcrumbs/dso-name.service';
1518/**
1619 * A component used to select collections from a specific list and returning the UUIDs of the selected collections
1720 */
18- export class CollectionSelectComponent extends ObjectSelectComponent < Collection > {
21+ export class CollectionSelectComponent extends ObjectSelectComponent < Collection > implements OnInit {
1922
20- constructor (
21- protected objectSelectService : ObjectSelectService ,
22- protected authorizationService : AuthorizationDataService ,
23- public dsoNameService : DSONameService ,
24- ) {
25- super ( objectSelectService , authorizationService ) ;
26- }
23+ /**
24+ * Collection of all the data that is used to display the {@link Collection} in the HTML.
25+ * By collecting this data here it doesn't need to be recalculated on evey change detection.
26+ */
27+ selectCollections$ : Observable < DSpaceObjectSelect < Collection > [ ] > ;
2728
2829 ngOnInit ( ) : void {
2930 super . ngOnInit ( ) ;
3031 if ( ! isNotEmpty ( this . confirmButton ) ) {
3132 this . confirmButton = 'collection.select.confirm' ;
3233 }
34+ this . selectCollections$ = this . dsoRD$ . pipe (
35+ hasValueOperator ( ) ,
36+ getAllSucceededRemoteDataPayload ( ) ,
37+ map ( ( collections : PaginatedList < Collection > ) => collections . page . map ( ( collection : Collection ) => Object . assign ( new DSpaceObjectSelect < Collection > ( ) , {
38+ dso : collection ,
39+ canSelect$ : this . canSelect ( collection ) ,
40+ selected$ : this . getSelected ( collection . id ) ,
41+ route : getCollectionPageRoute ( collection . id ) ,
42+ } as DSpaceObjectSelect < Collection > ) ) ) ,
43+ ) ;
3344 }
3445
3546}
0 commit comments