Fix Loan lock COB pagination (#1753)
Co-authored-by: Jose Alberto Hernandez <alberto@blue-daemon.local>
This commit is contained in:
co-authored by
Jose Alberto Hernandez
parent
02ed7362d3
commit
517584280f
+5
-3
@@ -23,7 +23,7 @@ import * as _ from 'lodash';
|
||||
})
|
||||
export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges {
|
||||
|
||||
SELECT_NAME_FIELD:string = 'select';
|
||||
SELECT_NAME_FIELD = 'select';
|
||||
/** Data Object */
|
||||
@Input() dataObject: any;
|
||||
@Input() entityId: string;
|
||||
@@ -163,7 +163,9 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
|
||||
this.selection.selected.forEach((data) => {
|
||||
this.systemService.deleteDatatableEntry(this.entityId, data.row[1], this.datatableName).subscribe(() => {
|
||||
this.datatableData.forEach((item: any, index: any) => {
|
||||
if (item.row[1] === data.row[1]) delete this.datatableData[index]
|
||||
if (item.row[1] === data.row[1]) {
|
||||
delete this.datatableData[index];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -192,7 +194,7 @@ export class DatatableMultiRowComponent implements OnInit, OnDestroy, OnChanges
|
||||
/** Whether the number of selected elements matches the total number of rows. */
|
||||
isAllSelected() {
|
||||
const numSelected = this.selection.selected;
|
||||
return (this.datatableData.length == numSelected);
|
||||
return (this.datatableData.length === numSelected);
|
||||
}
|
||||
|
||||
isAnySelected() {
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<mat-paginator [pageSizeOptions]="[10, 25, 50, 100]" showFirstLastButtons [pageSize]="pageSize"
|
||||
[pageIndex]="currentPage" (page)="pageEvent = handlePage($event)">
|
||||
<mat-paginator [hidden]="!showPaginator" [pageSizeOptions]="[100, 500, 1000, 5000]" [pageSize]="pageSize"
|
||||
[pageIndex]="currentPage" showFirstLastButtons (page)="changePaging($event)">
|
||||
</mat-paginator>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -26,15 +26,23 @@ export class LoanLockedComponent implements OnInit {
|
||||
selection: SelectionModel<any>;
|
||||
/** Displayed Columns for loan disbursal data */
|
||||
displayedColumns: string[] = ['select', 'loanId', 'lockPlacedOn', 'lockOwner', 'error', 'details'];
|
||||
|
||||
/** Paginator for the table */
|
||||
@ViewChild(MatPaginator, { static: true }) paginator: MatPaginator;
|
||||
@ViewChild(MatPaginator, {static: false})
|
||||
set paginator(value: MatPaginator) {
|
||||
this.dataSource.paginator = value;
|
||||
}
|
||||
|
||||
currentPage = 0;
|
||||
pageSize = 10;
|
||||
itemsToRead = 5000;
|
||||
pageSize = 100;
|
||||
/** Control for enable/disable button */
|
||||
allowRunInlineJob = false;
|
||||
/** Const for the jobName */
|
||||
jobName: String = 'LOAN_COB';
|
||||
|
||||
showPaginator = false;
|
||||
|
||||
/**
|
||||
* @param {LoansService} loansService Loans Service
|
||||
* @param {Router} router Router for navigation.
|
||||
@@ -49,29 +57,27 @@ export class LoanLockedComponent implements OnInit {
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.dataSource = new MatTableDataSource(this.loans);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.selection = new SelectionModel(true, []);
|
||||
this.allowRunInlineJob = false;
|
||||
this.getLoansLocked(this.currentPage);
|
||||
this.getLoansLocked(0);
|
||||
}
|
||||
|
||||
applyFilter(filterValue: string = '') {
|
||||
this.dataSource.filter = filterValue.trim().toLowerCase();
|
||||
}
|
||||
|
||||
handlePage(e: any) {
|
||||
changePaging(e: any) {
|
||||
this.pageSize = e.pageSize;
|
||||
if (this.currentPage !== e.pageIndex) {
|
||||
this.currentPage = e.pageIndex;
|
||||
this.pageSize = e.pageSize;
|
||||
this.getLoansLocked(this.currentPage);
|
||||
}
|
||||
}
|
||||
|
||||
getLoansLocked(page: number) {
|
||||
this.tasksService.getAllLoansLocked(page, this.pageSize).subscribe((data: any) => {
|
||||
this.tasksService.getAllLoansLocked(page, this.itemsToRead).subscribe((data: any) => {
|
||||
this.loans = data.content;
|
||||
this.dataSource = new MatTableDataSource(this.loans);
|
||||
this.dataSource.paginator = this.paginator;
|
||||
this.showPaginator = (this.loans.length > this.pageSize);
|
||||
this.allowRunInlineJob = false;
|
||||
this.selection = new SelectionModel(true, []);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user