Skip to content

Commit 5df579f

Browse files
authored
Merge pull request #5972 from IgniteUI/revert-5952-dmdimitrov/update-query-builder
Revert "docs(query-builder): update topic with nested queries and templating"
2 parents f280d57 + 37d4fd5 commit 5df579f

File tree

2 files changed

+25
-104
lines changed

2 files changed

+25
-104
lines changed

en/components/query-builder.md

Lines changed: 25 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ import { IGX_QUERY_BUILDER_DIRECTIVES, FilteringExpressionsTree, FieldType } fro
6464
selector: 'app-home',
6565
template: `
6666
<igx-query-builder #queryBuilder
67-
[entities]="entities"
67+
[fields]="fields"
6868
[(expressionTree)]="expressionTree"
6969
(expressionTreeChange)="onExpressionTreeChange()">
7070
</igx-query-builder>
@@ -76,7 +76,7 @@ import { IGX_QUERY_BUILDER_DIRECTIVES, FilteringExpressionsTree, FieldType } fro
7676
})
7777
export class HomeComponent {
7878
public expressionTree: FilteringExpressionsTree;
79-
public entities: Array<any>;
79+
public fields: FieldType [];
8080

8181
public onExpressionTreeChange() {
8282
...
@@ -88,53 +88,41 @@ Now that you have the Ignite UI for Angular Query Builder module or directives i
8888

8989
## Using the Angular Query Builder
9090

91-
If no expression tree is initially set, you start by creating a group of conditions linked with [`AND`]({environment:angularApiUrl}/enums/filteringlogic.html#and) or [`OR`]({environment:angularApiUrl}/enums/filteringlogic.html#or). Then you choose an entity and which of its fields the query should return. After that, conditions or sub-groups can be added.
91+
If no expression tree is initially set, you start with creating a group of conditions linked with [`AND`]({environment:angularApiUrl}/enums/filteringlogic.html#and) or [`OR`]({environment:angularApiUrl}/enums/filteringlogic.html#or). After that, conditions or sub-groups can be added.
9292

93-
In order to add a condition you select a field, an operand based on the field data type and a value if the operand is not unary. The operands `In` and `Not In` will allow you to create an inner query with conditions for a different entity instead of simply providing a value. Once the condition is committed, a chip with the condition information appears. By clicking the chip, you have the options to modify it or add another condition or group right after it.
93+
In order to add a condition, a field, an operand based on the field dataType and a value if the operand is not unary. Once the condition is committed, a chip with the condition information appears. By hovering or clicking the chip, you have the options to modify it or add another condition or group right after it.
9494

95-
If you select more than one condition chip, a context menu appears with options to group or delete the current selection. If you choose to create a group with the selected conditions, the newly created group will appear where the topmost selected condition was placed.
95+
If you select more than one condition chip, a context menu appears with options to create a group or delete the queries. If you choose to create a group with the selected conditions, the newly created group will appear where the topmost selected condition was placed.
9696

9797
In order to select a group, you can also click on its vertical line, which is colored based on the linking condition ([`AND`]({environment:angularApiUrl}/enums/filteringlogic.html#and) or [`OR`]({environment:angularApiUrl}/enums/filteringlogic.html#or)). If a single group is selected, you get a context menu with options to change its logic, ungroup or delete it.
9898

99-
Since every condition is related to a specific field from a particular entity changing the entity will lead to resetting all preset conditions and groups. When selecting a new entity a confirmation dialog will be shown, unless the [`showEntityChangeDialog`]({environment:angularApiUrl}/classes/igxquerybuildercomponent.html#showEntityChangeDialog) input property is set to false.
100-
101-
You can start using the component by setting the [`entities`]({environment:angularApiUrl}/classes/igxquerybuildercomponent.html#entities) property to an array describing the entity name and an array of its fields, where each field is defined by its name and data type. Once a field is selected it will automatically assign the corresponding operands based on the data type.
99+
You can start using the component by setting the [`fields`]({environment:angularApiUrl}/classes/igxquerybuildercomponent.html#fields) property to an array describing the field name and its data type. It will automatically assign the corresponding operands based on the data type.
102100
The Query Builder has the [`expressionTree`]({environment:angularApiUrl}/classes/igxquerybuildercomponent.html#expressionTree) input property. You could use it to set an initial state of the control and access the user-specified filtering logic.
103101

104102
```typescript
105103
ngAfterViewInit(): void {
106-
const innerTree = new FilteringExpressionsTree(FilteringLogic.And, undefined, 'Companies', ['ID']);
107-
innerTree.filteringOperands.push({
108-
fieldName: 'Employees',
109-
condition: IgxNumberFilteringOperand.instance().condition('greaterThan'),
110-
conditionName: 'greaterThan',
111-
searchVal: 100
112-
});
113-
innerTree.filteringOperands.push({
114-
fieldName: 'Contact',
115-
condition: IgxBooleanFilteringOperand.instance().condition('true'),
116-
conditionName: 'true'
117-
});
118-
119-
const tree = new FilteringExpressionsTree(FilteringLogic.And, undefined, 'Orders', ['*']);
104+
const tree = new FilteringExpressionsTree(FilteringLogic.And);
120105
tree.filteringOperands.push({
121-
fieldName: 'CompanyID',
122-
condition: IgxStringFilteringOperand.instance().condition('in'),
123-
conditionName: 'in',
124-
searchTree: innerTree
106+
fieldName: 'ID',
107+
condition: IgxStringFilteringOperand.instance().condition('contains'),
108+
searchVal: 'a',
109+
ignoreCase: true
125110
});
126-
tree.filteringOperands.push({
127-
fieldName: 'OrderDate',
128-
condition: IgxDateFilteringOperand.instance().condition('before'),
129-
conditionName: 'before',
130-
searchVal: new Date('2024-01-01T00:00:00.000Z')
111+
const subTree = new FilteringExpressionsTree(FilteringLogic.Or);
112+
subTree.filteringOperands.push({
113+
fieldName: 'ContactTitle',
114+
condition: IgxStringFilteringOperand.instance().condition('doesNotContain'),
115+
searchVal: 'b',
116+
ignoreCase: true
131117
});
132-
tree.filteringOperands.push({
133-
fieldName: 'ShippedDate',
134-
condition: IgxDateFilteringOperand.instance().condition('null'),
135-
conditionName: 'null'
118+
subTree.filteringOperands.push({
119+
fieldName: 'CompanyName',
120+
condition: IgxStringFilteringOperand.instance().condition('startsWith'),
121+
searchVal: 'c',
122+
ignoreCase: true
136123
});
137-
124+
tree.filteringOperands.push(subTree);
125+
138126
this.queryBuilder.expressionTree = tree;
139127
}
140128
```
@@ -143,76 +131,12 @@ The `expressionTree` is a two-way bindable property which means a corresponding
143131

144132
```html
145133
<igx-query-builder #queryBuilder
146-
[entities]="entities"
134+
[fields]="fields"
147135
[(expressionTree)]="expressionTree"
148136
(expressionTreeChange)="onExpressionTreeChange()">
149137
</igx-query-builder>
150138
```
151139

152-
## Templating
153-
154-
The Ignite UI for Angular Query Builder Component allows defining templates for the component's header and the search value using the following predefined reference names:
155-
156-
### Header
157-
158-
Passing content inside of the `igx-query-builder-header` allows templating the query builder header. The [`IgxQueryBuilderHeaderComponent`]({environment:angularApiUrl}/classes/igxquerybuilderheadercomponent.html) provides a way to hide the legend by setting the [`showLegend`]({environment:angularApiUrl}/classes/igxquerybuilderheadercomponent.html#showLegend) input property to false.
159-
160-
The code snippet below illustrates how to do this:
161-
162-
```html
163-
<igx-query-builder #queryBuilder [entities]="this.entities">
164-
<igx-query-builder-header [title]="'Query Builder Template Sample'" [showLegend]="true">
165-
</igx-query-builder-header>
166-
</igx-query-builder>
167-
```
168-
169-
### Search value
170-
171-
The search value of a condition can be templated using the [`igxQueryBuilderSearchValue`]({environment:angularApiUrl}/classes/igxquerybuildersearchvaluetemplatedirective.html) directive, applied to an `<ng-template>` inside of the `igx-query-builder`'s body:
172-
173-
```html
174-
<igx-query-builder #queryBuilder
175-
[entities]="entities"
176-
[expressionTree]="expressionTree">
177-
<ng-template #searchValueTemplate igxQueryBuilderSearchValue
178-
let-searchValue
179-
let-selectedField = "selectedField"
180-
let-selectedCondition = "selectedCondition"
181-
let-defaultSearchValueTemplate = "defaultSearchValueTemplate">
182-
@if (
183-
selectedField?.field === 'Region' &&
184-
(selectedCondition === 'equals' || selectedCondition === 'doesNotEqual')
185-
){
186-
<igx-select [placeholder]="'Select region'" [(ngModel)]="searchValue.value">
187-
<igx-select-item *ngFor="let reg of regionOptions" [value]="reg.value">
188-
{{ reg.text }}
189-
</igx-select-item>
190-
</igx-select>
191-
}
192-
@else if (
193-
selectedField?.field === 'OrderStatus' &&
194-
(selectedCondition === 'equals' || selectedCondition === 'doesNotEqual')
195-
){
196-
<igx-radio-group>
197-
<igx-radio class="radio-sample" *ngFor="let stat of statusOptions" value="{{stat.value}}" [(ngModel)]="searchValue.value">
198-
{{stat.text}}
199-
</igx-radio>
200-
</igx-radio-group>
201-
}
202-
@else {
203-
<ng-container #defaultTemplate *ngTemplateOutlet="defaultSearchValueTemplate"></ng-container>
204-
}
205-
</ng-template>
206-
</igx-query-builder>
207-
```
208-
209-
We’ve created this Angular Query Builder example to show you the templating functionalities for the header and the search value of the Angular Query Builder component.
210-
211-
<code-view style="height:530px"
212-
data-demos-base-url="{environment:demosBaseUrl}"
213-
iframe-src="{environment:demosBaseUrl}/interactions/query-builder-template-sample" alt="Angular Query Builder Templates Example">
214-
</code-view>
215-
216140
## Styling
217141

218142
To get started with styling the Query Builder, we need to import the `index` file, where all the theme functions and component mixins live:
@@ -522,8 +446,6 @@ You can also streamline your Angular app development using [WYSIWYG App Builder
522446
<div class="divider--half"></div>
523447

524448
* [IgxQueryBuilderComponent API]({environment:angularApiUrl}/classes/igxquerybuildercomponent.html)
525-
* [IgxQueryBuilderHeaderComponent]({environment:angularApiUrl}/classes/igxquerybuilderheadercomponent.html)
526-
* [IgxQueryBuilderSearchValueTemplateDirective]({environment:angularApiUrl}/classes/igxquerybuildersearchvaluetemplatedirective.html)
527449
* [IgxQueryBuilderComponent Styles]({environment:sassApiUrl}/index.html#function-query-builder-theme)
528450

529451
## Additional Resources

en/components/toc.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,6 @@
970970
- name: Query Builder
971971
href: query-builder.md
972972
new: false
973-
updated: true
974973
- name: Radio & Radio Group
975974
href: radio-button.md
976975
new: false

0 commit comments

Comments
 (0)