Explorar el Código

bug fix for number filter and pay-in list all income mode

tags/2.037
Patrick Sun hace 4 años
padre
commit
496c6e73e3
Se han modificado 6 ficheros con 45 adiciones y 20 borrados
  1. +3
    -5
      src/app/grid-filter/date-filter/date-filter.component.ts
  2. +15
    -5
      src/app/grid-filter/number-range-filter/number-range-filter.component.ts
  3. +1
    -1
      src/app/grid-filter/string-filter/string-filter.component.ts
  4. +1
    -0
      src/app/list-income/list-income.component.html
  5. +6
    -6
      src/app/pay-in/pay-in.component.html
  6. +19
    -3
      src/app/pay-in/pay-in.component.ts

+ 3
- 5
src/app/grid-filter/date-filter/date-filter.component.ts Ver fichero

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',

+ 15
- 5
src/app/grid-filter/number-range-filter/number-range-filter.component.ts Ver fichero

} }


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

+ 1
- 1
src/app/grid-filter/string-filter/string-filter.component.ts Ver fichero

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
}) })
); );

+ 1
- 0
src/app/list-income/list-income.component.html Ver fichero

[showLoanColumn]="true" [showLoanColumn]="true"
[showUploadColumn]="true" [showUploadColumn]="true"
[LoadDataNow]="startLoad" [LoadDataNow]="startLoad"
[allowFilter]="true"
> >
</app-pay-in> </app-pay-in>
</div> </div>

+ 6
- 6
src/app/pay-in/pay-in.component.html Ver fichero

[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>

+ 19
- 3
src/app/pay-in/pay-in.component.ts Ver fichero

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();
}
}
} }

Cargando…
Cancelar
Guardar