@easyquery/core 7.2.4-beta03 → 7.2.4-rc01

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.
@@ -3170,6 +3170,7 @@ __webpack_require__.d(__webpack_exports__, {
3170
3170
  DataModel: () => (/* reexport */ DataModel),
3171
3171
  DefaultAggregatesCalculator: () => (/* reexport */ DefaultAggregatesCalculator),
3172
3172
  EasyQueryDataLoader: () => (/* reexport */ EasyQueryDataLoader),
3173
+ EmptyChunk: () => (/* reexport */ EmptyChunk),
3173
3174
  Entity: () => (/* reexport */ Entity),
3174
3175
  EntityAttr: () => (/* reexport */ EntityAttr),
3175
3176
  EqAction: () => (/* reexport */ EqAction),
@@ -3476,6 +3477,14 @@ var eqconsts;
3476
3477
  ];
3477
3478
  })(eqconsts || (eqconsts = {}));
3478
3479
 
3480
+ ;// CONCATENATED MODULE: ./src/export/exporter.ts
3481
+ //possibly move it to the EasyData lib on the next update
3482
+ var EmptyChunk = {
3483
+ offset: 0,
3484
+ limit: 0,
3485
+ needTotal: false
3486
+ };
3487
+
3479
3488
  ;// CONCATENATED MODULE: ./src/dm/aggr_function.ts
3480
3489
 
