diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 70c5a83..7410a4d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -94,6 +94,7 @@ import {UploadInterceptor} from './lender-uploads/upload-status.interceptor'; import { UploadDetailComponent } from './upload-detail/upload-detail.component'; import {SafeUrlPipe} from './pipe/safe.url.pipe'; import { ImagePopupDialogComponent } from './image-popup-dialog/image-popup-dialog.component'; +import { PopupIncomeFilterComponent } from './popup-income-filter/popup-income-filter.component'; @@ -157,7 +158,8 @@ import { ImagePopupDialogComponent } from './image-popup-dialog/image-popup-dial UploadCardsComponent, UploadDetailComponent, SafeUrlPipe, - ImagePopupDialogComponent + ImagePopupDialogComponent, + PopupIncomeFilterComponent ], imports: [ BrowserModule, diff --git a/src/app/models/pay-in-list.filter.model.ts b/src/app/models/pay-in-list.filter.model.ts index 4b060c7..dd94afa 100644 --- a/src/app/models/pay-in-list.filter.model.ts +++ b/src/app/models/pay-in-list.filter.model.ts @@ -1,12 +1,44 @@ +import {SortDescriptor} from '@progress/kendo-data-query'; + export class PayInListFilterModel { LoanIds: string[]; - Uploads: string[]; + UploadIds: string[]; Take: number; Skip: number; TsFrom: Date; TsTo: Date; IdFrom: number; IdTo: number; - IncomeFrom: number; - IncomeTo: number; + TrailFrom: number; + TrailTo: number; + BalanceFrom: number; + BalanceTo: number; + AmountFrom: number; + AmountTo: number; + Sort?: SortDescriptor[]; + + constructor(payload: Partial) { + this.LoanIds = []; + if (payload.LoanIds !== undefined && payload.LoanIds.length > 0) { + payload.LoanIds.forEach(v => { this.LoanIds.push(v); }); + } + this.UploadIds = []; + if (payload.UploadIds !== undefined && payload.UploadIds.length > 0 ) { + payload.UploadIds.forEach(v => { this.UploadIds.push(v); }); + } + + const bigNumber = 9999999999; + this.Take = payload.Take || 10; + 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; + } } diff --git a/src/app/pay-in/pay-in.component.html b/src/app/pay-in/pay-in.component.html index d79759e..a24c505 100644 --- a/src/app/pay-in/pay-in.component.html +++ b/src/app/pay-in/pay-in.component.html @@ -1,9 +1,21 @@
@@ -11,7 +23,7 @@
- +
@@ -26,19 +38,28 @@
- + + + + + + - + - + {{ dataItem.Ts | date: 'yyyy-MM-dd' }} - + + + +
{{ dataItem.Balance | currency}}
unknown
@@ -64,7 +85,7 @@
- +
{{ dataItem.OffsetBalance | currency}}
unknown
@@ -89,18 +110,20 @@
- + -

-

