@syncfusion/ej2-querybuilder 33.2.6 → 33.2.10

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.
@@ -159,6 +159,7 @@ let QueryBuilder = class QueryBuilder extends Component {
159
159
  this.cloneGrpBtnClick = false;
160
160
  this.isMiddleGroup = false;
161
161
  this.cloneRuleBtnClick = false;
162
+ this.groupConnectorStates = {};
162
163
  this.isValueEmpty = false;
163
164
  this.isPropChange = false;
164
165
  this.isRuleClicked = false;
@@ -4780,6 +4781,16 @@ let QueryBuilder = class QueryBuilder extends Component {
4780
4781
  return visualElement;
4781
4782
  }
4782
4783
  dragStartHandler(e) {
4784
+ this.groupConnectorStates = {};
4785
+ const allGroupContainers = this.element.querySelectorAll('.e-group-container');
4786
+ allGroupContainers.forEach((grpContainer) => {
4787
+ if (grpContainer.id !== '') {
4788
+ const groupRule = this.getGroup(grpContainer);
4789
+ if (groupRule && groupRule.condition) {
4790
+ this.groupConnectorStates[grpContainer.id] = groupRule.condition.toUpperCase();
4791
+ }
4792
+ }
4793
+ });
4783
4794
  this.draggedRule = e.target;
4784
4795
  this.isDragEventPrevent = false;
4785
4796
  document.body.classList.add('e-prevent-select');
@@ -4866,6 +4877,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4866
4877
  if (this.isDragEventPrevent) {
4867
4878
  return;
4868
4879
  }
4880
+ let dropped = false;
4869
4881
  let targetGroup = closest(e.target, '.e-rule-container');
4870
4882
  if (isNullOrUndefined(targetGroup) && e.target.parentElement &&
4871
4883
  e.target.parentElement.classList.contains('e-btn-group') && this.enableSeparateConnector) {
@@ -4968,6 +4980,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4968
4980
  }
4969
4981
  }
4970
4982
  });
4983
+ dropped = true;
4971
4984
  }
4972
4985
  }
4973
4986
  else if (tgrt.classList.contains('e-rule-list') && tgrt.children.length === 0 && !isPreventelem) {
@@ -4998,6 +5011,7 @@ let QueryBuilder = class QueryBuilder extends Component {
4998
5011
  this.addRules([rule], groupId);
4999
5012
  }
5000
5013
  }
5014
+ dropped = true;
5001
5015
  }
5002
5016
  else if (tgrt.classList.contains('e-rule-list') && tgrt.children[0].classList.contains('e-group-container') && !isPreventelem) {
5003
5017
  const groupElem = closest(tgrt, '.e-group-container');
@@ -5052,6 +5066,7 @@ let QueryBuilder = class QueryBuilder extends Component {
5052
5066
  }
5053
5067
  }
5054
5068
  });
5069
+ dropped = true;
5055
5070
  }
5056
5071
  else if ((closest(e.target, '.e-group-container') || e.target.classList.contains('e-group-container')) && !isPreventelem) {
5057
5072
  let rule;
@@ -5086,10 +5101,14 @@ let QueryBuilder = class QueryBuilder extends Component {
5086
5101
  }
5087
5102
  }
5088
5103
  }
5104
+ dropped = true;
5089
5105
  }
5090
5106
  if (!isPreventelem) {
5091
5107
  this.trigger('ruleChange', { previousRule: prevRule, rule: this.getValidRules(), type: 'drag-and-drop' });
5092
5108
  }
5109
+ if (!dropped) {
5110
+ this.restoreGroupConnectorStates();
5111
+ }
5093
5112
  this.prvtEvtTgrDaD = false;
5094
5113
  document.body.classList.remove('e-prevent-select');
5095
5114
  let borderLineElem = this.element.querySelectorAll('.e-drag-rule-bottom-line');
@@ -5446,11 +5465,37 @@ let QueryBuilder = class QueryBuilder extends Component {
5446
5465
  if (dragElemnet) {
5447
5466
  remove(dragElemnet);
5448
5467
  }
5468
+ this.restoreGroupConnectorStates();
5449
5469
  if (this.enableSeparateConnector) {
5450
5470
  this.refresh();
5451
5471
  }
5452
5472
  }
5453
5473
  }
5474
+ restoreGroupConnectorStates() {
5475
+ const updatedGroupContainers = this.element.querySelectorAll('.e-group-container');
5476
+ updatedGroupContainers.forEach((grpContainer) => {
5477
+ const groupId = grpContainer.id;
5478
+ if (this.groupConnectorStates.hasOwnProperty(groupId)) {
5479
+ const savedCondition = this.groupConnectorStates[groupId];
5480
+ const groupRule = this.getGroup(grpContainer);
5481
+ if (groupRule) {
5482
+ groupRule.condition = savedCondition.toLowerCase();
5483
+ }
5484
+ const andElem = grpContainer.querySelector('.e-btngroup-and');
5485
+ const orElem = grpContainer.querySelector('.e-btngroup-or');
5486
+ if (andElem && orElem) {
5487
+ if (savedCondition === 'AND') {
5488
+ andElem.checked = true;
5489
+ orElem.checked = false;
5490
+ }
5491
+ else {
5492
+ orElem.checked = true;
5493
+ andElem.checked = false;
5494
+ }
5495
+ }
5496
+ }
5497
+ });
5498
+ }
5454
5499
  windowResizeHandler() {
5455
5500
  if (Browser.isDevice || window.innerWidth < 768) {
5456
5501
  this.displayMode = 'Vertical';
@@ -6309,6 +6354,12 @@ let QueryBuilder = class QueryBuilder extends Component {
6309
6354
  if (this.element.querySelectorAll('.e-group-container').length > this.maxGroupCount) {
6310
6355
  return null;
6311
6356
  }
6357
+ if (isNullOrUndefined(this.updatedRule) && this.allowDragAndDrop && this.dragElement) {
6358
+ this.updatedRule = {
6359
+ isLocked: ruleColl[i].isLocked, condition: ruleColl[i].condition,
6360
+ not: ruleColl[i].not
6361
+ };
6362
+ }
6312
6363
  parentElem = this.renderGroup(ruleColl[i], ruleColl[i].condition, parentElem, ruleColl[i].not);
6313
6364
  parentElem = this.importRules(ruleColl[i], parentElem, true);
6314
6365
  }