@syncfusion/ej2-querybuilder 19.4.38 → 19.4.48

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.
@@ -680,12 +680,19 @@ let QueryBuilder = class QueryBuilder extends Component {
680
680
  else {
681
681
  groupElem = closest(target, '.e-group-container');
682
682
  rules = this.getParentGroup(groupElem);
683
+ const custom = rule.custom;
683
684
  if (Object.keys(rule).length) {
684
685
  rules.rules.push({
685
686
  'field': rule.field, 'type': rule.type, 'label': rule.label, 'operator': rule.operator, value: rule.value
686
687
  });
688
+ if (custom) {
689
+ rules.rules[rules.rules.length - 1].custom = custom;
690
+ }
687
691
  }
688
692
  else {
693
+ if (custom) {
694
+ newRule.custom = custom;
695
+ }
689
696
  rules.rules.push(newRule);
690
697
  }
691
698
  }
@@ -1303,6 +1310,7 @@ let QueryBuilder = class QueryBuilder extends Component {
1303
1310
  ruleElem = ruleElem.previousElementSibling;
1304
1311
  index++;
1305
1312
  }
1313
+ rules.rules[index].value = '';
1306
1314
  this.changeRule(rules.rules[index], args);
1307
1315
  }
1308
1316
  }
@@ -1390,6 +1398,9 @@ let QueryBuilder = class QueryBuilder extends Component {
1390
1398
  getComponent(tooltipElem[i], 'tooltip').destroy();
1391
1399
  }
