@@ -172,17 +172,12 @@ export class IgxQueryBuilderTreeComponent implements AfterViewInit, OnDestroy {
172
172
@Input ( )
173
173
public set fields ( fields : FieldType [ ] ) {
174
174
this . _fields = fields ;
175
-
175
+
176
+ this . _fields = this . _fields ?. map ( f => ( { ...f , filters : this . getFilters ( f ) , pipeArgs : this . getPipeArgs ( f ) } ) ) ;
177
+
176
178
if ( ! this . _fields && this . isAdvancedFiltering ( ) ) {
177
179
this . _fields = this . entities [ 0 ] . fields ;
178
180
}
179
-
180
- if ( this . _fields ) {
181
- this . _fields . forEach ( field => {
182
- this . setFilters ( field ) ;
183
- this . setFormat ( field ) ;
184
- } ) ;
185
- }
186
181
}
187
182
188
183
/**
@@ -1182,7 +1177,7 @@ export class IgxQueryBuilderTreeComponent implements AfterViewInit, OnDestroy {
1182
1177
if ( ! this . selectedField ) {
1183
1178
this . fieldSelect . input . nativeElement . focus ( ) ;
1184
1179
} else if ( this . selectedField . filters . condition ( this . selectedCondition ) ?. isUnary ) {
1185
- this . conditionSelect . input . nativeElement . focus ( ) ;
1180
+ this . conditionSelect ? .input . nativeElement . focus ( ) ;
1186
1181
} else {
1187
1182
const input = this . searchValueInput ?. nativeElement || this . picker ?. getEditElement ( ) ;
1188
1183
input ?. focus ( ) ;
@@ -1485,16 +1480,19 @@ export class IgxQueryBuilderTreeComponent implements AfterViewInit, OnDestroy {
1485
1480
return ctx ;
1486
1481
}
1487
1482
1488
- private setFormat ( field : FieldType ) {
1489
- if ( ! field . pipeArgs ) {
1490
- field . pipeArgs = { digitsInfo : DEFAULT_PIPE_DIGITS_INFO } ;
1483
+ private getPipeArgs ( field : FieldType ) {
1484
+ let pipeArgs = { ...field . pipeArgs } ;
1485
+ if ( ! pipeArgs ) {
1486
+ pipeArgs = { digitsInfo : DEFAULT_PIPE_DIGITS_INFO } ;
1491
1487
}
1492
1488
1493
- if ( ! field . pipeArgs . format ) {
1494
- field . pipeArgs . format = field . dataType === DataType . Time ?
1489
+ if ( ! pipeArgs . format ) {
1490
+ pipeArgs . format = field . dataType === DataType . Time ?
1495
1491
DEFAULT_PIPE_TIME_FORMAT : field . dataType === DataType . DateTime ?
1496
1492
DEFAULT_PIPE_DATE_TIME_FORMAT : DEFAULT_PIPE_DATE_FORMAT ;
1497
1493
}
1494
+
1495
+ return pipeArgs ;
1498
1496
}
1499
1497
1500
1498
private selectDefaultCondition ( ) {
@@ -1503,30 +1501,24 @@ export class IgxQueryBuilderTreeComponent implements AfterViewInit, OnDestroy {
1503
1501
}
1504
1502
}
1505
1503
1506
- private setFilters ( field : FieldType ) {
1504
+ private getFilters ( field : FieldType ) {
1507
1505
if ( ! field . filters ) {
1508
1506
switch ( field . dataType ) {
1509
1507
case DataType . Boolean :
1510
- field . filters = IgxBooleanFilteringOperand . instance ( ) ;
1511
- break ;
1508
+ return IgxBooleanFilteringOperand . instance ( ) ;
1512
1509
case DataType . Number :
1513
1510
case DataType . Currency :
1514
1511
case DataType . Percent :
1515
- field . filters = IgxNumberFilteringOperand . instance ( ) ;
1516
- break ;
1512
+ return IgxNumberFilteringOperand . instance ( ) ;
1517
1513
case DataType . Date :
1518
- field . filters = IgxDateFilteringOperand . instance ( ) ;
1519
- break ;
1514
+ return IgxDateFilteringOperand . instance ( ) ;
1520
1515
case DataType . Time :
1521
- field . filters = IgxTimeFilteringOperand . instance ( ) ;
1522
- break ;
1516
+ return IgxTimeFilteringOperand . instance ( ) ;
1523
1517
case DataType . DateTime :
1524
- field . filters = IgxDateTimeFilteringOperand . instance ( ) ;
1525
- break ;
1518
+ return IgxDateTimeFilteringOperand . instance ( ) ;
1526
1519
case DataType . String :
1527
1520
default :
1528
- field . filters = IgxStringFilteringOperand . instance ( ) ;
1529
- break ;
1521
+ return IgxStringFilteringOperand . instance ( ) ;
1530
1522
}
1531
1523
}
1532
1524
}
0 commit comments