@super-green/query-builder 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +340 -0
- package/dist/query-builder/README.md +24 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-arrow-icon.directive.mjs +15 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-builder.component.mjs +769 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-builder.interfaces.mjs +2 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-button-group.directive.mjs +15 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-empty-warning.directive.mjs +15 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-entity.directive.mjs +15 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-field.directive.mjs +15 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-input.directive.mjs +28 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-operator.directive.mjs +15 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-remove-button.directive.mjs +15 -0
- package/dist/query-builder/esm2022/lib/query-builder/query-switch-group.directive.mjs +15 -0
- package/dist/query-builder/esm2022/lib/query-builder.module.mjs +73 -0
- package/dist/query-builder/esm2022/public-api.mjs +16 -0
- package/dist/query-builder/esm2022/query-builder.mjs +5 -0
- package/dist/query-builder/fesm2022/query-builder.mjs +961 -0
- package/dist/query-builder/fesm2022/query-builder.mjs.map +1 -0
- package/dist/query-builder/index.d.ts +5 -0
- package/dist/query-builder/lib/query-builder/query-arrow-icon.directive.d.ts +8 -0
- package/dist/query-builder/lib/query-builder/query-builder.component.d.ts +129 -0
- package/dist/query-builder/lib/query-builder/query-builder.interfaces.d.ts +143 -0
- package/dist/query-builder/lib/query-builder/query-button-group.directive.d.ts +8 -0
- package/dist/query-builder/lib/query-builder/query-empty-warning.directive.d.ts +8 -0
- package/dist/query-builder/lib/query-builder/query-entity.directive.d.ts +8 -0
- package/dist/query-builder/lib/query-builder/query-field.directive.d.ts +8 -0
- package/dist/query-builder/lib/query-builder/query-input.directive.d.ts +12 -0
- package/dist/query-builder/lib/query-builder/query-operator.directive.d.ts +8 -0
- package/dist/query-builder/lib/query-builder/query-remove-button.directive.d.ts +8 -0
- package/dist/query-builder/lib/query-builder/query-switch-group.directive.d.ts +8 -0
- package/dist/query-builder/lib/query-builder.module.d.ts +18 -0
- package/dist/query-builder/public-api.d.ts +12 -0
- package/package.json +56 -0
@@ -0,0 +1,961 @@
|
|
1
|
+
import * as i2 from '@angular/forms';
|
2
|
+
import { NG_VALUE_ACCESSOR, NG_VALIDATORS, FormsModule } from '@angular/forms';
|
3
|
+
import * as i0 from '@angular/core';
|
4
|
+
import { Directive, Input, forwardRef, Component, ViewChild, ContentChild, ContentChildren, NgModule } from '@angular/core';
|
5
|
+
import * as i1 from '@angular/common';
|
6
|
+
import { CommonModule } from '@angular/common';
|
7
|
+
|
8
|
+
class QueryOperatorDirective {
|
9
|
+
template;
|
10
|
+
constructor(template) {
|
11
|
+
this.template = template;
|
12
|
+
}
|
13
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryOperatorDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
14
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.2", type: QueryOperatorDirective, selector: "[queryOperator]", ngImport: i0 });
|
15
|
+
}
|
16
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryOperatorDirective, decorators: [{
|
17
|
+
type: Directive,
|
18
|
+
args: [{ selector: '[queryOperator]' }]
|
19
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }] });
|
20
|
+
|
21
|
+
class QueryFieldDirective {
|
22
|
+
template;
|
23
|
+
constructor(template) {
|
24
|
+
this.template = template;
|
25
|
+
}
|
26
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryFieldDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
27
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.2", type: QueryFieldDirective, selector: "[queryField]", ngImport: i0 });
|
28
|
+
}
|
29
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryFieldDirective, decorators: [{
|
30
|
+
type: Directive,
|
31
|
+
args: [{ selector: '[queryField]' }]
|
32
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }] });
|
33
|
+
|
34
|
+
class QueryEntityDirective {
|
35
|
+
template;
|
36
|
+
constructor(template) {
|
37
|
+
this.template = template;
|
38
|
+
}
|
39
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryEntityDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
40
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.2", type: QueryEntityDirective, selector: "[queryEntity]", ngImport: i0 });
|
41
|
+
}
|
42
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryEntityDirective, decorators: [{
|
43
|
+
type: Directive,
|
44
|
+
args: [{ selector: '[queryEntity]' }]
|
45
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }] });
|
46
|
+
|
47
|
+
class QuerySwitchGroupDirective {
|
48
|
+
template;
|
49
|
+
constructor(template) {
|
50
|
+
this.template = template;
|
51
|
+
}
|
52
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QuerySwitchGroupDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
53
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.2", type: QuerySwitchGroupDirective, selector: "[querySwitchGroup]", ngImport: i0 });
|
54
|
+
}
|
55
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QuerySwitchGroupDirective, decorators: [{
|
56
|
+
type: Directive,
|
57
|
+
args: [{ selector: '[querySwitchGroup]' }]
|
58
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }] });
|
59
|
+
|
60
|
+
class QueryButtonGroupDirective {
|
61
|
+
template;
|
62
|
+
constructor(template) {
|
63
|
+
this.template = template;
|
64
|
+
}
|
65
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryButtonGroupDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
66
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.2", type: QueryButtonGroupDirective, selector: "[queryButtonGroup]", ngImport: i0 });
|
67
|
+
}
|
68
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryButtonGroupDirective, decorators: [{
|
69
|
+
type: Directive,
|
70
|
+
args: [{ selector: '[queryButtonGroup]' }]
|
71
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }] });
|
72
|
+
|
73
|
+
class QueryInputDirective {
|
74
|
+
template;
|
75
|
+
/** Unique name for query input type. */
|
76
|
+
get queryInputType() { return this._type; }
|
77
|
+
set queryInputType(value) {
|
78
|
+
// If the directive is set without a type (updated programatically), then this setter will
|
79
|
+
// trigger with an empty string and should not overwrite the programatically set value.
|
80
|
+
if (!value) {
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
this._type = value;
|
84
|
+
}
|
85
|
+
_type;
|
86
|
+
constructor(template) {
|
87
|
+
this.template = template;
|
88
|
+
}
|
89
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryInputDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
90
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.2", type: QueryInputDirective, selector: "[queryInput]", inputs: { queryInputType: "queryInputType" }, ngImport: i0 });
|
91
|
+
}
|
92
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryInputDirective, decorators: [{
|
93
|
+
type: Directive,
|
94
|
+
args: [{ selector: '[queryInput]' }]
|
95
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }], propDecorators: { queryInputType: [{
|
96
|
+
type: Input
|
97
|
+
}] } });
|
98
|
+
|
99
|
+
class QueryRemoveButtonDirective {
|
100
|
+
template;
|
101
|
+
constructor(template) {
|
102
|
+
this.template = template;
|
103
|
+
}
|
104
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryRemoveButtonDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
105
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.2", type: QueryRemoveButtonDirective, selector: "[queryRemoveButton]", ngImport: i0 });
|
106
|
+
}
|
107
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryRemoveButtonDirective, decorators: [{
|
108
|
+
type: Directive,
|
109
|
+
args: [{ selector: '[queryRemoveButton]' }]
|
110
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }] });
|
111
|
+
|
112
|
+
class QueryEmptyWarningDirective {
|
113
|
+
template;
|
114
|
+
constructor(template) {
|
115
|
+
this.template = template;
|
116
|
+
}
|
117
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryEmptyWarningDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
118
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.2", type: QueryEmptyWarningDirective, selector: "[queryEmptyWarning]", ngImport: i0 });
|
119
|
+
}
|
120
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryEmptyWarningDirective, decorators: [{
|
121
|
+
type: Directive,
|
122
|
+
args: [{ selector: '[queryEmptyWarning]' }]
|
123
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }] });
|
124
|
+
|
125
|
+
class QueryArrowIconDirective {
|
126
|
+
template;
|
127
|
+
constructor(template) {
|
128
|
+
this.template = template;
|
129
|
+
}
|
130
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryArrowIconDirective, deps: [{ token: i0.TemplateRef }], target: i0.ɵɵFactoryTarget.Directive });
|
131
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.1.2", type: QueryArrowIconDirective, selector: "[queryArrowIcon]", ngImport: i0 });
|
132
|
+
}
|
133
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryArrowIconDirective, decorators: [{
|
134
|
+
type: Directive,
|
135
|
+
args: [{ selector: '[queryArrowIcon]' }]
|
136
|
+
}], ctorParameters: () => [{ type: i0.TemplateRef }] });
|
137
|
+
|
138
|
+
const CONTROL_VALUE_ACCESSOR = {
|
139
|
+
provide: NG_VALUE_ACCESSOR,
|
140
|
+
useExisting: forwardRef(() => QueryBuilderComponent),
|
141
|
+
multi: true
|
142
|
+
};
|
143
|
+
const VALIDATOR = {
|
144
|
+
provide: NG_VALIDATORS,
|
145
|
+
useExisting: forwardRef(() => QueryBuilderComponent),
|
146
|
+
multi: true
|
147
|
+
};
|
148
|
+
class QueryBuilderComponent {
|
149
|
+
changeDetectorRef;
|
150
|
+
fields;
|
151
|
+
filterFields;
|
152
|
+
entities;
|
153
|
+
defaultClassNames = {
|
154
|
+
arrowIconButton: 'q-arrow-icon-button',
|
155
|
+
arrowIcon: 'q-icon q-arrow-icon',
|
156
|
+
removeIcon: 'q-icon q-remove-icon',
|
157
|
+
addIcon: 'q-icon q-add-icon',
|
158
|
+
button: 'q-button',
|
159
|
+
buttonGroup: 'q-button-group',
|
160
|
+
removeButton: 'q-remove-button',
|
161
|
+
switchGroup: 'q-switch-group',
|
162
|
+
switchLabel: 'q-switch-label',
|
163
|
+
switchRadio: 'q-switch-radio',
|
164
|
+
rightAlign: 'q-right-align',
|
165
|
+
transition: 'q-transition',
|
166
|
+
collapsed: 'q-collapsed',
|
167
|
+
treeContainer: 'q-tree-container',
|
168
|
+
tree: 'q-tree',
|
169
|
+
row: 'q-row',
|
170
|
+
connector: 'q-connector',
|
171
|
+
rule: 'q-rule',
|
172
|
+
ruleSet: 'q-ruleset',
|
173
|
+
invalidRuleSet: 'q-invalid-ruleset',
|
174
|
+
emptyWarning: 'q-empty-warning',
|
175
|
+
fieldControl: 'q-field-control',
|
176
|
+
fieldControlSize: 'q-control-size',
|
177
|
+
entityControl: 'q-entity-control',
|
178
|
+
entityControlSize: 'q-control-size',
|
179
|
+
operatorControl: 'q-operator-control',
|
180
|
+
operatorControlSize: 'q-control-size',
|
181
|
+
inputControl: 'q-input-control',
|
182
|
+
inputControlSize: 'q-control-size'
|
183
|
+
};
|
184
|
+
defaultOperatorMap = {
|
185
|
+
string: ['=', '!=', 'contains', 'like'],
|
186
|
+
number: ['=', '!=', '>', '>=', '<', '<='],
|
187
|
+
time: ['=', '!=', '>', '>=', '<', '<='],
|
188
|
+
date: ['=', '!=', '>', '>=', '<', '<='],
|
189
|
+
category: ['=', '!=', 'in', 'not in'],
|
190
|
+
boolean: ['=']
|
191
|
+
};
|
192
|
+
disabled;
|
193
|
+
data = { condition: 'and', rules: [] };
|
194
|
+
// For ControlValueAccessor interface
|
195
|
+
onChangeCallback;
|
196
|
+
onTouchedCallback;
|
197
|
+
allowRuleset = true;
|
198
|
+
allowCollapse = false;
|
199
|
+
emptyMessage = 'A ruleset cannot be empty. Please add a rule or remove it all together.';
|
200
|
+
classNames;
|
201
|
+
operatorMap;
|
202
|
+
parentValue;
|
203
|
+
config = { fields: {} };
|
204
|
+
parentArrowIconTemplate;
|
205
|
+
parentInputTemplates;
|
206
|
+
parentOperatorTemplate;
|
207
|
+
parentFieldTemplate;
|
208
|
+
parentEntityTemplate;
|
209
|
+
parentSwitchGroupTemplate;
|
210
|
+
parentButtonGroupTemplate;
|
211
|
+
parentRemoveButtonTemplate;
|
212
|
+
parentEmptyWarningTemplate;
|
213
|
+
parentChangeCallback;
|
214
|
+
parentTouchedCallback;
|
215
|
+
persistValueOnFieldChange = false;
|
216
|
+
treeContainer;
|
217
|
+
buttonGroupTemplate;
|
218
|
+
switchGroupTemplate;
|
219
|
+
fieldTemplate;
|
220
|
+
entityTemplate;
|
221
|
+
operatorTemplate;
|
222
|
+
removeButtonTemplate;
|
223
|
+
emptyWarningTemplate;
|
224
|
+
inputTemplates;
|
225
|
+
arrowIconTemplate;
|
226
|
+
defaultTemplateTypes = [
|
227
|
+
'string', 'number', 'time', 'date', 'category', 'boolean', 'multiselect'
|
228
|
+
];
|
229
|
+
defaultPersistValueTypes = [
|
230
|
+
'string', 'number', 'time', 'date', 'boolean'
|
231
|
+
];
|
232
|
+
defaultEmptyList = [];
|
233
|
+
operatorsCache;
|
234
|
+
inputContextCache = new Map();
|
235
|
+
operatorContextCache = new Map();
|
236
|
+
fieldContextCache = new Map();
|
237
|
+
entityContextCache = new Map();
|
238
|
+
removeButtonContextCache = new Map();
|
239
|
+
buttonGroupContext;
|
240
|
+
constructor(changeDetectorRef) {
|
241
|
+
this.changeDetectorRef = changeDetectorRef;
|
242
|
+
}
|
243
|
+
// ----------OnInit Implementation----------
|
244
|
+
ngOnInit() { }
|
245
|
+
// ----------OnChanges Implementation----------
|
246
|
+
ngOnChanges(changes) {
|
247
|
+
const config = this.config;
|
248
|
+
const type = typeof config;
|
249
|
+
if (type === 'object') {
|
250
|
+
this.fields = Object.keys(config.fields).map((value) => {
|
251
|
+
const field = config.fields[value];
|
252
|
+
field.value = field.value || value;
|
253
|
+
return field;
|
254
|
+
});
|
255
|
+
if (config.entities) {
|
256
|
+
this.entities = Object.keys(config.entities).map((value) => {
|
257
|
+
const entity = config.entities[value];
|
258
|
+
entity.value = entity.value || value;
|
259
|
+
return entity;
|
260
|
+
});
|
261
|
+
}
|
262
|
+
else {
|
263
|
+
this.entities = null;
|
264
|
+
}
|
265
|
+
this.operatorsCache = {};
|
266
|
+
}
|
267
|
+
else {
|
268
|
+
throw new Error(`Expected 'config' must be a valid object, got ${type} instead.`);
|
269
|
+
}
|
270
|
+
}
|
271
|
+
// ----------Validator Implementation----------
|
272
|
+
validate(control) {
|
273
|
+
const errors = {};
|
274
|
+
const ruleErrorStore = [];
|
275
|
+
let hasErrors = false;
|
276
|
+
if (!this.config.allowEmptyRulesets && this.checkEmptyRuleInRuleset(this.data)) {
|
277
|
+
errors.empty = 'Empty rulesets are not allowed.';
|
278
|
+
hasErrors = true;
|
279
|
+
}
|
280
|
+
this.validateRulesInRuleset(this.data, ruleErrorStore);
|
281
|
+
if (ruleErrorStore.length) {
|
282
|
+
errors.rules = ruleErrorStore;
|
283
|
+
hasErrors = true;
|
284
|
+
}
|
285
|
+
return hasErrors ? errors : null;
|
286
|
+
}
|
287
|
+
// ----------ControlValueAccessor Implementation----------
|
288
|
+
get value() {
|
289
|
+
return this.data;
|
290
|
+
}
|
291
|
+
set value(value) {
|
292
|
+
// When component is initialized without a formControl, null is passed to value
|
293
|
+
this.data = value || { condition: 'and', rules: [] };
|
294
|
+
this.handleDataChange();
|
295
|
+
}
|
296
|
+
writeValue(obj) {
|
297
|
+
this.value = obj;
|
298
|
+
}
|
299
|
+
registerOnChange(fn) {
|
300
|
+
this.onChangeCallback = () => fn(this.data);
|
301
|
+
}
|
302
|
+
registerOnTouched(fn) {
|
303
|
+
this.onTouchedCallback = () => fn(this.data);
|
304
|
+
}
|
305
|
+
setDisabledState(isDisabled) {
|
306
|
+
this.disabled = isDisabled;
|
307
|
+
this.changeDetectorRef.detectChanges();
|
308
|
+
}
|
309
|
+
// ----------END----------
|
310
|
+
getDisabledState = () => {
|
311
|
+
return this.disabled;
|
312
|
+
};
|
313
|
+
findTemplateForRule(rule) {
|
314
|
+
const type = this.getInputType(rule.field, rule.operator);
|
315
|
+
if (type) {
|
316
|
+
const queryInput = this.findQueryInput(type);
|
317
|
+
if (queryInput) {
|
318
|
+
return queryInput.template;
|
319
|
+
}
|
320
|
+
else {
|
321
|
+
if (this.defaultTemplateTypes.indexOf(type) === -1) {
|
322
|
+
console.warn(`Could not find template for field with type: ${type}`);
|
323
|
+
}
|
324
|
+
}
|
325
|
+
}
|
326
|
+
return null;
|
327
|
+
}
|
328
|
+
findQueryInput(type) {
|
329
|
+
const templates = this.parentInputTemplates || this.inputTemplates;
|
330
|
+
return templates.find((item) => item.queryInputType === type);
|
331
|
+
}
|
332
|
+
getOperators(field) {
|
333
|
+
if (this.operatorsCache[field]) {
|
334
|
+
return this.operatorsCache[field];
|
335
|
+
}
|
336
|
+
let operators = this.defaultEmptyList;
|
337
|
+
const fieldObject = this.config.fields[field];
|
338
|
+
if (this.config.getOperators) {
|
339
|
+
return this.config.getOperators(field, fieldObject);
|
340
|
+
}
|
341
|
+
const type = fieldObject.type;
|
342
|
+
if (fieldObject && fieldObject.operators) {
|
343
|
+
operators = fieldObject.operators;
|
344
|
+
}
|
345
|
+
else if (type) {
|
346
|
+
operators = (this.operatorMap && this.operatorMap[type]) || this.defaultOperatorMap[type] || this.defaultEmptyList;
|
347
|
+
if (operators.length === 0) {
|
348
|
+
console.warn(`No operators found for field '${field}' with type ${fieldObject.type}. ` +
|
349
|
+
`Please define an 'operators' property on the field or use the 'operatorMap' binding to fix this.`);
|
350
|
+
}
|
351
|
+
if (fieldObject.nullable) {
|
352
|
+
operators = operators.concat(['is null', 'is not null']);
|
353
|
+
}
|
354
|
+
}
|
355
|
+
else {
|
356
|
+
console.warn(`No 'type' property found on field: '${field}'`);
|
357
|
+
}
|
358
|
+
// Cache reference to array object, so it won't be computed next time and trigger a rerender.
|
359
|
+
this.operatorsCache[field] = operators;
|
360
|
+
return operators;
|
361
|
+
}
|
362
|
+
getFields(entity) {
|
363
|
+
if (this.entities && entity) {
|
364
|
+
return this.fields.filter((field) => {
|
365
|
+
return field && field.entity === entity;
|
366
|
+
});
|
367
|
+
}
|
368
|
+
else {
|
369
|
+
return this.fields;
|
370
|
+
}
|
371
|
+
}
|
372
|
+
getInputType(field, operator) {
|
373
|
+
if (this.config.getInputType) {
|
374
|
+
return this.config.getInputType(field, operator);
|
375
|
+
}
|
376
|
+
if (!this.config.fields[field]) {
|
377
|
+
throw new Error(`No configuration for field '${field}' could be found! Please add it to config.fields.`);
|
378
|
+
}
|
379
|
+
const type = this.config.fields[field].type;
|
380
|
+
switch (operator) {
|
381
|
+
case 'is null':
|
382
|
+
case 'is not null':
|
383
|
+
return null; // No displayed component
|
384
|
+
case 'in':
|
385
|
+
case 'not in':
|
386
|
+
return type === 'category' || type === 'boolean' ? 'multiselect' : type;
|
387
|
+
default:
|
388
|
+
return type;
|
389
|
+
}
|
390
|
+
}
|
391
|
+
getOptions(field) {
|
392
|
+
if (this.config.getOptions) {
|
393
|
+
return this.config.getOptions(field);
|
394
|
+
}
|
395
|
+
return this.config.fields[field].options || this.defaultEmptyList;
|
396
|
+
}
|
397
|
+
getClassNames(...args) {
|
398
|
+
const clsLookup = this.classNames ? this.classNames : this.defaultClassNames;
|
399
|
+
const classNames = args.map((id) => clsLookup[id] || this.defaultClassNames[id]).filter((c) => !!c);
|
400
|
+
return classNames.length ? classNames.join(' ') : null;
|
401
|
+
}
|
402
|
+
getDefaultField(entity) {
|
403
|
+
if (!entity) {
|
404
|
+
return null;
|
405
|
+
}
|
406
|
+
else if (entity.defaultField !== undefined) {
|
407
|
+
return this.getDefaultValue(entity.defaultField);
|
408
|
+
}
|
409
|
+
else {
|
410
|
+
const entityFields = this.fields.filter((field) => {
|
411
|
+
return field && field.entity === entity.value;
|
412
|
+
});
|
413
|
+
if (entityFields && entityFields.length) {
|
414
|
+
return entityFields[0];
|
415
|
+
}
|
416
|
+
else {
|
417
|
+
console.warn(`No fields found for entity '${entity.name}'. ` +
|
418
|
+
`A 'defaultOperator' is also not specified on the field config. Operator value will default to null.`);
|
419
|
+
return null;
|
420
|
+
}
|
421
|
+
}
|
422
|
+
}
|
423
|
+
getDefaultOperator(field) {
|
424
|
+
if (field && field.defaultOperator !== undefined) {
|
425
|
+
return this.getDefaultValue(field.defaultOperator);
|
426
|
+
}
|
427
|
+
else {
|
428
|
+
const operators = this.getOperators(field.value);
|
429
|
+
if (operators && operators.length) {
|
430
|
+
return operators[0];
|
431
|
+
}
|
432
|
+
else {
|
433
|
+
console.warn(`No operators found for field '${field.value}'. ` +
|
434
|
+
`A 'defaultOperator' is also not specified on the field config. Operator value will default to null.`);
|
435
|
+
return null;
|
436
|
+
}
|
437
|
+
}
|
438
|
+
}
|
439
|
+
addRule(parent) {
|
440
|
+
if (this.disabled) {
|
441
|
+
return;
|
442
|
+
}
|
443
|
+
parent = parent || this.data;
|
444
|
+
if (this.config.addRule) {
|
445
|
+
this.config.addRule(parent);
|
446
|
+
}
|
447
|
+
else {
|
448
|
+
const field = this.fields[0];
|
449
|
+
parent.rules = parent.rules.concat([{
|
450
|
+
field: field.value,
|
451
|
+
operator: this.getDefaultOperator(field),
|
452
|
+
value: this.getDefaultValue(field.defaultValue),
|
453
|
+
entity: field.entity
|
454
|
+
}]);
|
455
|
+
}
|
456
|
+
this.handleTouched();
|
457
|
+
this.handleDataChange();
|
458
|
+
}
|
459
|
+
removeRule(rule, parent) {
|
460
|
+
if (this.disabled) {
|
461
|
+
return;
|
462
|
+
}
|
463
|
+
parent = parent || this.data;
|
464
|
+
if (this.config.removeRule) {
|
465
|
+
this.config.removeRule(rule, parent);
|
466
|
+
}
|
467
|
+
else {
|
468
|
+
parent.rules = parent.rules.filter((r) => r !== rule);
|
469
|
+
}
|
470
|
+
this.inputContextCache.delete(rule);
|
471
|
+
this.operatorContextCache.delete(rule);
|
472
|
+
this.fieldContextCache.delete(rule);
|
473
|
+
this.entityContextCache.delete(rule);
|
474
|
+
this.removeButtonContextCache.delete(rule);
|
475
|
+
this.handleTouched();
|
476
|
+
this.handleDataChange();
|
477
|
+
}
|
478
|
+
addRuleSet(parent) {
|
479
|
+
if (this.disabled) {
|
480
|
+
return;
|
481
|
+
}
|
482
|
+
parent = parent || this.data;
|
483
|
+
if (this.config.addRuleSet) {
|
484
|
+
this.config.addRuleSet(parent);
|
485
|
+
}
|
486
|
+
else {
|
487
|
+
parent.rules = parent.rules.concat([{ condition: 'and', rules: [] }]);
|
488
|
+
}
|
489
|
+
this.handleTouched();
|
490
|
+
this.handleDataChange();
|
491
|
+
}
|
492
|
+
removeRuleSet(ruleset, parent) {
|
493
|
+
if (this.disabled) {
|
494
|
+
return;
|
495
|
+
}
|
496
|
+
ruleset = ruleset || this.data;
|
497
|
+
parent = parent || this.parentValue;
|
498
|
+
if (this.config.removeRuleSet) {
|
499
|
+
this.config.removeRuleSet(ruleset, parent);
|
500
|
+
}
|
501
|
+
else {
|
502
|
+
parent.rules = parent.rules.filter((r) => r !== ruleset);
|
503
|
+
}
|
504
|
+
this.handleTouched();
|
505
|
+
this.handleDataChange();
|
506
|
+
}
|
507
|
+
transitionEnd(e) {
|
508
|
+
this.treeContainer.nativeElement.style.maxHeight = null;
|
509
|
+
}
|
510
|
+
toggleCollapse() {
|
511
|
+
this.computedTreeContainerHeight();
|
512
|
+
setTimeout(() => {
|
513
|
+
this.data.collapsed = !this.data.collapsed;
|
514
|
+
}, 100);
|
515
|
+
}
|
516
|
+
computedTreeContainerHeight() {
|
517
|
+
const nativeElement = this.treeContainer.nativeElement;
|
518
|
+
if (nativeElement && nativeElement.firstElementChild) {
|
519
|
+
nativeElement.style.maxHeight = (nativeElement.firstElementChild.clientHeight + 8) + 'px';
|
520
|
+
}
|
521
|
+
}
|
522
|
+
changeCondition(value) {
|
523
|
+
if (this.disabled) {
|
524
|
+
return;
|
525
|
+
}
|
526
|
+
this.data.condition = value;
|
527
|
+
this.handleTouched();
|
528
|
+
this.handleDataChange();
|
529
|
+
}
|
530
|
+
changeOperator(rule) {
|
531
|
+
if (this.disabled) {
|
532
|
+
return;
|
533
|
+
}
|
534
|
+
if (this.config.coerceValueForOperator) {
|
535
|
+
rule.value = this.config.coerceValueForOperator(rule.operator, rule.value, rule);
|
536
|
+
}
|
537
|
+
else {
|
538
|
+
rule.value = this.coerceValueForOperator(rule.operator, rule.value, rule);
|
539
|
+
}
|
540
|
+
this.handleTouched();
|
541
|
+
this.handleDataChange();
|
542
|
+
}
|
543
|
+
coerceValueForOperator(operator, value, rule) {
|
544
|
+
const inputType = this.getInputType(rule.field, operator);
|
545
|
+
if (inputType === 'multiselect' && !Array.isArray(value)) {
|
546
|
+
return [value];
|
547
|
+
}
|
548
|
+
return value;
|
549
|
+
}
|
550
|
+
changeInput() {
|
551
|
+
if (this.disabled) {
|
552
|
+
return;
|
553
|
+
}
|
554
|
+
this.handleTouched();
|
555
|
+
this.handleDataChange();
|
556
|
+
}
|
557
|
+
changeField(fieldValue, rule) {
|
558
|
+
if (this.disabled) {
|
559
|
+
return;
|
560
|
+
}
|
561
|
+
const inputContext = this.inputContextCache.get(rule);
|
562
|
+
const currentField = inputContext && inputContext.field;
|
563
|
+
const nextField = this.config.fields[fieldValue];
|
564
|
+
const nextValue = this.calculateFieldChangeValue(currentField, nextField, rule.value);
|
565
|
+
if (nextValue !== undefined) {
|
566
|
+
rule.value = nextValue;
|
567
|
+
}
|
568
|
+
else {
|
569
|
+
delete rule.value;
|
570
|
+
}
|
571
|
+
rule.operator = this.getDefaultOperator(nextField);
|
572
|
+
// Create new context objects so templates will automatically update
|
573
|
+
this.inputContextCache.delete(rule);
|
574
|
+
this.operatorContextCache.delete(rule);
|
575
|
+
this.fieldContextCache.delete(rule);
|
576
|
+
this.entityContextCache.delete(rule);
|
577
|
+
this.getInputContext(rule);
|
578
|
+
this.getFieldContext(rule);
|
579
|
+
this.getOperatorContext(rule);
|
580
|
+
this.getEntityContext(rule);
|
581
|
+
this.handleTouched();
|
582
|
+
this.handleDataChange();
|
583
|
+
}
|
584
|
+
changeEntity(entityValue, rule, index, data) {
|
585
|
+
if (this.disabled) {
|
586
|
+
return;
|
587
|
+
}
|
588
|
+
let i = index;
|
589
|
+
let rs = data;
|
590
|
+
const entity = this.entities.find((e) => e.value === entityValue);
|
591
|
+
const defaultField = this.getDefaultField(entity);
|
592
|
+
if (!rs) {
|
593
|
+
rs = this.data;
|
594
|
+
i = rs.rules.findIndex((x) => x === rule);
|
595
|
+
}
|
596
|
+
rule.field = defaultField.value;
|
597
|
+
rs.rules[i] = rule;
|
598
|
+
if (defaultField) {
|
599
|
+
this.changeField(defaultField.value, rule);
|
600
|
+
}
|
601
|
+
else {
|
602
|
+
this.handleTouched();
|
603
|
+
this.handleDataChange();
|
604
|
+
}
|
605
|
+
}
|
606
|
+
getDefaultValue(defaultValue) {
|
607
|
+
switch (typeof defaultValue) {
|
608
|
+
case 'function':
|
609
|
+
return defaultValue();
|
610
|
+
default:
|
611
|
+
return defaultValue;
|
612
|
+
}
|
613
|
+
}
|
614
|
+
getOperatorTemplate() {
|
615
|
+
const t = this.parentOperatorTemplate || this.operatorTemplate;
|
616
|
+
return t ? t.template : null;
|
617
|
+
}
|
618
|
+
getFieldTemplate() {
|
619
|
+
const t = this.parentFieldTemplate || this.fieldTemplate;
|
620
|
+
return t ? t.template : null;
|
621
|
+
}
|
622
|
+
getEntityTemplate() {
|
623
|
+
const t = this.parentEntityTemplate || this.entityTemplate;
|
624
|
+
return t ? t.template : null;
|
625
|
+
}
|
626
|
+
getArrowIconTemplate() {
|
627
|
+
const t = this.parentArrowIconTemplate || this.arrowIconTemplate;
|
628
|
+
return t ? t.template : null;
|
629
|
+
}
|
630
|
+
getButtonGroupTemplate() {
|
631
|
+
const t = this.parentButtonGroupTemplate || this.buttonGroupTemplate;
|
632
|
+
return t ? t.template : null;
|
633
|
+
}
|
634
|
+
getSwitchGroupTemplate() {
|
635
|
+
const t = this.parentSwitchGroupTemplate || this.switchGroupTemplate;
|
636
|
+
return t ? t.template : null;
|
637
|
+
}
|
638
|
+
getRemoveButtonTemplate() {
|
639
|
+
const t = this.parentRemoveButtonTemplate || this.removeButtonTemplate;
|
640
|
+
return t ? t.template : null;
|
641
|
+
}
|
642
|
+
getEmptyWarningTemplate() {
|
643
|
+
const t = this.parentEmptyWarningTemplate || this.emptyWarningTemplate;
|
644
|
+
return t ? t.template : null;
|
645
|
+
}
|
646
|
+
getQueryItemClassName(local) {
|
647
|
+
let cls = this.getClassNames('row', 'connector', 'transition');
|
648
|
+
cls += ' ' + this.getClassNames(local.ruleset ? 'ruleSet' : 'rule');
|
649
|
+
if (local.invalid) {
|
650
|
+
cls += ' ' + this.getClassNames('invalidRuleSet');
|
651
|
+
}
|
652
|
+
return cls;
|
653
|
+
}
|
654
|
+
getButtonGroupContext() {
|
655
|
+
if (!this.buttonGroupContext) {
|
656
|
+
this.buttonGroupContext = {
|
657
|
+
addRule: this.addRule.bind(this),
|
658
|
+
addRuleSet: this.allowRuleset && this.addRuleSet.bind(this),
|
659
|
+
removeRuleSet: this.allowRuleset && this.parentValue && this.removeRuleSet.bind(this),
|
660
|
+
getDisabledState: this.getDisabledState,
|
661
|
+
$implicit: this.data
|
662
|
+
};
|
663
|
+
}
|
664
|
+
return this.buttonGroupContext;
|
665
|
+
}
|
666
|
+
getRemoveButtonContext(rule) {
|
667
|
+
if (!this.removeButtonContextCache.has(rule)) {
|
668
|
+
this.removeButtonContextCache.set(rule, {
|
669
|
+
removeRule: this.removeRule.bind(this),
|
670
|
+
getDisabledState: this.getDisabledState,
|
671
|
+
$implicit: rule
|
672
|
+
});
|
673
|
+
}
|
674
|
+
return this.removeButtonContextCache.get(rule);
|
675
|
+
}
|
676
|
+
getFieldContext(rule) {
|
677
|
+
if (!this.fieldContextCache.has(rule)) {
|
678
|
+
this.fieldContextCache.set(rule, {
|
679
|
+
onChange: this.changeField.bind(this),
|
680
|
+
getFields: this.getFields.bind(this),
|
681
|
+
getDisabledState: this.getDisabledState,
|
682
|
+
fields: this.fields,
|
683
|
+
$implicit: rule
|
684
|
+
});
|
685
|
+
}
|
686
|
+
return this.fieldContextCache.get(rule);
|
687
|
+
}
|
688
|
+
getEntityContext(rule) {
|
689
|
+
if (!this.entityContextCache.has(rule)) {
|
690
|
+
this.entityContextCache.set(rule, {
|
691
|
+
onChange: this.changeEntity.bind(this),
|
692
|
+
getDisabledState: this.getDisabledState,
|
693
|
+
entities: this.entities,
|
694
|
+
$implicit: rule
|
695
|
+
});
|
696
|
+
}
|
697
|
+
return this.entityContextCache.get(rule);
|
698
|
+
}
|
699
|
+
getSwitchGroupContext() {
|
700
|
+
return {
|
701
|
+
onChange: this.changeCondition.bind(this),
|
702
|
+
getDisabledState: this.getDisabledState,
|
703
|
+
$implicit: this.data
|
704
|
+
};
|
705
|
+
}
|
706
|
+
getArrowIconContext() {
|
707
|
+
return {
|
708
|
+
getDisabledState: this.getDisabledState,
|
709
|
+
$implicit: this.data
|
710
|
+
};
|
711
|
+
}
|
712
|
+
getEmptyWarningContext() {
|
713
|
+
return {
|
714
|
+
getDisabledState: this.getDisabledState,
|
715
|
+
message: this.emptyMessage,
|
716
|
+
$implicit: this.data
|
717
|
+
};
|
718
|
+
}
|
719
|
+
getOperatorContext(rule) {
|
720
|
+
if (!this.operatorContextCache.has(rule)) {
|
721
|
+
this.operatorContextCache.set(rule, {
|
722
|
+
onChange: this.changeOperator.bind(this),
|
723
|
+
getDisabledState: this.getDisabledState,
|
724
|
+
operators: this.getOperators(rule.field),
|
725
|
+
$implicit: rule
|
726
|
+
});
|
727
|
+
}
|
728
|
+
return this.operatorContextCache.get(rule);
|
729
|
+
}
|
730
|
+
getInputContext(rule) {
|
731
|
+
if (!this.inputContextCache.has(rule)) {
|
732
|
+
this.inputContextCache.set(rule, {
|
733
|
+
onChange: this.changeInput.bind(this),
|
734
|
+
getDisabledState: this.getDisabledState,
|
735
|
+
options: this.getOptions(rule.field),
|
736
|
+
field: this.config.fields[rule.field],
|
737
|
+
$implicit: rule
|
738
|
+
});
|
739
|
+
}
|
740
|
+
return this.inputContextCache.get(rule);
|
741
|
+
}
|
742
|
+
calculateFieldChangeValue(currentField, nextField, currentValue) {
|
743
|
+
if (this.config.calculateFieldChangeValue != null) {
|
744
|
+
return this.config.calculateFieldChangeValue(currentField, nextField, currentValue);
|
745
|
+
}
|
746
|
+
const canKeepValue = () => {
|
747
|
+
if (currentField == null || nextField == null) {
|
748
|
+
return false;
|
749
|
+
}
|
750
|
+
return currentField.type === nextField.type
|
751
|
+
&& this.defaultPersistValueTypes.indexOf(currentField.type) !== -1;
|
752
|
+
};
|
753
|
+
if (this.persistValueOnFieldChange && canKeepValue()) {
|
754
|
+
return currentValue;
|
755
|
+
}
|
756
|
+
if (nextField && nextField.defaultValue !== undefined) {
|
757
|
+
return this.getDefaultValue(nextField.defaultValue);
|
758
|
+
}
|
759
|
+
return undefined;
|
760
|
+
}
|
761
|
+
checkEmptyRuleInRuleset(ruleset) {
|
762
|
+
if (!ruleset || !ruleset.rules || ruleset.rules.length === 0) {
|
763
|
+
return true;
|
764
|
+
}
|
765
|
+
else {
|
766
|
+
return ruleset.rules.some((item) => {
|
767
|
+
if (item.rules) {
|
768
|
+
return this.checkEmptyRuleInRuleset(item);
|
769
|
+
}
|
770
|
+
else {
|
771
|
+
return false;
|
772
|
+
}
|
773
|
+
});
|
774
|
+
}
|
775
|
+
}
|
776
|
+
validateRulesInRuleset(ruleset, errorStore) {
|
777
|
+
if (ruleset && ruleset.rules && ruleset.rules.length > 0) {
|
778
|
+
ruleset.rules.forEach((item) => {
|
779
|
+
if (item.rules) {
|
780
|
+
return this.validateRulesInRuleset(item, errorStore);
|
781
|
+
}
|
782
|
+
else if (item.field) {
|
783
|
+
const field = this.config.fields[item.field];
|
784
|
+
if (field && field.validator && field.validator.apply) {
|
785
|
+
const error = field.validator(item, ruleset);
|
786
|
+
if (error != null) {
|
787
|
+
errorStore.push(error);
|
788
|
+
}
|
789
|
+
}
|
790
|
+
}
|
791
|
+
});
|
792
|
+
}
|
793
|
+
}
|
794
|
+
handleDataChange() {
|
795
|
+
this.changeDetectorRef.markForCheck();
|
796
|
+
if (this.onChangeCallback) {
|
797
|
+
this.onChangeCallback();
|
798
|
+
}
|
799
|
+
if (this.parentChangeCallback) {
|
800
|
+
this.parentChangeCallback();
|
801
|
+
}
|
802
|
+
}
|
803
|
+
handleTouched() {
|
804
|
+
if (this.onTouchedCallback) {
|
805
|
+
this.onTouchedCallback();
|
806
|
+
}
|
807
|
+
if (this.parentTouchedCallback) {
|
808
|
+
this.parentTouchedCallback();
|
809
|
+
}
|
810
|
+
}
|
811
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryBuilderComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
812
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.1.2", type: QueryBuilderComponent, selector: "query-builder", inputs: { disabled: "disabled", data: "data", allowRuleset: "allowRuleset", allowCollapse: "allowCollapse", emptyMessage: "emptyMessage", classNames: "classNames", operatorMap: "operatorMap", parentValue: "parentValue", config: "config", parentArrowIconTemplate: "parentArrowIconTemplate", parentInputTemplates: "parentInputTemplates", parentOperatorTemplate: "parentOperatorTemplate", parentFieldTemplate: "parentFieldTemplate", parentEntityTemplate: "parentEntityTemplate", parentSwitchGroupTemplate: "parentSwitchGroupTemplate", parentButtonGroupTemplate: "parentButtonGroupTemplate", parentRemoveButtonTemplate: "parentRemoveButtonTemplate", parentEmptyWarningTemplate: "parentEmptyWarningTemplate", parentChangeCallback: "parentChangeCallback", parentTouchedCallback: "parentTouchedCallback", persistValueOnFieldChange: "persistValueOnFieldChange", value: "value" }, providers: [CONTROL_VALUE_ACCESSOR, VALIDATOR], queries: [{ propertyName: "buttonGroupTemplate", first: true, predicate: QueryButtonGroupDirective, descendants: true }, { propertyName: "switchGroupTemplate", first: true, predicate: QuerySwitchGroupDirective, descendants: true }, { propertyName: "fieldTemplate", first: true, predicate: QueryFieldDirective, descendants: true }, { propertyName: "entityTemplate", first: true, predicate: QueryEntityDirective, descendants: true }, { propertyName: "operatorTemplate", first: true, predicate: QueryOperatorDirective, descendants: true }, { propertyName: "removeButtonTemplate", first: true, predicate: QueryRemoveButtonDirective, descendants: true }, { propertyName: "emptyWarningTemplate", first: true, predicate: QueryEmptyWarningDirective, descendants: true }, { propertyName: "arrowIconTemplate", first: true, predicate: QueryArrowIconDirective, descendants: true }, { propertyName: "inputTemplates", predicate: QueryInputDirective }], viewQueries: [{ propertyName: "treeContainer", first: true, predicate: ["treeContainer"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div [ngClass]=\"getClassNames('switchRow')\">\r\n <ng-template #defaultArrowIcon>\r\n <i [ngClass]=\"getClassNames('arrowIcon')\"></i>\r\n </ng-template>\r\n\r\n <a *ngIf=\"allowCollapse\" (click)=\"toggleCollapse()\" [ngClass]=\"getClassNames('arrowIconButton', data.collapsed ? 'collapsed' : null)\">\r\n <ng-container *ngIf=\"getArrowIconTemplate() as template; else defaultArrowIcon\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getArrowIconContext()\"></ng-container>\r\n </ng-container>\r\n </a>\r\n\r\n <ng-container *ngIf=\"getButtonGroupTemplate() as template; else defaultButtonGroup\">\r\n <div [ngClass]=\"getClassNames('buttonGroup', 'rightAlign')\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getButtonGroupContext()\"></ng-container>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #defaultButtonGroup>\r\n <div [ngClass]=\"getClassNames('buttonGroup', 'rightAlign')\">\r\n <button type=\"button\" (click)=\"addRule()\" [ngClass]=\"getClassNames('button')\" [disabled]=disabled>\r\n <i [ngClass]=\"getClassNames('addIcon')\"></i> Rule\r\n </button>\r\n <button type=\"button\" (click)=\"addRuleSet()\" [ngClass]=\"getClassNames('button')\" *ngIf=\"allowRuleset\" [disabled]=disabled>\r\n <i [ngClass]=\"getClassNames('addIcon')\"></i> Ruleset\r\n </button>\r\n <ng-container *ngIf=\"!!parentValue && allowRuleset\">\r\n <button type=\"button\" (click)=\"removeRuleSet()\" [ngClass]=\"getClassNames('button', 'removeButton')\" [disabled]=disabled>\r\n <i [ngClass]=\"getClassNames('removeIcon')\"></i>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </ng-template>\r\n\r\n <ng-container *ngIf=\"getSwitchGroupTemplate() as template; else defaultSwitchGroup\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getSwitchGroupContext()\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-template #defaultSwitchGroup>\r\n <div [ngClass]=\"getClassNames('switchGroup', 'transition')\" *ngIf=\"data\">\r\n <div [ngClass]=\"getClassNames('switchControl')\">\r\n <input type=\"radio\" [ngClass]=\"getClassNames('switchRadio')\" [(ngModel)]=\"data.condition\" [disabled]=disabled\r\n value=\"and\" #andOption />\r\n <label (click)=\"changeCondition(andOption.value)\" [ngClass]=\"getClassNames('switchLabel')\">AND</label>\r\n </div>\r\n <div [ngClass]=\"getClassNames('switchControl')\">\r\n <input type=\"radio\" [ngClass]=\"getClassNames('switchRadio')\" [(ngModel)]=\"data.condition\" [disabled]=disabled\r\n value=\"or\" #orOption />\r\n <label (click)=\"changeCondition(orOption.value)\" [ngClass]=\"getClassNames('switchLabel')\">OR</label>\r\n </div>\r\n </div>\r\n </ng-template>\r\n</div>\r\n\r\n<div #treeContainer (transitionend)=\"transitionEnd($event)\" [ngClass]=\"getClassNames('treeContainer', data.collapsed ? 'collapsed' : null)\">\r\n <ul [ngClass]=\"getClassNames('tree')\" *ngIf=\"data && data.rules\">\r\n <ng-container *ngFor=\"let rule of data.rules;let i=index\">\r\n\r\n <ng-container *ngIf=\"{ruleset: !!rule.rules, invalid: !config.allowEmptyRulesets && rule.rules && rule.rules.length === 0} as local\">\r\n <li [ngClass]=\"getQueryItemClassName(local)\">\r\n <ng-container *ngIf=\"!local.ruleset\">\r\n\r\n <ng-container *ngIf=\"getRemoveButtonTemplate() as template; else defaultRemoveButton\">\r\n <div [ngClass]=\"getClassNames('buttonGroup', 'rightAlign')\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getRemoveButtonContext(rule)\"></ng-container>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #defaultRemoveButton>\r\n <div [ngClass]=\"getClassNames('removeButtonSize', 'rightAlign')\">\r\n <button type=\"button\" [ngClass]=\"getClassNames('button', 'removeButton')\" (click)=\"removeRule(rule, data)\" [disabled]=disabled>\r\n <i [ngClass]=\"getClassNames('removeIcon')\"></i>\r\n </button>\r\n </div>\r\n </ng-template>\r\n\r\n <div *ngIf=\"entities?.length > 0\" class=\"q-inline-block-display\">\r\n <ng-container *ngIf=\"getEntityTemplate() as template; else defaultEntity\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getEntityContext(rule)\"></ng-container>\r\n </ng-container>\r\n </div>\r\n\r\n <ng-template #defaultEntity>\r\n <div [ngClass]=\"getClassNames('entityControlSize')\">\r\n <select [ngClass]=\"getClassNames('entityControl')\" [(ngModel)]=\"rule.entity\" (ngModelChange)=\"changeEntity($event, rule,i,data)\"\r\n [disabled]=\"disabled\">\r\n <option *ngFor=\"let entity of entities\" [ngValue]=\"entity.value\">\r\n {{entity.name}}\r\n </option>\r\n </select>\r\n </div>\r\n </ng-template>\r\n\r\n <ng-container *ngIf=\"getFieldTemplate() as template; else defaultField\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getFieldContext(rule)\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-template #defaultField>\r\n <div [ngClass]=\"getClassNames('fieldControlSize')\">\r\n <select [ngClass]=\"getClassNames('fieldControl')\" [(ngModel)]=\"rule.field\" (ngModelChange)=\"changeField($event, rule)\"\r\n [disabled]=\"disabled\">\r\n <option *ngFor=\"let field of getFields(rule.entity)\" [ngValue]=\"field.value\">\r\n {{field.name}}\r\n </option>\r\n </select>\r\n </div>\r\n </ng-template>\r\n\r\n <ng-container *ngIf=\"getOperatorTemplate() as template; else defaultOperator\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getOperatorContext(rule)\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-template #defaultOperator>\r\n <div [ngClass]=\"getClassNames('operatorControlSize')\">\r\n <select [ngClass]=\"getClassNames('operatorControl')\" [(ngModel)]=\"rule.operator\" (ngModelChange)=\"changeOperator(rule)\"\r\n [disabled]=\"disabled\">\r\n <option *ngFor=\"let operator of getOperators(rule.field)\" [ngValue]=\"operator\">\r\n {{operator}}\r\n </option>\r\n </select>\r\n </div>\r\n </ng-template>\r\n\r\n <ng-container *ngIf=\"findTemplateForRule(rule) as template; else defaultInput\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getInputContext(rule)\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-template #defaultInput>\r\n <div [ngClass]=\"getClassNames('inputControlSize')\" [ngSwitch]=\"getInputType(rule.field, rule.operator)\">\r\n <input [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'string'\" type=\"text\">\r\n <input [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'number'\" type=\"number\">\r\n <input [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'date'\" type=\"date\">\r\n <input [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'time'\" type=\"time\">\r\n <select [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'category'\">\r\n <option *ngFor=\"let opt of getOptions(rule.field)\" [ngValue]=\"opt.value\">\r\n {{opt.name}}\r\n </option>\r\n </select>\r\n <ng-container *ngSwitchCase=\"'multiselect'\">\r\n <select [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" multiple>\r\n <option *ngFor=\"let opt of getOptions(rule.field)\" [ngValue]=\"opt.value\">\r\n {{opt.name}}\r\n </option>\r\n </select>\r\n </ng-container>\r\n <input [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'boolean'\" type=\"checkbox\">\r\n </div>\r\n </ng-template>\r\n\r\n </ng-container>\r\n <query-builder *ngIf=\"local.ruleset\" [data]=\"rule\" [disabled]=\"disabled\" [parentTouchedCallback]=\"parentTouchedCallback || onTouchedCallback\"\r\n [parentChangeCallback]=\"parentChangeCallback || onChangeCallback\" [parentInputTemplates]=\"parentInputTemplates || inputTemplates\"\r\n [parentOperatorTemplate]=\"parentOperatorTemplate || operatorTemplate\" [parentFieldTemplate]=\"parentFieldTemplate || fieldTemplate\"\r\n [parentEntityTemplate]=\"parentEntityTemplate || entityTemplate\" [parentSwitchGroupTemplate]=\"parentSwitchGroupTemplate || switchGroupTemplate\"\r\n [parentButtonGroupTemplate]=\"parentButtonGroupTemplate || buttonGroupTemplate\" [parentRemoveButtonTemplate]=\"parentRemoveButtonTemplate || removeButtonTemplate\"\r\n [parentEmptyWarningTemplate]=\"parentEmptyWarningTemplate || emptyWarningTemplate\" [parentArrowIconTemplate]=\"parentArrowIconTemplate || arrowIconTemplate\"\r\n [parentValue]=\"data\" [classNames]=\"classNames\" [config]=\"config\" [allowRuleset]=\"allowRuleset\"\r\n [allowCollapse]=\"allowCollapse\" [emptyMessage]=\"emptyMessage\" [operatorMap]=\"operatorMap\">\r\n </query-builder>\r\n\r\n <ng-container *ngIf=\"getEmptyWarningTemplate() as template; else defaultEmptyWarning\">\r\n <ng-container *ngIf=\"local.invalid\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getEmptyWarningContext()\"></ng-container>\r\n </ng-container>\r\n </ng-container>\r\n\r\n <ng-template #defaultEmptyWarning>\r\n <p [ngClass]=\"getClassNames('emptyWarning')\" *ngIf=\"local.invalid\">\r\n {{emptyMessage}}\r\n </p>\r\n </ng-template>\r\n </li>\r\n </ng-container>\r\n </ng-container>\r\n </ul>\r\n</div>", styles: ["@charset \"UTF-8\";:host{display:block;width:100%}:host .q-icon{font-style:normal;font-size:12px}:host .q-remove-icon:before{content:\"\\274c\"}:host .q-arrow-icon-button{float:left;margin:4px 6px 4px 0;transform:rotate(90deg);transition:linear .25s transform;cursor:pointer}:host .q-arrow-icon-button.q-collapsed{transform:rotate(0)}:host .q-arrow-icon:before{content:\"\\25b6\"}:host .q-add-icon{color:#555}:host .q-add-icon:before{content:\"\\2795\"}:host .q-remove-button{color:#b3415d;width:31px}:host .q-switch-group,:host .q-button-group{font-family:Lucida Grande,Tahoma,Verdana,sans-serif;overflow:hidden}:host .q-right-align{float:right}:host .q-button{margin-left:8px;padding:0 8px;background-color:#fff}:host .q-button:disabled{display:none}:host .q-control-size{display:inline-block;vertical-align:top;padding-right:10px}:host .q-input-control,:host .q-operator-control,:host .q-field-control,:host .q-entity-control{display:inline-block;padding:5px 8px;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;box-sizing:border-box;width:auto}:host .q-input-control:disabled,:host .q-operator-control:disabled,:host .q-field-control:disabled,:host .q-entity-control:disabled{border-color:transparent}:host .q-operator-control,:host .q-field-control,:host .q-entity-control,:host .q-input-control:not([type=checkbox]){min-height:32px;-webkit-appearance:none}:host .q-switch-label,:host .q-button{float:left;margin-bottom:0;font-size:14px;line-height:30px;font-weight:400;text-align:center;text-shadow:none;border:1px solid rgba(0,0,0,.2);box-sizing:border-box}:host .q-switch-label:hover,:host .q-button:hover{cursor:pointer;background-color:#f0f0f0}:host .q-switch-label{background-color:#e4e4e4;padding:0 8px}:host .q-switch-radio{position:absolute;clip:rect(0,0,0,0);height:1px;width:1px;border:0;overflow:hidden}:host .q-switch-radio:checked+.q-switch-label{border:1px solid rgb(97,158,215);background:#fff;color:#3176b3}:host .q-switch-radio:disabled+.q-switch-label{display:none}:host .q-switch-radio:checked:disabled+.q-switch-label{display:initial;color:initial;cursor:default;border-color:transparent}:host .q-invalid-ruleset{border:1px solid rgba(179,65,93,.5)!important;background:#b3415d1a!important}:host .q-empty-warning{color:#8d252e;text-align:center}:host .q-ruleset{border:1px solid #CCC}:host .q-rule{border:1px solid #CCC;background:#fff}:host .q-transition{-webkit-transition:all .1s ease-in-out;-moz-transition:all .1s ease-in-out;-ms-transition:all .1s ease-in-out;-o-transition:all .1s ease-in-out;transition:all .1s ease-in-out}:host .q-tree-container{width:100%;overflow:hidden;transition:ease-in .25s max-height}:host .q-tree-container.q-collapsed{max-height:0!important}:host .q-tree{list-style:none;margin:4px 0 2px}:host .q-row{padding:6px 8px;margin-top:6px}:host .q-connector{position:relative}:host .q-connector:before{top:-5px;border-width:0 0 2px 2px}:host .q-connector:after{border-width:0 0 0 2px;top:50%}:host .q-connector:before,:host .q-connector:after{content:\"\";left:-12px;border-color:#ccc;border-style:solid;width:9px;height:calc(50% + 6px);position:absolute}:host .q-connector:last-child:after{content:none}:host .q-inline-block-display{display:inline-block;vertical-align:top}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.SelectMultipleControlValueAccessor, selector: "select[multiple][formControlName],select[multiple][formControl],select[multiple][ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: QueryBuilderComponent, selector: "query-builder", inputs: ["disabled", "data", "allowRuleset", "allowCollapse", "emptyMessage", "classNames", "operatorMap", "parentValue", "config", "parentArrowIconTemplate", "parentInputTemplates", "parentOperatorTemplate", "parentFieldTemplate", "parentEntityTemplate", "parentSwitchGroupTemplate", "parentButtonGroupTemplate", "parentRemoveButtonTemplate", "parentEmptyWarningTemplate", "parentChangeCallback", "parentTouchedCallback", "persistValueOnFieldChange", "value"] }] });
|
813
|
+
}
|
814
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryBuilderComponent, decorators: [{
|
815
|
+
type: Component,
|
816
|
+
args: [{ selector: 'query-builder', providers: [CONTROL_VALUE_ACCESSOR, VALIDATOR], template: "<div [ngClass]=\"getClassNames('switchRow')\">\r\n <ng-template #defaultArrowIcon>\r\n <i [ngClass]=\"getClassNames('arrowIcon')\"></i>\r\n </ng-template>\r\n\r\n <a *ngIf=\"allowCollapse\" (click)=\"toggleCollapse()\" [ngClass]=\"getClassNames('arrowIconButton', data.collapsed ? 'collapsed' : null)\">\r\n <ng-container *ngIf=\"getArrowIconTemplate() as template; else defaultArrowIcon\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getArrowIconContext()\"></ng-container>\r\n </ng-container>\r\n </a>\r\n\r\n <ng-container *ngIf=\"getButtonGroupTemplate() as template; else defaultButtonGroup\">\r\n <div [ngClass]=\"getClassNames('buttonGroup', 'rightAlign')\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getButtonGroupContext()\"></ng-container>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #defaultButtonGroup>\r\n <div [ngClass]=\"getClassNames('buttonGroup', 'rightAlign')\">\r\n <button type=\"button\" (click)=\"addRule()\" [ngClass]=\"getClassNames('button')\" [disabled]=disabled>\r\n <i [ngClass]=\"getClassNames('addIcon')\"></i> Rule\r\n </button>\r\n <button type=\"button\" (click)=\"addRuleSet()\" [ngClass]=\"getClassNames('button')\" *ngIf=\"allowRuleset\" [disabled]=disabled>\r\n <i [ngClass]=\"getClassNames('addIcon')\"></i> Ruleset\r\n </button>\r\n <ng-container *ngIf=\"!!parentValue && allowRuleset\">\r\n <button type=\"button\" (click)=\"removeRuleSet()\" [ngClass]=\"getClassNames('button', 'removeButton')\" [disabled]=disabled>\r\n <i [ngClass]=\"getClassNames('removeIcon')\"></i>\r\n </button>\r\n </ng-container>\r\n </div>\r\n </ng-template>\r\n\r\n <ng-container *ngIf=\"getSwitchGroupTemplate() as template; else defaultSwitchGroup\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getSwitchGroupContext()\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-template #defaultSwitchGroup>\r\n <div [ngClass]=\"getClassNames('switchGroup', 'transition')\" *ngIf=\"data\">\r\n <div [ngClass]=\"getClassNames('switchControl')\">\r\n <input type=\"radio\" [ngClass]=\"getClassNames('switchRadio')\" [(ngModel)]=\"data.condition\" [disabled]=disabled\r\n value=\"and\" #andOption />\r\n <label (click)=\"changeCondition(andOption.value)\" [ngClass]=\"getClassNames('switchLabel')\">AND</label>\r\n </div>\r\n <div [ngClass]=\"getClassNames('switchControl')\">\r\n <input type=\"radio\" [ngClass]=\"getClassNames('switchRadio')\" [(ngModel)]=\"data.condition\" [disabled]=disabled\r\n value=\"or\" #orOption />\r\n <label (click)=\"changeCondition(orOption.value)\" [ngClass]=\"getClassNames('switchLabel')\">OR</label>\r\n </div>\r\n </div>\r\n </ng-template>\r\n</div>\r\n\r\n<div #treeContainer (transitionend)=\"transitionEnd($event)\" [ngClass]=\"getClassNames('treeContainer', data.collapsed ? 'collapsed' : null)\">\r\n <ul [ngClass]=\"getClassNames('tree')\" *ngIf=\"data && data.rules\">\r\n <ng-container *ngFor=\"let rule of data.rules;let i=index\">\r\n\r\n <ng-container *ngIf=\"{ruleset: !!rule.rules, invalid: !config.allowEmptyRulesets && rule.rules && rule.rules.length === 0} as local\">\r\n <li [ngClass]=\"getQueryItemClassName(local)\">\r\n <ng-container *ngIf=\"!local.ruleset\">\r\n\r\n <ng-container *ngIf=\"getRemoveButtonTemplate() as template; else defaultRemoveButton\">\r\n <div [ngClass]=\"getClassNames('buttonGroup', 'rightAlign')\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getRemoveButtonContext(rule)\"></ng-container>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #defaultRemoveButton>\r\n <div [ngClass]=\"getClassNames('removeButtonSize', 'rightAlign')\">\r\n <button type=\"button\" [ngClass]=\"getClassNames('button', 'removeButton')\" (click)=\"removeRule(rule, data)\" [disabled]=disabled>\r\n <i [ngClass]=\"getClassNames('removeIcon')\"></i>\r\n </button>\r\n </div>\r\n </ng-template>\r\n\r\n <div *ngIf=\"entities?.length > 0\" class=\"q-inline-block-display\">\r\n <ng-container *ngIf=\"getEntityTemplate() as template; else defaultEntity\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getEntityContext(rule)\"></ng-container>\r\n </ng-container>\r\n </div>\r\n\r\n <ng-template #defaultEntity>\r\n <div [ngClass]=\"getClassNames('entityControlSize')\">\r\n <select [ngClass]=\"getClassNames('entityControl')\" [(ngModel)]=\"rule.entity\" (ngModelChange)=\"changeEntity($event, rule,i,data)\"\r\n [disabled]=\"disabled\">\r\n <option *ngFor=\"let entity of entities\" [ngValue]=\"entity.value\">\r\n {{entity.name}}\r\n </option>\r\n </select>\r\n </div>\r\n </ng-template>\r\n\r\n <ng-container *ngIf=\"getFieldTemplate() as template; else defaultField\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getFieldContext(rule)\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-template #defaultField>\r\n <div [ngClass]=\"getClassNames('fieldControlSize')\">\r\n <select [ngClass]=\"getClassNames('fieldControl')\" [(ngModel)]=\"rule.field\" (ngModelChange)=\"changeField($event, rule)\"\r\n [disabled]=\"disabled\">\r\n <option *ngFor=\"let field of getFields(rule.entity)\" [ngValue]=\"field.value\">\r\n {{field.name}}\r\n </option>\r\n </select>\r\n </div>\r\n </ng-template>\r\n\r\n <ng-container *ngIf=\"getOperatorTemplate() as template; else defaultOperator\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getOperatorContext(rule)\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-template #defaultOperator>\r\n <div [ngClass]=\"getClassNames('operatorControlSize')\">\r\n <select [ngClass]=\"getClassNames('operatorControl')\" [(ngModel)]=\"rule.operator\" (ngModelChange)=\"changeOperator(rule)\"\r\n [disabled]=\"disabled\">\r\n <option *ngFor=\"let operator of getOperators(rule.field)\" [ngValue]=\"operator\">\r\n {{operator}}\r\n </option>\r\n </select>\r\n </div>\r\n </ng-template>\r\n\r\n <ng-container *ngIf=\"findTemplateForRule(rule) as template; else defaultInput\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getInputContext(rule)\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-template #defaultInput>\r\n <div [ngClass]=\"getClassNames('inputControlSize')\" [ngSwitch]=\"getInputType(rule.field, rule.operator)\">\r\n <input [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'string'\" type=\"text\">\r\n <input [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'number'\" type=\"number\">\r\n <input [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'date'\" type=\"date\">\r\n <input [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'time'\" type=\"time\">\r\n <select [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'category'\">\r\n <option *ngFor=\"let opt of getOptions(rule.field)\" [ngValue]=\"opt.value\">\r\n {{opt.name}}\r\n </option>\r\n </select>\r\n <ng-container *ngSwitchCase=\"'multiselect'\">\r\n <select [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" multiple>\r\n <option *ngFor=\"let opt of getOptions(rule.field)\" [ngValue]=\"opt.value\">\r\n {{opt.name}}\r\n </option>\r\n </select>\r\n </ng-container>\r\n <input [ngClass]=\"getClassNames('inputControl')\" [(ngModel)]=\"rule.value\" (ngModelChange)=\"changeInput()\"\r\n [disabled]=\"disabled\" *ngSwitchCase=\"'boolean'\" type=\"checkbox\">\r\n </div>\r\n </ng-template>\r\n\r\n </ng-container>\r\n <query-builder *ngIf=\"local.ruleset\" [data]=\"rule\" [disabled]=\"disabled\" [parentTouchedCallback]=\"parentTouchedCallback || onTouchedCallback\"\r\n [parentChangeCallback]=\"parentChangeCallback || onChangeCallback\" [parentInputTemplates]=\"parentInputTemplates || inputTemplates\"\r\n [parentOperatorTemplate]=\"parentOperatorTemplate || operatorTemplate\" [parentFieldTemplate]=\"parentFieldTemplate || fieldTemplate\"\r\n [parentEntityTemplate]=\"parentEntityTemplate || entityTemplate\" [parentSwitchGroupTemplate]=\"parentSwitchGroupTemplate || switchGroupTemplate\"\r\n [parentButtonGroupTemplate]=\"parentButtonGroupTemplate || buttonGroupTemplate\" [parentRemoveButtonTemplate]=\"parentRemoveButtonTemplate || removeButtonTemplate\"\r\n [parentEmptyWarningTemplate]=\"parentEmptyWarningTemplate || emptyWarningTemplate\" [parentArrowIconTemplate]=\"parentArrowIconTemplate || arrowIconTemplate\"\r\n [parentValue]=\"data\" [classNames]=\"classNames\" [config]=\"config\" [allowRuleset]=\"allowRuleset\"\r\n [allowCollapse]=\"allowCollapse\" [emptyMessage]=\"emptyMessage\" [operatorMap]=\"operatorMap\">\r\n </query-builder>\r\n\r\n <ng-container *ngIf=\"getEmptyWarningTemplate() as template; else defaultEmptyWarning\">\r\n <ng-container *ngIf=\"local.invalid\">\r\n <ng-container *ngTemplateOutlet=\"template; context: getEmptyWarningContext()\"></ng-container>\r\n </ng-container>\r\n </ng-container>\r\n\r\n <ng-template #defaultEmptyWarning>\r\n <p [ngClass]=\"getClassNames('emptyWarning')\" *ngIf=\"local.invalid\">\r\n {{emptyMessage}}\r\n </p>\r\n </ng-template>\r\n </li>\r\n </ng-container>\r\n </ng-container>\r\n </ul>\r\n</div>", styles: ["@charset \"UTF-8\";:host{display:block;width:100%}:host .q-icon{font-style:normal;font-size:12px}:host .q-remove-icon:before{content:\"\\274c\"}:host .q-arrow-icon-button{float:left;margin:4px 6px 4px 0;transform:rotate(90deg);transition:linear .25s transform;cursor:pointer}:host .q-arrow-icon-button.q-collapsed{transform:rotate(0)}:host .q-arrow-icon:before{content:\"\\25b6\"}:host .q-add-icon{color:#555}:host .q-add-icon:before{content:\"\\2795\"}:host .q-remove-button{color:#b3415d;width:31px}:host .q-switch-group,:host .q-button-group{font-family:Lucida Grande,Tahoma,Verdana,sans-serif;overflow:hidden}:host .q-right-align{float:right}:host .q-button{margin-left:8px;padding:0 8px;background-color:#fff}:host .q-button:disabled{display:none}:host .q-control-size{display:inline-block;vertical-align:top;padding-right:10px}:host .q-input-control,:host .q-operator-control,:host .q-field-control,:host .q-entity-control{display:inline-block;padding:5px 8px;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;box-sizing:border-box;width:auto}:host .q-input-control:disabled,:host .q-operator-control:disabled,:host .q-field-control:disabled,:host .q-entity-control:disabled{border-color:transparent}:host .q-operator-control,:host .q-field-control,:host .q-entity-control,:host .q-input-control:not([type=checkbox]){min-height:32px;-webkit-appearance:none}:host .q-switch-label,:host .q-button{float:left;margin-bottom:0;font-size:14px;line-height:30px;font-weight:400;text-align:center;text-shadow:none;border:1px solid rgba(0,0,0,.2);box-sizing:border-box}:host .q-switch-label:hover,:host .q-button:hover{cursor:pointer;background-color:#f0f0f0}:host .q-switch-label{background-color:#e4e4e4;padding:0 8px}:host .q-switch-radio{position:absolute;clip:rect(0,0,0,0);height:1px;width:1px;border:0;overflow:hidden}:host .q-switch-radio:checked+.q-switch-label{border:1px solid rgb(97,158,215);background:#fff;color:#3176b3}:host .q-switch-radio:disabled+.q-switch-label{display:none}:host .q-switch-radio:checked:disabled+.q-switch-label{display:initial;color:initial;cursor:default;border-color:transparent}:host .q-invalid-ruleset{border:1px solid rgba(179,65,93,.5)!important;background:#b3415d1a!important}:host .q-empty-warning{color:#8d252e;text-align:center}:host .q-ruleset{border:1px solid #CCC}:host .q-rule{border:1px solid #CCC;background:#fff}:host .q-transition{-webkit-transition:all .1s ease-in-out;-moz-transition:all .1s ease-in-out;-ms-transition:all .1s ease-in-out;-o-transition:all .1s ease-in-out;transition:all .1s ease-in-out}:host .q-tree-container{width:100%;overflow:hidden;transition:ease-in .25s max-height}:host .q-tree-container.q-collapsed{max-height:0!important}:host .q-tree{list-style:none;margin:4px 0 2px}:host .q-row{padding:6px 8px;margin-top:6px}:host .q-connector{position:relative}:host .q-connector:before{top:-5px;border-width:0 0 2px 2px}:host .q-connector:after{border-width:0 0 0 2px;top:50%}:host .q-connector:before,:host .q-connector:after{content:\"\";left:-12px;border-color:#ccc;border-style:solid;width:9px;height:calc(50% + 6px);position:absolute}:host .q-connector:last-child:after{content:none}:host .q-inline-block-display{display:inline-block;vertical-align:top}\n"] }]
|
817
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { disabled: [{
|
818
|
+
type: Input
|
819
|
+
}], data: [{
|
820
|
+
type: Input
|
821
|
+
}], allowRuleset: [{
|
822
|
+
type: Input
|
823
|
+
}], allowCollapse: [{
|
824
|
+
type: Input
|
825
|
+
}], emptyMessage: [{
|
826
|
+
type: Input
|
827
|
+
}], classNames: [{
|
828
|
+
type: Input
|
829
|
+
}], operatorMap: [{
|
830
|
+
type: Input
|
831
|
+
}], parentValue: [{
|
832
|
+
type: Input
|
833
|
+
}], config: [{
|
834
|
+
type: Input
|
835
|
+
}], parentArrowIconTemplate: [{
|
836
|
+
type: Input
|
837
|
+
}], parentInputTemplates: [{
|
838
|
+
type: Input
|
839
|
+
}], parentOperatorTemplate: [{
|
840
|
+
type: Input
|
841
|
+
}], parentFieldTemplate: [{
|
842
|
+
type: Input
|
843
|
+
}], parentEntityTemplate: [{
|
844
|
+
type: Input
|
845
|
+
}], parentSwitchGroupTemplate: [{
|
846
|
+
type: Input
|
847
|
+
}], parentButtonGroupTemplate: [{
|
848
|
+
type: Input
|
849
|
+
}], parentRemoveButtonTemplate: [{
|
850
|
+
type: Input
|
851
|
+
}], parentEmptyWarningTemplate: [{
|
852
|
+
type: Input
|
853
|
+
}], parentChangeCallback: [{
|
854
|
+
type: Input
|
855
|
+
}], parentTouchedCallback: [{
|
856
|
+
type: Input
|
857
|
+
}], persistValueOnFieldChange: [{
|
858
|
+
type: Input
|
859
|
+
}], treeContainer: [{
|
860
|
+
type: ViewChild,
|
861
|
+
args: ['treeContainer', { static: true }]
|
862
|
+
}], buttonGroupTemplate: [{
|
863
|
+
type: ContentChild,
|
864
|
+
args: [QueryButtonGroupDirective]
|
865
|
+
}], switchGroupTemplate: [{
|
866
|
+
type: ContentChild,
|
867
|
+
args: [QuerySwitchGroupDirective]
|
868
|
+
}], fieldTemplate: [{
|
869
|
+
type: ContentChild,
|
870
|
+
args: [QueryFieldDirective]
|
871
|
+
}], entityTemplate: [{
|
872
|
+
type: ContentChild,
|
873
|
+
args: [QueryEntityDirective]
|
874
|
+
}], operatorTemplate: [{
|
875
|
+
type: ContentChild,
|
876
|
+
args: [QueryOperatorDirective]
|
877
|
+
}], removeButtonTemplate: [{
|
878
|
+
type: ContentChild,
|
879
|
+
args: [QueryRemoveButtonDirective]
|
880
|
+
}], emptyWarningTemplate: [{
|
881
|
+
type: ContentChild,
|
882
|
+
args: [QueryEmptyWarningDirective]
|
883
|
+
}], inputTemplates: [{
|
884
|
+
type: ContentChildren,
|
885
|
+
args: [QueryInputDirective]
|
886
|
+
}], arrowIconTemplate: [{
|
887
|
+
type: ContentChild,
|
888
|
+
args: [QueryArrowIconDirective]
|
889
|
+
}], value: [{
|
890
|
+
type: Input
|
891
|
+
}] } });
|
892
|
+
|
893
|
+
class QueryBuilderModule {
|
894
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryBuilderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
895
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.1.2", ngImport: i0, type: QueryBuilderModule, declarations: [QueryBuilderComponent,
|
896
|
+
QueryInputDirective,
|
897
|
+
QueryOperatorDirective,
|
898
|
+
QueryFieldDirective,
|
899
|
+
QueryEntityDirective,
|
900
|
+
QueryButtonGroupDirective,
|
901
|
+
QuerySwitchGroupDirective,
|
902
|
+
QueryRemoveButtonDirective,
|
903
|
+
QueryEmptyWarningDirective,
|
904
|
+
QueryArrowIconDirective], imports: [CommonModule,
|
905
|
+
FormsModule], exports: [QueryBuilderComponent,
|
906
|
+
QueryInputDirective,
|
907
|
+
QueryOperatorDirective,
|
908
|
+
QueryFieldDirective,
|
909
|
+
QueryEntityDirective,
|
910
|
+
QueryButtonGroupDirective,
|
911
|
+
QuerySwitchGroupDirective,
|
912
|
+
QueryRemoveButtonDirective,
|
913
|
+
QueryEmptyWarningDirective,
|
914
|
+
QueryArrowIconDirective] });
|
915
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryBuilderModule, imports: [CommonModule,
|
916
|
+
FormsModule] });
|
917
|
+
}
|
918
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.1.2", ngImport: i0, type: QueryBuilderModule, decorators: [{
|
919
|
+
type: NgModule,
|
920
|
+
args: [{
|
921
|
+
imports: [
|
922
|
+
CommonModule,
|
923
|
+
FormsModule
|
924
|
+
],
|
925
|
+
declarations: [
|
926
|
+
QueryBuilderComponent,
|
927
|
+
QueryInputDirective,
|
928
|
+
QueryOperatorDirective,
|
929
|
+
QueryFieldDirective,
|
930
|
+
QueryEntityDirective,
|
931
|
+
QueryButtonGroupDirective,
|
932
|
+
QuerySwitchGroupDirective,
|
933
|
+
QueryRemoveButtonDirective,
|
934
|
+
QueryEmptyWarningDirective,
|
935
|
+
QueryArrowIconDirective
|
936
|
+
],
|
937
|
+
exports: [
|
938
|
+
QueryBuilderComponent,
|
939
|
+
QueryInputDirective,
|
940
|
+
QueryOperatorDirective,
|
941
|
+
QueryFieldDirective,
|
942
|
+
QueryEntityDirective,
|
943
|
+
QueryButtonGroupDirective,
|
944
|
+
QuerySwitchGroupDirective,
|
945
|
+
QueryRemoveButtonDirective,
|
946
|
+
QueryEmptyWarningDirective,
|
947
|
+
QueryArrowIconDirective
|
948
|
+
]
|
949
|
+
}]
|
950
|
+
}] });
|
951
|
+
|
952
|
+
/*
|
953
|
+
* Public API Surface of angular2-query-builder
|
954
|
+
*/
|
955
|
+
|
956
|
+
/**
|
957
|
+
* Generated bundle index. Do not edit.
|
958
|
+
*/
|
959
|
+
|
960
|
+
export { CONTROL_VALUE_ACCESSOR, QueryArrowIconDirective, QueryBuilderComponent, QueryBuilderModule, QueryButtonGroupDirective, QueryEmptyWarningDirective, QueryEntityDirective, QueryFieldDirective, QueryInputDirective, QueryOperatorDirective, QueryRemoveButtonDirective, QuerySwitchGroupDirective, VALIDATOR };
|
961
|
+
//# sourceMappingURL=query-builder.mjs.map
|