- +
+ diff --git a/src/app/pay-in/pay-in.component.ts b/src/app/pay-in/pay-in.component.ts index 3ba531a..5a85dee 100644 --- a/src/app/pay-in/pay-in.component.ts +++ b/src/app/pay-in/pay-in.component.ts @@ -1,10 +1,13 @@ -import {Component, Input, OnInit} from '@angular/core'; +import {Component, Input, OnInit, ViewChild} from '@angular/core'; import {PayInModel} from '../models/pay-in.model'; import {FormControl, FormGroup, Validators} from '@angular/forms'; import {PayInListFilterModel} from '../models/pay-in-list.filter.model'; import {PayInService} from '../service/pay-in.service'; import {PayInListResult} from '../models/pay-in-list-result.model'; import {Router} from '@angular/router'; +import {PopupIncomeFilterComponent} from '../popup-income-filter/popup-income-filter.component'; +import {PageChangeEvent, SortSettings} from '@progress/kendo-angular-grid'; +import {SortDescriptor} from '@progress/kendo-data-query'; const createFormGroup = dataItem => new FormGroup({ Id: new FormControl({value: dataItem.Id, disabled: true}, Validators.required), @@ -21,14 +24,10 @@ const createFormGroup = dataItem => new FormGroup({ styleUrls: ['./pay-in.component.scss'] }) export class PayInComponent implements OnInit { - @Input() loanFilter: string[] = []; - @Input() uploadsFilter: string[] = []; @Input() allowAddNew = true; @Input() allowEdit = true; - @Input() pageSize = 10; - @Input() skip = 0; - @Input() dateStart = new Date('1900-01-01'); - @Input() dateEnd = new Date('2038-12-31'); + @Input() filter: PayInListFilterModel = new PayInListFilterModel({}); + @ViewChild('filterDialog', {static: true}) filterDialog: PopupIncomeFilterComponent; public gridData: PayInListResult = { data: [], total: 0}; public incomeFormGroup: FormGroup; @@ -37,21 +36,38 @@ export class PayInComponent implements OnInit { public showBalance = true; public showOffsetBalance = true; + public pageable = true; + public sortable: SortSettings = { + mode: 'single' + }; + public filterable = false; + + public loading = false; constructor(private pis: PayInService, private router: Router) { } ngOnInit(): void { - this.pis.getPayInList(new PayInListFilterModel()).subscribe( + this.loadFilteredData(); + } + + 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 PayInModel(v)); + this.loading = false; }); + }, err => { + this.loading = false; + }, () => { + this.loading = false; } ); } - public addHandler({ sender }): void { this.closeEditor(sender); @@ -159,4 +175,33 @@ 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 pageChange(event: PageChangeEvent): void { + this.filter.Skip = event.skip; + this.loadFilteredData(); + } + + public sortChange(sort: SortDescriptor[]): void { + this.filter.Sort = sort; + this.loadFilteredData(); + } } diff --git a/src/app/popup-income-filter/popup-income-filter.component.html b/src/app/popup-income-filter/popup-income-filter.component.html new file mode 100644 index 0000000..64d3766 --- /dev/null +++ b/src/app/popup-income-filter/popup-income-filter.component.html @@ -0,0 +1,85 @@ + +
+
+ + ➜ + +
+ +
+ + ➜ + +
+ + +
+ + + ➜ + + +
+ +
+ + ➜ + +
+ +
+ + ➜ + +
+ +
+ +
+ +
+ + + + + + + + +
diff --git a/src/app/popup-income-filter/popup-income-filter.component.scss b/src/app/popup-income-filter/popup-income-filter.component.scss new file mode 100644 index 0000000..442a982 --- /dev/null +++ b/src/app/popup-income-filter/popup-income-filter.component.scss @@ -0,0 +1,5 @@ +.range-field { + margin-top:10px; + margin-bottom:30px; + border-bottom: 1px dotted lightgrey; +} diff --git a/src/app/popup-income-filter/popup-income-filter.component.spec.ts b/src/app/popup-income-filter/popup-income-filter.component.spec.ts new file mode 100644 index 0000000..80f4137 --- /dev/null +++ b/src/app/popup-income-filter/popup-income-filter.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PopupIncomeFilterComponent } from './popup-income-filter.component'; + +describe('PopupIncomeFilterComponent', () => { + let component: PopupIncomeFilterComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PopupIncomeFilterComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(PopupIncomeFilterComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/popup-income-filter/popup-income-filter.component.ts b/src/app/popup-income-filter/popup-income-filter.component.ts new file mode 100644 index 0000000..f5fee87 --- /dev/null +++ b/src/app/popup-income-filter/popup-income-filter.component.ts @@ -0,0 +1,42 @@ +import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core'; +import {PayInListFilterModel} from '../models/pay-in-list.filter.model'; + +@Component({ + selector: 'app-popup-income-filter', + templateUrl: './popup-income-filter.component.html', + styleUrls: ['./popup-income-filter.component.scss'] +}) +export class PopupIncomeFilterComponent implements OnInit { + public opened = false; + public filter: PayInListFilterModel; + @Output() public DoFilter: EventEmitter = new EventEmitter(); + constructor() { } + + ngOnInit(): void { + if ( this.filter === undefined) { + this.filter = new PayInListFilterModel({}); + } + } + + public close(status: string): void { + this.opened = false; + + if (status === 'filter' ){ + this.DoFilter.emit(this.filter); + } + + if (status === 'clear') { + this.clearFilter(); + this.DoFilter.emit(this.filter); + } + } + + private clearFilter(): void { + this.filter = new PayInListFilterModel({}); + } + + public show(): void { + this.opened = true; + } +} +