| if ( this.range > this.end ){ | if ( this.range > this.end ){ | ||||
| this.range = this.end; | this.range = this.end; | ||||
| } | } | ||||
| this.date = new Date(); | |||||
| this.date = null; | |||||
| } | } | ||||
| private rangeBetween(start: number, end: number): number[] { | private rangeBetween(start: number, end: number): number[] { | ||||
| this.debouncedDoFilter().then(); | this.debouncedDoFilter().then(); | ||||
| } | } | ||||
| public onRangeChange(r: number): void { | public onRangeChange(r: number): void { | ||||
| console.log(this.date, r); | |||||
| this.debouncedDoFilter().then(); | this.debouncedDoFilter().then(); | ||||
| } | } | ||||
| const fs: FilterDescriptor[] = []; | const fs: FilterDescriptor[] = []; | ||||
| const start: Date = new Date(this.date); start.setDate(this.date.getDate() - this.range); | const start: Date = new Date(this.date); start.setDate(this.date.getDate() - this.range); | ||||
| const end: Date = new Date(this.date); end.setDate(this.date.getDate() + this.range); | const end: Date = new Date(this.date); end.setDate(this.date.getDate() + this.range); | ||||
| console.log(new Date(start), new Date(end)); | |||||
| fs.push({ | fs.push({ | ||||
| field: this.fieldName, | field: this.fieldName, | ||||
| operator: 'gte', | operator: 'gte', | ||||
| value: start.getTime() | |||||
| value: start.getTime() / 1000 | |||||
| }); | }); | ||||
| fs.push({ | fs.push({ | ||||
| field: this.fieldName, | field: this.fieldName, | ||||
| operator: 'lte', | operator: 'lte', | ||||
| value: end.getTime() | |||||
| value: end.getTime() / 1000 | |||||
| }); | }); | ||||
| this.removeFilter(this.fieldName); | this.removeFilter(this.fieldName); | ||||
| const root: CompositeFilterDescriptor = this.filter || { logic: 'and', | const root: CompositeFilterDescriptor = this.filter || { logic: 'and', |
| } | } | ||||
| private initAvailableOperators(): void { | private initAvailableOperators(): void { | ||||
| this.availableOperators = this.AllOperatorMap.filter( v => { | |||||
| // console.log(v, this.options.indexOf(v.value), this.options); | |||||
| return this.options.indexOf(v.value) !== -1; | |||||
| } ); | |||||
| if ( this.availableOperators.length === 0) { | |||||
| this.availableOperators = []; | |||||
| const self = this; | |||||
| this.options.forEach( v => this.availableOperators.push(self.getOp(v)) ); | |||||
| if ( this.availableOperators.length <= 0) { | |||||
| this.availableOperators = [this.defaultOperator]; | this.availableOperators = [this.defaultOperator]; | ||||
| this.operator = this.defaultOperator; | this.operator = this.defaultOperator; | ||||
| }else{ | }else{ | ||||
| this.singleMode = this.operator.value !== 'range'; | this.singleMode = this.operator.value !== 'range'; | ||||
| } | } | ||||
| private getOp(key: string): Operator { | |||||
| let ret: Operator; | |||||
| this.AllOperatorMap.every( v => { | |||||
| if ( v.value === key ) { | |||||
| ret = v; | |||||
| } | |||||
| return v.value !== key; | |||||
| }); | |||||
| return ret; | |||||
| } | |||||
| // | // | ||||
| // Events handling | // Events handling |
| this.removeFilter(this.fieldName) : | this.removeFilter(this.fieldName) : | ||||
| this.updateFilter({ | this.updateFilter({ | ||||
| field: this.fieldName, | field: this.fieldName, | ||||
| operator: 'eq', | |||||
| operator: 'contains', | |||||
| value: v | value: v | ||||
| }) | }) | ||||
| ); | ); |
| [showLoanColumn]="true" | [showLoanColumn]="true" | ||||
| [showUploadColumn]="true" | [showUploadColumn]="true" | ||||
| [LoadDataNow]="startLoad" | [LoadDataNow]="startLoad" | ||||
| [allowFilter]="true" | |||||
| > | > | ||||
| </app-pay-in> | </app-pay-in> | ||||
| </div> | </div> |
| [pageSize]="filter.Take" | [pageSize]="filter.Take" | ||||
| [skip]="filter.Skip" | [skip]="filter.Skip" | ||||
| [sortable]="sortable" | [sortable]="sortable" | ||||
| [filterable]="allowFilter" | |||||
| [filterable]="filterable" | |||||
| [loading]="loading" | [loading]="loading" | ||||
| [sort]="filter.Sort" | [sort]="filter.Sort" | ||||
| <span *ngIf="uploadMeta.Id > 0 " class="badge badge-pill badge-primary specific-upload"> {{uploadMeta.Id}} </span> | <span *ngIf="uploadMeta.Id > 0 " class="badge badge-pill badge-primary specific-upload"> {{uploadMeta.Id}} </span> | ||||
| <span *ngIf="uploadMeta.Id > 0 " class="badge badge-secondary specific-upload"> {{uploadMeta.FileName}} </span> | <span *ngIf="uploadMeta.Id > 0 " class="badge badge-secondary specific-upload"> {{uploadMeta.FileName}} </span> | ||||
| <button *ngIf="false" kendoButton icon="filter" (click)="showFilter()" >Filter</button> | <button *ngIf="false" kendoButton icon="filter" (click)="showFilter()" >Filter</button> | ||||
| <kendo-switch [(ngModel)]="allowFilter" onLabel="⧩" | |||||
| offLabel="all"></kendo-switch> | |||||
| <kendo-switch *ngIf="allowFilter" [(ngModel)]="filterable" onLabel="⧩" offLabel="all" | |||||
| (valueChange)="onFilterEnable($event)"></kendo-switch> | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </ng-template> | </ng-template> | ||||
| <kendo-grid-column field="IncomeAmount" title="Income" width="150" format="{0:c}" editor="numeric"> | <kendo-grid-column field="IncomeAmount" title="Income" width="150" format="{0:c}" editor="numeric"> | ||||
| <ng-template kendoGridFilterCellTemplate let-filter let-column="column"> | <ng-template kendoGridFilterCellTemplate let-filter let-column="column"> | ||||
| <app-number-range-filter [filter]="filter" [fieldName]="'IncomeAmount'" | <app-number-range-filter [filter]="filter" [fieldName]="'IncomeAmount'" | ||||
| [options]="['eq', 'lte', 'gte', 'range']" [min]=0 | |||||
| [options]="['gte', 'eq', 'lte', 'range']" [min]=0 | |||||
| > | > | ||||
| </app-number-range-filter> | </app-number-range-filter> | ||||
| </ng-template> | </ng-template> | ||||
| <ng-template kendoGridFilterCellTemplate let-filter let-column="column"> | <ng-template kendoGridFilterCellTemplate let-filter let-column="column"> | ||||
| <app-number-range-filter [filter]="filter" [fieldName]="'Balance'" | <app-number-range-filter [filter]="filter" [fieldName]="'Balance'" | ||||
| [options]="['eq', 'lte', 'gte','range']" [min]=0 | |||||
| [options]="['gte', 'lte', 'eq','range']" [min]=0 | |||||
| > | > | ||||
| </app-number-range-filter> | </app-number-range-filter> | ||||
| </ng-template> | </ng-template> | ||||
| </ng-template> | </ng-template> | ||||
| <ng-template kendoGridFilterCellTemplate let-filter let-column="column"> | <ng-template kendoGridFilterCellTemplate let-filter let-column="column"> | ||||
| <app-number-range-filter [filter]="filter" [fieldName]="'OffsetBalance'" | <app-number-range-filter [filter]="filter" [fieldName]="'OffsetBalance'" | ||||
| [options]="['eq', 'lte', 'gte', 'range']" [min]=0 | |||||
| [options]="['gte', 'lte', 'eq', 'range']" [min]=0 | |||||
| > | > | ||||
| </app-number-range-filter> | </app-number-range-filter> | ||||
| </ng-template> | </ng-template> |
| RowClassArgs, | RowClassArgs, | ||||
| SortSettings, | SortSettings, | ||||
| DataStateChangeEvent, | DataStateChangeEvent, | ||||
| SelectableSettings | |||||
| SelectableSettings, PagerSettings | |||||
| } from '@progress/kendo-angular-grid'; | } from '@progress/kendo-angular-grid'; | ||||
| import {CompositeFilterDescriptor, FilterDescriptor, SortDescriptor} from '@progress/kendo-data-query'; | import {CompositeFilterDescriptor, FilterDescriptor, SortDescriptor} from '@progress/kendo-data-query'; | ||||
| import {UploadMetaModel} from '../models/uploadMetaModel'; | import {UploadMetaModel} from '../models/uploadMetaModel'; | ||||
| public showBalance = true; | public showBalance = true; | ||||
| public showOffsetBalance = true; | public showOffsetBalance = true; | ||||
| @Input() public pageable = true; | |||||
| @Input() public pageable: PagerSettings = { | |||||
| pageSizes: [2, 5, 10, 15, 20, 30, 40, 50, 100], | |||||
| previousNext: true | |||||
| }; | |||||
| @Input() public pageSize = 15; | @Input() public pageSize = 15; | ||||
| @Input() public Selection: number[] = []; | @Input() public Selection: number[] = []; | ||||
| public pageSizeOptions = [2, 5, 10, 15, 20, 30, 40, 50, 100]; | |||||
| public filterable: boolean; | |||||
| public sortable: SortSettings = { | public sortable: SortSettings = { | ||||
| mode: 'single' | mode: 'single' | ||||
| }; | }; | ||||
| public pageChange(event: PageChangeEvent): void { | public pageChange(event: PageChangeEvent): void { | ||||
| this.filter.Skip = event.skip; | this.filter.Skip = event.skip; | ||||
| this.filter.Take = event.take; | |||||
| // this.loadFilteredData(); | // this.loadFilteredData(); | ||||
| } | } | ||||
| public filterChange( filter: CompositeFilterDescriptor): void { | public filterChange( filter: CompositeFilterDescriptor): void { | ||||
| // console.log (filter, this.state.filter); | // console.log (filter, this.state.filter); | ||||
| this.filter.Skip = 0; | |||||
| } | } | ||||
| public dataStateChange(state: DataStateChangeEvent): void { | public dataStateChange(state: DataStateChangeEvent): void { | ||||
| this.state = state; | this.state = state; | ||||
| console.log(state); | |||||
| this.loadFilteredPayInList(); | this.loadFilteredPayInList(); | ||||
| console.log(state, this.state); | |||||
| } | } | ||||
| public onLoanChange(loan: LoanModel): void { | public onLoanChange(loan: LoanModel): void { | ||||
| }); | }); | ||||
| return found; | return found; | ||||
| } | } | ||||
| public onFilterEnable(filtering: boolean): void { | |||||
| if ( ! filtering ) { | |||||
| this.state.filter = { logic: 'and', filters: [] }; | |||||
| this.state.skip = 0; | |||||
| this.loadFilteredPayInList(); | |||||
| } | |||||
| } | |||||
| } | } |