@@ -19,6 +19,7 @@ import { resizeObserverIgnoreError } from '../../test-utils/helper-utils.spec';
19
19
20
20
const ADVANCED_FILTERING_OPERATOR_LINE_AND_CSS_CLASS = 'igx-filter-tree__line--and' ;
21
21
const ADVANCED_FILTERING_OPERATOR_LINE_OR_CSS_CLASS = 'igx-filter-tree__line--or' ;
22
+ const ADVANCED_FILTERING_OPERATOR_LINE_SELECTED_CSS_CLASS = 'igx-filter-tree__line--selected' ;
22
23
23
24
describe ( 'IgxGrid - Advanced Filtering' , ( ) => {
24
25
configureTestSuite ( ) ;
@@ -1494,6 +1495,66 @@ describe('IgxGrid - Advanced Filtering', () => {
1494
1495
. toBeNull ( 'actions container is visible' ) ;
1495
1496
} ) ) ;
1496
1497
1498
+ it ( 'Should select/deselect all child conditions and groups when clicking a group\'s operator line.' , fakeAsync ( ( ) => {
1499
+ // Apply advanced filter through API.
1500
+ const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
1501
+ tree . filteringOperands . push ( {
1502
+ fieldName : 'Downloads' , searchVal : 100 , condition : IgxNumberFilteringOperand . instance ( ) . condition ( 'greaterThan' )
1503
+ } ) ;
1504
+ const orTree = new FilteringExpressionsTree ( FilteringLogic . Or ) ;
1505
+ orTree . filteringOperands . push ( {
1506
+ fieldName : 'ProductName' , searchVal : 'angular' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1507
+ ignoreCase : true
1508
+ } ) ;
1509
+ orTree . filteringOperands . push ( {
1510
+ fieldName : 'ProductName' , searchVal : 'script' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1511
+ ignoreCase : true
1512
+ } ) ;
1513
+ const andTree = new FilteringExpressionsTree ( FilteringLogic . Or ) ;
1514
+ andTree . filteringOperands . push ( {
1515
+ fieldName : 'ProductName' , searchVal : 'a' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1516
+ ignoreCase : true
1517
+ } ) ;
1518
+ andTree . filteringOperands . push ( {
1519
+ fieldName : 'ProductName' , searchVal : 's' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1520
+ ignoreCase : true
1521
+ } ) ;
1522
+ orTree . filteringOperands . push ( andTree ) ;
1523
+ tree . filteringOperands . push ( orTree ) ;
1524
+ grid . advancedFilteringExpressionsTree = tree ;
1525
+ fix . detectChanges ( ) ;
1526
+
1527
+ // Open Advanced Filtering dialog.
1528
+ GridFunctions . clickAdvancedFilteringButton ( fix ) ;
1529
+ fix . detectChanges ( ) ;
1530
+
1531
+ // Click root group's operator line and verify that the root group and all of its children become selected.
1532
+ let rootOperatorLine = GridFunctions . getAdvancedFilteringTreeRootGroupOperatorLine ( fix ) ;
1533
+ rootOperatorLine . click ( ) ;
1534
+ tick ( 200 ) ;
1535
+ fix . detectChanges ( ) ;
1536
+ verifyChildrenSelection ( GridFunctions . getAdvancedFilteringExpressionsContainer ( fix ) , true ) ;
1537
+
1538
+ // Click root group's operator line again and verify that the root group and all of its children become unselected.
1539
+ rootOperatorLine = GridFunctions . getAdvancedFilteringTreeRootGroupOperatorLine ( fix ) ;
1540
+ rootOperatorLine . click ( ) ;
1541
+ tick ( 200 ) ;
1542
+ fix . detectChanges ( ) ;
1543
+ verifyChildrenSelection ( GridFunctions . getAdvancedFilteringExpressionsContainer ( fix ) , false ) ;
1544
+
1545
+ // Click an inner group's operator line and verify its children become selected.
1546
+ GridFunctions . clickAdvancedFilteringTreeGroupOperatorLine ( fix , [ 1 ] ) ;
1547
+ tick ( 200 ) ;
1548
+ fix . detectChanges ( ) ;
1549
+ verifyChildrenSelection ( GridFunctions . getAdvancedFilteringTreeItem ( fix , [ 1 ] ) , true ) ;
1550
+
1551
+ // Click an inner group's operator line again and verify its children become unselected.
1552
+ GridFunctions . clickAdvancedFilteringTreeGroupOperatorLine ( fix , [ 1 ] ) ;
1553
+ tick ( 200 ) ;
1554
+ fix . detectChanges ( ) ;
1555
+ verifyChildrenSelection ( GridFunctions . getAdvancedFilteringTreeItem ( fix , [ 1 ] ) , false ) ;
1556
+ } ) ) ;
1557
+
1497
1558
describe ( 'Context Menu' , ( ) => {
1498
1559
it ( 'Should discard added group when clicking its operator line without having a single expression.' , fakeAsync ( ( ) => {
1499
1560
// Open Advanced Filtering dialog.
@@ -1917,6 +1978,31 @@ describe('IgxGrid - Advanced Filtering', () => {
1917
1978
}
1918
1979
} ) ) ;
1919
1980
1981
+ it ( 'Ungroup button of the root group\'s context menu should be disabled.' ,
1982
+ fakeAsync ( ( ) => {
1983
+ // Apply advanced filter through API.
1984
+ const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
1985
+ tree . filteringOperands . push ( {
1986
+ fieldName : 'Downloads' , searchVal : 100 , condition : IgxNumberFilteringOperand . instance ( ) . condition ( 'greaterThan' )
1987
+ } ) ;
1988
+ grid . advancedFilteringExpressionsTree = tree ;
1989
+ fix . detectChanges ( ) ;
1990
+
1991
+ // Open Advanced Filtering dialog.
1992
+ GridFunctions . clickAdvancedFilteringButton ( fix ) ;
1993
+ fix . detectChanges ( ) ;
1994
+
1995
+ // Click root group's operator line.
1996
+ const rootOperatorLine = GridFunctions . getAdvancedFilteringTreeRootGroupOperatorLine ( fix ) ;
1997
+ rootOperatorLine . click ( ) ;
1998
+ tick ( 200 ) ;
1999
+ fix . detectChanges ( ) ;
2000
+
2001
+ // Verify the ungroup button is disabled.
2002
+ const ungroupButton = GridFunctions . getAdvancedFilteringContextMenuButtons ( fix ) [ 1 ] ;
2003
+ expect ( ungroupButton . classList . contains ( 'igx-button--disabled' ) ) . toBe ( true ) ;
2004
+ } ) ) ;
2005
+
1920
2006
it ( 'Should delete the group from the tree when click \'delete\' from context menu.' ,
1921
2007
fakeAsync ( ( ) => {
1922
2008
// Apply advanced filter through API.
@@ -2280,6 +2366,11 @@ function verifyOperatorLine(operatorLine: HTMLElement, operator: string) {
2280
2366
}
2281
2367
}
2282
2368
2369
+ function verifyOperatorLineSelection ( operatorLine : HTMLElement , shouldBeSelected : boolean ) {
2370
+ expect ( operatorLine . classList . contains ( ADVANCED_FILTERING_OPERATOR_LINE_SELECTED_CSS_CLASS ) )
2371
+ . toBe ( shouldBeSelected , 'incorrect selection state of the operator line' ) ;
2372
+ }
2373
+
2283
2374
function verifyExpressionChipContent ( fix , path : number [ ] , columnText : string , operatorText : string , valueText : string ) {
2284
2375
const chip = GridFunctions . getAdvancedFilteringTreeExpressionChip ( fix , path ) ;
2285
2376
const chipSpans = GridFunctions . sortNativeElementsHorizontally ( Array . from ( chip . querySelectorAll ( 'span' ) ) ) ;
@@ -2293,6 +2384,10 @@ function verifyExpressionChipContent(fix, path: number[], columnText: string, op
2293
2384
2294
2385
function verifyExpressionChipSelection ( fix , path : number [ ] , shouldBeSelected : boolean ) {
2295
2386
const chip = GridFunctions . getAdvancedFilteringTreeExpressionChip ( fix , path ) ;
2387
+ verifyExpressionChipSelectionByChip ( chip , shouldBeSelected ) ;
2388
+ }
2389
+
2390
+ function verifyExpressionChipSelectionByChip ( chip : HTMLElement , shouldBeSelected : boolean ) {
2296
2391
const chipItem = chip . querySelector ( '.igx-chip__item' ) ;
2297
2392
if ( shouldBeSelected ) {
2298
2393
expect ( chipItem . classList . contains ( 'igx-chip__item--selected' ) ) . toBe ( true , 'chip is not selected' ) ;
@@ -2305,6 +2400,20 @@ function verifyExpressionChipSelection(fix, path: number[], shouldBeSelected: bo
2305
2400
}
2306
2401
}
2307
2402
2403
+ /**
2404
+ * Verifies that all children (operator lines and expression chips) of the provided 'parent' are selected.
2405
+ */
2406
+ function verifyChildrenSelection ( parent : HTMLElement , shouldBeSelected : boolean ) {
2407
+ const allOperatorLines : any [ ] = Array . from ( parent . querySelectorAll ( '.igx-filter-tree__line' ) ) ;
2408
+ const allExpressionChips : any [ ] = Array . from ( parent . querySelectorAll ( '.igx-filter-tree__expression-item' ) ) ;
2409
+ for ( const operatorLine of allOperatorLines ) {
2410
+ verifyOperatorLineSelection ( operatorLine , shouldBeSelected ) ;
2411
+ }
2412
+ for ( const expressionChip of allExpressionChips ) {
2413
+ verifyExpressionChipSelectionByChip ( expressionChip , shouldBeSelected ) ;
2414
+ }
2415
+ }
2416
+
2308
2417
function verifyEditModeExpressionInputStates ( fix ,
2309
2418
columnSelectEnabled : boolean ,
2310
2419
operatorSelectEnabled : boolean ,
0 commit comments