|
9 | 9 | IgxStringFilteringOperand
|
10 | 10 | } from '../../data-operations/filtering-condition';
|
11 | 11 | import { GridFunctions } from '../../test-utils/grid-functions.spec';
|
12 |
| -import { FilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree'; |
| 12 | +import { FilteringExpressionsTree, IFilteringExpressionsTree } from '../../data-operations/filtering-expressions-tree'; |
13 | 13 | import { FilteringLogic } from '../../data-operations/filtering-expression.interface';
|
14 | 14 | import {
|
15 | 15 | IgxGridAdvancedFilteringColumnGroupComponent,
|
@@ -2298,6 +2298,71 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
|
2298 | 2298 | verifyOperatorLine(operatorLine, 'or');
|
2299 | 2299 | }));
|
2300 | 2300 |
|
| 2301 | + it('Should apply changes in the group\'s operator made via its context menu buttons.', fakeAsync(() => { |
| 2302 | + // Apply advanced filter through API. |
| 2303 | + const tree = new FilteringExpressionsTree(FilteringLogic.And); |
| 2304 | + tree.filteringOperands.push({ |
| 2305 | + fieldName: 'Downloads', searchVal: 100, condition: IgxNumberFilteringOperand.instance().condition('greaterThan') |
| 2306 | + }); |
| 2307 | + const orTree = new FilteringExpressionsTree(FilteringLogic.Or); |
| 2308 | + orTree.filteringOperands.push({ |
| 2309 | + fieldName: 'ProductName', searchVal: 'angular', condition: IgxStringFilteringOperand.instance().condition('contains'), |
| 2310 | + ignoreCase: true |
| 2311 | + }); |
| 2312 | + orTree.filteringOperands.push({ |
| 2313 | + fieldName: 'ProductName', searchVal: 'script', condition: IgxStringFilteringOperand.instance().condition('contains'), |
| 2314 | + ignoreCase: true |
| 2315 | + }); |
| 2316 | + tree.filteringOperands.push(orTree); |
| 2317 | + grid.advancedFilteringExpressionsTree = tree; |
| 2318 | + fix.detectChanges(); |
| 2319 | + |
| 2320 | + // Open Advanced Filtering dialog. |
| 2321 | + grid.openAdvancedFilteringDialog(); |
| 2322 | + fix.detectChanges(); |
| 2323 | + |
| 2324 | + // Verify current operator of inner group. |
| 2325 | + let operatorLine = GridFunctions.getAdvancedFilteringTreeGroupOperatorLine(fix, [1]); |
| 2326 | + verifyOperatorLine(operatorLine, 'or'); |
| 2327 | + |
| 2328 | + // Verify the advancedFilteringExpressionsTree inner group's filteringOperand's operator |
| 2329 | + expect(grid.advancedFilteringExpressionsTree.filteringOperands.length).toEqual(2); |
| 2330 | + expect((grid.advancedFilteringExpressionsTree.filteringOperands[1] as IFilteringExpressionsTree).operator).toEqual(1); |
| 2331 | + |
| 2332 | + // Click the innner group's operator line. |
| 2333 | + operatorLine.click(); |
| 2334 | + tick(400); |
| 2335 | + fix.detectChanges(); |
| 2336 | + |
| 2337 | + // Click the 'and' button of the button group in the context menu. |
| 2338 | + const buttonGroup = GridFunctions.getAdvancedFilteringContextMenuButtonGroup(fix); |
| 2339 | + const andOperatorButton: any = Array.from(buttonGroup.querySelectorAll('.igx-button-group__item')) |
| 2340 | + .find((b: any) => b.textContent.toLowerCase() === 'and'); |
| 2341 | + andOperatorButton.click(); |
| 2342 | + fix.detectChanges(); |
| 2343 | + |
| 2344 | + // Verify new operator of inner group. |
| 2345 | + operatorLine = GridFunctions.getAdvancedFilteringTreeGroupOperatorLine(fix, [1]); |
| 2346 | + verifyOperatorLine(operatorLine, 'and'); |
| 2347 | + |
| 2348 | + // Apply new advanced filtering logic |
| 2349 | + GridFunctions.clickAdvancedFilteringApplyButton(fix); |
| 2350 | + tick(100); |
| 2351 | + fix.detectChanges(); |
| 2352 | + |
| 2353 | + // Open the advanced filtering dialog |
| 2354 | + grid.openAdvancedFilteringDialog(); |
| 2355 | + fix.detectChanges(); |
| 2356 | + |
| 2357 | + // Verify the operator of inner group should persist as "And" |
| 2358 | + operatorLine = GridFunctions.getAdvancedFilteringTreeGroupOperatorLine(fix, [1]); |
| 2359 | + verifyOperatorLine(operatorLine, 'and'); |
| 2360 | + |
| 2361 | + // Verify the advancedFilteringExpressionsTree inner group's filteringOperand's operator |
| 2362 | + expect(grid.advancedFilteringExpressionsTree.filteringOperands.length).toEqual(2); |
| 2363 | + expect((grid.advancedFilteringExpressionsTree.filteringOperands[1] as IFilteringExpressionsTree).operator).toEqual(0); |
| 2364 | + })); |
| 2365 | + |
2301 | 2366 | it('Should ungroup the group\'s children and append them to next parent group when click \'ungroup\' from context menu.',
|
2302 | 2367 | fakeAsync(() => {
|
2303 | 2368 | // Apply advanced filter through API.
|
@@ -2355,6 +2420,25 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
|
2355 | 2420 | firstItem = GridFunctions.getAdvancedFilteringTreeItem(fix, [index]); // expression
|
2356 | 2421 | expect(firstItem.classList.contains(ADVANCED_FILTERING_EXPRESSION_ITEM_CLASS)).toBe(true);
|
2357 | 2422 | }
|
| 2423 | + |
| 2424 | + // Should apply this change to the advancedFilteringExpressionsTree |
| 2425 | + GridFunctions.clickAdvancedFilteringApplyButton(fix); |
| 2426 | + tick(100); |
| 2427 | + fix.detectChanges(); |
| 2428 | + |
| 2429 | + // Open the advanced filtering dialog |
| 2430 | + grid.openAdvancedFilteringDialog(); |
| 2431 | + fix.detectChanges(); |
| 2432 | + |
| 2433 | + // Verify the layout after as above |
| 2434 | + rootGroup = GridFunctions.getAdvancedFilteringTreeRootGroup(fix); // group |
| 2435 | + expect(GridFunctions.getAdvancedFilteringTreeChildItems(rootGroup, true).length).toBe(3); |
| 2436 | + expect(GridFunctions.getAdvancedFilteringTreeChildItems(rootGroup, false).length).toBe(3); |
| 2437 | + // Verify three expression in the root group are what remains, no inner groups |
| 2438 | + for (let index = 0; index < 3; index++) { |
| 2439 | + firstItem = GridFunctions.getAdvancedFilteringTreeItem(fix, [index]); // expression |
| 2440 | + expect(firstItem.classList.contains(ADVANCED_FILTERING_EXPRESSION_ITEM_CLASS)).toBe(true); |
| 2441 | + } |
2358 | 2442 | }));
|
2359 | 2443 |
|
2360 | 2444 | it('Ungroup button of the root group\'s context menu should be disabled.',
|
@@ -2437,6 +2521,26 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
|
2437 | 2521 |
|
2438 | 2522 | firstItem = GridFunctions.getAdvancedFilteringTreeItem(fix, [0]); // expression
|
2439 | 2523 | expect(firstItem.classList.contains(ADVANCED_FILTERING_EXPRESSION_ITEM_CLASS)).toBe(true);
|
| 2524 | + |
| 2525 | + // Should apply this change to the advancedFilteringExpressionsTree |
| 2526 | + GridFunctions.clickAdvancedFilteringApplyButton(fix); |
| 2527 | + tick(100); |
| 2528 | + fix.detectChanges(); |
| 2529 | + |
| 2530 | + // Open the advanced filtering dialog |
| 2531 | + grid.openAdvancedFilteringDialog(); |
| 2532 | + fix.detectChanges(); |
| 2533 | + |
| 2534 | + // Verify the layout after as above |
| 2535 | + rootGroup = GridFunctions.getAdvancedFilteringTreeRootGroup(fix); // group |
| 2536 | + expect(GridFunctions.getAdvancedFilteringTreeChildItems(rootGroup, true).length).toBe(1); |
| 2537 | + expect(GridFunctions.getAdvancedFilteringTreeChildItems(rootGroup, false).length).toBe(1); |
| 2538 | + |
| 2539 | + firstItem = GridFunctions.getAdvancedFilteringTreeItem(fix, [0]); // expression |
| 2540 | + expect(firstItem.classList.contains(ADVANCED_FILTERING_EXPRESSION_ITEM_CLASS)).toBe(true); |
| 2541 | + |
| 2542 | + // Verify the advancedFilteringExpressionsTree filteringOperands operator |
| 2543 | + expect(grid.advancedFilteringExpressionsTree.filteringOperands.length).toEqual(1); |
2440 | 2544 | }));
|
2441 | 2545 |
|
2442 | 2546 | it('Should close the context menu when clicking its close button.' , fakeAsync(() => {
|
|
0 commit comments