Skip to content

Commit

Permalink
Merge branch '13.0.x' into sstoychev/inner-scroll-extra-13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
3phase authored Feb 17, 2022
2 parents b26ef34 + a4cfa6d commit 0c95509
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ export class IgxExcelStyleSearchComponent implements AfterViewInit, OnDestroy {
const anyFiltered = this.esf.listData.some(i => i.isFiltered);
const anyUnfiltered = this.esf.listData.some(i => !i.isFiltered);

if (anyFiltered && anyUnfiltered) {
searchAllBtn.indeterminate = true;
}
searchAllBtn.indeterminate = anyFiltered && anyUnfiltered;

this.esf.listData.forEach(i => i.isSelected = i.isFiltered);
this.displayedListData = this.esf.listData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ export class IgxGridExcelStyleFilteringComponent extends BaseFilteringComponent
if (operand instanceof FilteringExpressionsTree) {
const columnExprTree = operand as FilteringExpressionsTree;
if (columnExprTree.fieldName === this.column.field) {
break;
continue;
}
}
expressionsTree.filteringOperands.push(operand);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,13 @@ export class IgxFilteringService implements OnDestroy {
const filteringIgnoreCase = ignoreCase || (col ? col.filteringIgnoreCase : false);

const filteringTree = grid.filteringExpressionsTree;
const columnFilteringExpressionsTree = grid.filteringExpressionsTree.find(field) as IFilteringExpressionsTree;
const columnFilteringExpressionsTree = filteringTree.find(field) as IFilteringExpressionsTree;
conditionOrExpressionTree = conditionOrExpressionTree ?? columnFilteringExpressionsTree;
const fieldFilterIndex = filteringTree.findIndex(field);
if (fieldFilterIndex > -1) {
filteringTree.filteringOperands.splice(fieldFilterIndex, 1);
}

const newFilteringTree: FilteringExpressionsTree =
this.prepare_filtering_expression(filteringTree, field, value, conditionOrExpressionTree,
filteringIgnoreCase, fieldFilterIndex, true);
filteringIgnoreCase, fieldFilterIndex, true);

const eventArgs: IFilteringEventArgs = {
owner: grid,
Expand Down Expand Up @@ -522,12 +520,11 @@ export class IgxFilteringService implements OnDestroy {
if (fieldFilterIndex > -1) {
filteringTree.filteringOperands.splice(fieldFilterIndex, 1);
}

this.prepare_filtering_expression(filteringTree, fieldName, term, conditionOrExpressionsTree, ignoreCase, fieldFilterIndex);
grid.filteringExpressionsTree = filteringTree;
}

/** Modifies the filteringState object to contain the newly added fitering conditions/expressions.
/** Modifies the filteringState object to contain the newly added filtering conditions/expressions.
* If createNewTree is true, filteringState will not be modified (because it directly affects the grid.filteringExpressionsTree),
* but a new object is created and returned.
*/
Expand All @@ -540,7 +537,6 @@ export class IgxFilteringService implements OnDestroy {
insertAtIndex = -1,
createNewTree = false): FilteringExpressionsTree {

const oldExpressionsTreeIndex = filteringState.findIndex(fieldName);
const expressionsTree = conditionOrExpressionsTree instanceof FilteringExpressionsTree ?
conditionOrExpressionsTree as IFilteringExpressionsTree : null;
const condition = conditionOrExpressionsTree instanceof FilteringExpressionsTree ?
Expand All @@ -550,20 +546,18 @@ export class IgxFilteringService implements OnDestroy {
const newExpressionsTree: FilteringExpressionsTree = createNewTree ?
new FilteringExpressionsTree(filteringState.operator, filteringState.fieldName) : filteringState as FilteringExpressionsTree;

if (oldExpressionsTreeIndex === -1) {
// no expressions tree found for this field
if (expressionsTree) {
if (insertAtIndex > -1) {
newExpressionsTree.filteringOperands.splice(insertAtIndex, 0, expressionsTree);
} else {
newExpressionsTree.filteringOperands.push(expressionsTree);
}
} else if (condition) {
// create expressions tree for this field and add the new expression to it
const newExprTree: FilteringExpressionsTree = new FilteringExpressionsTree(filteringState.operator, fieldName);
newExprTree.filteringOperands.push(newExpression);
newExpressionsTree.filteringOperands.push(newExprTree);
// no expressions tree found for this field
if (expressionsTree) {
if (insertAtIndex > -1) {
newExpressionsTree.filteringOperands[insertAtIndex] = expressionsTree;
} else {
newExpressionsTree.filteringOperands.push(expressionsTree);
}
} else if (condition) {
// create expressions tree for this field and add the new expression to it
const newExprTree: FilteringExpressionsTree = new FilteringExpressionsTree(filteringState.operator, fieldName);
newExprTree.filteringOperands.push(newExpression);
newExpressionsTree.filteringOperands.push(newExprTree);
}

return newExpressionsTree;
Expand All @@ -580,7 +574,7 @@ export class IgxFilteringService implements OnDestroy {
if (expressionsTree.operator === FilteringLogic.Or) {
const andOperatorsCount = this.getChildAndOperatorsCount(expressionsTree);

// having more that 'And' and operator in the sub-tree means that the filter could not be represented without parentheses.
// having more than one 'And' operator in the sub-tree means that the filter could not be represented without parentheses.
return andOperatorsCount > 1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ import {
import { GridSelectionMode, FilterMode } from '../common/enums';
import { ControlsFunction } from '../../test-utils/controls-functions.spec';
import { FormattedValuesFilteringStrategy } from '../../data-operations/filtering-strategy';
import { IgxCalendarComponent } from '../../calendar/calendar.component';
import { IgxInputGroupComponent } from '../../input-group/public_api';
import { formatDate } from '../../core/utils';
import { IgxCalendarComponent } from '../../calendar/calendar.component';

const DEBOUNCETIME = 30;
const FILTER_UI_ROW = 'igx-grid-filtering-row';
Expand Down Expand Up @@ -4348,8 +4348,8 @@ describe('IgxGrid - Filtering actions - Excel style filtering #grid', () => {
tick(100);
fix.detectChanges();
verifyExcelStyleFilterAvailableOptions(fix,
['Select All', '(Blanks)', 'False', 'True'],
[null, true, true, false]);
['Select All', '(Blanks)', 'False'],
[true, true, true]);

GridFunctions.clickExcelFilterIcon(fix, 'ProductName');
tick(100);
Expand Down

0 comments on commit 0c95509

Please sign in to comment.