@@ -1638,6 +1638,221 @@ describe('IgxGrid - Advanced Filtering', () => {
1638
1638
expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( firstItem , false ) . length ) . toBe ( 1 ) ;
1639
1639
verifyExpressionChipContent ( fix , [ 0 , 0 ] , 'ProductName' , 'Contains' , 'angular' ) ;
1640
1640
} ) ) ;
1641
+
1642
+ it ( 'Should show/hide group\'s context menu when clicking its operator line.' , fakeAsync ( ( ) => {
1643
+ // Apply advanced filter through API.
1644
+ const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
1645
+ tree . filteringOperands . push ( {
1646
+ fieldName : 'Downloads' , searchVal : 100 , condition : IgxNumberFilteringOperand . instance ( ) . condition ( 'greaterThan' )
1647
+ } ) ;
1648
+ const orTree = new FilteringExpressionsTree ( FilteringLogic . Or ) ;
1649
+ orTree . filteringOperands . push ( {
1650
+ fieldName : 'ProductName' , searchVal : 'angular' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1651
+ ignoreCase : true
1652
+ } ) ;
1653
+ orTree . filteringOperands . push ( {
1654
+ fieldName : 'ProductName' , searchVal : 'script' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1655
+ ignoreCase : true
1656
+ } ) ;
1657
+ tree . filteringOperands . push ( orTree ) ;
1658
+ grid . advancedFilteringExpressionsTree = tree ;
1659
+ fix . detectChanges ( ) ;
1660
+
1661
+ // Open Advanced Filtering dialog.
1662
+ GridFunctions . clickAdvancedFilteringButton ( fix ) ;
1663
+ fix . detectChanges ( ) ;
1664
+
1665
+ // Verify context menu is not visible.
1666
+ verifyContextMenuVisibility ( fix , false ) ;
1667
+
1668
+ // Click the innner group's operator line.
1669
+ const operatorLine = GridFunctions . getAdvancedFilteringTreeGroupOperatorLine ( fix , [ 1 ] ) ;
1670
+ operatorLine . click ( ) ;
1671
+ tick ( 400 ) ;
1672
+ fix . detectChanges ( ) ;
1673
+
1674
+ // Verify context menu is visible.
1675
+ verifyContextMenuVisibility ( fix , true ) ;
1676
+ verifyContextMenuType ( fix , true ) ;
1677
+
1678
+ // Click the innner group's operator line again.
1679
+ operatorLine . click ( ) ;
1680
+ tick ( 400 ) ;
1681
+ fix . detectChanges ( ) ;
1682
+
1683
+ // Verify context menu is no longer visible.
1684
+ verifyContextMenuVisibility ( fix , false ) ;
1685
+ } ) ) ;
1686
+
1687
+ it ( 'Should change the group\'s operator when using its context menu buttons.' , fakeAsync ( ( ) => {
1688
+ // Apply advanced filter through API.
1689
+ const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
1690
+ tree . filteringOperands . push ( {
1691
+ fieldName : 'Downloads' , searchVal : 100 , condition : IgxNumberFilteringOperand . instance ( ) . condition ( 'greaterThan' )
1692
+ } ) ;
1693
+ const orTree = new FilteringExpressionsTree ( FilteringLogic . Or ) ;
1694
+ orTree . filteringOperands . push ( {
1695
+ fieldName : 'ProductName' , searchVal : 'angular' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1696
+ ignoreCase : true
1697
+ } ) ;
1698
+ orTree . filteringOperands . push ( {
1699
+ fieldName : 'ProductName' , searchVal : 'script' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1700
+ ignoreCase : true
1701
+ } ) ;
1702
+ tree . filteringOperands . push ( orTree ) ;
1703
+ grid . advancedFilteringExpressionsTree = tree ;
1704
+ fix . detectChanges ( ) ;
1705
+
1706
+ // Open Advanced Filtering dialog.
1707
+ GridFunctions . clickAdvancedFilteringButton ( fix ) ;
1708
+ fix . detectChanges ( ) ;
1709
+
1710
+ // Verify current operator of inner group.
1711
+ let operatorLine = GridFunctions . getAdvancedFilteringTreeGroupOperatorLine ( fix , [ 1 ] ) ;
1712
+ verifyOperatorLine ( operatorLine , 'or' ) ;
1713
+
1714
+ // Click the innner group's operator line.
1715
+ operatorLine . click ( ) ;
1716
+ tick ( 400 ) ;
1717
+ fix . detectChanges ( ) ;
1718
+
1719
+ // Click the 'and' button of the button group in the context menu.
1720
+ const buttonGroup = GridFunctions . getAdvancedFilteringContextMenuButtonGroup ( fix ) ;
1721
+ const andOperatorButton : any = Array . from ( buttonGroup . querySelectorAll ( '.igx-button-group__item' ) )
1722
+ . find ( ( b : any ) => b . textContent . toLowerCase ( ) === 'and' ) ;
1723
+ andOperatorButton . click ( ) ;
1724
+ fix . detectChanges ( ) ;
1725
+
1726
+ // Verify new operator of inner group.
1727
+ operatorLine = GridFunctions . getAdvancedFilteringTreeGroupOperatorLine ( fix , [ 1 ] ) ;
1728
+ verifyOperatorLine ( operatorLine , 'and' ) ;
1729
+
1730
+ // Click the 'or' button of the button group in the context menu.
1731
+ const orOperatorButton : any = Array . from ( buttonGroup . querySelectorAll ( '.igx-button-group__item' ) )
1732
+ . find ( ( b : any ) => b . textContent . toLowerCase ( ) === 'or' ) ;
1733
+ orOperatorButton . click ( ) ;
1734
+ fix . detectChanges ( ) ;
1735
+
1736
+ // Verify new operator of inner group.
1737
+ operatorLine = GridFunctions . getAdvancedFilteringTreeGroupOperatorLine ( fix , [ 1 ] ) ;
1738
+ verifyOperatorLine ( operatorLine , 'or' ) ;
1739
+ } ) ) ;
1740
+
1741
+ it ( 'Should ungroup the group\'s children and append them to next parent group when click \'ungroup\' from context menu.' ,
1742
+ fakeAsync ( ( ) => {
1743
+ // Apply advanced filter through API.
1744
+ const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
1745
+ tree . filteringOperands . push ( {
1746
+ fieldName : 'Downloads' , searchVal : 100 , condition : IgxNumberFilteringOperand . instance ( ) . condition ( 'greaterThan' )
1747
+ } ) ;
1748
+ const orTree = new FilteringExpressionsTree ( FilteringLogic . Or ) ;
1749
+ orTree . filteringOperands . push ( {
1750
+ fieldName : 'ProductName' , searchVal : 'angular' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1751
+ ignoreCase : true
1752
+ } ) ;
1753
+ orTree . filteringOperands . push ( {
1754
+ fieldName : 'ProductName' , searchVal : 'script' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1755
+ ignoreCase : true
1756
+ } ) ;
1757
+ tree . filteringOperands . push ( orTree ) ;
1758
+ grid . advancedFilteringExpressionsTree = tree ;
1759
+ fix . detectChanges ( ) ;
1760
+
1761
+ // Open Advanced Filtering dialog.
1762
+ GridFunctions . clickAdvancedFilteringButton ( fix ) ;
1763
+ fix . detectChanges ( ) ;
1764
+
1765
+ // Verify tree layout before the the ungrouping with context menu.
1766
+ let rootGroup = GridFunctions . getAdvancedFilteringTreeRootGroup ( fix ) ; // group
1767
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( rootGroup , true ) . length ) . toBe ( 2 ) ;
1768
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( rootGroup , false ) . length ) . toBe ( 4 ) ;
1769
+
1770
+ let firstItem = GridFunctions . getAdvancedFilteringTreeItem ( fix , [ 0 ] ) ; // expression
1771
+ expect ( firstItem . classList . contains ( 'igx-filter-tree__expression-item' ) ) . toBe ( true ) ;
1772
+
1773
+ const secondItem = GridFunctions . getAdvancedFilteringTreeItem ( fix , [ 1 ] ) ; // group
1774
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( secondItem , true ) . length ) . toBe ( 2 ) ;
1775
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( secondItem , false ) . length ) . toBe ( 2 ) ;
1776
+
1777
+ // Click the innner group's operator line.
1778
+ const operatorLine = GridFunctions . getAdvancedFilteringTreeGroupOperatorLine ( fix , [ 1 ] ) ;
1779
+ operatorLine . click ( ) ;
1780
+ tick ( 400 ) ;
1781
+ fix . detectChanges ( ) ;
1782
+
1783
+ // Click "Ungroup" in context menu.
1784
+ const buttons = GridFunctions . getAdvancedFilteringContextMenuButtons ( fix ) ;
1785
+ buttons [ 1 ] . click ( ) ;
1786
+ tick ( 100 ) ;
1787
+ fix . detectChanges ( ) ;
1788
+
1789
+ // Verify tree layout after ungrouping a group with the context menu.
1790
+ rootGroup = GridFunctions . getAdvancedFilteringTreeRootGroup ( fix ) ; // group
1791
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( rootGroup , true ) . length ) . toBe ( 3 ) ;
1792
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( rootGroup , false ) . length ) . toBe ( 3 ) ;
1793
+ // Verify three expression in the root group are what remains.
1794
+ for ( let index = 0 ; index < 3 ; index ++ ) {
1795
+ firstItem = GridFunctions . getAdvancedFilteringTreeItem ( fix , [ index ] ) ; // expression
1796
+ expect ( firstItem . classList . contains ( 'igx-filter-tree__expression-item' ) ) . toBe ( true ) ;
1797
+ }
1798
+ } ) ) ;
1799
+
1800
+ it ( 'Should delete the group from the tree when click \'delete\' from context menu.' ,
1801
+ fakeAsync ( ( ) => {
1802
+ // Apply advanced filter through API.
1803
+ const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
1804
+ tree . filteringOperands . push ( {
1805
+ fieldName : 'Downloads' , searchVal : 100 , condition : IgxNumberFilteringOperand . instance ( ) . condition ( 'greaterThan' )
1806
+ } ) ;
1807
+ const orTree = new FilteringExpressionsTree ( FilteringLogic . Or ) ;
1808
+ orTree . filteringOperands . push ( {
1809
+ fieldName : 'ProductName' , searchVal : 'angular' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1810
+ ignoreCase : true
1811
+ } ) ;
1812
+ orTree . filteringOperands . push ( {
1813
+ fieldName : 'ProductName' , searchVal : 'script' , condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1814
+ ignoreCase : true
1815
+ } ) ;
1816
+ tree . filteringOperands . push ( orTree ) ;
1817
+ grid . advancedFilteringExpressionsTree = tree ;
1818
+ fix . detectChanges ( ) ;
1819
+
1820
+ // Open Advanced Filtering dialog.
1821
+ GridFunctions . clickAdvancedFilteringButton ( fix ) ;
1822
+ fix . detectChanges ( ) ;
1823
+
1824
+ // Verify tree layout before deleting a group through context menu.
1825
+ let rootGroup = GridFunctions . getAdvancedFilteringTreeRootGroup ( fix ) ; // group
1826
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( rootGroup , true ) . length ) . toBe ( 2 ) ;
1827
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( rootGroup , false ) . length ) . toBe ( 4 ) ;
1828
+
1829
+ let firstItem = GridFunctions . getAdvancedFilteringTreeItem ( fix , [ 0 ] ) ; // expression
1830
+ expect ( firstItem . classList . contains ( 'igx-filter-tree__expression-item' ) ) . toBe ( true ) ;
1831
+
1832
+ const secondItem = GridFunctions . getAdvancedFilteringTreeItem ( fix , [ 1 ] ) ; // group
1833
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( secondItem , true ) . length ) . toBe ( 2 ) ;
1834
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( secondItem , false ) . length ) . toBe ( 2 ) ;
1835
+
1836
+ // Click the innner group's operator line.
1837
+ const operatorLine = GridFunctions . getAdvancedFilteringTreeGroupOperatorLine ( fix , [ 1 ] ) ;
1838
+ operatorLine . click ( ) ;
1839
+ tick ( 400 ) ;
1840
+ fix . detectChanges ( ) ;
1841
+
1842
+ // Click "Delete" in context menu.
1843
+ const buttons = GridFunctions . getAdvancedFilteringContextMenuButtons ( fix ) ;
1844
+ buttons [ 2 ] . click ( ) ;
1845
+ tick ( 100 ) ;
1846
+ fix . detectChanges ( ) ;
1847
+
1848
+ // Verify tree layout after deleting a group through context menu.
1849
+ rootGroup = GridFunctions . getAdvancedFilteringTreeRootGroup ( fix ) ; // group
1850
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( rootGroup , true ) . length ) . toBe ( 1 ) ;
1851
+ expect ( GridFunctions . getAdvancedFilteringTreeChildItems ( rootGroup , false ) . length ) . toBe ( 1 ) ;
1852
+
1853
+ firstItem = GridFunctions . getAdvancedFilteringTreeItem ( fix , [ 0 ] ) ; // expression
1854
+ expect ( firstItem . classList . contains ( 'igx-filter-tree__expression-item' ) ) . toBe ( true ) ;
1855
+ } ) ) ;
1641
1856
} ) ;
1642
1857
1643
1858
describe ( 'Localization' , ( ) => {
@@ -2013,8 +2228,8 @@ function verifyContextMenuType(fix, shouldBeContextualGroup: boolean) {
2013
2228
if ( shouldBeContextualGroup ) {
2014
2229
expect ( contextMenuButtons . length ) . toBe ( 3 , 'incorrect buttons count in context menu' ) ;
2015
2230
expect ( contextMenuButtons [ 0 ] . innerText . toLowerCase ( ) ) . toBe ( 'close' ) ;
2016
- expect ( contextMenuButtons [ 1 ] . innerText . toLowerCase ( ) ) . toBe ( 'ungroup' ) ;
2017
- expect ( contextMenuButtons [ 2 ] . innerText . toLowerCase ( ) ) . toBe ( 'delete' ) ;
2231
+ expect ( contextMenuButtons [ 1 ] . querySelector ( 'span' ) . innerText . toLowerCase ( ) ) . toBe ( 'ungroup' ) ;
2232
+ expect ( contextMenuButtons [ 2 ] . querySelector ( 'span' ) . innerText . toLowerCase ( ) ) . toBe ( 'delete' ) ;
2018
2233
} else {
2019
2234
expect ( contextMenuButtons . length ) . toBe ( 4 , 'incorrect buttons count in context menu' ) ;
2020
2235
expect ( contextMenuButtons [ 0 ] . innerText . toLowerCase ( ) ) . toBe ( 'close' ) ;
0 commit comments