diff --git a/src/app/list-all-rewards/list-all-rewards.component.ts b/src/app/list-all-rewards/list-all-rewards.component.ts
index 0963cf6..e0c73ba 100644
--- a/src/app/list-all-rewards/list-all-rewards.component.ts
+++ b/src/app/list-all-rewards/list-all-rewards.component.ts
@@ -64,6 +64,7 @@ export class ListAllRewardsComponent implements OnInit {
public dataStateChange(state: DataStateChangeEvent): void {
this.state = state;
+ console.log(state);
this.loadRewards();
}
diff --git a/src/app/pay-in/pay-in.component.html b/src/app/pay-in/pay-in.component.html
index 80e529b..cd66111 100644
--- a/src/app/pay-in/pay-in.component.html
+++ b/src/app/pay-in/pay-in.component.html
@@ -2,14 +2,14 @@
[pageable]="pageable"
[navigable]="true"
[resizable]="true"
- [pageSize]="filter.Take"
- [skip]="filter.Skip"
+ [pageSize]="state.Take"
+ [skip]="state.Skip"
[sortable]="sortable"
[filterable]="filterable"
[loading]="loading"
- [sort]="filter.Sort"
- [filter]="filter.Filter"
+ [sort]="state.Sort"
+ [filter]="state.Filter"
[selectable]="selectable"
kendoGridSelectBy
@@ -38,7 +38,7 @@
0 " class="badge badge-pill badge-primary specific-upload"> {{uploadMeta.Id}}
0 " class="badge badge-secondary specific-upload"> {{uploadMeta.FileName}}
-
+
diff --git a/src/app/pay-in/pay-in.component.ts b/src/app/pay-in/pay-in.component.ts
index e71e3fc..94c0c45 100644
--- a/src/app/pay-in/pay-in.component.ts
+++ b/src/app/pay-in/pay-in.component.ts
@@ -41,7 +41,7 @@ export class PayInComponent implements OnInit {
@Input() selectable: SelectableSettings | boolean;
private filterUploadMeta: UploadMetaModel = new UploadMetaModel({});
public filterLoan = new LoanModel({});
- @Input() filter: PayInListFilterModel = new PayInListFilterModel({});
+ @Input() state: PayInListFilterModel = new PayInListFilterModel({});
// public state = new GridStateModel();
@Output() errorOccurred = new EventEmitter();
@Output() Updated = new EventEmitter();
@@ -85,13 +85,14 @@ export class PayInComponent implements OnInit {
this.lenderListView = this.lenderNameService;
this.lenderNameService.query();
if ( this.pageable ) {
- this.filter.Take = this.pageSize;
+ this.state.Take = this.pageSize;
}
this.rowClassCallbackBind = this.rowClassCallback.bind(this);
+ this.debouncedLoadFilteredData = debounce(this.loadFilteredPayInList, 500);
}
ngOnInit(): void {
- this.debouncedLoadFilteredData = debounce(this.loadFilteredPayInList, 500);
+
if (this.privateLoadDataNow) { // not in delayed loading mode
this.debouncedLoadFilteredData();
}
@@ -117,11 +118,13 @@ export class PayInComponent implements OnInit {
public loadFilteredPayInList(): void {
this.loading = true;
+ this.refreshFilterByUpload();
+ this.refreshFilterByLoanId();
const state = new GridStateModel();
- state.filter = this.filter.Filter;
- state.sort = this.filter.Sort;
- state.take = this.filter.Take;
- state.group = this.filter.Group;
+ state.filter = this.state.Filter;
+ state.sort = this.state.Sort;
+ state.take = this.state.Take;
+ state.group = this.state.Group;
this.pis.getFilteredPayInList(state).subscribe(
( resp: PayInListResult) => {
this.gridData.total = resp.total;
@@ -142,9 +145,9 @@ export class PayInComponent implements OnInit {
@Input() set uploadMeta(value: UploadMetaModel) {
this.filterUploadMeta = value;
if ( value.Id <= 0 ) {
- this.filter.UploadIds = [];
+ this.state.UploadIds = [];
} else{
- this.filter.UploadIds = [ value.Id.toString() ];
+ this.state.UploadIds = [ value.Id.toString() ];
}
this.debouncedLoadFilteredData();
// console.log('upload filter changed', value, this.filter);
@@ -158,9 +161,9 @@ export class PayInComponent implements OnInit {
@Input() set Loan(value: LoanModel){
this.filterLoan = value;
if ( value.Id === '' ) {
- this.filter.LoanIds = [];
+ this.state.LoanIds = [];
}else{
- this.filter.LoanIds = [ value.Id ];
+ this.state.LoanIds = [ value.Id ];
}
this.debouncedLoadFilteredData();
// console.log('filter loanId changed', value, this.filter);
@@ -314,7 +317,7 @@ export class PayInComponent implements OnInit {
}
public showUpload(id: number): void {
- this.router.navigate(['/upload-details', id]);
+ this.router.navigate(['/upload-details', id]).then();
}
@@ -355,26 +358,26 @@ export class PayInComponent implements OnInit {
// }
public pageChange(event: PageChangeEvent): void {
- this.filter.Skip = event.skip;
- this.filter.Take = event.take;
+ this.state.Skip = event.skip;
+ this.state.Take = event.take;
// this.loadFilteredData();
}
public sortChange(sort: SortDescriptor[]): void {
- this.filter.Sort = sort;
+ this.state.Sort = sort;
// this.loadFilteredData();
}
public filterChange( filter: CompositeFilterDescriptor): void {
// console.log (filter, this.state.filter);
- this.filter.Skip = 0;
+ this.state.Skip = 0;
}
public dataStateChange(state: DataStateChangeEvent): void {
- this.filter.Filter = state.filter;
- this.filter.Group = state.group;
- this.filter.Sort = state.sort;
- this.filter.Skip = state.skip;
- this.filter.Take = state.take;
+ this.state.Filter = state.filter;
+ this.state.Group = state.group;
+ this.state.Sort = state.sort;
+ this.state.Skip = state.skip;
+ this.state.Take = state.take;
// console.log(state);
this.loadFilteredPayInList();
}
@@ -442,9 +445,42 @@ export class PayInComponent implements OnInit {
public onFilterEnable(filtering: boolean): void {
if ( ! filtering ) {
- this.filter.Filter = { logic: 'and', filters: [] };
- this.filter.Skip = 0;
+ this.state.Filter = { logic: 'and', filters: [] };
+ this.state.Skip = 0;
this.loadFilteredPayInList();
}
}
+
+ private refreshFilterByUpload(): void{
+ // make a copy of existing filters
+ const newFilter = { logic: 'and', filters: [], ...this.state.Filter.filters};
+
+ // remove any existing filters about UploadsId
+ newFilter.filters = newFilter.filters.filter(v => {
+ if (!( 'field' in v) && v.operator === 'or') { // could be LoanId or UploadsIds
+ const subFilters = v.filters;
+ return ! subFilters.every( subf => subf.field === 'UploadIds' ); // if sub-filters are all about UploadsIds, we remove it
+ }
+ return true;
+ });
+
+ // build new filters
+ const uploadsFilter = { logic: 'or', filters: []};
+ this.state.UploadIds.forEach(v => {
+ uploadsFilter.filters.push( {
+ field: 'UploadId',
+ operator: 'eq',
+ value: v
+ });
+ });
+
+ // add new filter
+ newFilter.filters.push( uploadsFilter as CompositeFilterDescriptor );
+ this.state.Filter = newFilter as CompositeFilterDescriptor;
+
+ }
+
+ private refreshFilterByLoanId(): void{
+
+ }
}