diff --git a/src/app/collection-page/collection-page.component.ts b/src/app/collection-page/collection-page.component.ts index 1f30912d47..a9f2d9dd2e 100644 --- a/src/app/collection-page/collection-page.component.ts +++ b/src/app/collection-page/collection-page.component.ts @@ -1,6 +1,6 @@ import { - ChangeDetectionStrategy, ChangeDetectorRef, Component, OnDestroy, - OnInit + ChangeDetectionStrategy, ChangeDetectorRef, Component, DoCheck, OnChanges, OnDestroy, + OnInit, SimpleChanges } from '@angular/core'; import { ActivatedRoute, Params } from '@angular/router'; @@ -16,6 +16,8 @@ import { Item } from '../core/shared/item.model'; import { SortOptions, SortDirection } from '../core/cache/models/sort-options.model'; import { PaginationComponentOptions } from '../shared/pagination/pagination-component-options.model'; import { hasValue } from '../shared/empty.util'; +import { PageInfo } from '../core/shared/page-info.model'; +import { isUndefined } from 'util'; @Component({ selector: 'ds-collection-page', @@ -23,7 +25,7 @@ import { hasValue } from '../shared/empty.util'; templateUrl: './collection-page.component.html', changeDetection: ChangeDetectionStrategy.OnPush }) -export class CollectionPageComponent implements OnInit, OnDestroy { +export class CollectionPageComponent implements OnChanges, OnInit, OnDestroy { collectionData: RemoteData; itemData: RemoteData; logoData: RemoteData; @@ -31,6 +33,7 @@ export class CollectionPageComponent implements OnInit, OnDestroy { sortConfig: SortOptions; private subs: Subscription[] = []; private collectionId: string; + private pageInfoState: PageInfo; constructor( private collectionDataService: CollectionDataService, @@ -41,6 +44,10 @@ export class CollectionPageComponent implements OnInit, OnDestroy { } + ngOnChanges(changes: SimpleChanges) { + console.log(changes); + } + ngOnInit(): void { this.subs.push(this.route.params.map((params: Params) => params.id) .subscribe((id: string) => { @@ -84,13 +91,20 @@ export class CollectionPageComponent implements OnInit, OnDestroy { } updateResults() { - this.itemData = undefined; + this.itemData = null; + this.ref.markForCheck(); this.itemData = this.itemDataService.findAll({ scopeID: this.collectionId, currentPage: this.config.currentPage, elementsPerPage: this.config.pageSize, sort: this.sortConfig }); - // this.ref.detectChanges(); + this.itemData.pageInfo.subscribe((pageInfo) => { + if (isUndefined(this.pageInfoState) || this.pageInfoState !== pageInfo) { + this.pageInfoState = pageInfo; + this.ref.detectChanges(); + } + }); + } } diff --git a/src/app/core/cache/response-cache.service.ts b/src/app/core/cache/response-cache.service.ts index 99e26b3c20..3bb2ecaeeb 100644 --- a/src/app/core/cache/response-cache.service.ts +++ b/src/app/core/cache/response-cache.service.ts @@ -36,7 +36,6 @@ export class ResponseCacheService { get(key: string): Observable { return this.store.select('core', 'cache', 'response', key) .filter((entry) => this.isValid(entry)) - .distinctUntilChanged() } /** diff --git a/src/app/object-list/object-list.component.html b/src/app/object-list/object-list.component.html index b0ca991a93..da25195e27 100644 --- a/src/app/object-list/object-list.component.html +++ b/src/app/object-list/object-list.component.html @@ -1,4 +1,5 @@ ; @Input() config: PaginationComponentOptions; @@ -59,10 +59,26 @@ export class ObjectListComponent implements OnInit { @Output() sortFieldChange: EventEmitter = new EventEmitter(); data: any = {}; + ngOnChanges(changes: SimpleChanges) { + if (changes.objects && !changes.objects.isFirstChange()) { + this.pageInfo = this.objects.pageInfo; + } + } + ngOnInit(): void { this.pageInfo = this.objects.pageInfo; } + /** + * @param route + * Route is a singleton service provided by Angular. + * @param router + * Router is a singleton service provided by Angular. + */ + constructor( + private cdRef: ChangeDetectorRef) { + } + onPageChange(event) { this.pageChange.emit(event); } diff --git a/src/app/shared/pagination/pagination.component.html b/src/app/shared/pagination/pagination.component.html index 33c3dba1f3..b61920567d 100644 --- a/src/app/shared/pagination/pagination.component.html +++ b/src/app/shared/pagination/pagination.component.html @@ -1,34 +1,36 @@ -
-
-
- {{ 'pagination.showing.label' | translate }} - {{ 'pagination.showing.detail' | translate:showingDetail }} -
-
-
- -