@syncfusion/ej2-querybuilder 30.1.41 → 30.2.4
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/aceconfig.js +17 -0
- package/dist/ej2-querybuilder.min.js +2 -2
- package/dist/ej2-querybuilder.umd.min.js +2 -2
- package/dist/ej2-querybuilder.umd.min.js.map +1 -1
- package/dist/es6/ej2-querybuilder.es2015.js +575 -431
- package/dist/es6/ej2-querybuilder.es2015.js.map +1 -1
- package/dist/es6/ej2-querybuilder.es5.js +619 -470
- package/dist/es6/ej2-querybuilder.es5.js.map +1 -1
- package/dist/global/ej2-querybuilder.min.js +2 -2
- package/dist/global/ej2-querybuilder.min.js.map +1 -1
- package/dist/global/index.d.ts +1 -1
- package/package.json +7 -7
- package/src/query-builder/query-builder-model.d.ts +4 -4
- package/src/query-builder/query-builder.d.ts +9 -0
- package/src/query-builder/query-builder.js +618 -468
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChildProperty, Property, Collection, Component,
|
|
1
|
+
import { ChildProperty, Property, Collection, Component, removeClass, isNullOrUndefined, Animation, extend, closest, addClass, select, append, getComponent, detach, rippleEffect, getInstance, getValue, getNumericObject, Browser, classList, Internationalization, getUniqueID, L10n, Draggable, remove, compile, EventHandler, cldrData, Event, Complex, NotifyPropertyChanges } from '@syncfusion/ej2-base';
|
|
2
2
|
import { Button, CheckBox, RadioButton } from '@syncfusion/ej2-buttons';
|
|
3
3
|
import { MultiSelect, CheckBoxSelection, DropDownList, DropDownTree } from '@syncfusion/ej2-dropdowns';
|
|
4
4
|
import { Query, DataManager, Deferred, Predicate } from '@syncfusion/ej2-data';
|
|
@@ -174,37 +174,71 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
174
174
|
reset() {
|
|
175
175
|
this.isImportRules = false;
|
|
176
176
|
let bodyElem = this.element.querySelector('.e-group-body');
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
const inputElements = this.element.querySelectorAll('input.e-control');
|
|
178
|
+
const batchSize = 20;
|
|
179
|
+
let currentIndex = 0;
|
|
180
|
+
const processBatch = () => {
|
|
181
|
+
const endIndex = Math.min(currentIndex + batchSize, inputElements.length);
|
|
182
|
+
for (let i = currentIndex; i < endIndex; i++) {
|
|
183
|
+
const element = inputElements[i];
|
|
184
|
+
try {
|
|
185
|
+
if (element.className.indexOf('e-tooltip') > -1) {
|
|
186
|
+
const tooltip = getComponent(element, 'tooltip');
|
|
187
|
+
if (tooltip) {
|
|
188
|
+
tooltip.destroy();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else if (element.parentElement && element.parentElement.className.indexOf('e-tooltip') > -1) {
|
|
192
|
+
const tooltip = getComponent(element.parentElement, 'tooltip');
|
|
193
|
+
if (tooltip) {
|
|
194
|
+
tooltip.destroy();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
catch (e) {
|
|
199
|
+
console.warn('Error destroying tooltip:', e);
|
|
200
|
+
}
|
|
181
201
|
}
|
|
182
|
-
|
|
183
|
-
|
|
202
|
+
currentIndex = endIndex;
|
|
203
|
+
if (currentIndex < inputElements.length) {
|
|
204
|
+
requestAnimationFrame(processBatch);
|
|
184
205
|
}
|
|
206
|
+
};
|
|
207
|
+
if (inputElements.length > 0) {
|
|
208
|
+
processBatch();
|
|
185
209
|
}
|
|
186
210
|
if (bodyElem) {
|
|
187
|
-
bodyElem.
|
|
211
|
+
bodyElem.textContent = '';
|
|
188
212
|
}
|
|
189
213
|
else {
|
|
214
|
+
const fragment = document.createDocumentFragment();
|
|
190
215
|
const grpContainer = this.createElement('div', { attrs: { class: 'e-group-container' } });
|
|
191
216
|
const grpHeader = this.createElement('div', { attrs: { class: 'e-group-header' } });
|
|
192
217
|
const grpBody = this.createElement('div', { attrs: { class: 'e-group-body' } });
|
|
193
|
-
grpContainer.appendChild(grpHeader)
|
|
194
|
-
|
|
218
|
+
grpContainer.appendChild(grpHeader);
|
|
219
|
+
grpContainer.appendChild(grpBody);
|
|
220
|
+
fragment.appendChild(grpContainer);
|
|
221
|
+
this.element.appendChild(fragment);
|
|
195
222
|
bodyElem = this.element.querySelector('.e-group-body');
|
|
196
223
|
}
|
|
197
224
|
if (this.headerTemplate && this.isRoot) {
|
|
198
|
-
this.element.
|
|
225
|
+
this.element.textContent = '';
|
|
199
226
|
this.isRoot = false;
|
|
200
227
|
}
|
|
201
228
|
if (this.enableNotCondition) {
|
|
202
|
-
|
|
229
|
+
const toggleElements = this.element.querySelectorAll('.e-qb-toggle');
|
|
230
|
+
for (let i = 0; i < toggleElements.length; i++) {
|
|
231
|
+
removeClass([toggleElements[i]], 'e-active-toggle');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (bodyElem) {
|
|
235
|
+
bodyElem.appendChild(this.createElement('div', { attrs: { class: 'e-rule-list' } }));
|
|
203
236
|
}
|
|
204
|
-
bodyElem.appendChild(this.createElement('div', { attrs: { class: 'e-rule-list' } }));
|
|
205
237
|
this.levelColl[this.element.id + '_group0'] = [0];
|
|
206
238
|
this.setProperties({ rule: { condition: 'and', not: false, rules: [] } }, true);
|
|
207
|
-
|
|
239
|
+
if (bodyElem && bodyElem.parentElement) {
|
|
240
|
+
this.disableRuleCondition(bodyElem.parentElement);
|
|
241
|
+
}
|
|
208
242
|
}
|
|
209
243
|
getWrapper() {
|
|
210
244
|
return this.element;
|
|
@@ -239,11 +273,11 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
239
273
|
if (this.columns.length) {
|
|
240
274
|
this.columnSort();
|
|
241
275
|
const columns = this.columns;
|
|
242
|
-
|
|
243
|
-
this.updateCustomOperator(
|
|
244
|
-
if (!
|
|
245
|
-
if (columnKeys.indexOf(
|
|
246
|
-
value = this.dataColl[0][
|
|
276
|
+
columns.forEach((column) => {
|
|
277
|
+
this.updateCustomOperator(column, 'initial');
|
|
278
|
+
if (!column.type) {
|
|
279
|
+
if (columnKeys.indexOf(column.field) > -1) {
|
|
280
|
+
value = this.dataColl[0][column.field];
|
|
247
281
|
type = typeof value;
|
|
248
282
|
if (type === 'string') {
|
|
249
283
|
isDate = !isNaN(Date.parse(value));
|
|
@@ -252,28 +286,28 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
252
286
|
isDate = value instanceof Date && !isNaN(value.getTime());
|
|
253
287
|
type = 'string';
|
|
254
288
|
}
|
|
255
|
-
|
|
289
|
+
column.type = type;
|
|
256
290
|
isDate = false;
|
|
257
291
|
}
|
|
258
292
|
type = 'string';
|
|
259
293
|
}
|
|
260
|
-
if (!
|
|
261
|
-
|
|
294
|
+
if (!column.validation) {
|
|
295
|
+
column.validation = validateObj;
|
|
262
296
|
}
|
|
263
|
-
if (
|
|
297
|
+
if (column.category) {
|
|
264
298
|
groupBy = true;
|
|
265
299
|
}
|
|
266
300
|
else {
|
|
267
|
-
|
|
301
|
+
column.category = this.l10n.getConstant('OtherFields');
|
|
268
302
|
}
|
|
269
|
-
if (categories.indexOf(
|
|
270
|
-
categories.push(
|
|
303
|
+
if (categories.indexOf(column.category) < 0) {
|
|
304
|
+
categories.push(column.category);
|
|
271
305
|
}
|
|
272
|
-
if (!
|
|
273
|
-
(this.isLocale && this.isCustomOprCols.indexOf(
|
|
274
|
-
|
|
306
|
+
if (!column.operators ||
|
|
307
|
+
(this.isLocale && this.isCustomOprCols.indexOf(column.field) === -1)) {
|
|
308
|
+
column.operators = this.customOperators[column.type + 'Operator'];
|
|
275
309
|
}
|
|
276
|
-
}
|
|
310
|
+
});
|
|
277
311
|
if (groupBy && (categories.length > 1 || categories[0] !== this.l10n.getConstant('OtherFields'))) {
|
|
278
312
|
this.fields = { text: 'label', value: 'field', groupBy: 'category' };
|
|
279
313
|
}
|
|
@@ -290,8 +324,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
290
324
|
isDate = value instanceof Date && !isNaN(value.getTime());
|
|
291
325
|
type = 'string';
|
|
292
326
|
}
|
|
293
|
-
cols[i] = {
|
|
294
|
-
'
|
|
327
|
+
cols[i] = {
|
|
328
|
+
'field': columnKeys[i], 'label': columnKeys[i], 'type': isDate ? 'date' : type,
|
|
329
|
+
'validation': validateObj
|
|
330
|
+
};
|
|
295
331
|
isDate = false;
|
|
296
332
|
cols[i].operators = this.customOperators[cols[i].type + 'Operator'];
|
|
297
333
|
if (type === 'object') {
|
|
@@ -302,8 +338,28 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
302
338
|
}
|
|
303
339
|
}
|
|
304
340
|
else if (this.columns && this.columns.length) {
|
|
305
|
-
|
|
306
|
-
|
|
341
|
+
if (this.sortDirection !== 'Default') {
|
|
342
|
+
this.columnSort();
|
|
343
|
+
}
|
|
344
|
+
this.processColumnsInBatches();
|
|
345
|
+
if (this.columns.length > 50) {
|
|
346
|
+
setTimeout(() => {
|
|
347
|
+
this.updateSubFieldsFromColumns(this.columns);
|
|
348
|
+
}, 0);
|
|
349
|
+
}
|
|
350
|
+
else {
|
|
351
|
+
this.updateSubFieldsFromColumns(this.columns);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
this.trigger('dataBound', { type: 'dataBound' });
|
|
355
|
+
}
|
|
356
|
+
processColumnsInBatches() {
|
|
357
|
+
const columns = this.columns;
|
|
358
|
+
const batchSize = 10;
|
|
359
|
+
let processedCount = 0;
|
|
360
|
+
const processBatch = () => {
|
|
361
|
+
const endIdx = Math.min(processedCount + batchSize, columns.length);
|
|
362
|
+
for (let i = processedCount; i < endIdx; i++) {
|
|
307
363
|
if (columns[i].category && columns[i].category !== this.l10n.getConstant('OtherFields')) {
|
|
308
364
|
this.fields = { text: 'label', value: 'field', groupBy: 'category' };
|
|
309
365
|
}
|
|
@@ -316,11 +372,18 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
316
372
|
columns[i].operators = this.customOperators[columns[i].type + 'Operator'];
|
|
317
373
|
}
|
|
318
374
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
375
|
+
processedCount = endIdx;
|
|
376
|
+
if (processedCount < columns.length) {
|
|
377
|
+
requestAnimationFrame(processBatch);
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
processBatch();
|
|
322
381
|
}
|
|
323
382
|
updateSubFieldsFromColumns(col, field) {
|
|
383
|
+
if (col.length > 50) {
|
|
384
|
+
this.updateSubFieldsLarge(col, field);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
324
387
|
for (let i = 0; i < col.length; i++) {
|
|
325
388
|
if (this.separator !== '' && col[i].field.indexOf(this.separator) < 0) {
|
|
326
389
|
col[i].field = field ? field + this.separator + col[i].field : col[i].field;
|
|
@@ -337,6 +400,38 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
337
400
|
}
|
|
338
401
|
}
|
|
339
402
|
}
|
|
403
|
+
updateSubFieldsLarge(col, field) {
|
|
404
|
+
let i = 0;
|
|
405
|
+
const colLength = col.length;
|
|
406
|
+
const processNextBatch = () => {
|
|
407
|
+
const endIdx = Math.min(i + 10, colLength);
|
|
408
|
+
for (; i < endIdx; i++) {
|
|
409
|
+
if (this.separator !== '' && col[i].field.indexOf(this.separator) < 0) {
|
|
410
|
+
col[i].field = field ? field + this.separator + col[i].field : col[i].field;
|
|
411
|
+
}
|
|
412
|
+
if (col[i].operators) {
|
|
413
|
+
this.updateCustomOperator(col[i]);
|
|
414
|
+
}
|
|
415
|
+
else if (col[i].type && col[i].type !== 'object') {
|
|
416
|
+
col[i].operators = this.customOperators[col[i].type + 'Operator'];
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
if (i < colLength) {
|
|
420
|
+
requestAnimationFrame(processNextBatch);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
setTimeout(() => {
|
|
424
|
+
for (let j = 0; j < colLength; j++) {
|
|
425
|
+
if (col[j].columns) {
|
|
426
|
+
col[j].type = 'object';
|
|
427
|
+
this.updateSubFieldsFromColumns(col[j].columns, col[j].field);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}, 0);
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
processNextBatch();
|
|
434
|
+
}
|
|
340
435
|
updateSubFields(value, col, data) {
|
|
341
436
|
let sampCol;
|
|
342
437
|
col.columns = [];
|
|
@@ -501,8 +596,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
501
596
|
}
|
|
502
597
|
args = { groupID: groupID, cancel: false, type: 'condition', value: targetValue.toLowerCase() };
|
|
503
598
|
if (this.enableNotCondition) {
|
|
504
|
-
args = {
|
|
505
|
-
'
|
|
599
|
+
args = {
|
|
600
|
+
groupID: groupID, cancel: false, type: 'condition', value: targetValue.toLowerCase(),
|
|
601
|
+
'not': ariaChecked
|
|
602
|
+
};
|
|
506
603
|
}
|
|
507
604
|
}
|
|
508
605
|
if (!this.isImportRules) {
|
|
@@ -600,7 +697,7 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
600
697
|
appendRuleElem(target, column, type, parentId, action, rule) {
|
|
601
698
|
let ruleElem;
|
|
602
699
|
let elem;
|
|
603
|
-
const ruleListElem = target.querySelector('.e-rule-list');
|
|
700
|
+
const ruleListElem = target && target.querySelector('.e-rule-list');
|
|
604
701
|
let args;
|
|
605
702
|
if (type === 'change') {
|
|
606
703
|
ruleElem = select('#' + parentId, target);
|
|
@@ -726,23 +823,34 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
726
823
|
}
|
|
727
824
|
}
|
|
728
825
|
addRuleSuccessCallBack(args, trgt, rule, col, act, pId, isRlTmp) {
|
|
729
|
-
const
|
|
826
|
+
const isVertical = this.element.className.indexOf('e-device') > -1 || this.displayMode === 'Vertical';
|
|
827
|
+
const height = isVertical ? '250px' : '200px';
|
|
730
828
|
let ruleID;
|
|
731
829
|
const column = (rule && rule.field) ? this.getColumn(rule.field) : col ? col : this.columns[0];
|
|
732
830
|
let operators;
|
|
733
|
-
let dropDownList;
|
|
734
831
|
let ruleElem;
|
|
735
832
|
let newRule = { 'label': '', 'field': '', 'type': '', 'operator': '' };
|
|
736
833
|
if (!args.cancel) {
|
|
834
|
+
const fragment = document.createDocumentFragment();
|
|
737
835
|
if (column && column.ruleTemplate && rule.field) {
|
|
738
836
|
this.selectedColumn = column;
|
|
739
837
|
operators = this.selectedColumn.operators;
|
|
740
|
-
newRule = {
|
|
838
|
+
newRule = {
|
|
839
|
+
'label': column.label,
|
|
840
|
+
'field': column.field,
|
|
841
|
+
'type': column.type,
|
|
842
|
+
'operator': operators[0].value
|
|
843
|
+
};
|
|
741
844
|
const passedRule = Object.keys(rule).length ? rule : newRule;
|
|
742
845
|
ruleElem = this.appendRuleElem(trgt, column, act, pId, 'field', passedRule);
|
|
743
|
-
const
|
|
744
|
-
|
|
745
|
-
|
|
846
|
+
const actionArgs = {
|
|
847
|
+
requestType: 'template-initialize',
|
|
848
|
+
ruleID: ruleElem.id,
|
|
849
|
+
action: 'insert-rule',
|
|
850
|
+
fields: this.fields,
|
|
851
|
+
rule: passedRule
|
|
852
|
+
};
|
|
853
|
+
this.trigger('actionBegin', actionArgs);
|
|
746
854
|
}
|
|
747
855
|
else {
|
|
748
856
|
ruleElem = this.appendRuleElem(trgt, column, act, pId, 'field');
|
|
@@ -757,139 +865,30 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
757
865
|
addClass([element], 'e-round');
|
|
758
866
|
addClass([element], 'e-icon-btn');
|
|
759
867
|
element.setAttribute('title', this.l10n.getConstant('DeleteRule'));
|
|
760
|
-
const spanElement = this.createElement('span', {
|
|
761
|
-
|
|
868
|
+
const spanElement = this.createElement('span', {
|
|
869
|
+
attrs: { class: 'e-btn-icon e-icons e-delete-icon' }
|
|
870
|
+
});
|
|
871
|
+
element.appendChild(spanElement);
|
|
762
872
|
}
|
|
763
873
|
if (!this.showButtons.ruleDelete) {
|
|
764
874
|
element.classList.add('e-button-hide');
|
|
765
875
|
}
|
|
766
876
|
}
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
else {
|
|
771
|
-
ruleElem.className = 'e-rule-container e-horizontal-mode';
|
|
772
|
-
}
|
|
773
|
-
let previousRuleElem = ruleElem.previousElementSibling;
|
|
774
|
-
if (this.enableSeparateConnector) {
|
|
775
|
-
let prevRule;
|
|
776
|
-
let ruleContainer;
|
|
777
|
-
if (previousRuleElem && previousRuleElem.classList.contains('e-group-container')) {
|
|
778
|
-
ruleContainer = previousRuleElem.querySelectorAll('.e-rule-container');
|
|
779
|
-
previousRuleElem = ruleContainer[ruleContainer.length - 1];
|
|
780
|
-
}
|
|
781
|
-
if (previousRuleElem && previousRuleElem.classList.contains('e-rule-container')) {
|
|
782
|
-
prevRule = this.getRule(previousRuleElem);
|
|
783
|
-
}
|
|
784
|
-
if (this.headerTemplate && previousRuleElem && prevRule) {
|
|
785
|
-
this.headerTemplateFn(previousRuleElem, false, prevRule.condition, prevRule, previousRuleElem.id);
|
|
786
|
-
}
|
|
787
|
-
else if (isNullOrUndefined(previousRuleElem) && ruleElem.id !== this.element.id + '_group0_rule0') {
|
|
788
|
-
const group = ruleElem.closest('.e-group-container');
|
|
789
|
-
if (group && group.previousElementSibling) {
|
|
790
|
-
let prevElem = group.previousElementSibling;
|
|
791
|
-
const prevRuleContainer = prevElem.querySelectorAll('.e-rule-container');
|
|
792
|
-
if (prevElem.classList.contains('e-group-container')) {
|
|
793
|
-
prevElem = prevRuleContainer[prevRuleContainer.length - 1];
|
|
794
|
-
}
|
|
795
|
-
if (prevElem.classList.contains('e-rule-container')) {
|
|
796
|
-
const prevRule = this.getRule(prevElem);
|
|
797
|
-
this.headerTemplateFn(prevElem, false, prevRule.condition, prevRule, prevElem.id, true);
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
else {
|
|
801
|
-
this.headerTemplateFn(ruleElem, false, rule.condition, rule, ruleElem.id, true);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
else {
|
|
806
|
-
if (previousRuleElem && previousRuleElem.className.indexOf('e-rule-container') > -1) {
|
|
807
|
-
if (ruleElem.className.indexOf('e-joined-rule') < 0) {
|
|
808
|
-
ruleElem.className += ' e-joined-rule';
|
|
809
|
-
}
|
|
810
|
-
if (previousRuleElem.className.indexOf('e-prev-joined-rule') < 0) {
|
|
811
|
-
previousRuleElem.className += ' e-prev-joined-rule';
|
|
812
|
-
}
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
if (previousRuleElem && previousRuleElem.className.indexOf('e-group-container') > -1 &&
|
|
816
|
-
ruleElem.className.indexOf('e-separate-rule') < 0) {
|
|
817
|
-
ruleElem.className += ' e-separate-rule';
|
|
818
|
-
}
|
|
877
|
+
ruleElem.className = 'e-rule-container ' + (isVertical ? 'e-vertical-mode' : 'e-horizontal-mode');
|
|
878
|
+
const previousRuleElem = ruleElem.previousElementSibling;
|
|
879
|
+
this.processAdjacentElements(ruleElem, previousRuleElem, rule);
|
|
819
880
|
if (!this.isImportRules) {
|
|
820
881
|
this.updateAddedRule(trgt, rule, newRule, isRlTmp, pId, this.enableSeparateConnector ? true : null);
|
|
821
882
|
}
|
|
883
|
+
const ruleCount = this.rule.rules.length;
|
|
822
884
|
if (!column || (column && !column.ruleTemplate) || !rule.field) {
|
|
823
|
-
if (
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
ddlValue = this.GetRootColumnName(rule.field);
|
|
828
|
-
}
|
|
829
|
-
else if (this.autoSelectField) {
|
|
830
|
-
ddlValue = this.GetRootColumnName(rule.field);
|
|
831
|
-
}
|
|
832
|
-
else {
|
|
833
|
-
ddlValue = this.isImportRules ? this.GetRootColumnName(rule.field) : rule.field;
|
|
834
|
-
}
|
|
835
|
-
ddlField = {
|
|
836
|
-
dataSource: this.columns,
|
|
837
|
-
fields: this.fields, placeholder: this.l10n.getConstant('SelectField'),
|
|
838
|
-
popupHeight: ((this.columns.length > 5) ? height : 'auto'), close: this.fieldClose.bind(this, ruleElem.id + '_filterkey'),
|
|
839
|
-
change: this.changeField.bind(this), value: rule ? ddlValue : null, open: this.popupOpen.bind(this, true), cssClass: 'qb-dropdownlist'
|
|
840
|
-
};
|
|
841
|
-
if (this.fieldModel) {
|
|
842
|
-
ddlField = Object.assign({}, ddlField, this.fieldModel);
|
|
843
|
-
}
|
|
844
|
-
dropDownList = new DropDownList(ddlField);
|
|
845
|
-
dropDownList.appendTo('#' + ruleElem.id + '_filterkey');
|
|
846
|
-
let ddlVal;
|
|
847
|
-
if (this.separator && rule.field) {
|
|
848
|
-
ddlVal = this.GetRootColumnName(rule.field);
|
|
849
|
-
}
|
|
850
|
-
else {
|
|
851
|
-
ddlVal = this.isImportRules ? this.GetRootColumnName(rule.field) :
|
|
852
|
-
dropDownList.value;
|
|
853
|
-
}
|
|
854
|
-
this.selectedColumn = dropDownList.getDataByValue(ddlVal);
|
|
855
|
-
if (Object.keys(rule).length) {
|
|
856
|
-
this.changeRule(rule, {
|
|
857
|
-
element: dropDownList.element, itemData: this.selectedColumn
|
|
858
|
-
});
|
|
859
|
-
}
|
|
885
|
+
if (ruleCount > 20) {
|
|
886
|
+
setTimeout(() => {
|
|
887
|
+
this.applyFieldComponent(ruleElem, rule, height);
|
|
888
|
+
}, 0);
|
|
860
889
|
}
|
|
861
890
|
else {
|
|
862
|
-
|
|
863
|
-
const ddlValue = this.isImportRules ? rule.field : rule.field;
|
|
864
|
-
this.dummyDropdownTreeDs = extend([], this.columns, [], true);
|
|
865
|
-
this.updateDropdowntreeDS(this.dummyDropdownTreeDs);
|
|
866
|
-
ddlField = {
|
|
867
|
-
fields: { dataSource: this.dummyDropdownTreeDs,
|
|
868
|
-
value: 'field', text: 'label', child: 'columns', expanded: 'expanded', selectable: 'selectable' },
|
|
869
|
-
placeholder: this.l10n.getConstant('SelectField'), showClearButton: false,
|
|
870
|
-
popupHeight: ((this.columns.length > 5) ? height : 'auto'), changeOnBlur: false,
|
|
871
|
-
change: this.changeField.bind(this), value: !isNullOrUndefined(ddlValue) ? [ddlValue] : null,
|
|
872
|
-
open: this.popupOpen.bind(this, false), treeSettings: { expandOn: 'Click' },
|
|
873
|
-
cssClass: 'e-qb-ddt', filtering: this.dropdownTreeFiltering.bind(this), close: this.dropdownTreeClose.bind(this)
|
|
874
|
-
};
|
|
875
|
-
if (this.fieldModel) {
|
|
876
|
-
ddlField = Object.assign({}, ddlField, this.fieldModel);
|
|
877
|
-
}
|
|
878
|
-
const dropdowntree = new DropDownTree(ddlField);
|
|
879
|
-
dropdowntree.appendTo('#' + ruleElem.id + '_filterkey');
|
|
880
|
-
if (!isNullOrUndefined(dropdowntree.value)) {
|
|
881
|
-
const value = this.getLabelFromColumn(dropdowntree.value[0]);
|
|
882
|
-
dropdowntree.element.value = value;
|
|
883
|
-
}
|
|
884
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
885
|
-
const ddlVal = !isNullOrUndefined(rule.field) ?
|
|
886
|
-
this.GetRootColumnName(rule.field) : dropdowntree.value;
|
|
887
|
-
this.selectedColumn = this.getColumn(ddlVal);
|
|
888
|
-
if (Object.keys(rule).length) {
|
|
889
|
-
this.changeRule(rule, {
|
|
890
|
-
element: dropdowntree.element, itemData: this.selectedColumn
|
|
891
|
-
});
|
|
892
|
-
}
|
|
891
|
+
this.applyFieldComponent(ruleElem, rule, height);
|
|
893
892
|
}
|
|
894
893
|
}
|
|
895
894
|
ruleID = ruleElem.id.replace(this.element.id + '_', '');
|
|
@@ -898,46 +897,204 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
898
897
|
this.ruleLock(lockRuleTarget);
|
|
899
898
|
}
|
|
900
899
|
if (!this.isImportRules && !this.prvtEvtTgrDaD) {
|
|
901
|
-
this.trigger('change', {
|
|
900
|
+
this.trigger('change', {
|
|
901
|
+
groupID: trgt.id.replace(this.element.id + '_', ''),
|
|
902
|
+
ruleID: ruleID,
|
|
903
|
+
type: 'insertRule'
|
|
904
|
+
});
|
|
902
905
|
}
|
|
903
906
|
}
|
|
904
907
|
if (this.enableSeparateConnector && isNullOrUndefined(rule.condition) && ruleID) {
|
|
905
908
|
rule = this.getRule(ruleID);
|
|
906
909
|
}
|
|
907
910
|
if (this.enableSeparateConnector) {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
911
|
+
this.processConnectorElements(ruleElem);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
processAdjacentElements(ruleElem, previousRuleElem, rule) {
|
|
915
|
+
if (this.enableSeparateConnector) {
|
|
916
|
+
if (previousRuleElem && previousRuleElem.classList.contains('e-group-container')) {
|
|
917
|
+
const ruleContainer = previousRuleElem.querySelectorAll('.e-rule-container');
|
|
918
|
+
previousRuleElem = ruleContainer[ruleContainer.length - 1];
|
|
919
|
+
}
|
|
920
|
+
if (previousRuleElem && previousRuleElem.classList.contains('e-rule-container')) {
|
|
921
|
+
const prevRule = this.getRule(previousRuleElem);
|
|
922
|
+
if (this.headerTemplate) {
|
|
923
|
+
this.headerTemplateFn(previousRuleElem, false, prevRule.condition, prevRule, previousRuleElem.id);
|
|
915
924
|
}
|
|
916
|
-
prevElem = prevElem.previousElementSibling;
|
|
917
925
|
}
|
|
918
|
-
if (this.
|
|
926
|
+
else if (isNullOrUndefined(previousRuleElem) && ruleElem.id !== this.element.id + '_group0_rule0') {
|
|
927
|
+
this.handleOrphanedRuleElement(ruleElem, rule);
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
else {
|
|
931
|
+
if (previousRuleElem && previousRuleElem.className.indexOf('e-rule-container') > -1) {
|
|
932
|
+
ruleElem.classList.add('e-joined-rule');
|
|
933
|
+
previousRuleElem.classList.add('e-prev-joined-rule');
|
|
934
|
+
}
|
|
935
|
+
}
|
|
936
|
+
if (previousRuleElem && previousRuleElem.className.indexOf('e-group-container') > -1 &&
|
|
937
|
+
ruleElem.className.indexOf('e-separate-rule') < 0) {
|
|
938
|
+
ruleElem.className += ' e-separate-rule';
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
handleOrphanedRuleElement(ruleElem, rule) {
|
|
942
|
+
const group = ruleElem.closest('.e-group-container');
|
|
943
|
+
if (group && group.previousElementSibling) {
|
|
944
|
+
let prevElem = group.previousElementSibling;
|
|
945
|
+
const prevRuleContainer = prevElem.querySelectorAll('.e-rule-container');
|
|
946
|
+
if (prevElem.classList.contains('e-group-container')) {
|
|
947
|
+
prevElem = prevRuleContainer[prevRuleContainer.length - 1];
|
|
948
|
+
}
|
|
949
|
+
if (prevElem.classList.contains('e-rule-container')) {
|
|
919
950
|
const prevRule = this.getRule(prevElem);
|
|
920
|
-
|
|
921
|
-
notCondition: this.enableNotCondition ? true : undefined };
|
|
922
|
-
this.trigger('actionBegin', args);
|
|
951
|
+
this.headerTemplateFn(prevElem, false, prevRule.condition, prevRule, prevElem.id, true);
|
|
923
952
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
953
|
+
}
|
|
954
|
+
else {
|
|
955
|
+
this.headerTemplateFn(ruleElem, false, rule.condition, rule, ruleElem.id, true);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
processConnectorElements(ruleElem) {
|
|
959
|
+
let prevElem = ruleElem.previousElementSibling;
|
|
960
|
+
let ruleContainer;
|
|
961
|
+
while (prevElem && !prevElem.classList.contains('e-rule-container')) {
|
|
962
|
+
if (prevElem.classList.contains('e-group-container')) {
|
|
963
|
+
ruleContainer = prevElem.querySelectorAll('.e-rule-container');
|
|
964
|
+
prevElem = ruleContainer[ruleContainer.length - 1];
|
|
965
|
+
break;
|
|
966
|
+
}
|
|
967
|
+
prevElem = prevElem.previousElementSibling;
|
|
968
|
+
}
|
|
969
|
+
if (this.headerTemplate && prevElem) {
|
|
970
|
+
const prevRule = this.getRule(prevElem);
|
|
971
|
+
const args = {
|
|
972
|
+
requestType: 'rule-template-create',
|
|
973
|
+
ruleID: prevElem.id,
|
|
974
|
+
condition: prevRule.condition,
|
|
975
|
+
notCondition: this.enableNotCondition ? true : undefined
|
|
976
|
+
};
|
|
977
|
+
this.trigger('actionBegin', args);
|
|
978
|
+
}
|
|
979
|
+
else if (isNullOrUndefined(prevElem) && ruleElem.id !== this.element.id + '_group0_rule0') {
|
|
980
|
+
this.handleOrphanedConnectorElement(ruleElem);
|
|
981
|
+
}
|
|
982
|
+
this.setMultiConnector(ruleElem);
|
|
983
|
+
}
|
|
984
|
+
handleOrphanedConnectorElement(ruleElem) {
|
|
985
|
+
const group = ruleElem.closest('.e-group-container');
|
|
986
|
+
if (group && group.previousElementSibling && group.previousElementSibling.previousElementSibling) {
|
|
987
|
+
let prevElem = group.previousElementSibling.previousElementSibling;
|
|
988
|
+
if (prevElem.classList.contains('e-group-container')) {
|
|
989
|
+
const ruleContainer = prevElem.querySelectorAll('.e-rule-container');
|
|
990
|
+
prevElem = ruleContainer[ruleContainer.length - 1];
|
|
991
|
+
}
|
|
992
|
+
if (prevElem.classList.contains('e-rule-container')) {
|
|
993
|
+
const prevRule = this.getRule(prevElem);
|
|
994
|
+
const args = {
|
|
995
|
+
requestType: 'rule-template-create',
|
|
996
|
+
ruleID: prevElem.id,
|
|
997
|
+
condition: prevRule.condition,
|
|
998
|
+
notCondition: this.enableNotCondition ? true : undefined
|
|
999
|
+
};
|
|
1000
|
+
this.trigger('actionBegin', args);
|
|
939
1001
|
}
|
|
940
|
-
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
1004
|
+
applyFieldComponent(ruleElem, rule, height) {
|
|
1005
|
+
if (this.fieldMode === 'Default') {
|
|
1006
|
+
this.applyDropdownListComponent(ruleElem, rule, height);
|
|
1007
|
+
}
|
|
1008
|
+
else {
|
|
1009
|
+
this.applyDropdownTreeComponent(ruleElem, rule, height);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
applyDropdownListComponent(ruleElem, rule, height) {
|
|
1013
|
+
let ddlField;
|
|
1014
|
+
let ddlValue;
|
|
1015
|
+
if (this.separator && rule.field) {
|
|
1016
|
+
ddlValue = this.GetRootColumnName(rule.field);
|
|
1017
|
+
}
|
|
1018
|
+
else if (this.autoSelectField) {
|
|
1019
|
+
ddlValue = this.GetRootColumnName(rule.field);
|
|
1020
|
+
}
|
|
1021
|
+
else {
|
|
1022
|
+
ddlValue = this.isImportRules ? this.GetRootColumnName(rule.field) : rule.field;
|
|
1023
|
+
}
|
|
1024
|
+
ddlField = {
|
|
1025
|
+
dataSource: this.columns,
|
|
1026
|
+
fields: this.fields,
|
|
1027
|
+
placeholder: this.l10n.getConstant('SelectField'),
|
|
1028
|
+
popupHeight: ((this.columns.length > 5) ? height : 'auto'),
|
|
1029
|
+
close: this.fieldClose.bind(this, ruleElem.id + '_filterkey'),
|
|
1030
|
+
change: this.changeField.bind(this),
|
|
1031
|
+
value: rule ? ddlValue : null,
|
|
1032
|
+
open: this.popupOpen.bind(this, true),
|
|
1033
|
+
cssClass: 'qb-dropdownlist'
|
|
1034
|
+
};
|
|
1035
|
+
if (this.fieldModel) {
|
|
1036
|
+
ddlField = Object.assign({}, ddlField, this.fieldModel);
|
|
1037
|
+
}
|
|
1038
|
+
const dropDownList = new DropDownList(ddlField);
|
|
1039
|
+
dropDownList.appendTo('#' + ruleElem.id + '_filterkey');
|
|
1040
|
+
let ddlVal;
|
|
1041
|
+
if (this.separator && rule.field) {
|
|
1042
|
+
ddlVal = this.GetRootColumnName(rule.field);
|
|
1043
|
+
}
|
|
1044
|
+
else {
|
|
1045
|
+
ddlVal = this.isImportRules ? this.GetRootColumnName(rule.field) : dropDownList.value;
|
|
1046
|
+
}
|
|
1047
|
+
this.selectedColumn = dropDownList.getDataByValue(ddlVal);
|
|
1048
|
+
if (Object.keys(rule).length) {
|
|
1049
|
+
this.changeRule(rule, {
|
|
1050
|
+
element: dropDownList.element,
|
|
1051
|
+
itemData: this.selectedColumn
|
|
1052
|
+
});
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
applyDropdownTreeComponent(ruleElem, rule, height) {
|
|
1056
|
+
let ddlField;
|
|
1057
|
+
const ddlValue = this.isImportRules ? rule.field : rule.field;
|
|
1058
|
+
this.dummyDropdownTreeDs = extend([], this.columns, [], true);
|
|
1059
|
+
this.updateDropdowntreeDS(this.dummyDropdownTreeDs);
|
|
1060
|
+
ddlField = {
|
|
1061
|
+
fields: {
|
|
1062
|
+
dataSource: this.dummyDropdownTreeDs,
|
|
1063
|
+
value: 'field',
|
|
1064
|
+
text: 'label',
|
|
1065
|
+
child: 'columns',
|
|
1066
|
+
expanded: 'expanded',
|
|
1067
|
+
selectable: 'selectable'
|
|
1068
|
+
},
|
|
1069
|
+
placeholder: this.l10n.getConstant('SelectField'),
|
|
1070
|
+
showClearButton: false,
|
|
1071
|
+
popupHeight: ((this.columns.length > 5) ? height : 'auto'),
|
|
1072
|
+
changeOnBlur: false,
|
|
1073
|
+
change: this.changeField.bind(this),
|
|
1074
|
+
value: !isNullOrUndefined(ddlValue) ? [ddlValue] : null,
|
|
1075
|
+
open: this.popupOpen.bind(this, false),
|
|
1076
|
+
treeSettings: { expandOn: 'Click' },
|
|
1077
|
+
cssClass: 'e-qb-ddt',
|
|
1078
|
+
filtering: this.dropdownTreeFiltering.bind(this),
|
|
1079
|
+
close: this.dropdownTreeClose.bind(this)
|
|
1080
|
+
};
|
|
1081
|
+
if (this.fieldModel) {
|
|
1082
|
+
ddlField = Object.assign({}, ddlField, this.fieldModel);
|
|
1083
|
+
}
|
|
1084
|
+
const dropdowntree = new DropDownTree(ddlField);
|
|
1085
|
+
dropdowntree.appendTo('#' + ruleElem.id + '_filterkey');
|
|
1086
|
+
if (!isNullOrUndefined(dropdowntree.value)) {
|
|
1087
|
+
const value = this.getLabelFromColumn(dropdowntree.value[0]);
|
|
1088
|
+
dropdowntree.element.value = value;
|
|
1089
|
+
}
|
|
1090
|
+
const ddlVal = !isNullOrUndefined(rule.field) ?
|
|
1091
|
+
this.GetRootColumnName(rule.field) : dropdowntree.value;
|
|
1092
|
+
this.selectedColumn = this.getColumn(ddlVal);
|
|
1093
|
+
if (Object.keys(rule).length) {
|
|
1094
|
+
this.changeRule(rule, {
|
|
1095
|
+
element: dropdowntree.element,
|
|
1096
|
+
itemData: this.selectedColumn
|
|
1097
|
+
});
|
|
941
1098
|
}
|
|
942
1099
|
}
|
|
943
1100
|
dropdownTreeFiltering(args) {
|
|
@@ -951,7 +1108,6 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
951
1108
|
const ruleElem = document.getElementById(ruleElemID);
|
|
952
1109
|
this.ddTree = getComponent(ruleElem.querySelector('input.e-dropdowntree'), 'dropdowntree');
|
|
953
1110
|
const hierarchicalData = extend([], this.columns, [], true);
|
|
954
|
-
// Cancel the default filtering.
|
|
955
1111
|
args.cancel = true;
|
|
956
1112
|
if (args.text === '') {
|
|
957
1113
|
this.changeDataSource(hierarchicalData);
|
|
@@ -1110,7 +1266,8 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1110
1266
|
}
|
|
1111
1267
|
}
|
|
1112
1268
|
renderToolTip(element) {
|
|
1113
|
-
const tooltip = new Tooltip({
|
|
1269
|
+
const tooltip = new Tooltip({
|
|
1270
|
+
content: this.l10n.getConstant('ValidationMessage'), isSticky: true,
|
|
1114
1271
|
position: 'BottomCenter', cssClass: 'e-querybuilder-error', afterClose: () => {
|
|
1115
1272
|
tooltip.destroy();
|
|
1116
1273
|
}, beforeOpen: (args) => {
|
|
@@ -1118,7 +1275,8 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1118
1275
|
if (tooltipCloseElement) {
|
|
1119
1276
|
tooltipCloseElement.style.display = 'none';
|
|
1120
1277
|
}
|
|
1121
|
-
}
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1122
1280
|
tooltip.appendTo(element);
|
|
1123
1281
|
tooltip.open(element);
|
|
1124
1282
|
}
|
|
@@ -1276,7 +1434,6 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1276
1434
|
groupElem.appendChild(groupHdrElem);
|
|
1277
1435
|
grpBodyElem.appendChild(rulesElem);
|
|
1278
1436
|
groupElem.appendChild(grpBodyElem);
|
|
1279
|
-
// create button group in OR and AND process
|
|
1280
1437
|
if (!this.headerTemplate) {
|
|
1281
1438
|
if (this.allowDragAndDrop) {
|
|
1282
1439
|
dragClsName = 'e-icons e-drag-qb-rule';
|
|
@@ -1284,8 +1441,12 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1284
1441
|
else {
|
|
1285
1442
|
dragClsName = 'e-icons e-drag-qb-rule e-hidden';
|
|
1286
1443
|
}
|
|
1287
|
-
const spanDragElement = this.createElement('span', {
|
|
1288
|
-
|
|
1444
|
+
const spanDragElement = this.createElement('span', {
|
|
1445
|
+
attrs: {
|
|
1446
|
+
class: dragClsName, 'aria-label': 'drag handle',
|
|
1447
|
+
title: 'drag handle'
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1289
1450
|
groupHdrElem.appendChild(spanDragElement);
|
|
1290
1451
|
const className = this.enableSeparateConnector && !isConnector ? 'e-lib e-btn-group e-qb-toggle-btn' : 'e-lib e-btn-group';
|
|
1291
1452
|
glueElem = this.createElement('div', { attrs: { class: className, role: 'group' } });
|
|
@@ -1303,13 +1464,17 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1303
1464
|
}
|
|
1304
1465
|
inputElem = this.createElement('input', { attrs: { type: 'radio', class: 'e-btngroup-and', value: 'AND' } });
|
|
1305
1466
|
glueElem.appendChild(inputElem);
|
|
1306
|
-
labelElem = this.createElement('label', {
|
|
1307
|
-
|
|
1467
|
+
labelElem = this.createElement('label', {
|
|
1468
|
+
attrs: { class: 'e-lib e-btn e-btngroup-and-lbl e-small' },
|
|
1469
|
+
innerHTML: this.l10n.getConstant('AND')
|
|
1470
|
+
});
|
|
1308
1471
|
glueElem.appendChild(labelElem);
|
|
1309
1472
|
inputElem = this.createElement('input', { attrs: { type: 'radio', class: 'e-btngroup-or', value: 'OR' } });
|
|
1310
1473
|
glueElem.appendChild(inputElem);
|
|
1311
|
-
labelElem = this.createElement('label', {
|
|
1312
|
-
|
|
1474
|
+
labelElem = this.createElement('label', {
|
|
1475
|
+
attrs: { class: 'e-lib e-btn e-btngroup-or-lbl e-small' },
|
|
1476
|
+
innerHTML: this.l10n.getConstant('OR')
|
|
1477
|
+
});
|
|
1313
1478
|
glueElem.appendChild(labelElem);
|
|
1314
1479
|
groupHdrElem.appendChild(glueElem);
|
|
1315
1480
|
grpActElem = this.createElement('div', { attrs: { class: 'e-group-action' } });
|
|
@@ -1342,8 +1507,12 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1342
1507
|
else {
|
|
1343
1508
|
dragClsName = 'e-icons e-drag-qb-rule e-hidden';
|
|
1344
1509
|
}
|
|
1345
|
-
const spanDragElement = this.createElement('span', {
|
|
1346
|
-
|
|
1510
|
+
const spanDragElement = this.createElement('span', {
|
|
1511
|
+
attrs: {
|
|
1512
|
+
class: dragClsName, 'aria-label': 'drag handle',
|
|
1513
|
+
title: 'drag handle'
|
|
1514
|
+
}
|
|
1515
|
+
});
|
|
1347
1516
|
fieldElem.appendChild(spanDragElement);
|
|
1348
1517
|
const filterElem = this.createElement('input', { attrs: { type: 'text', class: 'e-filter-input' } });
|
|
1349
1518
|
tempElem.appendChild(filterElem);
|
|
@@ -1622,8 +1791,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1622
1791
|
}
|
|
1623
1792
|
this.updatedRule = null;
|
|
1624
1793
|
if (this.headerTemplate) {
|
|
1625
|
-
const args = {
|
|
1626
|
-
|
|
1794
|
+
const args = {
|
|
1795
|
+
requestType: 'header-template-create', ruleID: groupElem.id, condition: condition,
|
|
1796
|
+
notCondition: this.enableNotCondition ? not : undefined
|
|
1797
|
+
};
|
|
1627
1798
|
this.trigger('actionBegin', args);
|
|
1628
1799
|
}
|
|
1629
1800
|
else {
|
|
@@ -1662,9 +1833,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1662
1833
|
}
|
|
1663
1834
|
}
|
|
1664
1835
|
setMultiConnector(trgt) {
|
|
1665
|
-
if (this.enableSeparateConnector && !this.headerTemplate) {
|
|
1666
|
-
|
|
1667
|
-
|
|
1836
|
+
if (this.enableSeparateConnector && !this.headerTemplate && trgt.previousElementSibling) {
|
|
1837
|
+
const btnGroupElem = this.groupTemplate(true).querySelector('.e-btn-group');
|
|
1838
|
+
if (btnGroupElem) {
|
|
1839
|
+
trgt.parentElement.insertBefore(btnGroupElem, trgt);
|
|
1668
1840
|
const notElem = trgt.previousElementSibling.childNodes[0];
|
|
1669
1841
|
if (notElem.classList.contains('e-qb-toggle')) {
|
|
1670
1842
|
notElem.style.display = 'none';
|
|
@@ -1707,9 +1879,11 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1707
1879
|
groupHdr = groupElem;
|
|
1708
1880
|
}
|
|
1709
1881
|
if (this.headerTemplate) {
|
|
1710
|
-
args = {
|
|
1882
|
+
args = {
|
|
1883
|
+
requestType: 'header-template-initialize', ruleID: groupElem.id,
|
|
1711
1884
|
notCondition: this.enableNotCondition ? not : undefined,
|
|
1712
|
-
condition: condition, rule: this.getRuleCollection(rule, false), groupID: groupID
|
|
1885
|
+
condition: condition, rule: this.getRuleCollection(rule, false), groupID: groupID
|
|
1886
|
+
};
|
|
1713
1887
|
this.trigger('actionBegin', args);
|
|
1714
1888
|
if (this.enableSeparateConnector && groupElem.id.indexOf('rule') !== -1) {
|
|
1715
1889
|
args.requestType = 'rule-template-create';
|
|
@@ -1862,7 +2036,7 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1862
2036
|
templateChange(element, value, type) {
|
|
1863
2037
|
const grpElem = closest(element, '.e-group-container');
|
|
1864
2038
|
let eventsArgs;
|
|
1865
|
-
const rules = this.getParentGroup(grpElem);
|
|
2039
|
+
const rules = grpElem && this.getParentGroup(grpElem);
|
|
1866
2040
|
let ruleElem = closest(element, '.e-rule-container');
|
|
1867
2041
|
let index = 0;
|
|
1868
2042
|
if (this.allowValidation) {
|
|
@@ -1877,7 +2051,7 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1877
2051
|
index++;
|
|
1878
2052
|
}
|
|
1879
2053
|
}
|
|
1880
|
-
const rule = rules.rules[index];
|
|
2054
|
+
const rule = rules && rules.rules[index];
|
|
1881
2055
|
if (type === 'field') {
|
|
1882
2056
|
this.selectedColumn = this.getColumn(value);
|
|
1883
2057
|
}
|
|
@@ -1885,7 +2059,7 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1885
2059
|
this.selectedColumn = this.getColumn(rule.field);
|
|
1886
2060
|
}
|
|
1887
2061
|
let operVal;
|
|
1888
|
-
this.previousColumn = this.getColumn(rule.field);
|
|
2062
|
+
this.previousColumn = rule && this.getColumn(rule.field);
|
|
1889
2063
|
const beforeRules = this.getValidRules(this.rule);
|
|
1890
2064
|
if (this.selectedColumn) {
|
|
1891
2065
|
if (this.selectedColumn.operators) {
|
|
@@ -1900,11 +2074,16 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1900
2074
|
switch (type) {
|
|
1901
2075
|
case 'field':
|
|
1902
2076
|
if (isNullOrUndefined(value)) {
|
|
1903
|
-
rule
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2077
|
+
if (!isNullOrUndefined(rule)) {
|
|
2078
|
+
rule.field = '';
|
|
2079
|
+
rule.label = '';
|
|
2080
|
+
rule.type = '';
|
|
2081
|
+
rule.value = '';
|
|
2082
|
+
rule.operator = '';
|
|
2083
|
+
}
|
|
2084
|
+
else {
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
1908
2087
|
}
|
|
1909
2088
|
else {
|
|
1910
2089
|
rule.field = value;
|
|
@@ -1955,10 +2134,14 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
1955
2134
|
ruleElement.className.indexOf('e-separate-rule') < 0) {
|
|
1956
2135
|
ruleElement.className += ' e-separate-rule';
|
|
1957
2136
|
}
|
|
1958
|
-
const args = {
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
2137
|
+
const args = {
|
|
2138
|
+
requestType: 'template-create', action: type, ruleID: grpEle.id,
|
|
2139
|
+
fields: this.fields, rule: rule
|
|
2140
|
+
};
|
|
2141
|
+
eventsArgs = {
|
|
2142
|
+
groupID: grpElem.id.replace(this.element.id + '_', ''), ruleID: grpEle.id.replace(this.element.id + '_', ''),
|
|
2143
|
+
value: rule.field, type: 'field'
|
|
2144
|
+
};
|
|
1962
2145
|
this.trigger('actionBegin', args);
|
|
1963
2146
|
this.trigger('change', eventsArgs);
|
|
1964
2147
|
}
|
|
@@ -2097,8 +2280,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
2097
2280
|
const item = ddl.popupObj && ddl.popupObj.element.querySelector('.e-active');
|
|
2098
2281
|
const itemData = ddl.getItemData();
|
|
2099
2282
|
ddl.value = itemData.value;
|
|
2100
|
-
const customArgs = {
|
|
2101
|
-
|
|
2283
|
+
const customArgs = {
|
|
2284
|
+
element: ddl.element, value: itemData.value, isInteracted: true,
|
|
2285
|
+
previousItemData: this.prevItemData, previousItem: null, item: item, itemData: itemData, event: null, e: null
|
|
2286
|
+
};
|
|
2102
2287
|
if (ddl.previousValue !== ddl.value) {
|
|
2103
2288
|
this.changeField(customArgs);
|
|
2104
2289
|
}
|
|
@@ -2210,8 +2395,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
2210
2395
|
this.selectedColumn = this.getColumn(ddlValue);
|
|
2211
2396
|
const ruleElem = closest(flt, '.e-rule-container');
|
|
2212
2397
|
const ruleID = ruleElem.id.replace(this.element.id + '_', '');
|
|
2213
|
-
const eventsArgs = {
|
|
2214
|
-
|
|
2398
|
+
const eventsArgs = {
|
|
2399
|
+
groupID: grID, ruleID: ruleID, selectedField: this.fieldMode === 'DropdownTree' ?
|
|
2400
|
+
dl.value[0] : dl.value, cancel: false, type: 'field'
|
|
2401
|
+
};
|
|
2215
2402
|
if (!this.isImportRules && !this.prvtEvtTgrDaD) {
|
|
2216
2403
|
this.trigger('beforeChange', eventsArgs, (observedChangeArgs) => {
|
|
2217
2404
|
this.fieldChangeSuccess(observedChangeArgs, tmpRl, flt, rl, dArg);
|
|
@@ -2794,19 +2981,25 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
2794
2981
|
: getComponent(container.querySelector('.e-rule-filter .e-filter-input'), 'dropdownlist');
|
|
2795
2982
|
const column = this.fieldMode === 'DropdownTree' ? this.getColumn(ddlObj.value[0]) : this.getColumn(ddlObj.value);
|
|
2796
2983
|
if (typeof itemData.template === 'string' || itemData.template.write === undefined) {
|
|
2797
|
-
const args = {
|
|
2798
|
-
|
|
2984
|
+
const args = {
|
|
2985
|
+
rule: rule, ruleID: container.id, operator: tempRule.operator, field: column.field,
|
|
2986
|
+
requestType: 'value-template-create'
|
|
2987
|
+
};
|
|
2799
2988
|
this.trigger('actionBegin', args);
|
|
2800
2989
|
}
|
|
2801
2990
|
else {
|
|
2802
2991
|
const template = itemData.template;
|
|
2803
2992
|
if (typeof template.write === 'string') {
|
|
2804
|
-
getValue(template.write, window)({
|
|
2805
|
-
|
|
2993
|
+
getValue(template.write, window)({
|
|
2994
|
+
elements: tempElements.length > 1 ? tempElements : tempElements[0], values: rule.value,
|
|
2995
|
+
operator: tempRule.operator, field: column.field, dataSource: column.values
|
|
2996
|
+
});
|
|
2806
2997
|
}
|
|
2807
2998
|
else if (typeof itemData.template !== 'function') {
|
|
2808
|
-
itemData.template.write({
|
|
2809
|
-
|
|
2999
|
+
itemData.template.write({
|
|
3000
|
+
elements: tempElements.length > 1 ? tempElements : tempElements[0],
|
|
3001
|
+
values: rule.value, operator: tempRule.operator, field: column.field, dataSource: column.values
|
|
3002
|
+
});
|
|
2810
3003
|
}
|
|
2811
3004
|
}
|
|
2812
3005
|
}
|
|
@@ -3303,8 +3496,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
3303
3496
|
}
|
|
3304
3497
|
else {
|
|
3305
3498
|
if (typeof itemData.template === 'string' || itemData.template.create === undefined) {
|
|
3306
|
-
args = {
|
|
3307
|
-
|
|
3499
|
+
args = {
|
|
3500
|
+
requestType: 'value-template-initialize', ruleID: ruleID, field: field, operator: operator, rule: rule,
|
|
3501
|
+
renderTemplate: true
|
|
3502
|
+
};
|
|
3308
3503
|
this.trigger('actionBegin', args, (observedActionArgs) => {
|
|
3309
3504
|
isRendered = this.actionBeginSuccessCallBack(observedActionArgs, itemData, ruleID, field, target);
|
|
3310
3505
|
});
|
|
@@ -3512,7 +3707,6 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
3512
3707
|
element = element ? element : ruleElement.nextElementSibling.nextElementSibling.querySelector('input.e-control');
|
|
3513
3708
|
operator = getComponent(element, 'dropdownlist').value.toString();
|
|
3514
3709
|
rule.rules[index].operator = operator;
|
|
3515
|
-
// Value Fields
|
|
3516
3710
|
const valueContainer = ruleElement.nextElementSibling.nextElementSibling;
|
|
3517
3711
|
let elementCln = valueContainer.querySelectorAll('input.e-control');
|
|
3518
3712
|
if (elementCln.length < 1) {
|
|
@@ -3674,6 +3868,9 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
3674
3868
|
}
|
|
3675
3869
|
}
|
|
3676
3870
|
validateValue(rule, ruleElem, index) {
|
|
3871
|
+
if (isNullOrUndefined(rule) && isNullOrUndefined(ruleElem)) {
|
|
3872
|
+
return;
|
|
3873
|
+
}
|
|
3677
3874
|
if (!isNullOrUndefined(index)) {
|
|
3678
3875
|
rule = rule.rules[index];
|
|
3679
3876
|
}
|
|
@@ -3835,8 +4032,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
3835
4032
|
if (grouplen) {
|
|
3836
4033
|
this.isPublic = true;
|
|
3837
4034
|
for (let i = 0, len = groups.length; i < len; i++) {
|
|
3838
|
-
this.updatedRule = {
|
|
3839
|
-
|
|
4035
|
+
this.updatedRule = {
|
|
4036
|
+
isLocked: groups[i].isLocked, condition: groups[i].condition,
|
|
4037
|
+
not: groups[i].not
|
|
4038
|
+
};
|
|
3840
4039
|
this.importRules(groups[i], groupElem, false, groups[i].not);
|
|
3841
4040
|
}
|
|
3842
4041
|
this.isPublic = false;
|
|
@@ -3965,10 +4164,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
3965
4164
|
this.element.querySelector('.e-group-header').appendChild(collapseElem);
|
|
3966
4165
|
}
|
|
3967
4166
|
columnSort() {
|
|
3968
|
-
if (this.sortDirection.toLowerCase() === 'descending') {
|
|
4167
|
+
if (this.sortDirection && this.sortDirection.toLowerCase() === 'descending') {
|
|
3969
4168
|
this.columns = new DataManager(this.columns).executeLocal(new Query().sortByDesc('field'));
|
|
3970
4169
|
}
|
|
3971
|
-
else if (this.sortDirection.toLowerCase() === 'ascending') {
|
|
4170
|
+
else if (this.sortDirection && this.sortDirection.toLowerCase() === 'ascending') {
|
|
3972
4171
|
this.columns = new DataManager(this.columns).executeLocal(new Query().sortBy('field'));
|
|
3973
4172
|
}
|
|
3974
4173
|
}
|
|
@@ -4454,8 +4653,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
4454
4653
|
}
|
|
4455
4654
|
}
|
|
4456
4655
|
}
|
|
4457
|
-
const dragEventArgs = {
|
|
4458
|
-
|
|
4656
|
+
const dragEventArgs = {
|
|
4657
|
+
dragRuleID: targetElem !== null ? targetElem.id : grpElem !== null ? grpElem.id : null,
|
|
4658
|
+
dragGroupID: grpElem !== null ? grpElem.id : null, cancel: false
|
|
4659
|
+
};
|
|
4459
4660
|
this.trigger('drag', dragEventArgs);
|
|
4460
4661
|
this.isDragEventPrevent = dragEventArgs.cancel;
|
|
4461
4662
|
}
|
|
@@ -4475,8 +4676,10 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
4475
4676
|
let prevRule;
|
|
4476
4677
|
if (!isPreventelem) {
|
|
4477
4678
|
const targetGrp = closest(e.target, '.e-group-container');
|
|
4478
|
-
const dropEventArgs = {
|
|
4479
|
-
|
|
4679
|
+
const dropEventArgs = {
|
|
4680
|
+
cancel: false, dropRuleID: targetGroup !== null ? targetGroup.id
|
|
4681
|
+
: targetGrp !== null ? targetGrp.id : null, dropGroupID: targetGrp !== null ? targetGrp.id : null
|
|
4682
|
+
};
|
|
4480
4683
|
this.trigger('drop', dropEventArgs);
|
|
4481
4684
|
if (dropEventArgs.cancel) {
|
|
4482
4685
|
isPreventelem = true;
|
|
@@ -5242,7 +5445,8 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
5242
5445
|
else {
|
|
5243
5446
|
if (customObj && (customObj.type === 'question' || customObj.type === 'answer')) {
|
|
5244
5447
|
const notValue = rule.not;
|
|
5245
|
-
rule = {
|
|
5448
|
+
rule = {
|
|
5449
|
+
'label': rule.label, 'field': rule.field, 'operator': rule.operator, 'type': rule.type, 'value': rule.value,
|
|
5246
5450
|
'condition': rule.condition, 'rules': rule.rules
|
|
5247
5451
|
};
|
|
5248
5452
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -5564,21 +5768,40 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
5564
5768
|
let columns = this.columns;
|
|
5565
5769
|
let column;
|
|
5566
5770
|
columns = col ? col : columns;
|
|
5567
|
-
|
|
5771
|
+
const fieldParts = this.separator !== '' ? (field ? field.split(this.separator) : []) : [field];
|
|
5772
|
+
const rootField = fieldParts && fieldParts.length > 0 ? fieldParts[0] : null;
|
|
5773
|
+
for (let i = 0; i < columns.length; i++) {
|
|
5568
5774
|
if (columns[i].field === field) {
|
|
5569
5775
|
column = columns[i];
|
|
5570
5776
|
break;
|
|
5571
5777
|
}
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5778
|
+
}
|
|
5779
|
+
if (!column && this.separator !== '') {
|
|
5780
|
+
for (let i = 0; i < columns.length; i++) {
|
|
5781
|
+
if (columns[i].field === rootField) {
|
|
5782
|
+
if (columns[i].columns) {
|
|
5783
|
+
const subField = field.substring(rootField.length + this.separator.length);
|
|
5784
|
+
if (subField) {
|
|
5785
|
+
column = this.getColumn(subField, columns[i].columns);
|
|
5786
|
+
}
|
|
5787
|
+
else {
|
|
5788
|
+
column = columns[i];
|
|
5789
|
+
}
|
|
5790
|
+
}
|
|
5791
|
+
else {
|
|
5792
|
+
column = columns[i];
|
|
5793
|
+
}
|
|
5575
5794
|
break;
|
|
5576
5795
|
}
|
|
5577
5796
|
}
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5797
|
+
}
|
|
5798
|
+
if (!column) {
|
|
5799
|
+
for (let i = 0; i < columns.length; i++) {
|
|
5800
|
+
if (columns[i].columns) {
|
|
5801
|
+
column = this.getColumn(field, columns[i].columns);
|
|
5802
|
+
if (column) {
|
|
5803
|
+
break;
|
|
5804
|
+
}
|
|
5582
5805
|
}
|
|
5583
5806
|
}
|
|
5584
5807
|
}
|
|
@@ -6039,86 +6262,74 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
6039
6262
|
else {
|
|
6040
6263
|
queryStr += '(';
|
|
6041
6264
|
}
|
|
6042
|
-
let condition = rules.condition;
|
|
6043
6265
|
if (rules.not) {
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
rulesNotCondition = sqlLocale ? this.l10n.getConstant('NOT').toUpperCase() + ' (' : 'NOT (';
|
|
6047
|
-
queryStr += rulesNotCondition;
|
|
6048
|
-
}
|
|
6049
|
-
else {
|
|
6050
|
-
rulesNotCondition = sqlLocale ? ' ' + this.l10n.getConstant('NOT').toUpperCase() + ' (' : ' NOT (';
|
|
6051
|
-
queryStr += rulesNotCondition;
|
|
6052
|
-
}
|
|
6266
|
+
const notPrefix = sqlLocale ? this.l10n.getConstant('NOT').toUpperCase() + ' ' : 'NOT ';
|
|
6267
|
+
queryStr += isRoot ? notPrefix + '(' : ' ' + notPrefix + '(';
|
|
6053
6268
|
}
|
|
6054
|
-
if (rules.rules) {
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6269
|
+
if (rules.rules && rules.rules.length) {
|
|
6270
|
+
queryStr += rules.rules.reduce((result, rule, j) => {
|
|
6271
|
+
let ruleStr = '';
|
|
6272
|
+
if (rule.rules) {
|
|
6273
|
+
ruleStr = this.getSqlString(rule, enableEscape, '', sqlLocale);
|
|
6058
6274
|
if (this.enableSeparateConnector) {
|
|
6059
|
-
condition =
|
|
6275
|
+
rules.condition = rule.condition;
|
|
6060
6276
|
}
|
|
6061
6277
|
}
|
|
6062
6278
|
else {
|
|
6063
|
-
const rule = rules.rules[j];
|
|
6064
|
-
let valueStr = '';
|
|
6065
6279
|
const ruleOpertor = sqlLocale ? this.sqlOperators[rule.operator] : this.operators[rule.operator];
|
|
6280
|
+
let valueStr = '';
|
|
6066
6281
|
if (rule.value instanceof Array) {
|
|
6067
6282
|
if (rule.operator.toString().indexOf('between') > -1) {
|
|
6068
|
-
const ruleCondition = sqlLocale ? ' ' + this.l10n.getConstant('AND').toUpperCase() + ' ' : '
|
|
6283
|
+
const ruleCondition = sqlLocale ? ' ' + this.l10n.getConstant('AND').toUpperCase() + ' ' : ' AND ';
|
|
6069
6284
|
if (rule.type === 'date' && !this.isDateFunction(rule.value[0])) {
|
|
6070
|
-
valueStr
|
|
6285
|
+
valueStr = `"${rule.value[0]}"${ruleCondition}"${rule.value[1]}"`;
|
|
6071
6286
|
}
|
|
6072
6287
|
else {
|
|
6073
|
-
valueStr
|
|
6288
|
+
valueStr = `${rule.value[0]}${ruleCondition}${rule.value[1]}`;
|
|
6074
6289
|
}
|
|
6075
6290
|
}
|
|
6076
6291
|
else {
|
|
6077
6292
|
if (typeof rule.value[0] === 'string' && rule.value !== null) {
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
valueStr += ',"' + rule.value[k] + '"';
|
|
6081
|
-
}
|
|
6082
|
-
valueStr += ')';
|
|
6293
|
+
const valueArray = rule.value;
|
|
6294
|
+
valueStr = '("' + valueArray.join('","') + '")';
|
|
6083
6295
|
}
|
|
6084
6296
|
else {
|
|
6085
|
-
valueStr
|
|
6297
|
+
valueStr = `(${rule.value})`;
|
|
6086
6298
|
}
|
|
6087
6299
|
}
|
|
6088
6300
|
}
|
|
6089
6301
|
else {
|
|
6090
6302
|
if (rule.operator.toString().indexOf('startswith') > -1) {
|
|
6091
|
-
valueStr
|
|
6303
|
+
valueStr = rule.value ? `("${rule.value}%")` : `(${rule.value})`;
|
|
6092
6304
|
}
|
|
6093
6305
|
else if (rule.operator.toString().indexOf('endswith') > -1) {
|
|
6094
|
-
valueStr
|
|
6306
|
+
valueStr = rule.value ? `("%${rule.value}")` : `(${rule.value})`;
|
|
6095
6307
|
}
|
|
6096
6308
|
else if (rule.operator.toString().indexOf('contains') > -1) {
|
|
6097
|
-
valueStr
|
|
6309
|
+
valueStr = rule.value ? `("%${rule.value}%")` : `(${rule.value})`;
|
|
6098
6310
|
}
|
|
6099
6311
|
else {
|
|
6100
6312
|
if (rule.type === 'number' || typeof rule.value === 'boolean' ||
|
|
6101
6313
|
(rule.value === null && (rule.operator.toString().indexOf('empty') < -1))) {
|
|
6102
|
-
valueStr
|
|
6314
|
+
valueStr = `${rule.value}`;
|
|
6103
6315
|
}
|
|
6104
6316
|
else if (rule.operator.toString().indexOf('empty') > -1) {
|
|
6105
|
-
valueStr
|
|
6317
|
+
valueStr = '""';
|
|
6106
6318
|
}
|
|
6107
6319
|
else {
|
|
6108
|
-
valueStr
|
|
6320
|
+
valueStr = `"${rule.value}"`;
|
|
6109
6321
|
}
|
|
6110
6322
|
}
|
|
6111
6323
|
}
|
|
6324
|
+
let fieldName = rule.field;
|
|
6325
|
+
if (enableEscape) {
|
|
6326
|
+
fieldName = '`' + fieldName + '`';
|
|
6327
|
+
}
|
|
6328
|
+
else if (fieldName.indexOf(' ') > -1) {
|
|
6329
|
+
fieldName = '"' + fieldName + '"';
|
|
6330
|
+
}
|
|
6112
6331
|
if (rule.operator.toString().indexOf('null') > -1) {
|
|
6113
|
-
|
|
6114
|
-
rule.field = '`' + rule.field + '`';
|
|
6115
|
-
}
|
|
6116
|
-
else {
|
|
6117
|
-
if (rule.field.indexOf(' ') > -1) {
|
|
6118
|
-
rule.field = '"' + rule.field + '"';
|
|
6119
|
-
}
|
|
6120
|
-
}
|
|
6121
|
-
queryStr += rule.field + ' ' + ruleOpertor;
|
|
6332
|
+
ruleStr = fieldName + ' ' + ruleOpertor;
|
|
6122
6333
|
}
|
|
6123
6334
|
else {
|
|
6124
6335
|
let custOper = ruleOpertor;
|
|
@@ -6128,33 +6339,21 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
6128
6339
|
else if (rule.operator === 'isnotempty') {
|
|
6129
6340
|
custOper = '!=';
|
|
6130
6341
|
}
|
|
6131
|
-
|
|
6132
|
-
rule.field = '`' + rule.field + '`';
|
|
6133
|
-
}
|
|
6134
|
-
else {
|
|
6135
|
-
if (rule.field.indexOf(' ') > -1) {
|
|
6136
|
-
rule.field = '"' + rule.field + '"';
|
|
6137
|
-
}
|
|
6138
|
-
}
|
|
6139
|
-
queryStr += rule.field + ' ' + custOper + ' ' + valueStr;
|
|
6140
|
-
}
|
|
6141
|
-
if (rule.condition && rule.condition !== '') {
|
|
6142
|
-
condition = rule.condition;
|
|
6342
|
+
ruleStr = fieldName + ' ' + custOper + ' ' + valueStr;
|
|
6143
6343
|
}
|
|
6144
6344
|
}
|
|
6145
|
-
if (j !==
|
|
6146
|
-
|
|
6147
|
-
const rule = rules.rules[j];
|
|
6148
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6345
|
+
if (j !== rules.rules.length - 1) {
|
|
6346
|
+
let condition = rules.condition;
|
|
6149
6347
|
if (condition === '' || (rule && rule.condition !== '' && rule.custom && rule.custom.isCustom)) {
|
|
6150
6348
|
condition = rule.condition;
|
|
6151
6349
|
}
|
|
6152
6350
|
if (condition) {
|
|
6153
6351
|
condition = sqlLocale ? this.l10n.getConstant(condition.toUpperCase()).toUpperCase() : condition.toUpperCase();
|
|
6154
|
-
|
|
6352
|
+
ruleStr += ' ' + condition + ' ';
|
|
6155
6353
|
}
|
|
6156
6354
|
}
|
|
6157
|
-
|
|
6355
|
+
return result + ruleStr;
|
|
6356
|
+
}, '');
|
|
6158
6357
|
}
|
|
6159
6358
|
if (!isRoot) {
|
|
6160
6359
|
queryStr += ')';
|
|
@@ -6472,23 +6671,19 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
6472
6671
|
return subOp[i].length;
|
|
6473
6672
|
}
|
|
6474
6673
|
}
|
|
6475
|
-
//Left Parenthesis
|
|
6476
6674
|
if (/^\(/.exec(sqlString)) {
|
|
6477
6675
|
this.parser.push(['Left', '(']);
|
|
6478
6676
|
return 1;
|
|
6479
6677
|
}
|
|
6480
|
-
//Right Parenthesis
|
|
6481
6678
|
if (/^\)/.exec(sqlString)) {
|
|
6482
6679
|
this.parser.push(['Right', ')']);
|
|
6483
6680
|
return 1;
|
|
6484
6681
|
}
|
|
6485
|
-
//Boolean
|
|
6486
6682
|
if (/^(true|false)/.exec(sqlString)) {
|
|
6487
6683
|
matchValue = /^(true|false)/.exec(sqlString)[0];
|
|
6488
6684
|
this.parser.push(['String', matchValue]);
|
|
6489
6685
|
return matchValue.length;
|
|
6490
6686
|
}
|
|
6491
|
-
//Null
|
|
6492
6687
|
if (/^null/.exec(sqlString)) {
|
|
6493
6688
|
matchValue = /^null/.exec(sqlString)[0];
|
|
6494
6689
|
this.parser.push(['String', null]);
|
|
@@ -6513,7 +6708,6 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
6513
6708
|
return matchValue.length;
|
|
6514
6709
|
}
|
|
6515
6710
|
}
|
|
6516
|
-
//String
|
|
6517
6711
|
const singleString = this.getSingleQuoteString(sqlString);
|
|
6518
6712
|
if (singleString !== '') {
|
|
6519
6713
|
matchValue = singleString;
|
|
@@ -6533,24 +6727,20 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
6533
6727
|
!this.checkCondition(sqlString, matchValue)) {
|
|
6534
6728
|
matchValue = this.combineSingleQuoteString(sqlString, matchValue);
|
|
6535
6729
|
}
|
|
6536
|
-
// end
|
|
6537
6730
|
this.parser.push(['String', matchValue]);
|
|
6538
6731
|
return matchValue.length;
|
|
6539
6732
|
}
|
|
6540
|
-
// Double String
|
|
6541
6733
|
const doubleString = this.getDoubleQuoteString(sqlString);
|
|
6542
6734
|
if (doubleString !== '') {
|
|
6543
6735
|
matchValue = doubleString;
|
|
6544
6736
|
this.parser.push(['DoubleString', matchValue]);
|
|
6545
6737
|
return matchValue.length;
|
|
6546
6738
|
}
|
|
6547
|
-
//Number
|
|
6548
6739
|
if (/^\d*\.?\d+/.exec(sqlString)) {
|
|
6549
6740
|
matchValue = /^\d*\.?\d+/.exec(sqlString)[0];
|
|
6550
6741
|
this.parser.push(['Number', matchValue]);
|
|
6551
6742
|
return matchValue.length;
|
|
6552
6743
|
}
|
|
6553
|
-
//Negative Number
|
|
6554
6744
|
if (/^-?\d*\.?\d+/.exec(sqlString)) {
|
|
6555
6745
|
matchValue = /^-?\d*\.?\d+/.exec(sqlString)[0];
|
|
6556
6746
|
this.parser.push(['Number', matchValue]);
|
|
@@ -6718,7 +6908,7 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
6718
6908
|
fieldName += this.separator;
|
|
6719
6909
|
}
|
|
6720
6910
|
}
|
|
6721
|
-
return this.getColumn(fieldName).label;
|
|
6911
|
+
return this.getColumn(fieldName) ? this.getColumn(fieldName).label : '';
|
|
6722
6912
|
}
|
|
6723
6913
|
processParser(parser, rules, levelColl, sqlLocale) {
|
|
6724
6914
|
let j;
|
|
@@ -6950,12 +7140,16 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
6950
7140
|
}
|
|
6951
7141
|
}
|
|
6952
7142
|
if (this.enableSeparateConnector) {
|
|
6953
|
-
this.addRules([{
|
|
6954
|
-
'
|
|
7143
|
+
this.addRules([{
|
|
7144
|
+
'label': getRule.label, 'field': getRule.field, 'type': getRule.type, 'operator': getRule.operator,
|
|
7145
|
+
'value': getRule.value, 'condition': getRule.condition
|
|
7146
|
+
}], groupId);
|
|
6955
7147
|
}
|
|
6956
7148
|
else {
|
|
6957
|
-
this.addRules([{
|
|
6958
|
-
'
|
|
7149
|
+
this.addRules([{
|
|
7150
|
+
'label': getRule.label, 'field': getRule.field, 'type': getRule.type, 'operator': getRule.operator,
|
|
7151
|
+
'value': getRule.value
|
|
7152
|
+
}], groupId);
|
|
6959
7153
|
}
|
|
6960
7154
|
this.ruleIndex = -1;
|
|
6961
7155
|
}
|
|
@@ -7130,115 +7324,65 @@ let QueryBuilder = class QueryBuilder extends Component {
|
|
|
7130
7324
|
this.disableRuleControls(target, groupElem, isDisabled);
|
|
7131
7325
|
}
|
|
7132
7326
|
disableRuleControls(target, groupElem, isDisabled) {
|
|
7133
|
-
const
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7327
|
+
const disableComponents = (elements, componentGetter, isDisabled) => {
|
|
7328
|
+
elements.forEach((element) => {
|
|
7329
|
+
const component = componentGetter(element);
|
|
7330
|
+
if ('enabled' in component) {
|
|
7331
|
+
component.enabled = !isDisabled;
|
|
7332
|
+
}
|
|
7333
|
+
else if ('disabled' in component) {
|
|
7334
|
+
component.disabled = isDisabled;
|
|
7335
|
+
}
|
|
7336
|
+
});
|
|
7337
|
+
};
|
|
7338
|
+
const elements = {
|
|
7339
|
+
ddl: groupElem.querySelectorAll('.e-control.e-dropdownlist'),
|
|
7340
|
+
numeric: groupElem.querySelectorAll('.e-control.e-numerictextbox'),
|
|
7341
|
+
text: groupElem.querySelectorAll('.e-control.e-textbox'),
|
|
7342
|
+
date: groupElem.querySelectorAll('.e-control.e-datepicker'),
|
|
7343
|
+
checkbox: groupElem.querySelectorAll('.e-control.e-checkbox'),
|
|
7344
|
+
radio: groupElem.querySelectorAll('.e-control.e-radio'),
|
|
7345
|
+
multiSelect: groupElem.querySelectorAll('.e-control.e-multiselect'),
|
|
7346
|
+
deleteElem: groupElem.querySelectorAll('.e-rule-delete'),
|
|
7347
|
+
lockElem: groupElem.querySelectorAll('.e-lock-rule'),
|
|
7348
|
+
cloneElem: groupElem.querySelectorAll('.e-clone-rule'),
|
|
7349
|
+
ruleElem: groupElem.querySelectorAll('.e-rule-container')
|
|
7350
|
+
};
|
|
7351
|
+
elements.deleteElem.forEach((elem, i) => {
|
|
7145
7352
|
if (isDisabled) {
|
|
7146
|
-
if (ruleElem[i] && ruleElem[i].classList.contains('e-disable')) {
|
|
7147
|
-
ruleElem[i].classList.add('e-disable');
|
|
7353
|
+
if (elements.ruleElem[i] && elements.ruleElem[i].classList.contains('e-disable')) {
|
|
7354
|
+
elements.ruleElem[i].classList.add('e-disable');
|
|
7148
7355
|
}
|
|
7149
|
-
deleteElem[i].disabled = true;
|
|
7150
|
-
if (cloneElem[i]) {
|
|
7151
|
-
cloneElem[i].disabled = true;
|
|
7356
|
+
elements.deleteElem[i].disabled = true;
|
|
7357
|
+
if (elements.cloneElem[i]) {
|
|
7358
|
+
elements.cloneElem[i].disabled = true;
|
|
7152
7359
|
}
|
|
7153
|
-
if (lockElem[i] !== target) {
|
|
7154
|
-
lockElem[i].disabled = true;
|
|
7155
|
-
lockElem[i].children[0].classList.remove('e-unlock');
|
|
7156
|
-
lockElem[i].children[0].classList.add('e-lock');
|
|
7360
|
+
if (elements.lockElem[i] !== target) {
|
|
7361
|
+
elements.lockElem[i].disabled = true;
|
|
7362
|
+
elements.lockElem[i].children[0].classList.remove('e-unlock');
|
|
7363
|
+
elements.lockElem[i].children[0].classList.add('e-lock');
|
|
7157
7364
|
}
|
|
7158
7365
|
}
|
|
7159
7366
|
else {
|
|
7160
|
-
if (ruleElem[i]) {
|
|
7161
|
-
ruleElem[i].classList.remove('e-disable');
|
|
7367
|
+
if (elements.ruleElem[i]) {
|
|
7368
|
+
elements.ruleElem[i].classList.remove('e-disable');
|
|
7162
7369
|
}
|
|
7163
|
-
if (cloneElem[i]) {
|
|
7164
|
-
cloneElem[i].disabled = false;
|
|
7370
|
+
if (elements.cloneElem[i]) {
|
|
7371
|
+
elements.cloneElem[i].disabled = false;
|
|
7165
7372
|
}
|
|
7166
|
-
deleteElem[i].disabled = false;
|
|
7167
|
-
lockElem[i].disabled = false;
|
|
7168
|
-
lockElem[i].children[0].classList.remove('e-lock');
|
|
7169
|
-
lockElem[i].children[0].classList.add('e-unlock');
|
|
7170
|
-
}
|
|
7171
|
-
}
|
|
7172
|
-
let dropDownObj;
|
|
7173
|
-
let numericObj;
|
|
7174
|
-
let textObj;
|
|
7175
|
-
let dateObj;
|
|
7176
|
-
let checkBoxObj;
|
|
7177
|
-
let radioBtnObj;
|
|
7178
|
-
let multiSelectObj;
|
|
7179
|
-
for (let i = 0; i < ddlElement.length; i++) {
|
|
7180
|
-
dropDownObj = getComponent(ddlElement[i], 'dropdownlist');
|
|
7181
|
-
if (isDisabled) {
|
|
7182
|
-
dropDownObj.enabled = false;
|
|
7373
|
+
elements.deleteElem[i].disabled = false;
|
|
7374
|
+
elements.lockElem[i].disabled = false;
|
|
7375
|
+
elements.lockElem[i].children[0].classList.remove('e-lock');
|
|
7376
|
+
elements.lockElem[i].children[0].classList.add('e-unlock');
|
|
7183
7377
|
}
|
|
7184
|
-
|
|
7185
|
-
|
|
7186
|
-
|
|
7187
|
-
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
}
|
|
7193
|
-
else {
|
|
7194
|
-
numericObj.enabled = true;
|
|
7195
|
-
}
|
|
7196
|
-
}
|
|
7197
|
-
for (let i = 0; i < textElement.length; i++) {
|
|
7198
|
-
textObj = getComponent(textElement[i], 'textbox');
|
|
7199
|
-
if (isDisabled) {
|
|
7200
|
-
textObj.enabled = false;
|
|
7201
|
-
}
|
|
7202
|
-
else {
|
|
7203
|
-
textObj.enabled = true;
|
|
7204
|
-
}
|
|
7205
|
-
}
|
|
7206
|
-
for (let i = 0; i < dateElement.length; i++) {
|
|
7207
|
-
dateObj = getComponent(dateElement[i], 'datepicker');
|
|
7208
|
-
if (isDisabled) {
|
|
7209
|
-
dateObj.enabled = false;
|
|
7210
|
-
}
|
|
7211
|
-
else {
|
|
7212
|
-
dateObj.enabled = true;
|
|
7213
|
-
}
|
|
7214
|
-
}
|
|
7215
|
-
for (let i = 0; i < checkboxElement.length; i++) {
|
|
7216
|
-
checkBoxObj = getComponent(checkboxElement[i], 'checkbox');
|
|
7217
|
-
if (isDisabled) {
|
|
7218
|
-
checkBoxObj.disabled = true;
|
|
7219
|
-
}
|
|
7220
|
-
else {
|
|
7221
|
-
checkBoxObj.disabled = false;
|
|
7222
|
-
}
|
|
7223
|
-
}
|
|
7224
|
-
for (let i = 0; i < radioBtnElement.length; i++) {
|
|
7225
|
-
radioBtnObj = getComponent(radioBtnElement[i], 'radio');
|
|
7226
|
-
if (isDisabled) {
|
|
7227
|
-
radioBtnObj.disabled = true;
|
|
7228
|
-
}
|
|
7229
|
-
else {
|
|
7230
|
-
radioBtnObj.disabled = false;
|
|
7231
|
-
}
|
|
7232
|
-
}
|
|
7233
|
-
for (let i = 0; i < multiSelectElement.length; i++) {
|
|
7234
|
-
multiSelectObj = getComponent(multiSelectElement[i], 'multiselect');
|
|
7235
|
-
if (isDisabled) {
|
|
7236
|
-
multiSelectObj.enabled = false;
|
|
7237
|
-
}
|
|
7238
|
-
else {
|
|
7239
|
-
multiSelectObj.enabled = true;
|
|
7240
|
-
}
|
|
7241
|
-
}
|
|
7378
|
+
});
|
|
7379
|
+
disableComponents(elements.ddl, (elem) => getComponent(elem, 'dropdownlist'), isDisabled);
|
|
7380
|
+
disableComponents(elements.numeric, (elem) => getComponent(elem, 'numerictextbox'), isDisabled);
|
|
7381
|
+
disableComponents(elements.text, (elem) => getComponent(elem, 'textbox'), isDisabled);
|
|
7382
|
+
disableComponents(elements.date, (elem) => getComponent(elem, 'datepicker'), isDisabled);
|
|
7383
|
+
disableComponents(elements.checkbox, (elem) => getComponent(elem, 'checkbox'), isDisabled);
|
|
7384
|
+
disableComponents(elements.radio, (elem) => getComponent(elem, 'radio'), isDisabled);
|
|
7385
|
+
disableComponents(elements.multiSelect, (elem) => getComponent(elem, 'multiselect'), isDisabled);
|
|
7242
7386
|
}
|
|
7243
7387
|
};
|
|
7244
7388
|
__decorate([
|