1- import { ChangeDetectionStrategy , Component , OnInit , Inject } from '@angular/core' ;
1+ import { ChangeDetectionStrategy , Component , OnInit } from '@angular/core' ;
22import { ActivatedRoute , Router } from '@angular/router' ;
3- import { BehaviorSubject , combineLatest as observableCombineLatest , Observable , Subject } from 'rxjs' ;
4- import { filter , map , mergeMap , startWith , switchMap , take } from 'rxjs/operators' ;
5- import { PaginatedSearchOptions } from '../shared/search/models/paginated-search-options.model' ;
6- import { SearchService } from '../core/shared/search/search.service' ;
7- import { SortDirection , SortOptions } from '../core/cache/models/sort-options.model' ;
8- import { CollectionDataService } from '../core/data/collection-data.service' ;
9- import { PaginatedList } from '../core/data/paginated-list.model' ;
3+ import { Observable } from 'rxjs' ;
4+ import { filter , map , mergeMap , take } from 'rxjs/operators' ;
5+ import { SortOptions } from '../core/cache/models/sort-options.model' ;
106import { RemoteData } from '../core/data/remote-data' ;
117import { Bitstream } from '../core/shared/bitstream.model' ;
12-
138import { Collection } from '../core/shared/collection.model' ;
14- import { DSpaceObjectType } from '../core/shared/dspace-object-type.model' ;
15- import { Item } from '../core/shared/item.model' ;
16- import {
17- getAllSucceededRemoteDataPayload ,
18- getFirstSucceededRemoteData ,
19- toDSpaceObjectListRD
20- } from '../core/shared/operators' ;
21-
9+ import { getAllSucceededRemoteDataPayload } from '../core/shared/operators' ;
2210import { fadeIn , fadeInOut } from '../shared/animations/fade' ;
2311import { hasValue , isNotEmpty } from '../shared/empty.util' ;
2412import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model' ;
2513import { AuthService } from '../core/auth/auth.service' ;
26- import { PaginationService } from '../core/pagination/pagination.service' ;
2714import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service' ;
2815import { FeatureID } from '../core/data/feature-authorization/feature-id' ;
2916import { getCollectionPageRoute } from './collection-page-routing-paths' ;
3017import { redirectOn4xx } from '../core/shared/authorized.operators' ;
31- import { BROWSE_LINKS_TO_FOLLOW } from '../core/browse/browse.service' ;
3218import { DSONameService } from '../core/breadcrumbs/dso-name.service' ;
33- import { APP_CONFIG , AppConfig } from '../../../src/config/app-config.interface' ;
3419
3520@Component ( {
3621 selector : 'ds-collection-page' ,
@@ -44,14 +29,9 @@ import { APP_CONFIG, AppConfig } from '../../../src/config/app-config.interface'
4429} )
4530export class CollectionPageComponent implements OnInit {
4631 collectionRD$ : Observable < RemoteData < Collection > > ;
47- itemRD$ : Observable < RemoteData < PaginatedList < Item > > > ;
4832 logoRD$ : Observable < RemoteData < Bitstream > > ;
4933 paginationConfig : PaginationComponentOptions ;
5034 sortConfig : SortOptions ;
51- private paginationChanges$ : Subject < {
52- paginationConfig : PaginationComponentOptions ,
53- sortConfig : SortOptions
54- } > ;
5535
5636 /**
5737 * Whether the current user is a Community admin
@@ -64,23 +44,12 @@ export class CollectionPageComponent implements OnInit {
6444 collectionPageRoute$ : Observable < string > ;
6545
6646 constructor (
67- private collectionDataService : CollectionDataService ,
68- private searchService : SearchService ,
69- private route : ActivatedRoute ,
70- private router : Router ,
71- private authService : AuthService ,
72- private paginationService : PaginationService ,
73- private authorizationDataService : AuthorizationDataService ,
47+ protected route : ActivatedRoute ,
48+ protected router : Router ,
49+ protected authService : AuthService ,
50+ protected authorizationDataService : AuthorizationDataService ,
7451 public dsoNameService : DSONameService ,
75- @Inject ( APP_CONFIG ) public appConfig : AppConfig ,
7652 ) {
77- this . paginationConfig = Object . assign ( new PaginationComponentOptions ( ) , {
78- id : 'cp' ,
79- currentPage : 1 ,
80- pageSize : this . appConfig . browseBy . pageSize ,
81- } ) ;
82-
83- this . sortConfig = new SortOptions ( 'dc.date.accessioned' , SortDirection . DESC ) ;
8453 }
8554
8655 ngOnInit ( ) : void {
@@ -96,33 +65,6 @@ export class CollectionPageComponent implements OnInit {
9665 ) ;
9766 this . isCollectionAdmin$ = this . authorizationDataService . isAuthorized ( FeatureID . IsCollectionAdmin ) ;
9867
99- this . paginationChanges$ = new BehaviorSubject ( {
100- paginationConfig : this . paginationConfig ,
101- sortConfig : this . sortConfig
102- } ) ;
103-
104- const currentPagination$ = this . paginationService . getCurrentPagination ( this . paginationConfig . id , this . paginationConfig ) ;
105- const currentSort$ = this . paginationService . getCurrentSort ( this . paginationConfig . id , this . sortConfig ) ;
106-
107- this . itemRD$ = observableCombineLatest ( [ currentPagination$ , currentSort$ ] ) . pipe (
108- switchMap ( ( [ currentPagination , currentSort ] ) => this . collectionRD$ . pipe (
109- getFirstSucceededRemoteData ( ) ,
110- map ( ( rd ) => rd . payload . id ) ,
111- switchMap ( ( id : string ) => {
112- return this . searchService . search < Item > (
113- new PaginatedSearchOptions ( {
114- scope : id ,
115- pagination : currentPagination ,
116- sort : currentSort ,
117- dsoTypes : [ DSpaceObjectType . ITEM ]
118- } ) , null , true , true , ...BROWSE_LINKS_TO_FOLLOW )
119- . pipe ( toDSpaceObjectListRD ( ) ) as Observable < RemoteData < PaginatedList < Item > > > ;
120- } ) ,
121- startWith ( undefined ) // Make sure switching pages shows loading component
122- )
123- )
124- ) ;
125-
12668 this . collectionPageRoute$ = this . collectionRD$ . pipe (
12769 getAllSucceededRemoteDataPayload ( ) ,
12870 map ( ( collection ) => getCollectionPageRoute ( collection . id ) )
@@ -133,9 +75,5 @@ export class CollectionPageComponent implements OnInit {
13375 return isNotEmpty ( object ) ;
13476 }
13577
136- ngOnDestroy ( ) : void {
137- this . paginationService . clearPagination ( this . paginationConfig . id ) ;
138- }
139-
14078
14179}
0 commit comments