You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+297Lines changed: 297 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,12 @@
1
1
# NgxAngularQueryBuilder
2
2
3
+
The goal of this project is to enable Angular 12+ support for the original [angular2-query-builder](https://github.com/designermanjeets/Angular-QueryBuilder). It is *not* production ready. This project may not be maintained. Should the original project become active again, this library may be abandoned.
4
+
5
+
This project uses code from https://github.com/designermanjeets/Angular-QueryBuilder
6
+
which in turn is a fork from https://github.com/zebzhao/Angular-QueryBuilder both developed under the MIT License.
7
+
8
+
Please see the original project here:
9
+
3
10
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.2.13.
4
11
5
12
## Development server
@@ -25,3 +32,293 @@ Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To u
25
32
## Further help
26
33
27
34
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
Example of how you can completely customize the query component with another library like Angular Material. For the full example, please look at the [source code](https://github.com/zebzhao/Angular-QueryBuilder/blob/master/demo/src/app/app.component.ts) provided in the demo.
<mat-option*ngFor="let opt of options"[value]="opt.value">
202
+
{{ opt.name }}
203
+
</mat-option>
204
+
</mat-select>
205
+
</mat-form-field>
206
+
</ng-container>
207
+
...
208
+
</query-builder>
209
+
```
210
+
211
+
## Property Bindings Quick Reference
212
+
213
+
See [documentation](https://zebzhao.github.io/Angular-QueryBuilder/) for more details on interfaces and properties.
214
+
215
+
#### `query-builder`
216
+
|Name|Type|Required|Default|Description|
217
+
|:--- |:--- |:--- |:--- |:--- |
218
+
|`allowRuleset`|`boolean`|Optional|`true`| Displays the `+ Ruleset` button if `true`. |
219
+
|`allowCollapse`|`boolean`|Optional|`false`| Enables collapsible rule sets if `true`. ([See Demo](https://zebzhao.github.io/Angular-QueryBuilder/demo/)) |
220
+
|`classNames`|`object`|Optional|| CSS class names for different child elements in `query-builder` component. |
221
+
|`config`|`QueryBuilderConfig`|Required|| Configuration object for the main component. |
222
+
|`data`|`Ruleset`|Optional|| (Use `ngModel` or `value` instead.) |
223
+
|`emptyMessage`|`string`|Optional|| Message to display for an empty Ruleset if empty rulesets are not allowed. |
224
+
|`ngModel`|`Ruleset`|Optional|| Object that stores the state of the component. Supports 2-way binding. |
225
+
|`operatorMap`|`{ [key: string]: string[] }`|Optional|| Used to map field types to list of operators. |
226
+
|`persistValueOnFieldChange`|`boolean`|Optional|`false`| If `true`, when a field changes to another of the same type, and the type is one of: string, number, time, date, or boolean, persist the previous value. This option is ignored if config.calculateFieldChangeValue is provided. |
227
+
|`config.calculateFieldChangeValue`|`(currentField: Field, nextField: Field, currentValue: any) => any`|Optional|| Used to calculate the new value when a rule's field changes. |
228
+
|`value`|`Ruleset`|Optional|| Object that stores the state of the component. |
229
+
230
+
## Structural Directives
231
+
232
+
Use these directives to replace different parts of query builder with custom components. See [example](#customizing-with-angular-material), or [demo](https://zebzhao.github.io/Angular-QueryBuilder/demo/) to see how it's done.
233
+
234
+
#### `queryInput`
235
+
236
+
Used to replace the input component. Specify the type/queryInputType to match specific field types to input template.
237
+
238
+
|Context Name|Type|Description|
239
+
|:--- |:--- |:--- |
240
+
|`$implicit`|`Rule`|Current rule object which contains the field, value, and operator|
241
+
|`field`|`Field`|Current field object which contains the field's value and name|
242
+
|`options`|`Option[]`|List of options for the field, returned by `getOptions`|
243
+
|`onChange`|`() => void`|Callback to handle changes to the input component|
244
+
245
+
#### `queryOperator`
246
+
247
+
Used to replace the query operator selection component.
248
+
249
+
|Context Name|Type|Description|
250
+
|:--- |:--- |:--- |
251
+
|`$implicit`|`Rule`|Current rule object which contains the field, value, and operator|
252
+
|`operators`|`string[]`|List of operators for the field, returned by `getOperators`|
253
+
|`onChange`|`() => void`|Callback to handle changes to the operator component|
254
+
|`type`|`string`|Input binding specifying the field type mapped to this input template, specified using syntax in above example|
255
+
256
+
#### `queryField`
257
+
258
+
Used this directive to replace the query field selection component.
259
+
260
+
|Context Name|Type|Description|
261
+
|:--- |:--- |:--- |
262
+
|`$implicit`|`Rule`|Current rule object which contains the field, value, and operator|
263
+
|`getFields`|`(entityName: string) => void`|Get the list of fields corresponding to an entity|
264
+
|`fields`|`Field[]`|List of fields for the component, specified by `config`|
265
+
|`onChange`|`(fieldValue: string, rule: Rule) => void`|Callback to handle changes to the field component|
266
+
267
+
#### `queryEntity`
268
+
269
+
Used to replace entity selection component.
270
+
271
+
|Context Name|Type|Description|
272
+
|:--- |:--- |:--- |
273
+
|`$implicit`|`Rule`|Current rule object which contains the field, value, and operator|
274
+
|`entities`|`Entity[]`|List of entities for the component, specified by `config`|
275
+
|`onChange`|`(entityValue: string, rule: Rule) => void`|Callback to handle changes to the entity component|
276
+
277
+
#### `querySwitchGroup`
278
+
279
+
Useful for replacing the switch controls, for example the AND/OR conditions. More custom conditions can be specified by using this directive to override the default component.
280
+
281
+
|Context Name|Type|Description|
282
+
|:--- |:--- |:--- |
283
+
|`$implicit`|`RuleSet`|Current rule set object which contain a list of child rules|
284
+
|`onChange`|`() => void`|Callback to handle changes to the switch group component|
285
+
286
+
#### `queryArrowIcon`
287
+
288
+
Directive to replace the expand arrow used in collapse/accordion mode of the query builder.
289
+
290
+
|Context Name|Type|Description|
291
+
|:--- |:--- |:--- |
292
+
|`$implicit`|`RuleSet`|Current rule set object which contain a list of child rules|
293
+
294
+
#### `queryEmptyWarning`
295
+
296
+
Can be used to customize the default empty warning message, alternatively can specify the `emptyMessage` property binding.
297
+
298
+
|Context Name|Type|Description|
299
+
|:--- |:--- |:--- |
300
+
|`$implicit`|`RuleSet`|Current rule set object which contain a list of child rules|
301
+
|`message`|`string`|Value passed to `emptyMessage`|
302
+
303
+
#### `queryButtonGroup`
304
+
305
+
For replacing the default button group for Add, Add Ruleset, Remove Ruleset buttons.
306
+
307
+
|Context Name|Type|Description|
308
+
|:--- |:--- |:--- |
309
+
|`$implicit`|`RuleSet`|Current rule set object which contain a list of child rules|
310
+
|`addRule`|`() => void`|Function to handle adding a new rule|
311
+
|`addRuleSet`|`() => void`|Function to handle adding a new rule set|
312
+
|`removeRuleSet`|`() => void`|Function to handle removing the current rule set|
313
+
314
+
#### `queryRemoveButton`
315
+
316
+
Directive to replace the default remove single rule button component.
317
+
318
+
|Context Name|Type|Description|
319
+
|:--- |:--- |:--- |
320
+
|`$implicit`|`Rule`|Current rule object which contains the field, value, and operator|
321
+
|`removeRule`|`(rule: Rule) => void`|Function to handle removing a rule|
0 commit comments