Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw descriptive error when filtering without condition - 7.3.x #4900

Merged
merged 21 commits into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
6f2fd72
test(filter): tests for filter without cond #4897
tachojelev May 28, 2019
58f720d
fix(filter): throw descriptive error #4897
tachojelev May 28, 2019
2b415fd
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
tachojelev May 28, 2019
fe52c0e
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
tachojelev May 29, 2019
6b45604
fix(filter): make 'condition' param not opt #4897
tachojelev May 30, 2019
870dbad
Merge branch 'tzhelev/fix-4897-7.3.x' of https://github.com/IgniteUI/…
tachojelev May 30, 2019
bd6ced1
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
tachojelev May 30, 2019
5a5488f
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
tachojelev May 30, 2019
436dbab
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
tachojelev May 31, 2019
54648ed
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
gedinakova May 31, 2019
e067ee9
chore(*): merge 7.3.x #4897
tachojelev May 31, 2019
b095c8b
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
tachojelev Jun 4, 2019
81bc160
chore(*): address comments #4897
tachojelev Jun 4, 2019
321bb53
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
tachojelev Jun 4, 2019
3c7cfe5
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
kdinev Jun 6, 2019
5f81f3f
fix(filter): update filterGlobal logic #4897
tachojelev Jun 6, 2019
c30a57a
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
tachojelev Jun 6, 2019
6d27219
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
tachojelev Jun 6, 2019
d551051
chore(*): merge 7.3.x #4897
tachojelev Jun 7, 2019
8370b8b
chore(*): merge 7.3.x #4897
tachojelev Jun 10, 2019
0db52a2
Merge branch '7.3.x' into tzhelev/fix-4897-7.3.x
tachojelev Jun 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes for each version of this project will be documented in this

## 7.3.4

- `IgxGrid`, `IgxTreeGrid`, `IgxHierarchicalGrid`
- **Breaking Change** The **condition** parameter of the `filterGlobal` method is no longer optional. When the filterGlobal method is called with an invalid condition, it will not clear the existing filters for all columns.

### New feature
- `igxSlider` - exposing new `labels` property accepting a collection of literal values that become equally spread over the slider, by placing each element as a thumb label.
- `igxSlider` - deprecate **isContiunous** property.
Expand Down
12 changes: 7 additions & 5 deletions projects/igniteui-angular/src/lib/grids/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent & IGridDataBinda
}

public filter_global(term, condition, ignoreCase) {
if (!condition) {
return;
}

const grid = this.grid;
const filteringTree = grid.filteringExpressionsTree;
grid.endEdit(false);
Expand All @@ -318,11 +322,9 @@ export class GridBaseAPIService <T extends IgxGridBaseComponent & IGridDataBinda
}

filteringTree.filteringOperands = [];
if (condition) {
for (const column of grid.columns) {
this.prepare_filtering_expression(filteringTree, column.field, term,
condition, ignoreCase || column.filteringIgnoreCase);
}
for (const column of grid.columns) {
this.prepare_filtering_expression(filteringTree, column.field, term,
condition, ignoreCase || column.filteringIgnoreCase);
}

grid.filteringExpressionsTree = filteringTree;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ export class IgxFilteringService implements OnDestroy {
this.gridAPI.filter(field, value, conditionOrExpressionTree, filteringIgnoreCase);
} else {
const expressionsTreeForColumn = this.grid.filteringExpressionsTree.find(field);
if (expressionsTreeForColumn instanceof FilteringExpressionsTree) {
if (!expressionsTreeForColumn) {
throw new Error('Invalid condition or Expression Tree!');
} else if (expressionsTreeForColumn instanceof FilteringExpressionsTree) {
this.gridAPI.filter(field, value, expressionsTreeForColumn, filteringIgnoreCase);
} else {
const expressionForColumn = expressionsTreeForColumn as IFilteringExpression;
Expand Down Expand Up @@ -191,7 +193,7 @@ export class IgxFilteringService implements OnDestroy {
/**
* Filters all the `IgxColumnComponent` in the `IgxGridComponent` with the same condition.
*/
public filterGlobal(value: any, condition?, ignoreCase?) {
public filterGlobal(value: any, condition, ignoreCase?) {
this.gridAPI.filter_global(value, condition, ignoreCase);

// Wait for the change detection to update filtered data through the pipes and then emit the event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3633,7 +3633,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
* @param ignoreCase
* @memberof IgxGridBaseComponent
*/
public filterGlobal(value: any, condition?, ignoreCase?) {
public filterGlobal(value: any, condition, ignoreCase?) {
this.filteringService.filterGlobal(value, condition, ignoreCase);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,27 @@ describe('IgxGrid - Filtering actions', () => {
verifyExpressionUI(expressionUIs[3], expression21, FilteringLogic.And, FilteringLogic.Or);
verifyExpressionUI(expressionUIs[4], expression22, null, FilteringLogic.And);
}));

it('Should throw descriptive error when filter() is called without condition', fakeAsync(() => {
expect(() => {
grid.filter('Downloads', 100);
fix.detectChanges();
}).toThrowError('Invalid condition or Expression Tree!');
}));

it('Should not clear previous filtering when filterGlobal() is called with invalid condition', fakeAsync(() => {
grid.filter('Downloads', 100, IgxNumberFilteringOperand.instance().condition('greaterThan'), true);
fix.detectChanges();
expect(grid.rowList.length).toEqual(4);
expect(grid.getCellByColumn(0, 'Downloads').value).toEqual(254);

// Execute global filtering with invalid condition.
grid.filterGlobal(1000, null);
fix.detectChanges();

expect(grid.rowList.length).toEqual(4);
expect(grid.getCellByColumn(0, 'Downloads').value).toEqual(254);
}));
});

const expectedResults = [];
Expand Down