From a8b46412e1c884d49d10fa02d1ef93abf1c7947e Mon Sep 17 00:00:00 2001 From: Patrick Sun Date: Mon, 17 May 2021 11:21:30 +1000 Subject: [PATCH] bug fix for number filter and pay-in list all income mode --- src/app/app.config.model.ts | 4 +- .../date-filter/date-filter.component.ts | 16 ++- .../list-all-rewards.component.html | 58 ++++------- .../list-all-rewards.component.ts | 13 +-- src/app/models/pay-in-list.filter.model.ts | 30 ++---- src/app/pay-in/pay-in.component.html | 6 +- src/app/pay-in/pay-in.component.ts | 99 ++++++++++--------- 7 files changed, 106 insertions(+), 120 deletions(-) diff --git a/src/app/app.config.model.ts b/src/app/app.config.model.ts index bb92e6d..c13d634 100644 --- a/src/app/app.config.model.ts +++ b/src/app/app.config.model.ts @@ -5,7 +5,9 @@ export class AppConfigModel { public Socket = 'ws://c5016.biukop.com.au:8080/api/v1/'; public SessionStorageKey = 'sk'; public Version ? = environment.appVersion; - constructor(payload: Partial) { + + constructor(payload?: Partial) { + if (!payload) { payload = {}; } this.Server = payload.Server || 'https://c5016.biukop.com.au:8080/api/v1/'; this.Socket = payload.Socket || 'ws://c5016.biukop.com.au:8080/api/v1/'; this.SessionStorageKey = payload.SessionStorageKey || 'sk'; diff --git a/src/app/grid-filter/date-filter/date-filter.component.ts b/src/app/grid-filter/date-filter/date-filter.component.ts index e526432..99940b7 100644 --- a/src/app/grid-filter/date-filter/date-filter.component.ts +++ b/src/app/grid-filter/date-filter/date-filter.component.ts @@ -14,6 +14,7 @@ export class DateFilterComponent extends BaseFilterCellComponent implements OnI @Input() fieldName = ''; @Input() start = 0; @Input() end = 0; + @Input() format = 'Date'; public date: Date; @Input() public range = 0; @@ -79,11 +80,20 @@ export class DateFilterComponent extends BaseFilterCellComponent implements OnI this.applyFilter(this.updateFilter({ field: this.fieldName, operator: 'eq', - value: this.date + value: this.getOutput(this.date) })); } } + private getOutput(d: Date): Date| number { + switch ( this.format ){ + case 'unixtimestamp': + return d.getTime() / 1000; + default: + return d; + } + } + private buildRangeFilter(): void { const fs: FilterDescriptor[] = []; const start: Date = new Date(this.date); start.setDate(this.date.getDate() - this.range); @@ -91,13 +101,13 @@ export class DateFilterComponent extends BaseFilterCellComponent implements OnI fs.push({ field: this.fieldName, operator: 'gte', - value: start.getTime() / 1000 + value: this.getOutput(start) }); fs.push({ field: this.fieldName, operator: 'lte', - value: end.getTime() / 1000 + value: this.getOutput(end) }); this.removeFilter(this.fieldName); const root: CompositeFilterDescriptor = this.filter || { logic: 'and', diff --git a/src/app/list-all-rewards/list-all-rewards.component.html b/src/app/list-all-rewards/list-all-rewards.component.html index 208fa55..88f3c8e 100644 --- a/src/app/list-all-rewards/list-all-rewards.component.html +++ b/src/app/list-all-rewards/list-all-rewards.component.html @@ -17,18 +17,16 @@ class="fullheight_grid" > - + - - + + @@ -37,12 +35,10 @@ {{ dataItem.Amount | currency }} - - + + @@ -51,30 +47,21 @@
{{ dataItem.ToDisplay }}
- - + +
- - + + - - + + @@ -82,11 +69,8 @@ {{dataItem.Status}} - - + + @@ -97,11 +81,9 @@ - - + + 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 8de9e5c..0963cf6 100644 --- a/src/app/list-all-rewards/list-all-rewards.component.ts +++ b/src/app/list-all-rewards/list-all-rewards.component.ts @@ -19,16 +19,17 @@ export class ListAllRewardsComponent implements OnInit { public gridView: GridDataResult; public state: State = { skip: 0, - take: 20 + take: 20, + filter: {logic: 'and', filters: []} }; public loading = true; public selectTableSettings: SelectableSettings | boolean = true; - private multipleSelection: SelectableSettings = { - checkboxOnly: false, - mode: 'multiple', - drag: false - }; + // private multipleSelection: SelectableSettings = { + // checkboxOnly: false, + // mode: 'multiple', + // drag: false + // }; public EnableSelectButton = true; @Input() selectedRewards: RewardModel[] = []; diff --git a/src/app/models/pay-in-list.filter.model.ts b/src/app/models/pay-in-list.filter.model.ts index 7a65f8b..f1acc02 100644 --- a/src/app/models/pay-in-list.filter.model.ts +++ b/src/app/models/pay-in-list.filter.model.ts @@ -1,22 +1,13 @@ -import {SortDescriptor} from '@progress/kendo-data-query'; +import {CompositeFilterDescriptor, GroupDescriptor, SortDescriptor} from '@progress/kendo-data-query'; export class PayInListFilterModel { LoanIds: string[]; UploadIds: string[]; Take: number; Skip: number; - TsFrom: Date; - TsTo: Date; - IdFrom: number; - IdTo: number; - TrailFrom: number; - TrailTo: number; - BalanceFrom: number; - BalanceTo: number; - AmountFrom: number; - AmountTo: number; Sort?: SortDescriptor[]; - + Group?: Array; + Filter?: CompositeFilterDescriptor; constructor(payload: Partial) { this.LoanIds = []; if (payload.LoanIds !== undefined && payload.LoanIds.length > 0) { @@ -26,19 +17,10 @@ export class PayInListFilterModel { if (payload.UploadIds !== undefined && payload.UploadIds.length > 0 ) { payload.UploadIds.forEach(v => { this.UploadIds.push(v); }); } - - const bigNumber = 9999999999; this.Take = payload.Take || 0; this.Skip = payload.Skip || 0; - this.TsFrom = payload.TsFrom? new Date(payload.TsFrom) : new Date('1900-01-01'); - this.TsTo = payload.TsTo? new Date(payload.TsTo) : new Date('2038-01-01'); - this.IdFrom = payload.IdFrom || 0; - this.IdTo = payload.IdTo || bigNumber; - this.TrailFrom = payload.TrailFrom || 0; - this.TrailTo = payload.TrailTo || bigNumber; - this.BalanceFrom = payload.BalanceFrom || -1 ; - this.BalanceTo = payload.BalanceTo || bigNumber; - this.AmountFrom = payload.AmountFrom || 0; - this.AmountTo = payload.AmountTo || bigNumber; + this.Sort = payload.Sort || []; + this.Group = payload.Group || []; + this.Filter = payload.Filter || { logic: 'and', filters: [] }; } } diff --git a/src/app/pay-in/pay-in.component.html b/src/app/pay-in/pay-in.component.html index 2893048..80e529b 100644 --- a/src/app/pay-in/pay-in.component.html +++ b/src/app/pay-in/pay-in.component.html @@ -9,7 +9,7 @@ [loading]="loading" [sort]="filter.Sort" - [filter]="state.filter" + [filter]="filter.Filter" [selectable]="selectable" kendoGridSelectBy @@ -109,7 +109,7 @@ - + @@ -208,4 +208,4 @@ - + diff --git a/src/app/pay-in/pay-in.component.ts b/src/app/pay-in/pay-in.component.ts index 9b5cd9b..e71e3fc 100644 --- a/src/app/pay-in/pay-in.component.ts +++ b/src/app/pay-in/pay-in.component.ts @@ -42,10 +42,10 @@ export class PayInComponent implements OnInit { private filterUploadMeta: UploadMetaModel = new UploadMetaModel({}); public filterLoan = new LoanModel({}); @Input() filter: PayInListFilterModel = new PayInListFilterModel({}); - public state = new GridStateModel(); + // public state = new GridStateModel(); @Output() errorOccurred = new EventEmitter(); @Output() Updated = new EventEmitter(); - @ViewChild('filterDialog', {static: true}) filterDialog: PopupIncomeFilterComponent; + // @ViewChild('filterDialog', {static: true}) filterDialog: PopupIncomeFilterComponent; @ViewChild('grid', {static: true}) grid: GridComponent; private privateLoadDataNow = false; @@ -91,33 +91,38 @@ export class PayInComponent implements OnInit { } ngOnInit(): void { - this.debouncedLoadFilteredData = debounce(this.loadFilteredData, 500); + this.debouncedLoadFilteredData = debounce(this.loadFilteredPayInList, 500); if (this.privateLoadDataNow) { // not in delayed loading mode this.debouncedLoadFilteredData(); } } - public loadFilteredData(): void{ - this.loading = true; - this.pis.getPayInList(this.filter).subscribe( - ( resp: PayInListResult) => { - this.gridData.total = resp.total; - this.gridData.data = []; - resp.data.forEach(v => { - this.gridData.data.push(new PayInModelEx(v)); - }); - this.loading = false; - }, err => { - this.loading = false; - }, () => { - this.loading = false; - } - ); - } + // public loadFilteredData(): void{ + // this.loading = true; + // this.pis.getPayInList(this.filter).subscribe( + // ( resp: PayInListResult) => { + // this.gridData.total = resp.total; + // this.gridData.data = []; + // resp.data.forEach(v => { + // this.gridData.data.push(new PayInModelEx(v)); + // }); + // this.loading = false; + // }, err => { + // this.loading = false; + // }, () => { + // this.loading = false; + // } + // ); + // } public loadFilteredPayInList(): void { this.loading = true; - this.pis.getFilteredPayInList(this.state).subscribe( + const state = new GridStateModel(); + state.filter = this.filter.Filter; + state.sort = this.filter.Sort; + state.take = this.filter.Take; + state.group = this.filter.Group; + this.pis.getFilteredPayInList(state).subscribe( ( resp: PayInListResult) => { this.gridData.total = resp.total; this.gridData.data = []; @@ -242,7 +247,7 @@ export class PayInComponent implements OnInit { this.Loan.cuPayIn( model); this.updatePiInGrid(model); this.Updated.emit(model); - console.log(this); + // console.log(this); }, err => { // TODO: this.errorOccurred.emit('Error saving Income'); @@ -329,25 +334,25 @@ export class PayInComponent implements OnInit { } } - public showFilter(): void{ - this.filterDialog.show(); - } - - public doFilter(filter: PayInListFilterModel): void { - this.filter.BalanceTo = filter.BalanceTo; - this.filter.BalanceFrom = filter.BalanceFrom; - this.filter.AmountFrom = filter.AmountFrom; - this.filter.AmountTo = filter.AmountTo; - - this.filter.Take = filter.Take; - this.filter.TrailFrom = filter.TrailFrom; - this.filter.TrailTo = filter.TrailTo; - this.filter.IdFrom = filter.IdFrom; - this.filter.IdTo = filter.IdTo; - this.filter.TsFrom = filter.TsFrom; - this.filter.TsTo = filter.TsTo; - this.loadFilteredData(); - } + // public showFilter(): void{ + // this.filterDialog.show(); + // } + + // public doFilter(filter: PayInListFilterModel): void { + // this.filter.BalanceTo = filter.BalanceTo; + // this.filter.BalanceFrom = filter.BalanceFrom; + // this.filter.AmountFrom = filter.AmountFrom; + // this.filter.AmountTo = filter.AmountTo; + // + // this.filter.Take = filter.Take; + // this.filter.TrailFrom = filter.TrailFrom; + // this.filter.TrailTo = filter.TrailTo; + // this.filter.IdFrom = filter.IdFrom; + // this.filter.IdTo = filter.IdTo; + // this.filter.TsFrom = filter.TsFrom; + // this.filter.TsTo = filter.TsTo; + // this.loadFilteredData(); + // } public pageChange(event: PageChangeEvent): void { this.filter.Skip = event.skip; @@ -365,8 +370,12 @@ export class PayInComponent implements OnInit { this.filter.Skip = 0; } public dataStateChange(state: DataStateChangeEvent): void { - this.state = state; - console.log(state); + 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; + // console.log(state); this.loadFilteredPayInList(); } @@ -433,8 +442,8 @@ export class PayInComponent implements OnInit { public onFilterEnable(filtering: boolean): void { if ( ! filtering ) { - this.state.filter = { logic: 'and', filters: [] }; - this.state.skip = 0; + this.filter.Filter = { logic: 'and', filters: [] }; + this.filter.Skip = 0; this.loadFilteredPayInList(); } }