108555: Removed pageInfoState Input since it wasn't used and almost all the components gave the incorrect type of data to it

This commit is contained in:
Alexandre Vryghem
2024-04-18 19:27:26 +02:00
parent 45e8977db7
commit da31c4f253
19 changed files with 6 additions and 60 deletions

View File

@@ -13,11 +13,9 @@ import {
import { Observable, of as observableOf, Subscription } from 'rxjs';
import { HostWindowService } from '../host-window.service';
import { HostWindowState } from '../search/host-window.reducer';
import { PaginationComponentOptions } from './pagination-component-options.model';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { hasValue } from '../empty.util';
import { PageInfo } from '../../core/shared/page-info.model';
import { PaginationService } from '../../core/pagination/pagination.service';
import { map, take } from 'rxjs/operators';
import { RemoteData } from '../../core/data/remote-data';
@@ -47,11 +45,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
*/
@Input() collectionSize: number;
/**
* Page state of a Remote paginated objects.
*/
@Input() pageInfoState: Observable<PageInfo> = undefined;
/**
* Configuration for the NgbPagination component.
*/
@@ -136,18 +129,13 @@ export class PaginationComponent implements OnDestroy, OnInit {
/**
* Current page.
*/
public currentPage$;
public currentPage$: Observable<number>;
/**
* Current page in the state of a Remote paginated objects.
*/
public currentPageState: number = undefined;
/**
* An observable of HostWindowState type
*/
public hostWindow: Observable<HostWindowState>;
/**
* ID for the pagination instance. This ID is used in the routing to retrieve the pagination options.
* This ID needs to be unique between different pagination components when more than one will be displayed on the same page.
@@ -162,7 +150,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
/**
* Number of items per page.
*/
public pageSize$;
public pageSize$: Observable<number>;
/**
* Declare SortDirection enumeration to use it in the template
@@ -183,7 +171,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
/**
* Name of the field that's used to sort by
*/
public sortField$;
public sortField$: Observable<string>;
public defaultSortField = 'name';
/**
@@ -237,7 +225,7 @@ export class PaginationComponent implements OnDestroy, OnInit {
map((currentPagination) => currentPagination.pageSize)
);
let sortOptions;
let sortOptions: SortOptions;
if (this.sortOptions) {
sortOptions = this.sortOptions;
} else {
@@ -251,16 +239,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
);
}
/**
* @param cdRef
* ChangeDetectorRef is a singleton service provided by Angular.
* @param route
* Route is a singleton service provided by Angular.
* @param router
* Router is a singleton service provided by Angular.
* @param hostWindowService
* the HostWindowService singleton.
*/
constructor(private cdRef: ChangeDetectorRef,
private paginationService: PaginationService,
public hostWindowService: HostWindowService) {
@@ -299,17 +277,6 @@ export class PaginationComponent implements OnDestroy, OnInit {
this.emitPaginationChange();
}
/**
* Method to change the route to the given sort field
*
* @param sortField
* The sort field being navigated to.
*/
public doSortFieldChange(field: string) {
this.updateParams({ pageId: this.id, page: 1, sortField: field });
this.emitPaginationChange();
}
/**
* Method to emit a general pagination change event
*/
@@ -333,8 +300,8 @@ export class PaginationComponent implements OnDestroy, OnInit {
if (collectionSize) {
showingDetails = this.paginationService.getCurrentPagination(this.id, this.paginationOptions).pipe(
map((currentPaginationOptions) => {
let firstItem;
let lastItem;
let firstItem: number;
let lastItem: number;
const pageMax = currentPaginationOptions.pageSize * currentPaginationOptions.currentPage;
firstItem = currentPaginationOptions.pageSize * (currentPaginationOptions.currentPage - 1) + 1;