@easyquery/enterprise 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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * EasyQuery.JS Enterprise 7.2.4-beta03 (https://korzh.com/easyquery/javascript)
2
+ * EasyQuery.JS Enterprise 7.2.4-rc01 (https://korzh.com/easyquery/javascript)
3
3
  * Copyright 2023 Korzh.com. All rights reserved.
4
4
  *
5
5
  * EasyQuery.JS commercial licenses may be obtained at
@@ -13092,6 +13092,7 @@ __webpack_require__.d(public_api_namespaceObject, {
13092
13092
  DataModel: () => (DataModel),
13093
13093
  DefaultAggregatesCalculator: () => (DefaultAggregatesCalculator),
13094
13094
  EasyQueryDataLoader: () => (EasyQueryDataLoader),
13095
+ EmptyChunk: () => (EmptyChunk),
13095
13096
  Entity: () => (Entity),
13096
13097
  EntityAttr: () => (EntityAttr),
13097
13098
  EqAction: () => (EqAction),
@@ -13480,6 +13481,14 @@ var eqconsts;
13480
13481
  ];
13481
13482
  })(eqconsts || (eqconsts = {}));
13482
13483
  //# sourceMappingURL=constants.js.map
13484
+ ;// CONCATENATED MODULE: ../core/dist/lib/export/exporter.js
13485
+ //possibly move it to the EasyData lib on the next update
13486
+ var EmptyChunk = {
13487
+ offset: 0,
13488
+ limit: 0,
13489
+ needTotal: false
13490
+ };
13491
+ //# sourceMappingURL=exporter.js.map
13483
13492
  ;// CONCATENATED MODULE: ../core/dist/lib/dm/aggr_function.js
13484
13493
 
13485
13494
  /**
@@ -15066,12 +15075,14 @@ var QueryColumn = /** @class */ (function () {
15066
15075
  /** The parameters associated with this column */
15067
15076
  this.params = [];
15068
15077
  this._isHidden = false;
15078
+ this.query = query;
15069
15079
  this._id = public_api.utils.generateId('col');
15070
15080
  this.caption = '';
15071
- this.sorting = SortDirection.None;
15072
- this.sortIndex = -1;
15081
+ this._sorting = SortDirection.None;
15082
+ this._sortIndex = -1;
15073
15083
  this.expr = new Expression(this);
15074
15084
  this.blockId = '';
15085
+ this.justsorted = justsorted;
15075
15086
  }
15076
15087
  Object.defineProperty(QueryColumn.prototype, "id", {
15077
15088
  get: function () {
@@ -15080,6 +15091,51 @@ var QueryColumn = /** @class */ (function () {
15080
15091
  enumerable: false,
15081
15092
  configurable: true
15082
15093
  });
15094
+ Object.defineProperty(QueryColumn.prototype, "sorting", {
15095
+ /** Column sorting direction */
15096
+ get: function () {
15097
+ if (this.query) {
15098
+ return this.query.getColumnSorting(this);
15099
+ }
15100
+ else {
15101
+ return this._sorting;
15102
+ }
15103
+ },
15104
+ set: function (direction) {
15105
+ if (this.query) {
15106
+ this.query.setColumnSorting(this, direction);
15107
+ }
15108
+ else {
15109
+ this._sorting = direction;
15110
+ }
15111
+ },
15112
+ enumerable: false,
15113
+ configurable: true
15114
+ });
15115
+ ;
15116
+ Object.defineProperty(QueryColumn.prototype, "sortIndex", {
15117
+ /** The index of the column in the sorting list. */
15118
+ get: function () {
15119
+ if (this.query) {
15120
+ return this.query.getColumnSortIndex(this);
15121
+ }
15122
+ else {
15123
+ return this._sortIndex;
15124
+ }
15125
+ },
15126
+ set: function (index) {
15127
+ if (this.query) {
15128
+ this.query.setColumnSortIndex(this, index);
15129
+ }
15130
+ else {
15131
+ this._sortIndex = index;
15132
+ }
15133
+ },
15134
+ enumerable: false,
15135
+ configurable: true
15136
+ });
15137
+ ;
15138
+ ;
15083
15139
  QueryColumn.prototype.getModel = function () {
15084
15140
  return this.query.getModel();
15085
15141
  };
@@ -15134,8 +15190,8 @@ var QueryColumn = /** @class */ (function () {
15134
15190
  }
15135
15191
  this.caption = colData.cptn;
15136
15192
  if (typeof colData.srt !== 'undefined') {
15137
- this.sorting = colData.srt;
15138
- this.sortIndex = (typeof colData.srtidx !== 'undefined')
15193
+ this._sorting = colData.srt;
15194
+ this._sortIndex = (typeof colData.srtidx !== 'undefined')
15139
15195
  ? colData.srtidx
15140
15196
  : -1;
15141
15197
  }
@@ -15161,7 +15217,7 @@ var QueryColumn = /** @class */ (function () {
15161
15217
  if (typeof this.caption !== 'undefined') {
15162
15218
  obj.cptn = this.caption;
15163
15219
  }
15164
- if (typeof this.sorting !== 'undefined' && this.sorting != SortDirection.None) {
15220
+ if (this.sorting != SortDirection.None) {
15165
15221
  obj.srt = this.sorting;
15166
15222
  obj.srtidx = this.sortIndex;
15167
15223
  }
@@ -15629,7 +15685,8 @@ var Query = /** @class */ (function () {
15629
15685
  this.root = new Condition(this, CondTag.Group);
15630
15686
  this.extraConditions = new Condition(this, CondTag.Group);
15631
15687
  this.columns = new Array();
15632
- this.justsorted = new Array();
15688
+ //this.justsorted = new Array<QueryColumn>();
15689
+ this.sortedColumns = new Array();
15633
15690
  if (!this.id) {
15634
15691
  this.regenerateId();
15635
15692
  }
@@ -15780,6 +15837,7 @@ var Query = /** @class */ (function () {
15780
15837
  });
15781
15838
  };
15782
15839
  Query.prototype.processQueryForAggregation = function (silent) {
15840
+ var _this = this;
15783
15841
  if (silent === void 0) { silent = false; }
15784
15842
  var aggrSettings = this.getAggregationSettings();
15785
15843
  var groups = aggrSettings.getGroups();
@@ -15793,19 +15851,21 @@ var Query = /** @class */ (function () {
15793
15851
  if (groupColIds.indexOf(col.id) >= 0) {
15794
15852
  groupedCols.push(col);
15795
15853
  }
15796
- else if (col.sorting != SortDirection.None) {
15854
+ else if (this.getColumnSorting(col) != SortDirection.None) {
15797
15855
  sortedCols.push(col);
15798
15856
  }
15799
15857
  }
15800
15858
  var sortIndex_1 = 0;
15801
15859
  groupedCols.forEach(function (col) {
15802
- if (col.sorting == SortDirection.None) {
15803
- col.sorting = SortDirection.Ascending;
15860
+ if (_this.getColumnSorting(col) == SortDirection.None) {
15861
+ _this.setColumnSorting(col, SortDirection.Ascending);
15804
15862
  }
15805
- col.sortIndex = sortIndex_1++;
15863
+ _this.setColumnSortIndex(col, sortIndex_1++);
15864
+ //col.sortIndex = sortIndex++;
15806
15865
  });
15807
15866
  sortedCols.forEach(function (col) {
15808
- col.sortIndex = sortIndex_1++;
15867
+ _this.setColumnSortIndex(col, sortIndex_1++);
15868
+ // col.sortIndex = sortIndex++;
15809
15869
  });
15810
15870
  if (!silent) {
15811
15871
  this.fireChangedEvent({
@@ -16036,12 +16096,14 @@ var Query = /** @class */ (function () {
16036
16096
  }
16037
16097
  this.name = data.name;
16038
16098
  this.description = data.desc;
16039
- this.justsorted = [];
16099
+ //this.justsorted = [];
16100
+ this.sortedColumns = [];
16040
16101
  if (data.justsortcols) {
16041
16102
  for (var i = 0; i < data.justsortcols.length; i++) {
16042
16103
  var newCol = this.createColumn(true);
16043
16104
  newCol.loadFromData(this.model, data.justsortcols[i]);
16044
- this.justsorted.push(newCol);
16105
+ //this.justsorted.push(newCol);
16106
+ this.addColumnToSorted(newCol);
16045
16107
  }
16046
16108
  }
16047
16109
  if (data.cols) {
@@ -16049,8 +16111,15 @@ var Query = /** @class */ (function () {
16049
16111
  var newCol = this.createColumn();
16050
16112
  newCol.loadFromData(this.model, data.cols[i]);
16051
16113
  this.columns.push(newCol);
16114
+ if (newCol._sorting != SortDirection.None) {
16115
+ this.addColumnToSorted(newCol);
16116
+ }
16052
16117
  }
16053
16118
  }
16119
+ this.sortedColumns.sort(function (col1, col2) {
16120
+ return col1.sortIndex - col2.sortIndex;
16121
+ });
16122
+ this.fixupSortingIndices();
16054
16123
  if (data.extraData) {
16055
16124
  this.extraData = data.extraData;
16056
16125
  }
@@ -16140,6 +16209,7 @@ var Query = /** @class */ (function () {
16140
16209
  */
16141
16210
  Query.prototype.toJSONData = function () {
16142
16211
  var _this = this;
16212
+ this.fixupSortingIndices();
16143
16213
  var obj = {
16144
16214
  modelId: this.model ? this.model.getId() : null,
16145
16215
  modelName: this.model ? this.model.getName() : null
@@ -16154,9 +16224,14 @@ var Query = /** @class */ (function () {
16154
16224
  obj.cols.push(this.columns[i].saveToData());
16155
16225
  }
16156
16226
  obj.justsortcols = [];
16157
- for (var i = 0; i < this.justsorted.length; i++) {
16158
- obj.justsortcols.push(this.justsorted[i].saveToData());
16159
- }
16227
+ // for (let i = 0; i < this.justsorted.length; i++) {
16228
+ // obj.justsortcols.push(this.justsorted[i].saveToData());
16229
+ // }
16230
+ this.sortedColumns.forEach(function (col) {
16231
+ if (col.isJustSorted()) {
16232
+ obj.justsortcols.push(col.saveToData());
16233
+ }
16234
+ });
16160
16235
  if (this.extraData) {
16161
16236
  obj.extraData = this.extraData;
16162
16237
  }
@@ -16229,7 +16304,8 @@ var Query = /** @class */ (function () {
16229
16304
  */
16230
16305
  Query.prototype.clearColumns = function () {
16231
16306
  this.columns = [];
16232
- this.justsorted = [];
16307
+ //this.justsorted = [];
16308
+ this.sortedColumns = [];
16233
16309
  };
16234
16310
  /**
16235
16311
  * Clears all conditions in query.
@@ -16321,31 +16397,34 @@ var Query = /** @class */ (function () {
16321
16397
  cols.pop();
16322
16398
  return cols;
16323
16399
  };
16400
+ Query.prototype.addColumnToSorted = function (col) {
16401
+ var colJson = JSON.stringify(col.expr.saveToData());
16402
+ var isUnique = true;
16403
+ this.sortedColumns.forEach(function (scol) {
16404
+ var qcolJson = JSON.stringify(scol.expr.saveToData());
16405
+ if (qcolJson === colJson) {
16406
+ isUnique = false;
16407
+ }
16408
+ });
16409
+ if (isUnique) {
16410
+ this.sortedColumns.push(col);
16411
+ }
16412
+ };
16324
16413
  /**
16325
16414
  * Get array of columns used only in sorting.
16326
16415
  * @retruns Columns.
16327
16416
  */
16328
16417
  Query.prototype.getJustSortedColumns = function () {
16329
- return this.justsorted;
16418
+ return this.sortedColumns.filter(function (col) {
16419
+ return col.isJustSorted();
16420
+ });
16330
16421
  };
16331
16422
  /**
16332
16423
  * Gets array of columns used in sorting
16333
16424
  * @retruns Columns
16334
16425
  */
16335
16426
  Query.prototype.getSortedColumns = function () {
16336
- var sortedCols = new Array();
16337
- var cols = this.getColumns()
16338
- .concat(this.getJustSortedColumns());
16339
- for (var i = 0; i < cols.length; i++) {
16340
- var col = cols[i];
16341
- if (col.sortIndex >= 0) {
16342
- sortedCols.push(col);
16343
- }
16344
- }
16345
- sortedCols.sort(function (col1, col2) {
16346
- return col1.sortIndex - col2.sortIndex;
16347
- });
16348
- return sortedCols;
16427
+ return this.sortedColumns;
16349
16428
  };
16350
16429
  /**
16351
16430
  * Gets Colummn sorting index.
@@ -16353,17 +16432,48 @@ var Query = /** @class */ (function () {
16353
16432
  * @retruns The index.
16354
16433
  */
16355
16434
  Query.prototype.getColumnSortIndex = function (col) {
16356
- if (col.sorting != SortDirection.None) {
16357
- if (col.sortIndex < 0) {
16358
- var cols = this.getColumns()
16359
- .concat(this.getJustSortedColumns());
16360
- return public_api.utils.indexOfArrayItem(cols, col);
16435
+ return this.sortedColumns.indexOf(col);
16436
+ };
16437
+ Query.prototype.setColumnSortIndex = function (col, index) {
16438
+ if (index < 0)
16439
+ return;
16440
+ var colIdx = this.getColumnSortIndex(col);
16441
+ if (colIdx < 0) {
16442
+ this.addColumnToSorted(col);
16443
+ colIdx = this.sortedColumns.length - 1;
16444
+ }
16445
+ public_api.utils.moveArrayItem(this.sortedColumns, colIdx, index);
16446
+ this.fixupSortingIndices();
16447
+ };
16448
+ Query.prototype.getColumnSorting = function (col) {
16449
+ var idx = this.getColumnSortIndex(col);
16450
+ if (idx >= 0) {
16451
+ return col._sorting != SortDirection.None ? col._sorting : SortDirection.Ascending;
16452
+ }
16453
+ else {
16454
+ return SortDirection.None;
16455
+ }
16456
+ };
16457
+ Query.prototype.setColumnSorting = function (col, direction) {
16458
+ var idx = this.getColumnSortIndex(col);
16459
+ col._sorting = direction;
16460
+ if (idx >= 0) {
16461
+ if (direction == SortDirection.None) {
16462
+ public_api.utils.removeArrayItem(this.sortedColumns, col);
16463
+ this.fixupSortingIndices();
16361
16464
  }
16362
- else {
16363
- return col.sortIndex;
16465
+ }
16466
+ else {
16467
+ if (direction != SortDirection.None) {
16468
+ this.addColumnToSorted(col);
16469
+ this.fixupSortingIndices();
16364
16470
  }
16365
16471
  }
16366
- return -1;
16472
+ };
16473
+ Query.prototype.fixupSortingIndices = function () {
16474
+ this.sortedColumns.forEach(function (col, index) {
16475
+ col._sortIndex = index;
16476
+ });
16367
16477
  };
16368
16478
  Query.prototype.createColumn = function (justsorted) {
16369
16479
  if (justsorted === void 0) { justsorted = false; }
@@ -16388,9 +16498,9 @@ var Query = /** @class */ (function () {
16388
16498
  * }});
16389
16499
  */
16390
16500
  Query.prototype.addColumn = function (descriptor, author) {
16391
- var columns = (descriptor.justsorted)
16392
- ? this.justsorted
16393
- : this.columns;
16501
+ // let columns = (descriptor.justsorted)
16502
+ // ? this.justsorted
16503
+ // : this.columns;
16394
16504
  var newColumn;
16395
16505
  if (descriptor.column) {
16396
16506
  newColumn = descriptor.column;
@@ -16452,17 +16562,22 @@ var Query = /** @class */ (function () {
16452
16562
  newColumn.expr.dataType = attr.dataType;
16453
16563
  }
16454
16564
  newColumn.caption = descriptor.caption || newColumn.caption;
16455
- newColumn.sorting = descriptor.sorting || SortDirection.None;
16456
- newColumn.sortIndex = descriptor.sortIndex || -1;
16565
+ newColumn._sorting = descriptor.sorting || SortDirection.None;
16566
+ newColumn._sortIndex = descriptor.sortIndex || -1;
16457
16567
  newColumn.enabled = public_api.utils.getIfDefined(descriptor.enabled, true);
16458
16568
  newColumn.setReadOnly(public_api.utils.getIfDefined(descriptor.readonly, false));
16459
16569
  }
16460
- if (descriptor.index && descriptor.index >= 0 && descriptor.index < columns.length) {
16461
- columns.splice(descriptor.index, 0, newColumn);
16462
- }
16463
- else {
16464
- columns.push(newColumn);
16570
+ var justsorted = descriptor.justsorted || (descriptor.column && descriptor.column.isJustSorted());
16571
+ if (!justsorted) {
16572
+ if (descriptor.index && descriptor.index >= 0 && descriptor.index < this.columns.length) {
16573
+ this.columns.splice(descriptor.index, 0, newColumn);
16574
+ }
16575
+ else {
16576
+ this.columns.push(newColumn);
16577
+ }
16465
16578
  }
16579
+ this.setColumnSorting(newColumn, newColumn._sorting);
16580
+ this.fireColumnsChangedEvent(QueryChangeAction.Add, newColumn, justsorted);
16466
16581
  return newColumn;
16467
16582
  };
16468
16583
  /**
@@ -16477,6 +16592,7 @@ var Query = /** @class */ (function () {
16477
16592
  * query.addColumn(column, 1)
16478
16593
  */
16479
16594
  Query.prototype.addColumnObj = function (column, index, author) {
16595
+ var _this = this;
16480
16596
  var columns = this.columns;
16481
16597
  if (typeof column.length == "undefined") {
16482
16598
  if (typeof index == "number") {
@@ -16485,6 +16601,10 @@ var Query = /** @class */ (function () {
16485
16601
  else {
16486
16602
  columns.push(column);
16487
16603
  }
16604
+ if (column.sorting != SortDirection.None) {
16605
+ this.addColumnToSorted(column);
16606
+ }
16607
+ this.fixupSortingIndices();
16488
16608
  }
16489
16609
  else {
16490
16610
  if (typeof index == "number") {
@@ -16493,6 +16613,12 @@ var Query = /** @class */ (function () {
16493
16613
  else {
16494
16614
  columns.push.apply(columns, [].concat(column));
16495
16615
  }
16616
+ column.forEach(function (col) {
16617
+ if (col.sorting != SortDirection.None) {
16618
+ _this.addColumnToSorted(col);
16619
+ }
16620
+ });
16621
+ this.fixupSortingIndices();
16496
16622
  }
16497
16623
  };
16498
16624
  /**
@@ -16572,10 +16698,11 @@ var Query = /** @class */ (function () {
16572
16698
  * @param author The author
16573
16699
  */
16574
16700
  Query.prototype.removeColumn = function (column, author) {
16575
- var columns = (column.isJustSorted())
16576
- ? this.getJustSortedColumns()
16577
- : this.getColumns();
16578
- public_api.utils.removeArrayItem(columns, column);
16701
+ // const columns = (column.isJustSorted())
16702
+ // ? this.getJustSortedColumns()
16703
+ // : this.getColumns();
16704
+ public_api.utils.removeArrayItem(this.columns, column);
16705
+ public_api.utils.removeArrayItem(this.sortedColumns, column);
16579
16706
  };
16580
16707
  /**
16581
16708
  * Adds a condition group - a group of simple conditions (predicates) linked by AND or OR
@@ -16681,10 +16808,13 @@ var Query = /** @class */ (function () {
16681
16808
  }
16682
16809
  if (columns.length > 0) {
16683
16810
  removeFromArray(this.getColumns(), columns);
16811
+ removeFromArray(this.sortedColumns, columns);
16684
16812
  }
16685
16813
  if (justSortedColumns.length > 0) {
16686
- removeFromArray(this.getJustSortedColumns(), justSortedColumns);
16814
+ //removeFromArray(this.getJustSortedColumns(), justSortedColumns);
16815
+ removeFromArray(this.sortedColumns, justSortedColumns);
16687
16816
  }
16817
+ this.fixupSortingIndices();
16688
16818
  };
16689
16819
  /**
16690
16820
  * Fires process event.
@@ -17263,7 +17393,7 @@ var EqQueryFileLoader = /** @class */ (function () {
17263
17393
  });
17264
17394
  var request = actionResult.getRequest();
17265
17395
  return actionResult.then(function (responseData) {
17266
- var blob = new Blob([JSON.stringify(responseData)]);
17396
+ var blob = new Blob([responseData]);
17267
17397
  var dispositionHeader = request.getXMLHttpRequest().getResponseHeader("Content-Disposition");
17268
17398
  var fileName = dispositionHeader
17269
17399
  ? dispositionHeader.match(/filename="(.*)"/)[1]
@@ -17695,6 +17825,7 @@ var EqActionResult;
17695
17825
  })(EqActionResult || (EqActionResult = {}));
17696
17826
  //# sourceMappingURL=action.js.map
17697
17827
  ;// CONCATENATED MODULE: ../core/dist/lib/eqs/eqs_exporter.js
17828
+
17698
17829
  var EqServerExporter = /** @class */ (function () {
17699
17830
  function EqServerExporter(context) {
17700
17831
  this.context = context;
@@ -17710,7 +17841,8 @@ var EqServerExporter = /** @class */ (function () {
17710
17841
  var query = exportOptions.query || this.context.getQuery();
17711
17842
  var modelId = query.getModel().getId();
17712
17843
  var requestData = {
17713
- 'settings': exportOptions.settings
17844
+ 'settings': exportOptions.settings,
17845
+ 'chunk': EmptyChunk
17714
17846
  };
17715
17847
  if (typeof (exportOptions.queryId) !== 'undefined') {
17716
17848
  requestData.queryId = exportOptions.queryId;
@@ -17775,6 +17907,8 @@ var context_assign = (undefined && undefined.__assign) || function () {
17775
17907
 
17776
17908
 
17777
17909
 
17910
+
17911
+
17778
17912
  /**
17779
17913
  * Encapsulates all information about EasyQuery components on some webpage
17780
17914
  * and provides some basic operation over those components
@@ -17787,6 +17921,7 @@ var context_assign = (undefined && undefined.__assign) || function () {
17787
17921
  var EqContext = /** @class */ (function () {
17788
17922
  function EqContext() {
17789
17923
  var _this = this;
17924
+ this.options = {};
17790
17925
  this.servicesInitialized = false;
17791
17926
  this.internalListCache = {};
17792
17927
  this.loadModelOnStart = true;
@@ -17980,6 +18115,7 @@ var EqContext = /** @class */ (function () {
17980
18115
  if (!this.servicesInitialized)
17981
18116
  this.initStart();
17982
18117
  options = options || {};
18118
+ this.setOptions(options);
17983
18119
  if (typeof (options.debugMode) !== 'undefined') {
17984
18120
  this.debugMode = options.debugMode;
17985
18121
  }
@@ -18101,6 +18237,9 @@ var EqContext = /** @class */ (function () {
18101
18237
  this.fireEvent('ready');
18102
18238
  }
18103
18239
  };
18240
+ EqContext.prototype.setOptions = function (options) {
18241
+ public_api.utils.assignDeep(this.options, options);
18242
+ };
18104
18243
  Object.defineProperty(EqContext.prototype, "backendInfo", {
18105
18244
  get: function () {
18106
18245
  return this._backendInfo;
@@ -18558,6 +18697,7 @@ var EqContext = /** @class */ (function () {
18558
18697
  validate: false
18559
18698
  });
18560
18699
  }
18700
+ _this.limitCustomSqlColumns();
18561
18701
  _this.fireEvent('loadQuery');
18562
18702
  _this.endProcess({
18563
18703
  result: EqActionResult.Success,
@@ -19141,6 +19281,7 @@ var EqContext = /** @class */ (function () {
19141
19281
  EqContext.prototype.exportResult = function (options) {
19142
19282
  var _this = this;
19143
19283
  options = options || {};
19284
+ options.chunk = options.chunk || EmptyChunk;
19144
19285
  if (this.beforeExportResult) {
19145
19286
  this.beforeExportResult(this, options);
19146
19287
  }
@@ -19190,6 +19331,15 @@ var EqContext = /** @class */ (function () {
19190
19331
  }
19191
19332
  }
19192
19333
  };
19334
+ EqContext.prototype.limitCustomSqlColumns = function () {
19335
+ if (!this.options.allowCustomExpressions) {
19336
+ this.query.getColumns().forEach(function (col) {
19337
+ if (col.expr.tag === ExprTag.CustomSql) {
19338
+ col.enabled = false;
19339
+ }
19340
+ });
19341
+ }
19342
+ };
19193
19343
  return EqContext;
19194
19344
  }());
19195
19345
 
@@ -21409,10 +21559,20 @@ var ColumnRendererCP = /** @class */ (function () {
21409
21559
  enumerable: false,
21410
21560
  configurable: true
21411
21561
  });
21562
+ Object.defineProperty(ColumnRendererCP.prototype, "columnEnabled", {
21563
+ get: function () {
21564
+ return this.column.enabled;
21565
+ },
21566
+ set: function (value) {
21567
+ this.column.enabled = value;
21568
+ },
21569
+ enumerable: false,
21570
+ configurable: true
21571
+ });
21412
21572
  ColumnRendererCP.prototype.render = function () {
21413
21573
  var _this = this;
21414
21574
  this.baseAttr = this.getAttribute();
21415
- if (this.getButtonsToShow().indexOf("sorting") >= 0 && this.column.enabled) {
21575
+ if (this.getButtonsToShow().indexOf("sorting") >= 0 && this.columnEnabled) {
21416
21576
  this.sortingButton = this.renderSoringButton(this.column.sorting);
21417
21577
  if (this.column.sorting !== SortDirection.None) {
21418
21578
  this.sortingButton.style.display = 'block';
@@ -21482,12 +21642,12 @@ var ColumnRendererCP = /** @class */ (function () {
21482
21642
  }
21483
21643
  //end enable button
21484
21644
  //start aggr func button
21485
- if (_this.getButtonsToShow().indexOf("type") >= 0 && _this.column.enabled) {
21645
+ if (_this.getButtonsToShow().indexOf("type") >= 0 && _this.columnEnabled) {
21486
21646
  builder.addChildElement(_this.renderColumnTypeButton());
21487
21647
  }
21488
21648
  //end aggr func button
21489
21649
  //start format selector button
21490
- if (_this.getButtonsToShow().indexOf("format") >= 0 && _this.column.enabled) {
21650
+ if (_this.getButtonsToShow().indexOf("format") >= 0 && _this.columnEnabled) {
21491
21651
  builder.addChildElement(_this.renderColumnFormatButton());
21492
21652
  }
21493
21653
  //end format selector button
@@ -21700,9 +21860,9 @@ var ColumnRendererCP = /** @class */ (function () {
21700
21860
  .title(public_api.i18n.getText('CmdToggleEnable'))
21701
21861
  .attr('tabIndex', '0')
21702
21862
  .addClass("".concat(this.cssPrefix, "-colelement ").concat(this.cssPrefix, "-column-checkbox"))
21703
- .addClass("".concat(this.column.enabled ? 'enabled' : ''))
21863
+ .addClass("".concat(this.columnEnabled ? 'enabled' : ''))
21704
21864
  .on('click', function () {
21705
- _this.column.enabled = !_this.column.enabled;
21865
+ _this.columnEnabled = !_this.columnEnabled;
21706
21866
  _this.column.fireChangedEvent();
21707
21867
  return false;
21708
21868
  })
@@ -21758,8 +21918,8 @@ var ColumnRendererCP = /** @class */ (function () {
21758
21918
  };
21759
21919
  ColumnRendererCP.prototype.getClassesToAdd = function () {
21760
21920
  var result = "";
21761
- result += this.column.enabled ? '' : " ".concat(this.cssPrefix, "-disabled");
21762
- if (this.column.enabled) {
21921
+ result += this.columnEnabled ? '' : " ".concat(this.cssPrefix, "-disabled");
21922
+ if (this.columnEnabled) {
21763
21923
  result += this.column.isReadOnly() ? " ".concat(this.cssPrefix, "-readonly") : '';
21764
21924
  }
21765
21925
  result += this.column.isHidden() ? " ".concat(this.cssPrefix, "-hidden") : '';
@@ -21816,7 +21976,7 @@ var ColumnRendererCP = /** @class */ (function () {
21816
21976
  .addChild('div', function (b) { return b
21817
21977
  .addClass("".concat(utils/* eqCssPrefix */.YR, "-button"), "".concat(utils/* eqCssPrefix */.YR, "-column-button"), "".concat(utils/* eqCssPrefix */.YR, "-column-button-enable"))
21818
21978
  .title(public_api.i18n.getText('CmdToggleEnable'))
21819
- .addClass(_this.column.enabled ? 'enabled' : '')
21979
+ .addClass(_this.columnEnabled ? 'enabled' : '')
21820
21980
  .attr('tabIndex', '0')
21821
21981
  .on('click', function (evt) { return _this.buttonMenuHandler(ColumnAction.Enable, evt); }) //touchstart
21822
21982
  .on('keypress', function (evt) { if (evt.keyCode == 13) {
@@ -21824,7 +21984,7 @@ var ColumnRendererCP = /** @class */ (function () {
21824
21984
  } }); }).toDOM();
21825
21985
  };
21826
21986
  ColumnRendererCP.prototype.isEditable = function () {
21827
- return this.column.enabled && !this.column.isReadOnly();
21987
+ return this.columnEnabled && !this.column.isReadOnly();
21828
21988
  };
21829
21989
  ColumnRendererCP.prototype.changeFormatHandler = function (ev) {
21830
21990
  var _this = this;
@@ -21990,7 +22150,7 @@ var ColumnRendererCP = /** @class */ (function () {
21990
22150
  curQuery.fireColumnsChangedEvent(QueryChangeAction.Delete, this.column);
21991
22151
  break;
21992
22152
  case ColumnAction.Enable:
21993
- this.column.enabled = !this.column.enabled;
22153
+ this.columnEnabled = !this.columnEnabled;
21994
22154
  this.fireColumnChanged();
21995
22155
  break;
21996
22156
  case ColumnAction.Hidden:
@@ -22064,7 +22224,7 @@ var ColumnRendererCP = /** @class */ (function () {
22064
22224
  _this.buttonMenuHandler(action, evt);
22065
22225
  },
22066
22226
  itemFilterCallback: function (item) {
22067
- var result = _this.column.enabled || item.id === "__group" || item.id === "enable" || item.id === "delete";
22227
+ var result = _this.columnEnabled || item.id === "__group" || item.id === "enable" || item.id === "delete";
22068
22228
  return result;
22069
22229
  },
22070
22230
  menuClosedCallback: function () {
@@ -22157,7 +22317,7 @@ var ColumnRendererCP = /** @class */ (function () {
22157
22317
  ColumnRendererCP.prototype.getButtonMenuSelectedItems = function () {
22158
22318
  var _this = this;
22159
22319
  var arrSelected = [];
22160
- if (this.column.enabled) {
22320
+ if (this.columnEnabled) {
22161
22321
  arrSelected.push("enable");
22162
22322
  }
22163
22323
  ;
@@ -22573,13 +22733,6 @@ var CustomSqlColumnRendererCP = /** @class */ (function (_super) {
22573
22733
  _this.dataTypeMenu = null;
22574
22734
  return _this;
22575
22735
  }
22576
- CustomSqlColumnRendererCP.prototype.render = function () {
22577
- if (!this.panel.areCustomExpressionsAllowed() && this.column.enabled) {
22578
- this.column.enabled = false;
22579
- this.fireColumnChanged();
22580
- }
22581
- return _super.prototype.render.call(this);
22582
- };
22583
22736
  CustomSqlColumnRendererCP.prototype.renderEnabledButton = function () {
22584
22737
  var elem = _super.prototype.renderEnabledButton.call(this);
22585
22738
  var child = elem.children[0];
@@ -23137,6 +23290,7 @@ var ColumnsPanel = /** @class */ (function (_super) {
23137
23290
  };
23138
23291
  ColumnsPanel.prototype.setOptions = function (options) {
23139
23292
  public_api.utils.assignDeep(this.options, options);
23293
+ this.getContext().options.allowCustomExpressions = options.allowCustomExpressions;
23140
23294
  if (browser_utils/* browserUtils.isMobileMode */.z.isMobileMode()) {
23141
23295
  this.options.buttons = ["menu"];
23142
23296
  this.options.showHeader = false;
@@ -23356,7 +23510,7 @@ var ColumnsPanel = /** @class */ (function (_super) {
23356
23510
  };
23357
23511
  ColumnsPanel.prototype.areCustomExpressionsAllowed = function () {
23358
23512
  var query = this.getQuery();
23359
- return query.isEx() && this.options.allowCustomExpressions;
23513
+ return query.isEx() && this.getContext().options.allowCustomExpressions;
23360
23514
  };
23361
23515
  ColumnsPanel.prototype.addAllColumnsToEntitiesList = function (list) {
23362
23516
  var _this = this;
@@ -25197,66 +25351,21 @@ var SortingBar = /** @class */ (function (_super) {
25197
25351
  && edata.part != QueryChangePart.Columns && edata.part != QueryChangePart.All)) {
25198
25352
  return;
25199
25353
  }
25200
- switch (edata.action) {
25201
- case QueryChangeAction.Modify: {
25202
- var columns = edata.changee;
25203
- var modifyColumn_1 = function (column) {
25204
- var colEl = _this.columnsBlock.querySelector("div[data-id='".concat(column.id, "']"));
25205
- if (colEl) {
25206
- _this.renderColumn(column, colEl);
25207
- }
25208
- };
25209
- if (Array.isArray(columns)) {
25210
- columns.forEach(function (col) { return modifyColumn_1(col); });
25211
- }
25212
- else {
25213
- modifyColumn_1(columns);
25214
- }
25215
- break;
25216
- }
25217
- case QueryChangeAction.Add: {
25218
- var columns = edata.changee;
25219
- var addColumn_1 = function (column) {
25220
- _this.addColumnElement(column);
25221
- };
25222
- if (Array.isArray(columns)) {
25223
- columns.forEach(function (col) { return addColumn_1(col); });
25224
- }
25225
- else {
25226
- addColumn_1(columns);
25227
- }
25228
- break;
25229
- }
25230
- case QueryChangeAction.Delete: {
25231
- var columns = edata.changee;
25232
- var deleteColumn_1 = function (column) {
25233
- var colEl = _this.columnsBlock.querySelector("div[data-id='".concat(column.id, "']"));
25234
- if (colEl)
25235
- _this.columnsBlock.removeChild(colEl);
25236
- };
25237
- if (Array.isArray(columns)) {
25238
- columns.forEach(function (col) { return deleteColumn_1(col); });
25239
- }
25240
- else {
25241
- deleteColumn_1(columns);
25242
- }
25243
- break;
25244
- }
25245
- default:
25246
- _this.refresh();
25247
- break;
25248
- }
25354
+ _this.refresh();
25249
25355
  });
25250
25356
  };
25251
25357
  SortingBar.prototype.detachQueryObserver = function () {
25252
25358
  if (this.queryEventCallbackId) {
25253
- var query = this.getContext().getQuery();
25359
+ var query = this.getQuery();
25254
25360
  query.removeChangedCallback(this.queryEventCallbackId);
25255
25361
  }
25256
25362
  };
25257
25363
  SortingBar.prototype.getQuery = function () {
25258
25364
  return this.getContext().getQuery();
25259
25365
  };
25366
+ SortingBar.prototype.getModel = function () {
25367
+ return this.getContext().getModel();
25368
+ };
25260
25369
  SortingBar.prototype.destroyCore = function () {
25261
25370
  this.detachQueryObserver();
25262
25371
  this.clear();
@@ -25294,7 +25403,7 @@ var SortingBar = /** @class */ (function (_super) {
25294
25403
  this.entitiesMenu.showMenu(menuOptions);
25295
25404
  };
25296
25405
  SortingBar.prototype.createEntitiesMenu = function () {
25297
- var model = this.getContext().getModel();
25406
+ var model = this.getModel();
25298
25407
  if (!model || model.isEmpty())
25299
25408
  return null;
25300
25409
  var menuId = this.slot.id;
@@ -25307,7 +25416,7 @@ var SortingBar = /** @class */ (function (_super) {
25307
25416
  this.entitiesMenu = new PopupMenu(options);
25308
25417
  };
25309
25418
  SortingBar.prototype.createSortMenu = function () {
25310
- var model = this.getContext().getModel();
25419
+ var model = this.getModel();
25311
25420
  if (!model || model.isEmpty())
25312
25421
  return null;
25313
25422
  var menuId = this.slot.id;
@@ -25344,8 +25453,8 @@ var SortingBar = /** @class */ (function (_super) {
25344
25453
  }
25345
25454
  (0,lib_public_api.domel)(this.slot)
25346
25455
  .addChildElement(this.columnsBlock);
25347
- var query = this.context.getQuery();
25348
- var columns = query.getColumns().concat(query.getJustSortedColumns());
25456
+ var query = this.getQuery();
25457
+ var columns = query.getSortedColumns(); // .getColumns().concat(query.getJustSortedColumns());
25349
25458
  columns.forEach(function (column, index) {
25350
25459
  var slot = _this.renderColumn(column);
25351
25460
  _this.columnsBlock.appendChild(slot);
@@ -25353,8 +25462,8 @@ var SortingBar = /** @class */ (function (_super) {
25353
25462
  };
25354
25463
  SortingBar.prototype.addNewColumn = function (attrId) {
25355
25464
  var _this = this;
25356
- var model = this.getContext().getModel();
25357
- var query = this.getContext().getQuery();
25465
+ var model = this.getModel();
25466
+ var query = this.getQuery();
25358
25467
  var getColumnByAttrId = function (attrid) {
25359
25468
  var attribute = model.getAttributeById(attrid);
25360
25469
  if (!attribute) {
@@ -25373,60 +25482,28 @@ var SortingBar = /** @class */ (function (_super) {
25373
25482
  }
25374
25483
  var column = query.createColumn(true);
25375
25484
  column.caption = _this.getDefaultColumnCaption(attribute);
25376
- column.sorting = SortDirection.Ascending;
25377
- column.sortIndex = _this.getQuery().getColumnSortIndex(column);
25485
+ column._sorting = SortDirection.Ascending;
25486
+ //column.sortIndex = this.getQuery().getColumnSortIndex(column);
25378
25487
  column.expr.tag = ExprTag.EntityAttribute;
25488
+ column.expr.dataType = attribute.dataType;
25379
25489
  //column.expr.id = attrid;
25380
25490
  column.expr.setValue(attrid, true);
25381
25491
  column.params.concat(attribute.params);
25382
25492
  return column;
25383
25493
  };
25384
- if (!this.getContext().getQuery()) {
25494
+ if (!this.getQuery()) {
25385
25495
  return;
25386
25496
  }
25387
- return this.addColumn(getColumnByAttrId(attrId));
25497
+ var newCol = getColumnByAttrId(attrId);
25498
+ return this.getQuery().addColumn({
25499
+ column: newCol
25500
+ });
25388
25501
  };
25389
25502
  SortingBar.prototype.getDefaultColumnCaption = function (attr) {
25390
25503
  var format = this.options.titleElementFormat || this.options.attrElementFormat;
25391
- var model = this.getContext().getModel();
25504
+ var model = this.getModel();
25392
25505
  return model.getAttributeText(attr, format);
25393
25506
  };
25394
- SortingBar.prototype.addColumn = function (column) {
25395
- var query = this.getContext().getQuery();
25396
- if (!query) {
25397
- return;
25398
- }
25399
- column = this.checkColumn(column);
25400
- if (!column) {
25401
- return;
25402
- }
25403
- column = query.addColumn({
25404
- caption: column.caption,
25405
- attributeId: column.expr.value,
25406
- sorting: column.sorting,
25407
- sortIndex: column.sortIndex,
25408
- justsorted: true
25409
- });
25410
- query.fireChangedEvent({
25411
- part: QueryChangePart.SortingColumns,
25412
- action: QueryChangeAction.Add,
25413
- changee: column
25414
- });
25415
- return column;
25416
- };
25417
- SortingBar.prototype.checkColumn = function (col) {
25418
- var query = this.getContext().getQuery();
25419
- var columns = query.getColumns()
25420
- .concat(query.getJustSortedColumns());
25421
- var colJson = JSON.stringify(col.expr.saveToData());
25422
- for (var i = 0; i < columns.length; i++) {
25423
- var qcolJson = JSON.stringify(columns[i].expr.saveToData());
25424
- if (qcolJson === colJson) {
25425
- return null;
25426
- }
25427
- }
25428
- return col;
25429
- };
25430
25507
  SortingBar.prototype.renderColumn = function (column, elem) {
25431
25508
  var renderer = new ColumnRendererSB(this, column, elem);
25432
25509
  if (renderer) {
@@ -25435,14 +25512,6 @@ var SortingBar = /** @class */ (function (_super) {
25435
25512
  }
25436
25513
  return null;
25437
25514
  };
25438
- //adds one column to the bar on the specified position
25439
- SortingBar.prototype.addColumnElement = function (column) {
25440
- var newColBlock = this.renderColumn(column);
25441
- this.columnsBlock.appendChild(newColBlock);
25442
- if (this.options.columnRenderedCallback) {
25443
- this.options.columnRenderedCallback(newColBlock);
25444
- }
25445
- };
25446
25515
  SortingBar.prototype.clear = function () {
25447
25516
  this.slot.innerHTML = '';
25448
25517
  };