3481
3490
  /**
@@ -5062,12 +5071,14 @@ var QueryColumn = /** @class */ (function () {
5062
5071
  /** The parameters associated with this column */
5063
5072
  this.params = [];
5064
5073
  this._isHidden = false;
5074
+ this.query = query;
5065
5075
  this._id = public_api/* utils.generateId */.P6.generateId('col');
5066
5076
  this.caption = '';
5067
- this.sorting = SortDirection.None;
5068
- this.sortIndex = -1;
5077
+ this._sorting = SortDirection.None;
5078
+ this._sortIndex = -1;
5069
5079
  this.expr = new Expression(this);
5070
5080
  this.blockId = '';
5081
+ this.justsorted = justsorted;
5071
5082
  }
5072
5083
  Object.defineProperty(QueryColumn.prototype, "id", {
5073
5084
  get: function () {
@@ -5076,6 +5087,51 @@ var QueryColumn = /** @class */ (function () {
5076
5087
  enumerable: false,
5077
5088
  configurable: true
5078
5089
  });
5090
+ Object.defineProperty(QueryColumn.prototype, "sorting", {
5091
+ /** Column sorting direction */
5092
+ get: function () {
5093
+ if (this.query) {
5094
+ return this.query.getColumnSorting(this);
5095
+ }
5096
+ else {
5097
+ return this._sorting;
5098
+ }
5099
+ },
5100
+ set: function (direction) {
5101
+ if (this.query) {
5102
+ this.query.setColumnSorting(this, direction);
5103
+ }
5104
+ else {
5105
+ this._sorting = direction;
5106
+ }
5107
+ },
5108
+ enumerable: false,
5109
+ configurable: true
5110
+ });
5111
+ ;
5112
+ Object.defineProperty(QueryColumn.prototype, "sortIndex", {
5113
+ /** The index of the column in the sorting list. */
5114
+ get: function () {
5115
+ if (this.query) {
5116
+ return this.query.getColumnSortIndex(this);
5117
+ }
5118
+ else {
5119
+ return this._sortIndex;
5120
+ }
5121
+ },
5122
+ set: function (index) {
5123
+ if (this.query) {
5124
+ this.query.setColumnSortIndex(this, index);
5125
+ }
5126
+ else {
5127
+ this._sortIndex = index;
5128
+ }
5129
+ },
5130
+ enumerable: false,
5131
+ configurable: true
5132
+ });
5133
+ ;
5134
+ ;
5079
5135
  QueryColumn.prototype.getModel = function () {
5080
5136
  return this.query.getModel();
5081
5137
  };
@@ -5130,8 +5186,8 @@ var QueryColumn = /** @class */ (function () {
5130
5186
  }
5131
5187
  this.caption = colData.cptn;
5132
5188
  if (typeof colData.srt !== 'undefined') {
5133
- this.sorting = colData.srt;
5134
- this.sortIndex = (typeof colData.srtidx !== 'undefined')
5189
+ this._sorting = colData.srt;
5190
+ this._sortIndex = (typeof colData.srtidx !== 'undefined')
5135
5191
  ? colData.srtidx
5136
5192
  : -1;
5137
5193
  }
@@ -5157,7 +5213,7 @@ var QueryColumn = /** @class */ (function () {
5157
5213
  if (typeof this.caption !== 'undefined') {
5158
5214
  obj.cptn = this.caption;
5159
5215
  }
5160
- if (typeof this.sorting !== 'undefined' && this.sorting != SortDirection.None) {
5216
+ if (this.sorting != SortDirection.None) {
5161
5217
  obj.srt = this.sorting;
5162
5218
  obj.srtidx = this.sortIndex;
5163
5219
  }
@@ -5625,7 +5681,8 @@ var Query = /** @class */ (function () {
5625
5681
  this.root = new Condition(this, CondTag.Group);
5626
5682
  this.extraConditions = new Condition(this, CondTag.Group);
5627
5683
  this.columns = new Array();
5628
- this.justsorted = new Array();
5684
+ //this.justsorted = new Array<QueryColumn>();
5685
+ this.sortedColumns = new Array();
5629
5686
  if (!this.id) {
5630
5687
  this.regenerateId();
5631
5688
  }
@@ -5776,6 +5833,7 @@ var Query = /** @class */ (function () {
5776
5833
  });
5777
5834
  };
5778
5835
  Query.prototype.processQueryForAggregation = function (silent) {
5836
+ var _this = this;
5779
5837
  if (silent === void 0) { silent = false; }
5780
5838
  var aggrSettings = this.getAggregationSettings();
5781
5839
  var groups = aggrSettings.getGroups();
@@ -5789,19 +5847,21 @@ var Query = /** @class */ (function () {
5789
5847
  if (groupColIds.indexOf(col.id) >= 0) {
5790
5848
  groupedCols.push(col);
5791
5849
  }
5792
- else if (col.sorting != SortDirection.None) {
5850
+ else if (this.getColumnSorting(col) != SortDirection.None) {
5793
5851
  sortedCols.push(col);
5794
5852
  }
5795
5853
  }
5796
5854
  var sortIndex_1 = 0;
5797
5855
  groupedCols.forEach(function (col) {
5798
- if (col.sorting == SortDirection.None) {
5799
- col.sorting = SortDirection.Ascending;
5856
+ if (_this.getColumnSorting(col) == SortDirection.None) {
5857
+ _this.setColumnSorting(col, SortDirection.Ascending);
5800
5858
  }
5801
- col.sortIndex = sortIndex_1++;
5859
+ _this.setColumnSortIndex(col, sortIndex_1++);
5860
+ //col.sortIndex = sortIndex++;
5802
5861
  });
5803
5862
  sortedCols.forEach(function (col) {
5804
- col.sortIndex = sortIndex_1++;
5863
+ _this.setColumnSortIndex(col, sortIndex_1++);
5864
+ // col.sortIndex = sortIndex++;
5805
5865
  });
5806
5866
  if (!silent) {
5807
5867
  this.fireChangedEvent({
@@ -6032,12 +6092,14 @@ var Query = /** @class */ (function () {
6032
6092
  }
6033
6093
  this.name = data.name;
6034
6094
  this.description = data.desc;
6035
- this.justsorted = [];
6095
+ //this.justsorted = [];
6096
+ this.sortedColumns = [];
6036
6097
  if (data.justsortcols) {
6037
6098
  for (var i = 0; i < data.justsortcols.length; i++) {
6038
6099
  var newCol = this.createColumn(true);
6039
6100
  newCol.loadFromData(this.model, data.justsortcols[i]);
6040
- this.justsorted.push(newCol);
6101
+ //this.justsorted.push(newCol);
6102
+ this.addColumnToSorted(newCol);
6041
6103
  }
6042
6104
  }
6043
6105
  if (data.cols) {
@@ -6045,8 +6107,15 @@ var Query = /** @class */ (function () {
6045
6107
  var newCol = this.createColumn();
6046
6108
  newCol.loadFromData(this.model, data.cols[i]);
6047
6109
  this.columns.push(newCol);
6110
+ if (newCol._sorting != SortDirection.None) {
6111
+ this.addColumnToSorted(newCol);
6112
+ }
6048
6113
  }
6049
6114
  }
6115
+ this.sortedColumns.sort(function (col1, col2) {
6116
+ return col1.sortIndex - col2.sortIndex;
6117
+ });
6118
+ this.fixupSortingIndices();
6050
6119
  if (data.extraData) {
6051
6120
  this.extraData = data.extraData;
6052
6121
  }
@@ -6136,6 +6205,7 @@ var Query = /** @class */ (function () {
6136
6205
  */
6137
6206
  Query.prototype.toJSONData = function () {
6138
6207
  var _this = this;
6208
+ this.fixupSortingIndices();
6139
6209
  var obj = {
6140
6210
  modelId: this.model ? this.model.getId() : null,
6141
6211
  modelName: this.model ? this.model.getName() : null
@@ -6150,9 +6220,14 @@ var Query = /** @class */ (function () {
6150
6220
  obj.cols.push(this.columns[i].saveToData());
6151
6221
  }
6152
6222
  obj.justsortcols = [];
6153
- for (var i = 0; i < this.justsorted.length; i++) {
6154
- obj.justsortcols.push(this.justsorted[i].saveToData());
6155
- }
6223
+ // for (let i = 0; i < this.justsorted.length; i++) {
6224
+ // obj.justsortcols.push(this.justsorted[i].saveToData());
6225
+ // }
6226
+ this.sortedColumns.forEach(function (col) {
6227
+ if (col.isJustSorted()) {
6228
+ obj.justsortcols.push(col.saveToData());
6229
+ }
6230
+ });
6156
6231
  if (this.extraData) {
6157
6232
  obj.extraData = this.extraData;
6158
6233
  }
@@ -6225,7 +6300,8 @@ var Query = /** @class */ (function () {
6225
6300
  */
6226
6301
  Query.prototype.clearColumns = function () {
6227
6302
  this.columns = [];
6228
- this.justsorted = [];
6303
+ //this.justsorted = [];
6304
+ this.sortedColumns = [];
6229
6305
  };
6230
6306
  /**
6231
6307
  * Clears all conditions in query.
@@ -6317,31 +6393,34 @@ var Query = /** @class */ (function () {
6317
6393
  cols.pop();
6318
6394
  return cols;
6319
6395
  };
6396
+ Query.prototype.addColumnToSorted = function (col) {
6397
+ var colJson = JSON.stringify(col.expr.saveToData());
6398
+ var isUnique = true;
6399
+ this.sortedColumns.forEach(function (scol) {
6400
+ var qcolJson = JSON.stringify(scol.expr.saveToData());
6401
+ if (qcolJson === colJson) {
6402
+ isUnique = false;
6403
+ }
6404
+ });
6405
+ if (isUnique) {
6406
+ this.sortedColumns.push(col);
6407
+ }
6408
+ };
6320
6409
  /**
6321
6410
  * Get array of columns used only in sorting.
6322
6411
  * @retruns Columns.
6323
6412
  */
6324
6413
  Query.prototype.getJustSortedColumns = function () {
6325
- return this.justsorted;
6414
+ return this.sortedColumns.filter(function (col) {
6415
+ return col.isJustSorted();
6416
+ });
6326
6417
  };
6327
6418
  /**
6328
6419
  * Gets array of columns used in sorting
6329
6420
  * @retruns Columns
6330
6421
  */
6331
6422
  Query.prototype.getSortedColumns = function () {
6332
- var sortedCols = new Array();
6333
- var cols = this.getColumns()
6334
- .concat(this.getJustSortedColumns());
6335
- for (var i = 0; i < cols.length; i++) {
6336
- var col = cols[i];
6337
- if (col.sortIndex >= 0) {
6338
- sortedCols.push(col);
6339
- }
6340
- }
6341
- sortedCols.sort(function (col1, col2) {
6342
- return col1.sortIndex - col2.sortIndex;
6343
- });
6344
- return sortedCols;
6423
+ return this.sortedColumns;
6345
6424
  };
6346
6425
  /**
6347
6426
  * Gets Colummn sorting index.
@@ -6349,17 +6428,48 @@ var Query = /** @class */ (function () {
6349
6428
  * @retruns The index.
6350
6429
  */
6351
6430
  Query.prototype.getColumnSortIndex = function (col) {
6352
- if (col.sorting != SortDirection.None) {
6353
- if (col.sortIndex < 0) {
6354
- var cols = this.getColumns()
6355
- .concat(this.getJustSortedColumns());
6356
- return public_api/* utils.indexOfArrayItem */.P6.indexOfArrayItem(cols, col);
6431
+ return this.sortedColumns.indexOf(col);
6432
+ };
6433
+ Query.prototype.setColumnSortIndex = function (col, index) {
6434
+ if (index < 0)
6435
+ return;
6436
+ var colIdx = this.getColumnSortIndex(col);
6437
+ if (colIdx < 0) {
6438
+ this.addColumnToSorted(col);
6439
+ colIdx = this.sortedColumns.length - 1;
6440
+ }
6441
+ public_api/* utils.moveArrayItem */.P6.moveArrayItem(this.sortedColumns, colIdx, index);
6442
+ this.fixupSortingIndices();
6443
+ };
6444
+ Query.prototype.getColumnSorting = function (col) {
6445
+ var idx = this.getColumnSortIndex(col);
6446
+ if (idx >= 0) {
6447
+ return col._sorting != SortDirection.None ? col._sorting : SortDirection.Ascending;
6448
+ }
6449
+ else {
6450
+ return SortDirection.None;
6451
+ }
6452
+ };
6453
+ Query.prototype.setColumnSorting = function (col, direction) {
6454
+ var idx = this.getColumnSortIndex(col);
6455
+ col._sorting = direction;
6456
+ if (idx >= 0) {
6457
+ if (direction == SortDirection.None) {
6458
+ public_api/* utils.removeArrayItem */.P6.removeArrayItem(this.sortedColumns, col);
6459
+ this.fixupSortingIndices();
6357
6460
  }
6358
- else {
6359
- return col.sortIndex;
6461
+ }
6462
+ else {
6463
+ if (direction != SortDirection.None) {
6464
+ this.addColumnToSorted(col);
6465
+ this.fixupSortingIndices();
6360
6466
  }
6361
6467
  }
6362
- return -1;
6468
+ };
6469
+ Query.prototype.fixupSortingIndices = function () {
6470
+ this.sortedColumns.forEach(function (col, index) {
6471
+ col._sortIndex = index;
6472
+ });
6363
6473
  };
6364
6474
  Query.prototype.createColumn = function (justsorted) {
6365
6475
  if (justsorted === void 0) { justsorted = false; }
@@ -6384,9 +6494,9 @@ var Query = /** @class */ (function () {
6384
6494
  * }});
6385
6495
  */
6386
6496
  Query.prototype.addColumn = function (descriptor, author) {
6387
- var columns = (descriptor.justsorted)
6388
- ? this.justsorted
6389
- : this.columns;
6497
+ // let columns = (descriptor.justsorted)
6498
+ // ? this.justsorted
6499
+ // : this.columns;
6390
6500
  var newColumn;
6391
6501
  if (descriptor.column) {
6392
6502
  newColumn = descriptor.column;
@@ -6448,17 +6558,22 @@ var Query = /** @class */ (function () {
6448
6558
  newColumn.expr.dataType = attr.dataType;
6449
6559
  }
6450
6560
  newColumn.caption = descriptor.caption || newColumn.caption;
6451
- newColumn.sorting = descriptor.sorting || SortDirection.None;
6452
- newColumn.sortIndex = descriptor.sortIndex || -1;
6561
+ newColumn._sorting = descriptor.sorting || SortDirection.None;
6562
+ newColumn._sortIndex = descriptor.sortIndex || -1;
6453
6563
  newColumn.enabled = public_api/* utils.getIfDefined */.P6.getIfDefined(descriptor.enabled, true);
6454
6564
  newColumn.setReadOnly(public_api/* utils.getIfDefined */.P6.getIfDefined(descriptor.readonly, false));
6455
6565
  }
6456
- if (descriptor.index && descriptor.index >= 0 && descriptor.index < columns.length) {
6457
- columns.splice(descriptor.index, 0, newColumn);
6458
- }
6459
- else {
6460
- columns.push(newColumn);
6566
+ var justsorted = descriptor.justsorted || (descriptor.column && descriptor.column.isJustSorted());
6567
+ if (!justsorted) {
6568
+ if (descriptor.index && descriptor.index >= 0 && descriptor.index < this.columns.length) {
6569
+ this.columns.splice(descriptor.index, 0, newColumn);
6570
+ }
6571
+ else {
6572
+ this.columns.push(newColumn);
6573
+ }
6461
6574
  }
6575
+ this.setColumnSorting(newColumn, newColumn._sorting);
6576
+ this.fireColumnsChangedEvent(QueryChangeAction.Add, newColumn, justsorted);
6462
6577
  return newColumn;
6463
6578
  };
6464
6579
  /**
@@ -6473,6 +6588,7 @@ var Query = /** @class */ (function () {
6473
6588
  * query.addColumn(column, 1)
6474
6589
  */
6475
6590
  Query.prototype.addColumnObj = function (column, index, author) {
6591
+ var _this = this;
6476
6592
  var columns = this.columns;
6477
6593
  if (typeof column.length == "undefined") {
6478
6594
  if (typeof index == "number") {
@@ -6481,6 +6597,10 @@ var Query = /** @class */ (function () {
6481
6597
  else {
6482
6598
  columns.push(column);
6483
6599
  }
6600
+ if (column.sorting != SortDirection.None) {
6601
+ this.addColumnToSorted(column);
6602
+ }
6603
+ this.fixupSortingIndices();
6484
6604
  }
6485
6605
  else {
6486
6606
  if (typeof index == "number") {
@@ -6489,6 +6609,12 @@ var Query = /** @class */ (function () {
6489
6609
  else {
6490
6610
  columns.push.apply(columns, [].concat(column));
6491
6611
  }
6612
+ column.forEach(function (col) {
6613
+ if (col.sorting != SortDirection.None) {
6614
+ _this.addColumnToSorted(col);
6615
+ }
6616
+ });
6617
+ this.fixupSortingIndices();
6492
6618
  }
6493
6619
  };
6494
6620
  /**
@@ -6568,10 +6694,11 @@ var Query = /** @class */ (function () {
6568
6694
  * @param author The author
6569
6695
  */
6570
6696
  Query.prototype.removeColumn = function (column, author) {
6571
- var columns = (column.isJustSorted())
6572
- ? this.getJustSortedColumns()
6573
- : this.getColumns();
6574
- public_api/* utils.removeArrayItem */.P6.removeArrayItem(columns, column);
6697
+ // const columns = (column.isJustSorted())
6698
+ // ? this.getJustSortedColumns()
6699
+ // : this.getColumns();
6700
+ public_api/* utils.removeArrayItem */.P6.removeArrayItem(this.columns, column);
6701
+ public_api/* utils.removeArrayItem */.P6.removeArrayItem(this.sortedColumns, column);
6575
6702
  };
6576
6703
  /**
6577
6704
  * Adds a condition group - a group of simple conditions (predicates) linked by AND or OR
@@ -6677,10 +6804,13 @@ var Query = /** @class */ (function () {
6677
6804
  }
6678
6805
  if (columns.length > 0) {
6679
6806
  removeFromArray(this.getColumns(), columns);
6807
+ removeFromArray(this.sortedColumns, columns);
6680
6808
  }
6681
6809
  if (justSortedColumns.length > 0) {
6682
- removeFromArray(this.getJustSortedColumns(), justSortedColumns);
6810
+ //removeFromArray(this.getJustSortedColumns(), justSortedColumns);
6811
+ removeFromArray(this.sortedColumns, justSortedColumns);
6683
6812
  }
6813
+ this.fixupSortingIndices();
6684
6814
  };
6685
6815
  /**
6686
6816
  * Fires process event.
@@ -7257,7 +7387,7 @@ var EqQueryFileLoader = /** @class */ (function () {
7257
7387
  });
7258
7388
  var request = actionResult.getRequest();
7259
7389
  return actionResult.then(function (responseData) {
7260
- var blob = new Blob([JSON.stringify(responseData)]);
7390
+ var blob = new Blob([responseData]);
7261
7391
  var dispositionHeader = request.getXMLHttpRequest().getResponseHeader("Content-Disposition");
7262
7392
  var fileName = dispositionHeader
7263
7393
  ? dispositionHeader.match(/filename="(.*)"/)[1]
@@ -7686,6 +7816,7 @@ var EqActionResult;
7686
7816
  })(EqActionResult || (EqActionResult = {}));
7687
7817
 
7688
7818
  ;// CONCATENATED MODULE: ./src/eqs/eqs_exporter.ts
7819
+
7689
7820
  var EqServerExporter = /** @class */ (function () {
7690
7821
  function EqServerExporter(context) {
7691
7822
  this.context = context;
@@ -7701,7 +7832,8 @@ var EqServerExporter = /** @class */ (function () {
7701
7832
  var query = exportOptions.query || this.context.getQuery();
7702
7833
  var modelId = query.getModel().getId();
7703
7834
  var requestData = {
7704
- 'settings': exportOptions.settings
7835
+ 'settings': exportOptions.settings,
7836
+ 'chunk': EmptyChunk
7705
7837
  };
7706
7838
  if (typeof (exportOptions.queryId) !== 'undefined') {
7707
7839
  requestData.queryId = exportOptions.queryId;
@@ -7766,6 +7898,8 @@ var context_assign = (undefined && undefined.__assign) || function () {
7766
7898
 
7767
7899
 
7768
7900
 
7901
+
7902
+
7769
7903
  /**
7770
7904
  * Encapsulates all information about EasyQuery components on some webpage
7771
7905
  * and provides some basic operation over those components
@@ -7778,6 +7912,7 @@ var context_assign = (undefined && undefined.__assign) || function () {
7778
7912
  var EqContext = /** @class */ (function () {
7779
7913
  function EqContext() {
7780
7914
  var _this = this;
7915
+ this.options = {};
7781
7916
  this.servicesInitialized = false;
7782
7917
  this.internalListCache = {};
7783
7918
  this.loadModelOnStart = true;
@@ -7971,6 +8106,7 @@ var EqContext = /** @class */ (function () {
7971
8106
  if (!this.servicesInitialized)
7972
8107
  this.initStart();
7973
8108
  options = options || {};
8109
+ this.setOptions(options);
7974
8110
  if (typeof (options.debugMode) !== 'undefined') {
7975
8111
  this.debugMode = options.debugMode;
7976
8112
  }
@@ -8092,6 +8228,9 @@ var EqContext = /** @class */ (function () {
8092
8228
  this.fireEvent('ready');
8093
8229
  }
8094
8230
  };
8231
+ EqContext.prototype.setOptions = function (options) {
8232
+ public_api/* utils.assignDeep */.P6.assignDeep(this.options, options);
8233
+ };
8095
8234
  Object.defineProperty(EqContext.prototype, "backendInfo", {
8096
8235
  get: function () {
8097
8236
  return this._backendInfo;
@@ -8549,6 +8688,7 @@ var EqContext = /** @class */ (function () {
8549
8688
  validate: false
8550
8689
  });
8551
8690
  }
8691
+ _this.limitCustomSqlColumns();
8552
8692
  _this.fireEvent('loadQuery');
8553
8693
  _this.endProcess({
8554
8694
  result: EqActionResult.Success,
@@ -9132,6 +9272,7 @@ var EqContext = /** @class */ (function () {
9132
9272
  EqContext.prototype.exportResult = function (options) {
9133
9273
  var _this = this;
9134
9274
  options = options || {};
9275
+ options.chunk = options.chunk || EmptyChunk;
9135
9276
  if (this.beforeExportResult) {
9136
9277
  this.beforeExportResult(this, options);
9137
9278
  }
@@ -9181,6 +9322,15 @@ var EqContext = /** @class */ (function () {
9181
9322
  }
9182
9323
  }
9183
9324
  };
9325
+ EqContext.prototype.limitCustomSqlColumns = function () {
9326
+ if (!this.options.allowCustomExpressions) {
9327
+ this.query.getColumns().forEach(function (col) {
9328
+ if (col.expr.tag === ExprTag.CustomSql) {
9329
+ col.enabled = false;
9330
+ }
9331
+ });
9332
+ }
9333
+ };
9184
9334
  return EqContext;
9185
9335
  }());
9186
9336