Skip to content

Commit 85d0dc3

Browse files
committed
fix(adv-filtering): refactoring - parseValue method moved to data util #6257
1 parent ead0c04 commit 85d0dc3

File tree

4 files changed

+15
-37
lines changed

4 files changed

+15
-37
lines changed

projects/igniteui-angular/src/lib/data-operations/data-util.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,14 @@ export class DataUtil {
210210
return data;
211211
}
212212

213+
public static parseValue(dataType: DataType, value: any): any {
214+
if (dataType === DataType.Number) {
215+
value = parseFloat(value);
216+
}
217+
218+
return value;
219+
}
220+
213221
private static findParentFromPath(data: any[], primaryKey: any, childDataKey: any, path: any[]): any {
214222
let collection: any[] = data;
215223
let result: any;

projects/igniteui-angular/src/lib/grids/filtering/advanced-filtering/advanced-filtering-dialog.component.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { takeUntil, first } from 'rxjs/operators';
1818
import { Subject } from 'rxjs';
1919
import { KEYS } from '../../../core/utils';
2020
import { AbsoluteScrollStrategy, AutoPositionStrategy } from '../../../services/index';
21-
import { DataType } from './../../../data-operations/data-util';
21+
import { DataType, DataUtil } from './../../../data-operations/data-util';
2222

2323
/**
2424
*@hidden
@@ -302,23 +302,13 @@ export class IgxAdvancedFilteringDialogComponent implements AfterViewInit, OnDes
302302
if (this.editedExpression) {
303303
this.editedExpression.expression.fieldName = this.selectedColumn.field;
304304
this.editedExpression.expression.condition = this.selectedColumn.filters.condition(this.selectedCondition);
305-
this.editedExpression.expression.searchVal = this.transformValue(this.searchValue);
305+
this.editedExpression.expression.searchVal = DataUtil.parseValue(this.selectedColumn.dataType, this.searchValue);
306306

307307
this.editedExpression.inEditMode = false;
308308
this.editedExpression = null;
309309
}
310310
}
311311

312-
private transformValue(value): any {
313-
if (this.selectedColumn.dataType === DataType.Number) {
314-
value = parseFloat(value);
315-
} else if (this.selectedColumn.dataType === DataType.Boolean) {
316-
value = Boolean(value);
317-
}
318-
319-
return value;
320-
}
321-
322312
public cancelOperandAdd() {
323313
if (this.addModeExpression) {
324314
this.addModeExpression.inAddMode = false;

projects/igniteui-angular/src/lib/grids/filtering/excel-style/excel-style-default-expression.component.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import {
99
ViewChild
1010
} from '@angular/core';
1111
import { IgxColumnComponent } from '../../column.component';
12-
import { ExpressionUI } from '../grid-filtering.service';
12+
import { ExpressionUI, IgxFilteringService } from '../grid-filtering.service';
1313
import { IgxButtonGroupComponent } from '../../../buttonGroup/buttonGroup.component';
1414
import { IgxDropDownItemComponent, IgxDropDownComponent } from '../../../drop-down/index';
1515
import { IgxInputGroupComponent, IgxInputDirective } from '../../../input-group/index';
16-
import { DataType } from '../../../data-operations/data-util';
16+
import { DataType, DataUtil } from '../../../data-operations/data-util';
1717
import { IFilteringOperation } from '../../../data-operations/filtering-condition';
1818
import { OverlaySettings, ConnectedPositioningStrategy, CloseScrollStrategy } from '../../../services/index';
1919
import { KEYS, IBaseEventArgs } from '../../../core/utils';
@@ -167,7 +167,7 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
167167
}
168168

169169
public onValuesInput(eventArgs) {
170-
this.expressionUI.expression.searchVal = this.transformValue(eventArgs.target.value);
170+
this.expressionUI.expression.searchVal = DataUtil.parseValue(this.column.dataType, eventArgs.target.value);
171171
}
172172

173173
public onLogicOperatorButtonClicked(eventArgs, buttonIndex: number) {
@@ -207,14 +207,4 @@ export class IgxExcelStyleDefaultExpressionComponent implements AfterViewInit {
207207

208208
event.stopPropagation();
209209
}
210-
211-
private transformValue(value): any {
212-
if (this.column.dataType === DataType.Number) {
213-
value = parseFloat(value);
214-
} else if (this.column.dataType === DataType.Boolean) {
215-
value = Boolean(value);
216-
}
217-
218-
return value;
219-
}
220210
}

projects/igniteui-angular/src/lib/grids/filtering/grid-filtering-row.component.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
ChangeDetectionStrategy,
1414
ViewRef
1515
} from '@angular/core';
16-
import { DataType } from '../../data-operations/data-util';
16+
import { DataType, DataUtil } from '../../data-operations/data-util';
1717
import { IgxColumnComponent } from '../column.component';
1818
import { IgxDropDownComponent, ISelectionEventArgs } from '../../drop-down/index';
1919
import { IFilteringOperation } from '../../data-operations/filtering-condition';
@@ -100,7 +100,7 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
100100
this.expression.searchVal = null;
101101
this.showHideArrowButtons();
102102
} else {
103-
this.expression.searchVal = this.transformValue(val);
103+
this.expression.searchVal = DataUtil.parseValue(this.column.dataType, val);
104104
if (this.expressionsList.find(item => item.expression === this.expression) === undefined) {
105105
this.addExpression(true);
106106
}
@@ -659,16 +659,6 @@ export class IgxGridFilteringRowComponent implements AfterViewInit {
659659
});
660660
}
661661

662-
private transformValue(value): any {
663-
if (this.column.dataType === DataType.Number) {
664-
value = parseFloat(value);
665-
} else if (this.column.dataType === DataType.Boolean) {
666-
value = Boolean(value);
667-
}
668-
669-
return value;
670-
}
671-
672662
private addExpression(isSelected: boolean) {
673663
const exprUI = new ExpressionUI();
674664
exprUI.expression = this.expression;

0 commit comments

Comments
 (0)