11import { Component , Input , OnDestroy , OnInit } from '@angular/core' ;
2+ import { ActivatedRoute } from '@angular/router' ;
23
34import { BehaviorSubject , combineLatest as observableCombineLatest } from 'rxjs' ;
45
@@ -9,7 +10,6 @@ import { PaginatedList } from '../../core/data/paginated-list.model';
910import { PaginationComponentOptions } from '../../shared/pagination/pagination-component-options.model' ;
1011import { SortDirection , SortOptions } from '../../core/cache/models/sort-options.model' ;
1112import { CommunityDataService } from '../../core/data/community-data.service' ;
12- import { takeUntilCompletedRemoteData } from '../../core/shared/operators' ;
1313import { switchMap } from 'rxjs/operators' ;
1414import { PaginationService } from '../../core/pagination/pagination.service' ;
1515import { hasValue } from '../../shared/empty.util' ;
@@ -52,8 +52,10 @@ export class CommunityPageSubCommunityListComponent implements OnInit, OnDestroy
5252 */
5353 subCommunitiesRDObs : BehaviorSubject < RemoteData < PaginatedList < Community > > > = new BehaviorSubject < RemoteData < PaginatedList < Community > > > ( { } as any ) ;
5454
55- constructor ( private cds : CommunityDataService ,
56- private paginationService : PaginationService
55+ constructor (
56+ protected cds : CommunityDataService ,
57+ protected paginationService : PaginationService ,
58+ protected route : ActivatedRoute ,
5759 ) {
5860 }
5961
@@ -62,9 +64,11 @@ export class CommunityPageSubCommunityListComponent implements OnInit, OnDestroy
6264 this . config . id = this . pageId ;
6365 if ( hasValue ( this . pageSize ) ) {
6466 this . config . pageSize = this . pageSize ;
67+ } else {
68+ this . config . pageSize = this . route . snapshot . queryParams [ this . pageId + '.rpp' ] ?? this . config . pageSize ;
6569 }
66- this . config . currentPage = 1 ;
67- this . sortConfig = new SortOptions ( 'dc.title' , SortDirection . ASC ) ;
70+ this . config . currentPage = this . route . snapshot . queryParams [ this . pageId + '.page' ] ?? 1 ;
71+ this . sortConfig = new SortOptions ( 'dc.title' , SortDirection [ this . route . snapshot . queryParams [ this . pageId + '.sd' ] ] ?? SortDirection . ASC ) ;
6872 this . initPage ( ) ;
6973 }
7074
@@ -86,15 +90,6 @@ export class CommunityPageSubCommunityListComponent implements OnInit, OnDestroy
8690 ) . subscribe ( ( results ) => {
8791 this . subCommunitiesRDObs . next ( results ) ;
8892 } ) ;
89-
90-
91- this . cds . findByParent ( this . community . id , {
92- currentPage : this . config . currentPage ,
93- elementsPerPage : this . config . pageSize ,
94- sort : { field : this . sortConfig . field , direction : this . sortConfig . direction }
95- } ) . pipe ( takeUntilCompletedRemoteData ( ) ) . subscribe ( ( results ) => {
96- this . subCommunitiesRDObs . next ( results ) ;
97- } ) ;
9893 }
9994
10095 ngOnDestroy ( ) : void {
0 commit comments