@@ -28,6 +28,7 @@ import { By } from '@angular/platform-browser';
2828import { IgxDateTimeEditorDirective } from '../../directives/date-time-editor/date-time-editor.directive' ;
2929import { QueryBuilderSelectors } from '../../query-builder/query-builder.common' ;
3030import { IgxHGridRemoteOnDemandComponent } from '../hierarchical-grid/hierarchical-grid.spec' ;
31+ import { IGridResourceStrings } from '../../core/i18n/grid-resources' ;
3132
3233describe ( 'IgxGrid - Advanced Filtering #grid - ' , ( ) => {
3334 beforeEach ( waitForAsync ( ( ) => {
@@ -1263,47 +1264,75 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
12631264 it ( 'Should correctly change resource strings for Advanced Filtering dialog.' , fakeAsync ( ( ) => {
12641265 const fix = TestBed . createComponent ( IgxGridAdvancedFilteringComponent ) ;
12651266 const grid : IgxGridComponent = fix . componentInstance . grid ;
1266- grid . resourceStrings = Object . assign ( { } , grid . resourceStrings , {
1267+ const myResourceStrings : IGridResourceStrings = {
12671268 igx_grid_filter_operator_and : 'My and' ,
12681269 igx_grid_filter_operator_or : 'My or' ,
12691270 igx_grid_advanced_filter_title : 'My advanced filter' ,
12701271 igx_grid_advanced_filter_end_group : 'My end group' ,
12711272 igx_grid_advanced_filter_create_and_group : 'My create and group' ,
12721273 igx_grid_advanced_filter_and_label : 'My and' ,
12731274 igx_grid_advanced_filter_or_label : 'My or' ,
1275+ igx_grid_advanced_filter_add_condition : 'Add my condition' ,
12741276 igx_grid_advanced_filter_add_condition_root : 'My condition' ,
12751277 igx_grid_advanced_filter_add_group_root : 'My group' ,
1278+ igx_grid_advanced_filter_add_group : 'Add my group' ,
12761279 igx_grid_advanced_filter_ungroup : 'My ungroup' ,
1280+ igx_grid_advanced_filter_switch_group : 'My switch to {0}' ,
12771281 igx_grid_advanced_filter_delete_filters : 'My delete filters'
1282+ } ;
1283+
1284+ grid . resourceStrings = {
1285+ ...grid . resourceStrings ,
1286+ ...myResourceStrings
1287+ } ;
1288+
1289+ const tree = new FilteringExpressionsTree ( FilteringLogic . And ) ;
1290+ tree . filteringOperands . push ( {
1291+ fieldName : 'ProductName' ,
1292+ condition : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) ,
1293+ searchVal : 'angular' ,
1294+ ignoreCase : true
12781295 } ) ;
1296+
1297+ grid . advancedFilteringExpressionsTree = tree ;
12791298 fix . detectChanges ( ) ;
12801299
12811300 // Open Advanced Filtering dialog.
12821301 grid . openAdvancedFilteringDialog ( ) ;
12831302 fix . detectChanges ( ) ;
12841303
12851304 expect ( QueryBuilderFunctions . getQueryBuilderHeaderText ( fix ) . trim ( ) ) . toBe ( 'My advanced filter' ) ;
1286- expect ( QueryBuilderFunctions . getQueryBuilderInitialAddConditionBtn ( fix ) . querySelector ( 'span' ) . innerText )
1305+ expect ( ( QueryBuilderFunctions . getQueryBuilderTreeRootGroupButtons ( fix , 0 ) [ 0 ] as HTMLElement ) . querySelector ( 'span' ) . innerText )
12871306 . toBe ( 'My condition' ) ;
1307+ expect ( ( QueryBuilderFunctions . getQueryBuilderTreeRootGroupButtons ( fix , 0 ) [ 1 ] as HTMLElement ) . querySelector ( 'span' ) . innerText )
1308+ . toBe ( 'My group' ) ;
12881309
1289- QueryBuilderFunctions . clickQueryBuilderInitialAddConditionBtn ( fix , 0 ) ;
1310+ QueryBuilderFunctions . clickQueryBuilderGroupContextMenu ( fix , 0 ) ;
12901311 tick ( 100 ) ;
12911312 fix . detectChanges ( ) ;
1313+
1314+ const groupDDLItems = QueryBuilderFunctions . getQueryBuilderGroupContextMenuDropDownItems ( fix ) ;
1315+ expect ( groupDDLItems [ 0 ] . innerText ) . toBe ( 'My switch to MY OR' ) ;
1316+ expect ( groupDDLItems [ 1 ] . innerText ) . toBe ( 'My ungroup' ) ;
12921317
1318+ QueryBuilderFunctions . clickQueryBuilderGroupContextMenu ( fix , 0 ) ;
1319+ tick ( 100 ) ;
1320+ fix . detectChanges ( ) ;
12931321
1294- // Populate edit inputs.
1295- QueryBuilderFunctions . selectColumnInEditModeExpression ( fix , 1 ) ; // Select 'ProductName' column.
1296- QueryBuilderFunctions . selectOperatorInEditModeExpression ( fix , 0 ) ; // Select 'Contains' operator.
1322+ // Hover the condition chip to show the add button
1323+ const expressionItem = fix . nativeElement . querySelectorAll ( `.${ QueryBuilderSelectors . FILTER_TREE_EXPRESSION_ITEM } ` ) [ 0 ] ;
1324+ expressionItem . dispatchEvent ( new MouseEvent ( 'mouseenter' ) ) ;
1325+ tick ( ) ;
1326+ fix . detectChanges ( ) ;
12971327
1298- const input = QueryBuilderFunctions . getQueryBuilderValueInput ( fix ) . querySelector ( 'input' ) ;
1299- UIInteractions . clickAndSendInputElementValue ( input , 'angular' , fix ) ; // Type filter value.
1300- // Commit the populated expression.
1301- QueryBuilderFunctions . clickQueryBuilderExpressionCommitButton ( fix ) ;
1328+ // Click the add icon to display the adding buttons and verify their content.
1329+ QueryBuilderFunctions . clickQueryBuilderTreeExpressionChipIcon ( fix , [ 0 ] , 'add' ) ;
13021330 fix . detectChanges ( ) ;
1303- expect ( ( QueryBuilderFunctions . getQueryBuilderTreeRootGroupButtons ( fix , 0 ) [ 0 ] as HTMLElement ) . querySelector ( 'span' ) . innerText )
1304- . toBe ( 'My condition' ) ;
1305- expect ( ( QueryBuilderFunctions . getQueryBuilderTreeRootGroupButtons ( fix , 0 ) [ 1 ] as HTMLElement ) . querySelector ( 'span' ) . innerText )
1306- . toBe ( 'My group' ) ;
1331+ tick ( 50 ) ;
1332+
1333+ const addingButtons : any = QueryBuilderFunctions . getQueryBuilderTreeRootGroupButtons ( fix , 0 ) ;
1334+ expect ( addingButtons [ 0 ] . innerText ) . toBe ( 'add\nMy condition' ) ;
1335+ expect ( addingButtons [ 1 ] . innerText ) . toBe ( 'add\nMy group' ) ;
13071336 } ) ) ;
13081337 } ) ;
13091338
@@ -1792,6 +1821,70 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
17921821 expectedValues = [ 'ID' , 'ProductName' ] ;
17931822 expect ( dropdownValues ) . toEqual ( expectedValues ) ;
17941823 } ) ) ;
1824+
1825+ it ( 'Should correctly change resource strings for hierarchical Advanced Filtering dialog.' , fakeAsync ( ( ) => {
1826+ debugger
1827+ hgrid . closeAdvancedFilteringDialog ( false ) ;
1828+ tick ( 200 ) ;
1829+ fix . detectChanges ( ) ;
1830+
1831+ const innerTree = new FilteringExpressionsTree ( 0 , undefined , 'childData' , [ 'ID' ] ) ;
1832+ innerTree . filteringOperands . push ( {
1833+ fieldName : 'ID' ,
1834+ ignoreCase : false ,
1835+ conditionName : IgxStringFilteringOperand . instance ( ) . condition ( 'contains' ) . name ,
1836+ searchVal : '39'
1837+ } ) ;
1838+
1839+ const tree = new FilteringExpressionsTree ( 0 , undefined , 'rootData' , [ 'ID' ] ) ;
1840+ tree . filteringOperands . push ( {
1841+ fieldName : 'ID' ,
1842+ conditionName : IgxStringFilteringOperand . instance ( ) . condition ( 'inQuery' ) . name ,
1843+ ignoreCase : false ,
1844+ searchTree : innerTree
1845+ } ) ;
1846+
1847+ hgrid . advancedFilteringExpressionsTree = tree ;
1848+
1849+ const myResourceStrings : IGridResourceStrings = {
1850+ igx_grid_filter_operator_and : 'My and' ,
1851+ igx_grid_filter_operator_or : 'My or' ,
1852+ igx_grid_advanced_filter_title : 'My advanced filter' ,
1853+ igx_grid_advanced_filter_end_group : 'My end group' ,
1854+ igx_grid_advanced_filter_create_and_group : 'My create and group' ,
1855+ igx_grid_advanced_filter_and_label : 'My and' ,
1856+ igx_grid_advanced_filter_or_label : 'My or' ,
1857+ igx_grid_advanced_filter_add_condition : 'Add my condition' ,
1858+ igx_grid_advanced_filter_add_condition_root : 'My condition' ,
1859+ igx_grid_advanced_filter_add_group_root : 'My group' ,
1860+ igx_grid_advanced_filter_add_group : 'Add my group' ,
1861+ igx_grid_advanced_filter_ungroup : 'My ungroup' ,
1862+ igx_grid_advanced_filter_switch_group : 'My switch to {0}' ,
1863+ igx_grid_advanced_filter_delete_filters : 'My delete filters' ,
1864+ igx_grid_advanced_filter_from_label : 'My from' ,
1865+ igx_grid_advanced_filter_query_value_placeholder : 'My sub-query results' ,
1866+ } ;
1867+
1868+ hgrid . resourceStrings = {
1869+ ...hgrid . resourceStrings ,
1870+ ...myResourceStrings
1871+ } ;
1872+
1873+ fix . detectChanges ( ) ;
1874+
1875+ // Open Advanced Filtering dialog.
1876+ hgrid . openAdvancedFilteringDialog ( ) ;
1877+ fix . detectChanges ( ) ;
1878+
1879+ // Open up the sub-query
1880+ QueryBuilderFunctions . clickQueryBuilderTreeExpressionChip ( fix , [ 0 ] ) ;
1881+ tick ( 100 ) ;
1882+ fix . detectChanges ( ) ;
1883+
1884+ const valueInput : any = QueryBuilderFunctions . getQueryBuilderValueInput ( fix ) ;
1885+ expect ( valueInput . querySelector ( 'input' ) . placeholder ) . toBe ( 'My sub-query results' ) ;
1886+
1887+ } ) ) ;
17951888 } ) ;
17961889} ) ;
17971890
0 commit comments