@easyquery/core 7.2.0-rc04 → 7.2.0-rc05

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.
@@ -1570,6 +1570,7 @@ var meta_entity_MetaEntityAttr = /** @class */ (function () {
1570
1570
  this.lookupEntity = dto.lent;
1571
1571
  this.dataAttr = dto.dattr;
1572
1572
  this.lookupDataAttr = dto.ldattr;
1573
+ this.defaultValue = dto.defVal;
1573
1574
  this.isNullable = utils_utils.getIfDefined(dto.nul, this.isNullable);
1574
1575
  this.isEditable = utils_utils.getIfDefined(dto.ied, this.isEditable);
1575
1576
  this.showOnView = utils_utils.getIfDefined(dto.ivis || dto.sov, this.showOnView);
@@ -5594,8 +5595,6 @@ var query_Query = /** @class */ (function () {
5594
5595
  }
5595
5596
  this.setDefaultName();
5596
5597
  this.description = "";
5597
- this.modelId = "";
5598
- this.modelName = "";
5599
5598
  this.model = (model) ? model : new data_model_DataModel();
5600
5599
  if (data) {
5601
5600
  this.loadFromData(data);
@@ -5609,10 +5608,14 @@ var query_Query = /** @class */ (function () {
5609
5608
  this.parentQuery = options.parent;
5610
5609
  }
5611
5610
  this.addChangedCallback(function (ev) {
5612
- if (ev.data && ev.data.part === QueryChangePart.Columns
5613
- && ev.data.action !== QueryChangeAction.Modify
5611
+ if (ev.data
5612
+ && ((ev.data.part & QueryChangePart.Columns) > 0)
5614
5613
  && !ev.data.aggregation) {
5615
- _this.aggrSettings.clear();
5614
+ if (_this._enableAggregation && _this.updateAggregationSettings()) {
5615
+ _this.fireChangedEvent({
5616
+ part: QueryChangePart.Aggregation
5617
+ });
5618
+ }
5616
5619
  }
5617
5620
  });
5618
5621
  }
@@ -5633,19 +5636,6 @@ var query_Query = /** @class */ (function () {
5633
5636
  this.processQueryForAggregation();
5634
5637
  var aggrCols = this.columns.filter(function (c) { return c.enabled
5635
5638
  && c.expr.tag == ExprTag.AggregateFunction; });
5636
- // // query contains aggregate columns
5637
- // if (aggrCols.length) {
5638
- // for (const col of aggrCols) {
5639
- // const attr = this.model.getAttributeById(col.expr.args[0].value);
5640
- // this.changeColumnType(col, ExprTag.EntityAttribute, {
5641
- // caption: this.model.getAttributeText(attr, `{attr}`)
5642
- // });
5643
- // }
5644
- // this.fireChangedEvent({
5645
- // part: QueryChangePart.Columns,
5646
- // wasModified: true
5647
- // });
5648
- // }
5649
5639
  }
5650
5640
  if (!this._enableAggregation) {
5651
5641
  this.aggrSettings.clear();
@@ -5654,6 +5644,40 @@ var query_Query = /** @class */ (function () {
5654
5644
  enumerable: true,
5655
5645
  configurable: true
5656
5646
  });
5647
+ Query.prototype.updateAggregationSettings = function () {
5648
+ var hasChanged = false;
5649
+ var aggrSettings = this.getAggregationSettings();
5650
+ for (var i = aggrSettings.groups.length - 1; i >= 0; i--) {
5651
+ var group = aggrSettings.groups[i];
5652
+ var _loop_1 = function (j) {
5653
+ var colId = group.columns[j];
5654
+ if (!this_1.columns.find(function (col) { return col.id === colId; })) {
5655
+ group.columns.splice(j, 1);
5656
+ hasChanged = true;
5657
+ }
5658
+ };
5659
+ var this_1 = this;
5660
+ for (var j = group.columns.length - 1; j >= 0; j--) {
5661
+ _loop_1(j);
5662
+ }
5663
+ if (group.columns.length == 0) {
5664
+ aggrSettings.groups.slice(i, 1);
5665
+ }
5666
+ }
5667
+ var aggregates = aggrSettings.getAggregates();
5668
+ var _loop_2 = function (i) {
5669
+ var aggr = aggregates[i];
5670
+ if (!this_2.columns.find(function (col) { return col.id === aggr.colId; })) {
5671
+ aggregates.splice(i, 1);
5672
+ hasChanged = true;
5673
+ }
5674
+ };
5675
+ var this_2 = this;
5676
+ for (var i = aggregates.length - 1; i >= 0; i--) {
5677
+ _loop_2(i);
5678
+ }
5679
+ return hasChanged;
5680
+ };
5657
5681
  Query.prototype.createSubQuery = function () {
5658
5682
  return new Query(this.model);
5659
5683
  };