@syncfusion/ej2-querybuilder 20.4.42 → 20.4.51

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.
@@ -612,7 +612,13 @@ let QueryBuilder = class QueryBuilder extends Component {
612
612
  if (!column || (column && !column.ruleTemplate) || !rule.field) {
613
613
  if (this.fieldMode === 'Default') {
614
614
  let ddlField;
615
- const ddlValue = this.isImportRules ? this.GetRootColumnName(rule.field) : rule.field;
615
+ let ddlValue;
616
+ if (this.separator && rule.field) {
617
+ ddlValue = this.GetRootColumnName(rule.field);
618
+ }
619
+ else {
620
+ ddlValue = this.isImportRules ? this.GetRootColumnName(rule.field) : rule.field;
621
+ }
616
622
  ddlField = {
617
623
  dataSource: this.columns,
618
624
  fields: this.fields, placeholder: this.l10n.getConstant('SelectField'),
@@ -624,8 +630,13 @@ let QueryBuilder = class QueryBuilder extends Component {
624
630
  }
625
631
  dropDownList = new DropDownList(ddlField);
626
632
  dropDownList.appendTo('#' + ruleElem.id + '_filterkey');
627
- const ddlVal = this.isImportRules ?
628
- this.GetRootColumnName(rule.field) : dropDownList.value;
633
+ let ddlVal;
634
+ if (this.separator && rule.field) {
635
+ ddlVal = this.GetRootColumnName(rule.field);
636
+ }
637
+ else {
638
+ ddlVal = this.isImportRules ? this.GetRootColumnName(rule.field) : dropDownList.value;
639
+ }
629
640
  this.selectedColumn = dropDownList.getDataByValue(ddlVal);
630
641
  if (Object.keys(rule).length) {
631
642
  this.changeRule(rule, {
@@ -641,7 +652,7 @@ let QueryBuilder = class QueryBuilder extends Component {
641
652
  value: 'field', text: 'label', child: 'columns', expanded: 'expanded' },
642
653
  placeholder: this.l10n.getConstant('SelectField'), showClearButton: false,
643
654
  popupHeight: ((this.columns.length > 5) ? height : 'auto'), changeOnBlur: false,
644
- change: this.changeField.bind(this), value: this.isImportRules ? [ddlValue] : null,
655
+ change: this.changeField.bind(this), value: !isNullOrUndefined(ddlValue) ? [ddlValue] : null,
645
656
  open: this.popupOpen.bind(this, false)
646
657
  };
647
658
  if (this.fieldModel) {
@@ -654,7 +665,7 @@ let QueryBuilder = class QueryBuilder extends Component {
654
665
  dropdowntree.element.value = value;
655
666
  }
656
667
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
657
- const ddlVal = this.isImportRules ?
668
+ const ddlVal = !isNullOrUndefined(rule.field) ?
658
669
  this.GetRootColumnName(rule.field) : dropdowntree.value;
659
670
  this.selectedColumn = this.getColumn(ddlVal);
660
671
  if (Object.keys(rule).length) {
@@ -731,7 +742,6 @@ let QueryBuilder = class QueryBuilder extends Component {
731
742
  const tooltip = new Tooltip({ content: this.l10n.getConstant('ValidationMessage'),
732
743
  position: 'BottomCenter', cssClass: 'e-querybuilder-error' });
733
744
  tooltip.appendTo(element);
734
- // eslint-disable-next-line
735
745
  tooltip.open(element);
736
746
  }
737
747
  /**
@@ -1068,7 +1078,7 @@ let QueryBuilder = class QueryBuilder extends Component {
1068
1078
  return groupElem;
1069
1079
  }
1070
1080
  /**
1071
- * notify the changes to component.
1081
+ * Notify the changes to component.
1072
1082
  *
1073
1083
  * @param {string | number | boolean | Date | string[] | number[] | Date[]} value - 'value' to be passed to update the rule value.
1074
1084
  * @param {Element} element - 'element' to be passed to update the rule.
@@ -1346,6 +1356,9 @@ let QueryBuilder = class QueryBuilder extends Component {
1346
1356
  if (column && column.ruleTemplate) {
1347
1357
  this.templateChange(args.element, column.field, 'field');
1348
1358
  }
1359
+ else if (column && column.columns && column.columns[0].ruleTemplate) {
1360
+ this.templateChange(args.element, column.columns[0].field, 'field');
1361
+ }
1349
1362
  else {
1350
1363
  const groupElem = closest(args.element, '.e-group-container');
1351
1364
  const rules = this.getParentGroup(groupElem);
@@ -1499,7 +1512,8 @@ let QueryBuilder = class QueryBuilder extends Component {
1499
1512
  }
1500
1513
  const dropDownList = new DropDownList(ddlField);
1501
1514
  dropDownList.appendTo('#' + ruleId + '_subfilterkey' + this.subFilterCounter);
1502
- if (this.isImportRules) {
1515
+ if (this.isImportRules || (this.previousColumn && this.previousColumn.ruleTemplate &&
1516
+ this.GetRootColumnName(rule.field) === this.GetRootColumnName(this.previousColumn.field))) {
1503
1517
  const subField = this.selectedColumn.columns;
1504
1518
  for (let i = 0; i < subField.length; i++) {
1505
1519
  if (rule.field === subField[i].field || rule.field.indexOf(subField[i].field) > -1) {
@@ -1514,12 +1528,13 @@ let QueryBuilder = class QueryBuilder extends Component {
1514
1528
  this.subFieldElem = subFieldElem;
1515
1529
  // eslint-disable-next-line
1516
1530
  ddlArgs.itemData = ddlArgs.itemData;
1517
- if (!this.isImportRules || (!subFieldValue && this.selectedColumn.columns)) {
1531
+ if (!subFieldValue && this.selectedColumn.columns) {
1518
1532
  if (!subFieldValue && this.isImportRules) {
1519
1533
  dropDownList.value = null;
1520
1534
  }
1521
1535
  this.selectedColumn = this.selectedColumn.columns[0];
1522
1536
  }
1537
+ this.previousColumn = this.selectedColumn;
1523
1538
  if (!this.selectedColumn.columns) {
1524
1539
  this.changeRuleValues(tempElem, rule, tempRule, ddlArgs);
1525
1540
  }
@@ -1731,7 +1746,7 @@ let QueryBuilder = class QueryBuilder extends Component {
1731
1746
  }
1732
1747
  }
1733
1748
  /**
1734
- * return values bound to the column.
1749
+ * Return values bound to the column.
1735
1750
  *
1736
1751
  * @param {string} field - 'field' to be passed to get the field values.
1737
1752
  * @returns {object[]} - Values bound to the column
@@ -3783,7 +3798,7 @@ let QueryBuilder = class QueryBuilder extends Component {
3783
3798
  }
3784
3799
  }
3785
3800
  /**
3786
- * return the Query from current rules collection.
3801
+ * Return the Query from current rules collection.
3787
3802
  *
3788
3803
  * @returns {Promise} - Query from current rules collection
3789
3804
  * @blazorType object
@@ -3983,7 +3998,7 @@ let QueryBuilder = class QueryBuilder extends Component {
3983
3998
  }
3984
3999
  /* eslint-disable */
3985
4000
  /**
3986
- * return the operator bound to the column.
4001
+ * Return the operator bound to the column.
3987
4002
  *
3988
4003
  * @returns {[key: string]: Object}[] - Operator bound to the column
3989
4004
  */
@@ -4630,10 +4645,22 @@ let QueryBuilder = class QueryBuilder extends Component {
4630
4645
  if (/^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(sqlString)) {
4631
4646
  // eslint-disable-next-line
4632
4647
  matchValue = /^'((?:[^\\']+?|\\.|'')*)'(?!')/.exec(sqlString)[0];
4648
+ if (matchValue[matchValue.length - 2] === '(') {
4649
+ let isClosed = false;
4650
+ for (let j = matchValue.length; j < sqlString.length; j++) {
4651
+ matchValue += sqlString[j];
4652
+ if (sqlString[j] === ')') {
4653
+ isClosed = true;
4654
+ }
4655
+ if (isClosed && sqlString[j] === "'") {
4656
+ break;
4657
+ }
4658
+ }
4659
+ }
4633
4660
  this.parser.push(['String', matchValue]);
4634
4661
  return matchValue.length;
4635
4662
  }
4636
- //Double String
4663
+ // Double String
4637
4664
  // eslint-disable-next-line
4638
4665
  if (/^"([^\\"]*(?:\\.[^\\"]*)*)"/.exec(sqlString)) {
4639
4666
  // eslint-disable-next-line
@@ -4830,7 +4857,11 @@ let QueryBuilder = class QueryBuilder extends Component {
4830
4857
  break;
4831
4858
  }
4832
4859
  if (operator.indexOf('like') > -1 && parser[j][0] === 'String') {
4833
- const val = parser[j][1] ? parser[j][1].replace(/'/g, '').replace(/%/g, '') : parser[j][1];
4860
+ let val = parser[j][1];
4861
+ if (parser[j][1] && parser[j][1][0] === "'") {
4862
+ val = parser[j][1].substring(1, parser[j][1].length - 1);
4863
+ }
4864
+ val = val ? val.replace(/%/g, '') : parser[j][1];
4834
4865
  rule.value = val;
4835
4866
  rule.type = 'string';
4836
4867
  }
@@ -4842,7 +4873,11 @@ let QueryBuilder = class QueryBuilder extends Component {
4842
4873
  numVal.push(Number(parser[j][1]));
4843
4874
  }
4844
4875
  else if (parser[j][0] === 'String') {
4845
- strVal.push(parser[j][1].replace(/'/g, ''));
4876
+ let val = parser[j][1];
4877
+ if (parser[j][1] && parser[j][1][0] === "'") {
4878
+ val = parser[j][1].substring(1, parser[j][1].length - 1);
4879
+ }
4880
+ strVal.push(val);
4846
4881
  }
4847
4882
  }
4848
4883
  else {
@@ -4850,7 +4885,11 @@ let QueryBuilder = class QueryBuilder extends Component {
4850
4885
  numVal.push(Number(parser[j][1]));
4851
4886
  }
4852
4887
  else if (parser[j][0] === 'String') {
4853
- strVal.push(parser[j][1].replace(/'/g, ''));
4888
+ let val = parser[j][1];
4889
+ if (parser[j][1] && parser[j][1][0] === "'") {
4890
+ val = parser[j][1].substring(1, parser[j][1].length - 1);
4891
+ }
4892
+ strVal.push(val);
4854
4893
  }
4855
4894
  }
4856
4895
  rule.type = this.getTypeFromColumn(rule);