-
Notifications
You must be signed in to change notification settings - Fork 160
fix(query-builder): refactor expression tree change emission for consistency - master #17081
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
base: master
Are you sure you want to change the base?
Changes from all commits
9bbaf62
51b5477
e18183c
58b16b7
6602fbf
ebbca6e
a2a5ff4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -327,14 +327,35 @@ export class IgxQueryBuilderComponent implements OnDestroy { | |
| this.queryTree.setAddButtonFocus(); | ||
| } | ||
|
|
||
| private serializeExpressionTreeCallback(key: string, val: unknown): unknown { | ||
| if (key === 'externalObject') { | ||
| return undefined; | ||
| } | ||
| if (key === 'searchVal' && val instanceof Set) { | ||
| // Ensure Set-based search values (e.g. for "in" conditions) are serialized correctly | ||
| // JSON.stringify(new Set([...])) => '{}' by default, so convert to an array first | ||
| return Array.from(val); | ||
| } | ||
|
|
||
IMinchev64 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return val; | ||
| } | ||
|
|
||
| private getSerializableExpressionTree(tree: IExpressionTree): IExpressionTree { | ||
| if (!tree) { | ||
| return tree; | ||
| } | ||
|
|
||
| return JSON.parse(JSON.stringify(tree, this.serializeExpressionTreeCallback)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is introducing a behavior change. Let's say that any of the filtering operands is having custom logic as condition. The condition contains
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have not tested this but what would happen if there are dates as |
||
| } | ||
|
|
||
| protected onExpressionTreeChange(tree: IExpressionTree) { | ||
| if (tree && this.entities && tree !== this._expressionTree) { | ||
| this._expressionTree = recreateTree(tree, this.entities); | ||
| } else { | ||
| this._expressionTree = tree; | ||
| } | ||
| if (this._shouldEmitTreeChange) { | ||
| this.expressionTreeChange.emit(tree); | ||
| this.expressionTreeChange.emit(this.getSerializableExpressionTree(this._expressionTree)); | ||
| } | ||
IMinchev64 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
|
|
@@ -389,4 +410,3 @@ export class IgxQueryBuilderComponent implements OnDestroy { | |
| }); | ||
| } | ||
| } | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of this going into a separate method?