@easyquery/core 7.2.4-rc04 → 7.2.4-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.
@@ -6412,7 +6412,6 @@ var Query = /** @class */ (function () {
6412
6412
  }
6413
6413
  public_api/* utils.moveArrayItem */.P6.moveArrayItem(this.sortedColumns, colIdx, index);
6414
6414
  this.fixupSortingIndices();
6415
- this.fireColumnsChangedEvent(QueryChangeAction.All);
6416
6415
  };
6417
6416
  Query.prototype.getColumnSorting = function (col) {
6418
6417
  var idx = this.getColumnSortIndex(col);
@@ -6439,7 +6438,6 @@ var Query = /** @class */ (function () {
6439
6438
  }
6440
6439
  }
6441
6440
  this.adjustColumnsSorting();
6442
- this.fireColumnsChangedEvent(QueryChangeAction.Modify, col, col.isJustSorted());
6443
6441
  };
6444
6442
  Query.prototype.fixupSortingIndices = function () {
6445
6443
  this.sortedColumns.forEach(function (col, index) {
@@ -6488,10 +6486,8 @@ var Query = /** @class */ (function () {
6488
6486
  * sortIndex: SortDirection.Ascending
6489
6487
  * }});
6490
6488
  */
6491
- Query.prototype.addColumn = function (descriptor, author) {
6492
- // let columns = (descriptor.justsorted)
6493
- // ? this.justsorted
6494
- // : this.columns;
6489
+ Query.prototype.addColumn = function (descriptor, silent) {
6490
+ if (silent === void 0) { silent = false; }
6495
6491
  var newColumn;
6496
6492
  if (descriptor.column) {
6497
6493
  newColumn = descriptor.column;
@@ -6508,10 +6504,10 @@ var Query = /** @class */ (function () {
6508
6504
  throw new Error("Incorrect attribute id (".concat(descriptor.attributeId, "): addColumn"));
6509
6505
  }
6510
6506
  }
6511
- else {
6512
- throw new Error('Not enought data for addColumn operation. Need attribute or attributeId');
6507
+ else if (typeof descriptor.constValue === 'undefined' && !descriptor.customSql) {
6508
+ throw new Error('Not enought data for addColumn operation. One of the following options must be defined: attribute, attributeId, constValue or customSlq');
6513
6509
  }
6514
- if (!attr.useInResult) {
6510
+ if (attr && !attr.useInResult) {
6515
6511
  if (attr.lookupAttr) {
6516
6512
  attr = this.model.getAttributeById(attr.lookupAttr);
6517
6513
  }
@@ -6519,22 +6515,29 @@ var Query = /** @class */ (function () {
6519
6515
  throw new Error("Can't use this attribute for a column");
6520
6516
  }
6521
6517
  }
6522
- if (descriptor.aggrFuncId && descriptor.cusomtSql) {
6518
+ if (descriptor.aggrFuncId && descriptor.customSql) {
6523
6519
  console.warn("Column cannot be created using aggrFuncId and customSql at the same time. " +
6524
6520
  "cusomSql will be used.");
6525
6521
  }
6526
- if (descriptor.cusomtSql) {
6522
+ if (typeof descriptor.constValue !== 'undefined') {
6523
+ newColumn.expr.tag = ExprTag.Constant;
6524
+ newColumn.expr.setValue(descriptor.constValue);
6525
+ newColumn.expr.kind = DataKind.Scalar;
6526
+ newColumn.expr.dataType = descriptor.constType || public_api/* DataType.String */.g.String;
6527
+ }
6528
+ else if (descriptor.customSql) {
6527
6529
  newColumn.caption = 'Custom SQL Column';
6528
6530
  newColumn.expr.tag = ExprTag.CustomSql;
6529
- newColumn.expr.baseAttrId = attr.id;
6530
- newColumn.expr.sql = descriptor.cusomtSql;
6531
+ newColumn.expr.sql = descriptor.customSql;
6531
6532
  newColumn.expr.kind = DataKind.Query;
6532
6533
  newColumn.expr.dataType = public_api/* DataType.Unknown */.g.Unknown;
6534
+ newColumn.expr.baseAttrId = descriptor.attributeId;
6535
+ if (!this.context.options.allowCustomExpressions) {
6536
+ newColumn.enabled = false;
6537
+ }
6533
6538
  }
6534
6539
  else if (descriptor.aggrFuncId) {
6535
6540
  var funcId = descriptor.aggrFuncId;
6536
- newColumn.caption = attr.caption + ' '
6537
- + this.model.getAggrFunctionCaption(descriptor.aggrFuncId);
6538
6541
  newColumn.expr.tag = ExprTag.AggregateFunction;
6539
6542
  newColumn.expr.func = descriptor.aggrFuncId;
6540
6543
  newColumn.expr.kind = DataKind.Scalar;
@@ -6543,16 +6546,18 @@ var Query = /** @class */ (function () {
6543
6546
  var arg = new Expression(newColumn);
6544
6547
  arg.setValue(attr.id, true);
6545
6548
  arg.tag = ExprTag.EntityAttribute;
6549
+ arg.kind = DataKind.Attribute;
6546
6550
  arg.dataType = attr.dataType;
6547
6551
  newColumn.expr.args.push(arg);
6548
6552
  }
6549
6553
  else {
6550
- newColumn.caption = attr.caption;
6551
6554
  newColumn.expr.setValue(attr.id, true);
6552
6555
  newColumn.expr.tag = ExprTag.EntityAttribute;
6556
+ newColumn.expr.kind = DataKind.Attribute;
6553
6557
  newColumn.expr.dataType = attr.dataType;
6558
+ newColumn.params.concat(attr.params);
6554
6559
  }
6555
- newColumn.caption = descriptor.caption || newColumn.caption;
6560
+ newColumn.caption = descriptor.caption || this.context.getDefaultColumnCaption(newColumn);
6556
6561
  newColumn._sorting = descriptor.sorting || SortDirection.None;
6557
6562
  newColumn._sortIndex = descriptor.sortIndex || -1;
6558
6563
  newColumn.enabled = public_api/* utils.getIfDefined */.P6.getIfDefined(descriptor.enabled, true);
@@ -6568,7 +6573,9 @@ var Query = /** @class */ (function () {
6568
6573
  }
6569
6574
  }
6570
6575
  this.setColumnSorting(newColumn, newColumn._sorting);
6571
- this.fireColumnsChangedEvent(QueryChangeAction.Add, newColumn, justsorted);
6576
+ if (!silent) {
6577
+ this.fireColumnsChangedEvent(QueryChangeAction.Add, newColumn, justsorted);
6578
+ }
6572
6579
  return newColumn;
6573
6580
  };
6574
6581
  /**
@@ -6622,9 +6629,6 @@ var Query = /** @class */ (function () {
6622
6629
  if (column.isJustSorted())
6623
6630
  return;
6624
6631
  args = args || {};
6625
- column.caption = (typeof args.caption !== 'undefined')
6626
- ? args.caption
6627
- : '';
6628
6632
  if (tag === ExprTag.AggregateFunction) {
6629
6633
  if (!args.funcId)
6630
6634
  throw Error('"funcId" argument is not defined');
@@ -6662,22 +6666,24 @@ var Query = /** @class */ (function () {
6662
6666
  || column.expr.tag === ExprTag.ParentEntityAttribute) {
6663
6667
  return;
6664
6668
  }
6665
- var exprId = (column.expr.tag === ExprTag.CustomSql)
6666
- ? column.expr.baseAttrId
6667
- : column.expr.args[0].value;
6668
- var attr = this.model.getAttributeById(exprId);
6669
+ var attrId = (column.expr.tag == ExprTag.AggregateFunction)
6670
+ ? column.expr.args[0].value
6671
+ : column.expr.baseAttrId;
6672
+ var attr = attrId
6673
+ ? this.model.getAttributeById(attrId)
6674
+ : this.model.getFirstUICAttr();
6669
6675
  var expr = new Expression(column);
6670
6676
  expr.tag = ExprTag.EntityAttribute;
6671
- expr.dataType = attr != null ? attr.dataType : public_api/* DataType.Unknown */.g.Unknown;
6672
- expr.setValue(exprId, true);
6677
+ expr.dataType = attr.dataType;
6678
+ expr.setValue(attr.id, true);
6673
6679
  column.expr = expr;
6674
6680
  }
6681
+ column.caption = this.context.getDefaultColumnCaption(column);
6675
6682
  };
6676
6683
  /**
6677
6684
  * Moves the column with specified index to another position.
6678
6685
  * @param index1 The index of the column that should be moved.
6679
6686
  * @param index2 The index of the position the column should be moved to
6680
- * @param author The author
6681
6687
  */
6682
6688
  Query.prototype.moveColumn = function (index1, index2) {
6683
6689
  var columns = this.getColumns();
@@ -6687,12 +6693,8 @@ var Query = /** @class */ (function () {
6687
6693
  /**
6688
6694
  * Removes the column.
6689
6695
  * @param column The column to be removed.
6690
- * @param author The author
6691
6696
  */
6692
- Query.prototype.removeColumn = function (column, author) {
6693
- // const columns = (column.isJustSorted())
6694
- // ? this.getJustSortedColumns()
6695
- // : this.getColumns();
6697
+ Query.prototype.removeColumn = function (column) {
6696
6698
  public_api/* utils.removeArrayItem */.P6.removeArrayItem(this.columns, column);
6697
6699
  public_api/* utils.removeArrayItem */.P6.removeArrayItem(this.sortedColumns, column);
6698
6700
  };
@@ -7806,13 +7808,6 @@ var InMemoryModelStorage = /** @class */ (function () {
7806
7808
  }());
7807
7809
 
7808
7810
 
7809
- ;// CONCATENATED MODULE: ./src/main/action.ts
7810
- var EqActionResult;
7811
- (function (EqActionResult) {
7812
- EqActionResult[EqActionResult["Error"] = 0] = "Error";
7813
- EqActionResult[EqActionResult["Success"] = 1] = "Success";
7814
- })(EqActionResult || (EqActionResult = {}));
7815
-
7816
7811
  ;// CONCATENATED MODULE: ./src/eqs/eqs_exporter.ts
7817
7812
 
7818
7813
  var EqServerExporter = /** @class */ (function () {
@@ -7874,6 +7869,13 @@ var EqServerExporter = /** @class */ (function () {
7874
7869
  }());
7875
7870
 
7876
7871
 
7872
+ ;// CONCATENATED MODULE: ./src/main/action.ts
7873
+ var EqActionResult;
7874
+ (function (EqActionResult) {
7875
+ EqActionResult[EqActionResult["Error"] = 0] = "Error";
7876
+ EqActionResult[EqActionResult["Success"] = 1] = "Success";
7877
+ })(EqActionResult || (EqActionResult = {}));
7878
+
7877
7879
  ;// CONCATENATED MODULE: ./src/main/context.ts
7878
7880
  var context_assign = (undefined && undefined.__assign) || function () {
7879
7881
  context_assign = Object.assign || function(t) {
@@ -7911,7 +7913,9 @@ var EqContext = /** @class */ (function () {
7911
7913
  function EqContext() {
7912
7914
  var _this = this;
7913
7915
  this.options = {
7914
- syncSortOrderWithColumnsOrder: true
7916
+ syncSortOrderWithColumnsOrder: true,
7917
+ attributeFormat: '{entity} {attr}',
7918
+ columnTitleFormat: null //means it will be the same as attributeFormat
7915
7919
  };
7916
7920
  this.servicesInitialized = false;
7917
7921
  this.internalListCache = {};
@@ -9330,6 +9334,37 @@ var EqContext = /** @class */ (function () {
9330
9334
  });
9331
9335
  }
9332
9336
  };
9337
+ EqContext.prototype.getAttributeTitle = function (attr) {
9338
+ var format = this.options.attributeFormat;
9339
+ return this.getModel().getAttributeText(attr, format);
9340
+ };
9341
+ EqContext.prototype.getColumnTitle = function (attr) {
9342
+ var format = this.options.columnTitleFormat || this.options.attributeFormat;
9343
+ return this.getModel().getAttributeText(attr, format);
9344
+ };
9345
+ EqContext.prototype.getDefaultColumnCaption = function (column) {
9346
+ var attr;
9347
+ var model = this.getModel();
9348
+ switch (column.expr.tag) {
9349
+ case ExprTag.Constant:
9350
+ return "Contant Column";
9351
+ case ExprTag.CustomSql:
9352
+ return "SQL Column";
9353
+ case ExprTag.ParentColumn:
9354
+ return "Parent Column";
9355
+ case ExprTag.Query:
9356
+ return "Query Column";
9357
+ case ExprTag.EntityAttribute:
9358
+ case ExprTag.ParentEntityAttribute:
9359
+ attr = model.getAttributeById(column.expr.value);
9360
+ return this.getColumnTitle(attr);
9361
+ case ExprTag.AggregateFunction:
9362
+ attr = model.getAttributeById(column.expr.args[0].value);
9363
+ return this.getColumnTitle(attr) + ' ' + model.getAggrFunctionCaption(column.expr.func);
9364
+ default:
9365
+ return 'Column';
9366
+ }
9367
+ };
9333
9368
  return EqContext;
9334
9369
  }());
9335
9370