1392
1400
  if (!args.cancel) {
1401
+ if (this.selectedColumn === null) {
1402
+ return;
1403
+ }
1393
1404
  tempRule.type = this.selectedColumn.type;
1394
1405
  if (ruleElem.querySelector('.e-template')) {
1395
1406
  rule.value = '';
@@ -1424,7 +1435,8 @@ let QueryBuilder = class QueryBuilder extends Component {
1424
1435
  tempElem.appendChild(subFieldElem);
1425
1436
  const height = (this.element.className.indexOf('e-device') > -1) ? '250px' : '200px';
1426
1437
  const subFieldData = Object.keys(this.selectedColumn.columns[0]);
1427
- const dropDownList = new DropDownList({
1438
+ let ddlField;
1439
+ ddlField = {
1428
1440
  dataSource: this.selectedColumn.columns,
1429
1441
  fields: this.fields,
1430
1442
  placeholder: this.l10n.getConstant('SelectField'),
@@ -1432,7 +1444,11 @@ let QueryBuilder = class QueryBuilder extends Component {
1432
1444
  change: this.changeField.bind(this),
1433
1445
  index: 0,
1434
1446
  open: this.popupOpen.bind(this, false)
1435
- });
1447
+ };
1448
+ if (this.fieldModel) {
1449
+ ddlField = Object.assign({}, ddlField, this.fieldModel);
1450
+ }
1451
+ const dropDownList = new DropDownList(ddlField);
1436
1452
  dropDownList.appendTo('#' + ruleId + '_subfilterkey' + this.subFilterCounter);
1437
1453
  if (this.isImportRules) {
1438
1454
  const subField = this.selectedColumn.columns;
@@ -1829,8 +1845,10 @@ let QueryBuilder = class QueryBuilder extends Component {
1829
1845
  }
1830
1846
  closePopup(i, args) {
1831
1847
  const element = document.getElementById(args.popup.element.id.replace('_popup', ''));
1832
- const value = getComponent(element, 'multiselect').value;
1833
- this.updateRules(element, value, i);
1848
+ if (element) {
1849
+ const value = getComponent(element, 'multiselect').value;
1850
+ this.updateRules(element, value, i);
1851
+ }
1834
1852
  }
1835
1853
  processTemplate(target, itemData, rule, tempRule) {
1836
1854
  const container = closest(target, '.e-rule-container');
@@ -3378,7 +3396,11 @@ let QueryBuilder = class QueryBuilder extends Component {
3378
3396
  }
3379
3397
  }
3380
3398
  const isTemplateRendered = clnruleElem.querySelector('.e-template-value');
3381
- detach(clnruleElem);
3399
+ try {
3400
+ detach(clnruleElem);
3401
+ }
3402
+ catch (err) {
3403
+ }
3382
3404
  if (column && column.ruleTemplate) {
3383
3405
  this.clearQBTemplate([clnruleElem.id]);
3384
3406
  }
@@ -3498,10 +3520,14 @@ let QueryBuilder = class QueryBuilder extends Component {
3498
3520
  }
3499
3521
  }
3500
3522
  if ((this.isRefreshed && this.enablePersistence) || (this.rule.field !== '' && rule.operator !== '' && (rule.value !== '' &&
3501
- rule.value !== undefined))) {
3523
+ rule.value !== undefined)) || (customObj && customObj.isQuestion)) {
3524
+ const condition = rule.condition;
3502
3525
  rule = {
3503
3526
  'label': rule.label, 'field': rule.field, 'operator': rule.operator, 'type': rule.type, 'value': rule.value
3504
3527
  };
3528
+ if (condition) {
3529
+ rule.condition = condition;
3530
+ }
3505
3531
  if (customObj) {
3506
3532
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3507
3533
  rule.custom = customObj;
@@ -3810,6 +3836,12 @@ let QueryBuilder = class QueryBuilder extends Component {
3810
3836
  break;
3811
3837
  }
3812
3838
  }
3839
+ else if (field.indexOf(this.separator) > -1) {
3840
+ if (columns[i].field === field.split(this.separator)[0]) {
3841
+ column = columns[i];
3842
+ break;
3843
+ }
3844
+ }
3813
3845
  }
3814
3846
  return column;
3815
3847
  }
@@ -3899,7 +3931,7 @@ let QueryBuilder = class QueryBuilder extends Component {
3899
3931
  }
3900
3932
  if (!(operator.indexOf('null') > -1 || operator.indexOf('empty') > -1)) {
3901
3933
  for (let j = 0, jLen = value.length; j < jLen; j++) {
3902
- if (value[j] !== '') {
3934
+ if (value[j] !== '' || ((operator === 'in' || operator === 'notin') && column.type === 'string')) {
3903
3935
  if (j === 0) {
3904
3936
  const gte = 'greaterthanorequal';
3905
3937
  switch (operator) {
@@ -4041,7 +4073,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4041
4073
  if (!isNullOrUndefined(ruleColl)) {
4042
4074
  for (let i = 0, len = ruleColl.length; i < len; i++) {
4043
4075
  const keys = Object.keys(ruleColl[i]);
4044
- if (!isNullOrUndefined(ruleColl[i].rules) && keys.indexOf('rules') > -1) {
4076
+ if (!isNullOrUndefined(ruleColl[i].rules) && keys.indexOf('rules') > -1 && (ruleColl[i].rules.length !== 0)) {
4045
4077
  parentElem = this.renderGroup(ruleColl[i], ruleColl[i].condition, parentElem, ruleColl[i].not);
4046
4078
  parentElem = this.importRules(ruleColl[i], parentElem, true);
4047
4079
  }
@@ -4198,7 +4230,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4198
4230
  else {
4199
4231
  queryStr += '(';
4200
4232
  }
4201
- const condition = rules.condition;
4233
+ let condition = rules.condition;
4202
4234
  if (rules.not) {
4203
4235
  if (isRoot) {
4204
4236
  queryStr += 'NOT (';
@@ -4277,8 +4309,14 @@ let QueryBuilder = class QueryBuilder extends Component {
4277
4309
  }
4278
4310
  queryStr += rule.field + ' ' + this.operators[rule.operator] + ' ' + valueStr;
4279
4311
  }
4312
+ if (rule.condition && rule.condition != '') {
4313
+ condition = rule.condition;
4314
+ }
4280
4315
  }
4281
4316
  if (j !== jLen - 1) {
4317
+ if (condition === '') {
4318
+ condition = rules.rules[j].condition;
4319
+ }
4282
4320
  queryStr += ' ' + condition.toUpperCase() + ' ';
4283
4321
  }
4284
4322
  }