@easyquery/ui 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 Community 7.2.4-beta03 (https://korzh.com/easyquery/javascript)
2
+ * EasyQuery.JS Community 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
@@ -12013,6 +12013,7 @@ __webpack_require__.d(public_api_namespaceObject, {
12013
12013
  DataModel: function() { return DataModel; },
12014
12014
  DefaultAggregatesCalculator: function() { return DefaultAggregatesCalculator; },
12015
12015
  EasyQueryDataLoader: function() { return EasyQueryDataLoader; },
12016
+ EmptyChunk: function() { return EmptyChunk; },
12016
12017
  Entity: function() { return Entity; },
12017
12018
  EntityAttr: function() { return EntityAttr; },
12018
12019
  EqAction: function() { return EqAction; },
@@ -12389,6 +12390,14 @@ var eqconsts;
12389
12390
  ];
12390
12391
  })(eqconsts || (eqconsts = {}));
12391
12392
  //# sourceMappingURL=constants.js.map
12393
+ ;// CONCATENATED MODULE: ../core/dist/lib/export/exporter.js
12394
+ //possibly move it to the EasyData lib on the next update
12395
+ var EmptyChunk = {
12396
+ offset: 0,
12397
+ limit: 0,
12398
+ needTotal: false
12399
+ };
12400
+ //# sourceMappingURL=exporter.js.map
12392
12401
  ;// CONCATENATED MODULE: ../core/dist/lib/dm/aggr_function.js
12393
12402
 
12394
12403
  /**
@@ -13975,12 +13984,14 @@ var QueryColumn = /** @class */ (function () {
13975
13984
  /** The parameters associated with this column */
13976
13985
  this.params = [];
13977
13986
  this._isHidden = false;
13987
+ this.query = query;
13978
13988
  this._id = public_api.utils.generateId('col');
13979
13989
  this.caption = '';
13980
- this.sorting = SortDirection.None;
13981
- this.sortIndex = -1;
13990
+ this._sorting = SortDirection.None;
13991
+ this._sortIndex = -1;
13982
13992
  this.expr = new Expression(this);
13983
13993
  this.blockId = '';
13994
+ this.justsorted = justsorted;
13984
13995
  }
13985
13996
  Object.defineProperty(QueryColumn.prototype, "id", {
13986
13997
  get: function () {
@@ -13989,6 +14000,51 @@ var QueryColumn = /** @class */ (function () {
13989
14000
  enumerable: false,
13990
14001
  configurable: true
13991
14002
  });
14003
+ Object.defineProperty(QueryColumn.prototype, "sorting", {
14004
+ /** Column sorting direction */
14005
+ get: function () {
14006
+ if (this.query) {
14007
+ return this.query.getColumnSorting(this);
14008
+ }
14009
+ else {
14010
+ return this._sorting;
14011
+ }
14012
+ },
14013
+ set: function (direction) {
14014
+ if (this.query) {
14015
+ this.query.setColumnSorting(this, direction);
14016
+ }
14017
+ else {
14018
+ this._sorting = direction;
14019
+ }
14020
+ },
14021
+ enumerable: false,
14022
+ configurable: true
14023
+ });
14024
+ ;
14025
+ Object.defineProperty(QueryColumn.prototype, "sortIndex", {
14026
+ /** The index of the column in the sorting list. */
14027
+ get: function () {
14028
+ if (this.query) {
14029
+ return this.query.getColumnSortIndex(this);
14030
+ }
14031
+ else {
14032
+ return this._sortIndex;
14033
+ }
14034
+ },
14035
+ set: function (index) {
14036
+ if (this.query) {
14037
+ this.query.setColumnSortIndex(this, index);
14038
+ }
14039
+ else {
14040
+ this._sortIndex = index;
14041
+ }
14042
+ },
14043
+ enumerable: false,
14044
+ configurable: true
14045
+ });
14046
+ ;
14047
+ ;
13992
14048
  QueryColumn.prototype.getModel = function () {
13993
14049
  return this.query.getModel();
13994
14050
  };
@@ -14043,8 +14099,8 @@ var QueryColumn = /** @class */ (function () {
14043
14099
  }
14044
14100
  this.caption = colData.cptn;
14045
14101
  if (typeof colData.srt !== 'undefined') {
14046
- this.sorting = colData.srt;
14047
- this.sortIndex = (typeof colData.srtidx !== 'undefined')
14102
+ this._sorting = colData.srt;
14103
+ this._sortIndex = (typeof colData.srtidx !== 'undefined')
14048
14104
  ? colData.srtidx
14049
14105
  : -1;
14050
14106
  }
@@ -14070,7 +14126,7 @@ var QueryColumn = /** @class */ (function () {
14070
14126
  if (typeof this.caption !== 'undefined') {
14071
14127
  obj.cptn = this.caption;
14072
14128
  }
14073
- if (typeof this.sorting !== 'undefined' && this.sorting != SortDirection.None) {
14129
+ if (this.sorting != SortDirection.None) {
14074
14130
  obj.srt = this.sorting;
14075
14131
  obj.srtidx = this.sortIndex;
14076
14132
  }
@@ -14538,7 +14594,8 @@ var Query = /** @class */ (function () {
14538
14594
  this.root = new Condition(this, CondTag.Group);
14539
14595
  this.extraConditions = new Condition(this, CondTag.Group);
14540
14596
  this.columns = new Array();
14541
- this.justsorted = new Array();
14597
+ //this.justsorted = new Array<QueryColumn>();
14598
+ this.sortedColumns = new Array();
14542
14599
  if (!this.id) {
14543
14600
  this.regenerateId();
14544
14601
  }
@@ -14689,6 +14746,7 @@ var Query = /** @class */ (function () {
14689
14746
  });
14690
14747
  };
14691
14748
  Query.prototype.processQueryForAggregation = function (silent) {
14749
+ var _this = this;
14692
14750
  if (silent === void 0) { silent = false; }
14693
14751
  var aggrSettings = this.getAggregationSettings();
14694
14752
  var groups = aggrSettings.getGroups();
@@ -14702,19 +14760,21 @@ var Query = /** @class */ (function () {
14702
14760
  if (groupColIds.indexOf(col.id) >= 0) {
14703
14761
  groupedCols.push(col);
14704
14762
  }
14705
- else if (col.sorting != SortDirection.None) {
14763
+ else if (this.getColumnSorting(col) != SortDirection.None) {
14706
14764
  sortedCols.push(col);
14707
14765
  }
14708
14766
  }
14709
14767
  var sortIndex_1 = 0;
14710
14768
  groupedCols.forEach(function (col) {
14711
- if (col.sorting == SortDirection.None) {
14712
- col.sorting = SortDirection.Ascending;
14769
+ if (_this.getColumnSorting(col) == SortDirection.None) {
14770
+ _this.setColumnSorting(col, SortDirection.Ascending);
14713
14771
  }
14714
- col.sortIndex = sortIndex_1++;
14772
+ _this.setColumnSortIndex(col, sortIndex_1++);
14773
+ //col.sortIndex = sortIndex++;
14715
14774
  });
14716
14775
  sortedCols.forEach(function (col) {
14717
- col.sortIndex = sortIndex_1++;
14776
+ _this.setColumnSortIndex(col, sortIndex_1++);
14777
+ // col.sortIndex = sortIndex++;
14718
14778
  });
14719
14779
  if (!silent) {
14720
14780
  this.fireChangedEvent({
@@ -14945,12 +15005,14 @@ var Query = /** @class */ (function () {
14945
15005
  }
14946
15006
  this.name = data.name;
14947
15007
  this.description = data.desc;
14948
- this.justsorted = [];
15008
+ //this.justsorted = [];
15009
+ this.sortedColumns = [];
14949
15010
  if (data.justsortcols) {
14950
15011
  for (var i = 0; i < data.justsortcols.length; i++) {
14951
15012
  var newCol = this.createColumn(true);
14952
15013
  newCol.loadFromData(this.model, data.justsortcols[i]);
14953
- this.justsorted.push(newCol);
15014
+ //this.justsorted.push(newCol);
15015
+ this.addColumnToSorted(newCol);
14954
15016
  }
14955
15017
  }
14956
15018
  if (data.cols) {
@@ -14958,8 +15020,15 @@ var Query = /** @class */ (function () {
14958
15020
  var newCol = this.createColumn();
14959
15021
  newCol.loadFromData(this.model, data.cols[i]);
14960
15022
  this.columns.push(newCol);
15023
+ if (newCol._sorting != SortDirection.None) {
15024
+ this.addColumnToSorted(newCol);
15025
+ }
14961
15026
  }
14962
15027
  }
15028
+ this.sortedColumns.sort(function (col1, col2) {
15029
+ return col1.sortIndex - col2.sortIndex;
15030
+ });
15031
+ this.fixupSortingIndices();
14963
15032
  if (data.extraData) {
14964
15033
  this.extraData = data.extraData;
14965
15034
  }
@@ -15049,6 +15118,7 @@ var Query = /** @class */ (function () {
15049
15118
  */
15050
15119
  Query.prototype.toJSONData = function () {
15051
15120
  var _this = this;
15121
+ this.fixupSortingIndices();
15052
15122
  var obj = {
15053
15123
  modelId: this.model ? this.model.getId() : null,
15054
15124
  modelName: this.model ? this.model.getName() : null
@@ -15063,9 +15133,14 @@ var Query = /** @class */ (function () {
15063
15133
  obj.cols.push(this.columns[i].saveToData());
15064
15134
  }
15065
15135
  obj.justsortcols = [];
15066
- for (var i = 0; i < this.justsorted.length; i++) {
15067
- obj.justsortcols.push(this.justsorted[i].saveToData());
15068
- }
15136
+ // for (let i = 0; i < this.justsorted.length; i++) {
15137
+ // obj.justsortcols.push(this.justsorted[i].saveToData());
15138
+ // }
15139
+ this.sortedColumns.forEach(function (col) {
15140
+ if (col.isJustSorted()) {
15141
+ obj.justsortcols.push(col.saveToData());
15142
+ }
15143
+ });
15069
15144
  if (this.extraData) {
15070
15145
  obj.extraData = this.extraData;
15071
15146
  }
@@ -15138,7 +15213,8 @@ var Query = /** @class */ (function () {
15138
15213
  */
15139
15214
  Query.prototype.clearColumns = function () {
15140
15215
  this.columns = [];
15141
- this.justsorted = [];
15216
+ //this.justsorted = [];
15217
+ this.sortedColumns = [];
15142
15218
  };
15143
15219
  /**
15144
15220
  * Clears all conditions in query.
@@ -15230,31 +15306,34 @@ var Query = /** @class */ (function () {
15230
15306
  cols.pop();
15231
15307
  return cols;
15232
15308
  };
15309
+ Query.prototype.addColumnToSorted = function (col) {
15310
+ var colJson = JSON.stringify(col.expr.saveToData());
15311
+ var isUnique = true;
15312
+ this.sortedColumns.forEach(function (scol) {
15313
+ var qcolJson = JSON.stringify(scol.expr.saveToData());
15314
+ if (qcolJson === colJson) {
15315
+ isUnique = false;
15316
+ }
15317
+ });
15318
+ if (isUnique) {
15319
+ this.sortedColumns.push(col);
15320
+ }
15321
+ };
15233
15322
  /**
15234
15323
  * Get array of columns used only in sorting.
15235
15324
  * @retruns Columns.
15236
15325
  */
15237
15326
  Query.prototype.getJustSortedColumns = function () {
15238
- return this.justsorted;
15327
+ return this.sortedColumns.filter(function (col) {
15328
+ return col.isJustSorted();
15329
+ });
15239
15330
  };
15240
15331
  /**
15241
15332
  * Gets array of columns used in sorting
15242
15333
  * @retruns Columns
15243
15334
  */
15244
15335
  Query.prototype.getSortedColumns = function () {
15245
- var sortedCols = new Array();
15246
- var cols = this.getColumns()
15247
- .concat(this.getJustSortedColumns());
15248
- for (var i = 0; i < cols.length; i++) {
15249
- var col = cols[i];
15250
- if (col.sortIndex >= 0) {
15251
- sortedCols.push(col);
15252
- }
15253
- }
15254
- sortedCols.sort(function (col1, col2) {
15255
- return col1.sortIndex - col2.sortIndex;
15256
- });
15257
- return sortedCols;
15336
+ return this.sortedColumns;
15258
15337
  };
15259
15338
  /**
15260
15339
  * Gets Colummn sorting index.
@@ -15262,17 +15341,48 @@ var Query = /** @class */ (function () {
15262
15341
  * @retruns The index.
15263
15342
  */
15264
15343
  Query.prototype.getColumnSortIndex = function (col) {
15265
- if (col.sorting != SortDirection.None) {
15266
- if (col.sortIndex < 0) {
15267
- var cols = this.getColumns()
15268
- .concat(this.getJustSortedColumns());
15269
- return public_api.utils.indexOfArrayItem(cols, col);
15344
+ return this.sortedColumns.indexOf(col);
15345
+ };
15346
+ Query.prototype.setColumnSortIndex = function (col, index) {
15347
+ if (index < 0)
15348
+ return;
15349
+ var colIdx = this.getColumnSortIndex(col);
15350
+ if (colIdx < 0) {
15351
+ this.addColumnToSorted(col);
15352
+ colIdx = this.sortedColumns.length - 1;
15353
+ }
15354
+ public_api.utils.moveArrayItem(this.sortedColumns, colIdx, index);
15355
+ this.fixupSortingIndices();
15356
+ };
15357
+ Query.prototype.getColumnSorting = function (col) {
15358
+ var idx = this.getColumnSortIndex(col);
15359
+ if (idx >= 0) {
15360
+ return col._sorting != SortDirection.None ? col._sorting : SortDirection.Ascending;
15361
+ }
15362
+ else {
15363
+ return SortDirection.None;
15364
+ }
15365
+ };
15366
+ Query.prototype.setColumnSorting = function (col, direction) {
15367
+ var idx = this.getColumnSortIndex(col);
15368
+ col._sorting = direction;
15369
+ if (idx >= 0) {
15370
+ if (direction == SortDirection.None) {
15371
+ public_api.utils.removeArrayItem(this.sortedColumns, col);
15372
+ this.fixupSortingIndices();
15270
15373
  }
15271
- else {
15272
- return col.sortIndex;
15374
+ }
15375
+ else {
15376
+ if (direction != SortDirection.None) {
15377
+ this.addColumnToSorted(col);
15378
+ this.fixupSortingIndices();
15273
15379
  }
15274
15380
  }
15275
- return -1;
15381
+ };
15382
+ Query.prototype.fixupSortingIndices = function () {
15383
+ this.sortedColumns.forEach(function (col, index) {
15384
+ col._sortIndex = index;
15385
+ });
15276
15386
  };
15277
15387
  Query.prototype.createColumn = function (justsorted) {
15278
15388
  if (justsorted === void 0) { justsorted = false; }
@@ -15297,9 +15407,9 @@ var Query = /** @class */ (function () {
15297
15407
  * }});
15298
15408
  */
15299
15409
  Query.prototype.addColumn = function (descriptor, author) {
15300
- var columns = (descriptor.justsorted)
15301
- ? this.justsorted
15302
- : this.columns;
15410
+ // let columns = (descriptor.justsorted)
15411
+ // ? this.justsorted
15412
+ // : this.columns;
15303
15413
  var newColumn;
15304
15414
  if (descriptor.column) {
15305
15415
  newColumn = descriptor.column;
@@ -15361,17 +15471,22 @@ var Query = /** @class */ (function () {
15361
15471
  newColumn.expr.dataType = attr.dataType;
15362
15472
  }
15363
15473
  newColumn.caption = descriptor.caption || newColumn.caption;
15364
- newColumn.sorting = descriptor.sorting || SortDirection.None;
15365
- newColumn.sortIndex = descriptor.sortIndex || -1;
15474
+ newColumn._sorting = descriptor.sorting || SortDirection.None;
15475
+ newColumn._sortIndex = descriptor.sortIndex || -1;
15366
15476
  newColumn.enabled = public_api.utils.getIfDefined(descriptor.enabled, true);
15367
15477
  newColumn.setReadOnly(public_api.utils.getIfDefined(descriptor.readonly, false));
15368
15478
  }
15369
- if (descriptor.index && descriptor.index >= 0 && descriptor.index < columns.length) {
15370
- columns.splice(descriptor.index, 0, newColumn);
15371
- }
15372
- else {
15373
- columns.push(newColumn);
15479
+ var justsorted = descriptor.justsorted || (descriptor.column && descriptor.column.isJustSorted());
15480
+ if (!justsorted) {
15481
+ if (descriptor.index && descriptor.index >= 0 && descriptor.index < this.columns.length) {
15482
+ this.columns.splice(descriptor.index, 0, newColumn);
15483
+ }
15484
+ else {
15485
+ this.columns.push(newColumn);
15486
+ }
15374
15487
  }
15488
+ this.setColumnSorting(newColumn, newColumn._sorting);
15489
+ this.fireColumnsChangedEvent(QueryChangeAction.Add, newColumn, justsorted);
15375
15490
  return newColumn;
15376
15491
  };
15377
15492
  /**
@@ -15386,6 +15501,7 @@ var Query = /** @class */ (function () {
15386
15501
  * query.addColumn(column, 1)
15387
15502
  */
15388
15503
  Query.prototype.addColumnObj = function (column, index, author) {
15504
+ var _this = this;
15389
15505
  var columns = this.columns;
15390
15506
  if (typeof column.length == "undefined") {
15391
15507
  if (typeof index == "number") {
@@ -15394,6 +15510,10 @@ var Query = /** @class */ (function () {
15394
15510
  else {
15395
15511
  columns.push(column);
15396
15512
  }
15513
+ if (column.sorting != SortDirection.None) {
15514
+ this.addColumnToSorted(column);
15515
+ }
15516
+ this.fixupSortingIndices();
15397
15517
  }
15398
15518
  else {
15399
15519
  if (typeof index == "number") {
@@ -15402,6 +15522,12 @@ var Query = /** @class */ (function () {
15402
15522
  else {
15403
15523
  columns.push.apply(columns, [].concat(column));
15404
15524
  }
15525
+ column.forEach(function (col) {
15526
+ if (col.sorting != SortDirection.None) {
15527
+ _this.addColumnToSorted(col);
15528
+ }
15529
+ });
15530
+ this.fixupSortingIndices();
15405
15531
  }
15406
15532
  };
15407
15533
  /**
@@ -15481,10 +15607,11 @@ var Query = /** @class */ (function () {
15481
15607
  * @param author The author
15482
15608
  */
15483
15609
  Query.prototype.removeColumn = function (column, author) {
15484
- var columns = (column.isJustSorted())
15485
- ? this.getJustSortedColumns()
15486
- : this.getColumns();
15487
- public_api.utils.removeArrayItem(columns, column);
15610
+ // const columns = (column.isJustSorted())
15611
+ // ? this.getJustSortedColumns()
15612
+ // : this.getColumns();
15613
+ public_api.utils.removeArrayItem(this.columns, column);
15614
+ public_api.utils.removeArrayItem(this.sortedColumns, column);
15488
15615
  };
15489
15616
  /**
15490
15617
  * Adds a condition group - a group of simple conditions (predicates) linked by AND or OR
@@ -15590,10 +15717,13 @@ var Query = /** @class */ (function () {
15590
15717
  }
15591
15718
  if (columns.length > 0) {
15592
15719
  removeFromArray(this.getColumns(), columns);
15720
+ removeFromArray(this.sortedColumns, columns);
15593
15721
  }
15594
15722
  if (justSortedColumns.length > 0) {
15595
- removeFromArray(this.getJustSortedColumns(), justSortedColumns);
15723
+ //removeFromArray(this.getJustSortedColumns(), justSortedColumns);
15724
+ removeFromArray(this.sortedColumns, justSortedColumns);
15596
15725
  }
15726
+ this.fixupSortingIndices();
15597
15727
  };
15598
15728
  /**
15599
15729
  * Fires process event.
@@ -16172,7 +16302,7 @@ var EqQueryFileLoader = /** @class */ (function () {
16172
16302
  });
16173
16303
  var request = actionResult.getRequest();
16174
16304
  return actionResult.then(function (responseData) {
16175
- var blob = new Blob([JSON.stringify(responseData)]);
16305
+ var blob = new Blob([responseData]);
16176
16306
  var dispositionHeader = request.getXMLHttpRequest().getResponseHeader("Content-Disposition");
16177
16307
  var fileName = dispositionHeader
16178
16308
  ? dispositionHeader.match(/filename="(.*)"/)[1]
@@ -16604,6 +16734,7 @@ var EqActionResult;
16604
16734
  })(EqActionResult || (EqActionResult = {}));
16605
16735
  //# sourceMappingURL=action.js.map
16606
16736
  ;// CONCATENATED MODULE: ../core/dist/lib/eqs/eqs_exporter.js
16737
+
16607
16738
  var EqServerExporter = /** @class */ (function () {
16608
16739
  function EqServerExporter(context) {
16609
16740
  this.context = context;
@@ -16619,7 +16750,8 @@ var EqServerExporter = /** @class */ (function () {
16619
16750
  var query = exportOptions.query || this.context.getQuery();
16620
16751
  var modelId = query.getModel().getId();
16621
16752
  var requestData = {
16622
- 'settings': exportOptions.settings
16753
+ 'settings': exportOptions.settings,
16754
+ 'chunk': EmptyChunk
16623
16755
  };
16624
16756
  if (typeof (exportOptions.queryId) !== 'undefined') {
16625
16757
  requestData.queryId = exportOptions.queryId;
@@ -16684,6 +16816,8 @@ var context_assign = (undefined && undefined.__assign) || function () {
16684
16816
 
16685
16817
 
16686
16818
 
16819
+
16820
+
16687
16821
  /**
16688
16822
  * Encapsulates all information about EasyQuery components on some webpage
16689
16823
  * and provides some basic operation over those components
@@ -16696,6 +16830,7 @@ var context_assign = (undefined && undefined.__assign) || function () {
16696
16830
  var EqContext = /** @class */ (function () {
16697
16831
  function EqContext() {
16698
16832
  var _this = this;
16833
+ this.options = {};
16699
16834
  this.servicesInitialized = false;
16700
16835
  this.internalListCache = {};
16701
16836
  this.loadModelOnStart = true;
@@ -16889,6 +17024,7 @@ var EqContext = /** @class */ (function () {
16889
17024
  if (!this.servicesInitialized)
16890
17025
  this.initStart();
16891
17026
  options = options || {};
17027
+ this.setOptions(options);
16892
17028
  if (typeof (options.debugMode) !== 'undefined') {
16893
17029
  this.debugMode = options.debugMode;
16894
17030
  }
@@ -17010,6 +17146,9 @@ var EqContext = /** @class */ (function () {
17010
17146
  this.fireEvent('ready');
17011
17147
  }
17012
17148
  };
17149
+ EqContext.prototype.setOptions = function (options) {
17150
+ public_api.utils.assignDeep(this.options, options);
17151
+ };
17013
17152
  Object.defineProperty(EqContext.prototype, "backendInfo", {
17014
17153
  get: function () {
17015
17154
  return this._backendInfo;
@@ -17467,6 +17606,7 @@ var EqContext = /** @class */ (function () {
17467
17606
  validate: false
17468
17607
  });
17469
17608
  }
17609
+ _this.limitCustomSqlColumns();
17470
17610
  _this.fireEvent('loadQuery');
17471
17611
  _this.endProcess({
17472
17612
  result: EqActionResult.Success,
@@ -18050,6 +18190,7 @@ var EqContext = /** @class */ (function () {
18050
18190
  EqContext.prototype.exportResult = function (options) {
18051
18191
  var _this = this;
18052
18192
  options = options || {};
18193
+ options.chunk = options.chunk || EmptyChunk;
18053
18194
  if (this.beforeExportResult) {
18054
18195
  this.beforeExportResult(this, options);
18055
18196
  }
@@ -18099,6 +18240,15 @@ var EqContext = /** @class */ (function () {
18099
18240
  }
18100
18241
  }
18101
18242
  };
18243
+ EqContext.prototype.limitCustomSqlColumns = function () {
18244
+ if (!this.options.allowCustomExpressions) {
18245
+ this.query.getColumns().forEach(function (col) {
18246
+ if (col.expr.tag === ExprTag.CustomSql) {
18247
+ col.enabled = false;
18248
+ }
18249
+ });
18250
+ }
18251
+ };
18102
18252
  return EqContext;
18103
18253
  }());
18104
18254
 
@@ -20318,10 +20468,20 @@ var ColumnRendererCP = /** @class */ (function () {
20318
20468
  enumerable: false,
20319
20469
  configurable: true
20320
20470
  });
20471
+ Object.defineProperty(ColumnRendererCP.prototype, "columnEnabled", {
20472
+ get: function () {
20473
+ return this.column.enabled;
20474
+ },
20475
+ set: function (value) {
20476
+ this.column.enabled = value;
20477
+ },
20478
+ enumerable: false,
20479
+ configurable: true
20480
+ });
20321
20481
  ColumnRendererCP.prototype.render = function () {
20322
20482
  var _this = this;
20323
20483
  this.baseAttr = this.getAttribute();
20324
- if (this.getButtonsToShow().indexOf("sorting") >= 0 && this.column.enabled) {
20484
+ if (this.getButtonsToShow().indexOf("sorting") >= 0 && this.columnEnabled) {
20325
20485
  this.sortingButton = this.renderSoringButton(this.column.sorting);
20326
20486
  if (this.column.sorting !== SortDirection.None) {
20327
20487
  this.sortingButton.style.display = 'block';
@@ -20391,12 +20551,12 @@ var ColumnRendererCP = /** @class */ (function () {
20391
20551
  }
20392
20552
  //end enable button
20393
20553
  //start aggr func button
20394
- if (_this.getButtonsToShow().indexOf("type") >= 0 && _this.column.enabled) {
20554
+ if (_this.getButtonsToShow().indexOf("type") >= 0 && _this.columnEnabled) {
20395
20555
  builder.addChildElement(_this.renderColumnTypeButton());
20396
20556
  }
20397
20557
  //end aggr func button
20398
20558
  //start format selector button
20399
- if (_this.getButtonsToShow().indexOf("format") >= 0 && _this.column.enabled) {
20559
+ if (_this.getButtonsToShow().indexOf("format") >= 0 && _this.columnEnabled) {
20400
20560
  builder.addChildElement(_this.renderColumnFormatButton());
20401
20561
  }
20402
20562
  //end format selector button
@@ -20609,9 +20769,9 @@ var ColumnRendererCP = /** @class */ (function () {
20609
20769
  .title(public_api.i18n.getText('CmdToggleEnable'))
20610
20770
  .attr('tabIndex', '0')
20611
20771
  .addClass("".concat(this.cssPrefix, "-colelement ").concat(this.cssPrefix, "-column-checkbox"))
20612
- .addClass("".concat(this.column.enabled ? 'enabled' : ''))
20772
+ .addClass("".concat(this.columnEnabled ? 'enabled' : ''))
20613
20773
  .on('click', function () {
20614
- _this.column.enabled = !_this.column.enabled;
20774
+ _this.columnEnabled = !_this.columnEnabled;
20615
20775
  _this.column.fireChangedEvent();
20616
20776
  return false;
20617
20777
  })
@@ -20667,8 +20827,8 @@ var ColumnRendererCP = /** @class */ (function () {
20667
20827
  };
20668
20828
  ColumnRendererCP.prototype.getClassesToAdd = function () {
20669
20829
  var result = "";
20670
- result += this.column.enabled ? '' : " ".concat(this.cssPrefix, "-disabled");
20671
- if (this.column.enabled) {
20830
+ result += this.columnEnabled ? '' : " ".concat(this.cssPrefix, "-disabled");
20831
+ if (this.columnEnabled) {
20672
20832
  result += this.column.isReadOnly() ? " ".concat(this.cssPrefix, "-readonly") : '';
20673
20833
  }
20674
20834
  result += this.column.isHidden() ? " ".concat(this.cssPrefix, "-hidden") : '';
@@ -20725,7 +20885,7 @@ var ColumnRendererCP = /** @class */ (function () {
20725
20885
  .addChild('div', function (b) { return b
20726
20886
  .addClass("".concat(utils/* eqCssPrefix */.YR, "-button"), "".concat(utils/* eqCssPrefix */.YR, "-column-button"), "".concat(utils/* eqCssPrefix */.YR, "-column-button-enable"))
20727
20887
  .title(public_api.i18n.getText('CmdToggleEnable'))
20728
- .addClass(_this.column.enabled ? 'enabled' : '')
20888
+ .addClass(_this.columnEnabled ? 'enabled' : '')
20729
20889
  .attr('tabIndex', '0')
20730
20890
  .on('click', function (evt) { return _this.buttonMenuHandler(ColumnAction.Enable, evt); }) //touchstart
20731
20891
  .on('keypress', function (evt) { if (evt.keyCode == 13) {
@@ -20733,7 +20893,7 @@ var ColumnRendererCP = /** @class */ (function () {
20733
20893
  } }); }).toDOM();
20734
20894
  };
20735
20895
  ColumnRendererCP.prototype.isEditable = function () {
20736
- return this.column.enabled && !this.column.isReadOnly();
20896
+ return this.columnEnabled && !this.column.isReadOnly();
20737
20897
  };
20738
20898
  ColumnRendererCP.prototype.changeFormatHandler = function (ev) {
20739
20899
  var _this = this;
@@ -20899,7 +21059,7 @@ var ColumnRendererCP = /** @class */ (function () {
20899
21059
  curQuery.fireColumnsChangedEvent(QueryChangeAction.Delete, this.column);
20900
21060
  break;
20901
21061
  case ColumnAction.Enable:
20902
- this.column.enabled = !this.column.enabled;
21062
+ this.columnEnabled = !this.columnEnabled;
20903
21063
  this.fireColumnChanged();
20904
21064
  break;
20905
21065
  case ColumnAction.Hidden:
@@ -20973,7 +21133,7 @@ var ColumnRendererCP = /** @class */ (function () {
20973
21133
  _this.buttonMenuHandler(action, evt);
20974
21134
  },
20975
21135
  itemFilterCallback: function (item) {
20976
- var result = _this.column.enabled || item.id === "__group" || item.id === "enable" || item.id === "delete";
21136
+ var result = _this.columnEnabled || item.id === "__group" || item.id === "enable" || item.id === "delete";
20977
21137
  return result;
20978
21138
  },
20979
21139
  menuClosedCallback: function () {
@@ -21066,7 +21226,7 @@ var ColumnRendererCP = /** @class */ (function () {
21066
21226
  ColumnRendererCP.prototype.getButtonMenuSelectedItems = function () {
21067
21227
  var _this = this;
21068
21228
  var arrSelected = [];
21069
- if (this.column.enabled) {
21229
+ if (this.columnEnabled) {
21070
21230
  arrSelected.push("enable");
21071
21231
  }
21072
21232
  ;
@@ -21482,13 +21642,6 @@ var CustomSqlColumnRendererCP = /** @class */ (function (_super) {
21482
21642
  _this.dataTypeMenu = null;
21483
21643
  return _this;
21484
21644
  }
21485
- CustomSqlColumnRendererCP.prototype.render = function () {
21486
- if (!this.panel.areCustomExpressionsAllowed() && this.column.enabled) {
21487
- this.column.enabled = false;
21488
- this.fireColumnChanged();
21489
- }
21490
- return _super.prototype.render.call(this);
21491
- };
21492
21645
  CustomSqlColumnRendererCP.prototype.renderEnabledButton = function () {
21493
21646
  var elem = _super.prototype.renderEnabledButton.call(this);
21494
21647
  var child = elem.children[0];
@@ -22046,6 +22199,7 @@ var ColumnsPanel = /** @class */ (function (_super) {
22046
22199
  };
22047
22200
  ColumnsPanel.prototype.setOptions = function (options) {
22048
22201
  public_api.utils.assignDeep(this.options, options);
22202
+ this.getContext().options.allowCustomExpressions = options.allowCustomExpressions;
22049
22203
  if (browser_utils/* browserUtils.isMobileMode */.z.isMobileMode()) {
22050
22204
  this.options.buttons = ["menu"];
22051
22205
  this.options.showHeader = false;
@@ -22265,7 +22419,7 @@ var ColumnsPanel = /** @class */ (function (_super) {
22265
22419
  };
22266
22420
  ColumnsPanel.prototype.areCustomExpressionsAllowed = function () {
22267
22421
  var query = this.getQuery();
22268
- return query.isEx() && this.options.allowCustomExpressions;
22422
+ return query.isEx() && this.getContext().options.allowCustomExpressions;
22269
22423
  };
22270
22424
  ColumnsPanel.prototype.addAllColumnsToEntitiesList = function (list) {
22271
22425
  var _this = this;
@@ -24106,66 +24260,21 @@ var SortingBar = /** @class */ (function (_super) {
24106
24260
  && edata.part != QueryChangePart.Columns && edata.part != QueryChangePart.All)) {
24107
24261
  return;
24108
24262
  }
24109
- switch (edata.action) {
24110
- case QueryChangeAction.Modify: {
24111
- var columns = edata.changee;
24112
- var modifyColumn_1 = function (column) {
24113
- var colEl = _this.columnsBlock.querySelector("div[data-id='".concat(column.id, "']"));
24114
- if (colEl) {
24115
- _this.renderColumn(column, colEl);
24116
- }
24117
- };
24118
- if (Array.isArray(columns)) {
24119
- columns.forEach(function (col) { return modifyColumn_1(col); });
24120
- }
24121
- else {
24122
- modifyColumn_1(columns);
24123
- }
24124
- break;
24125
- }
24126
- case QueryChangeAction.Add: {
24127
- var columns = edata.changee;
24128
- var addColumn_1 = function (column) {
24129
- _this.addColumnElement(column);
24130
- };
24131
- if (Array.isArray(columns)) {
24132
- columns.forEach(function (col) { return addColumn_1(col); });
24133
- }
24134
- else {
24135
- addColumn_1(columns);
24136
- }
24137
- break;
24138
- }
24139
- case QueryChangeAction.Delete: {
24140
- var columns = edata.changee;
24141
- var deleteColumn_1 = function (column) {
24142
- var colEl = _this.columnsBlock.querySelector("div[data-id='".concat(column.id, "']"));
24143
- if (colEl)
24144
- _this.columnsBlock.removeChild(colEl);
24145
- };
24146
- if (Array.isArray(columns)) {
24147
- columns.forEach(function (col) { return deleteColumn_1(col); });
24148
- }
24149
- else {
24150
- deleteColumn_1(columns);
24151
- }
24152
- break;
24153
- }
24154
- default:
24155
- _this.refresh();
24156
- break;
24157
- }
24263
+ _this.refresh();
24158
24264
  });
24159
24265
  };
24160
24266
  SortingBar.prototype.detachQueryObserver = function () {
24161
24267
  if (this.queryEventCallbackId) {
24162
- var query = this.getContext().getQuery();
24268
+ var query = this.getQuery();
24163
24269
  query.removeChangedCallback(this.queryEventCallbackId);
24164
24270
  }
24165
24271
  };
24166
24272
  SortingBar.prototype.getQuery = function () {
24167
24273
  return this.getContext().getQuery();
24168
24274
  };
24275
+ SortingBar.prototype.getModel = function () {
24276
+ return this.getContext().getModel();
24277
+ };
24169
24278
  SortingBar.prototype.destroyCore = function () {
24170
24279
  this.detachQueryObserver();
24171
24280
  this.clear();
@@ -24203,7 +24312,7 @@ var SortingBar = /** @class */ (function (_super) {
24203
24312
  this.entitiesMenu.showMenu(menuOptions);
24204
24313
  };
24205
24314
  SortingBar.prototype.createEntitiesMenu = function () {
24206
- var model = this.getContext().getModel();
24315
+ var model = this.getModel();
24207
24316
  if (!model || model.isEmpty())
24208
24317
  return null;
24209
24318
  var menuId = this.slot.id;
@@ -24216,7 +24325,7 @@ var SortingBar = /** @class */ (function (_super) {
24216
24325
  this.entitiesMenu = new PopupMenu(options);
24217
24326
  };
24218
24327
  SortingBar.prototype.createSortMenu = function () {
24219
- var model = this.getContext().getModel();
24328
+ var model = this.getModel();
24220
24329
  if (!model || model.isEmpty())
24221
24330
  return null;
24222
24331
  var menuId = this.slot.id;
@@ -24253,8 +24362,8 @@ var SortingBar = /** @class */ (function (_super) {
24253
24362
  }
24254
24363
  (0,lib_public_api.domel)(this.slot)
24255
24364
  .addChildElement(this.columnsBlock);
24256
- var query = this.context.getQuery();
24257
- var columns = query.getColumns().concat(query.getJustSortedColumns());
24365
+ var query = this.getQuery();
24366
+ var columns = query.getSortedColumns(); // .getColumns().concat(query.getJustSortedColumns());
24258
24367
  columns.forEach(function (column, index) {
24259
24368
  var slot = _this.renderColumn(column);
24260
24369
  _this.columnsBlock.appendChild(slot);
@@ -24262,8 +24371,8 @@ var SortingBar = /** @class */ (function (_super) {
24262
24371
  };
24263
24372
  SortingBar.prototype.addNewColumn = function (attrId) {
24264
24373
  var _this = this;
24265
- var model = this.getContext().getModel();
24266
- var query = this.getContext().getQuery();
24374
+ var model = this.getModel();
24375
+ var query = this.getQuery();
24267
24376
  var getColumnByAttrId = function (attrid) {
24268
24377
  var attribute = model.getAttributeById(attrid);
24269
24378
  if (!attribute) {
@@ -24282,60 +24391,28 @@ var SortingBar = /** @class */ (function (_super) {
24282
24391
  }
24283
24392
  var column = query.createColumn(true);
24284
24393
  column.caption = _this.getDefaultColumnCaption(attribute);
24285
- column.sorting = SortDirection.Ascending;
24286
- column.sortIndex = _this.getQuery().getColumnSortIndex(column);
24394
+ column._sorting = SortDirection.Ascending;
24395
+ //column.sortIndex = this.getQuery().getColumnSortIndex(column);
24287
24396
  column.expr.tag = ExprTag.EntityAttribute;
24397
+ column.expr.dataType = attribute.dataType;
24288
24398
  //column.expr.id = attrid;
24289
24399
  column.expr.setValue(attrid, true);
24290
24400
  column.params.concat(attribute.params);
24291
24401
  return column;
24292
24402
  };
24293
- if (!this.getContext().getQuery()) {
24403
+ if (!this.getQuery()) {
24294
24404
  return;
24295
24405
  }
24296
- return this.addColumn(getColumnByAttrId(attrId));
24406
+ var newCol = getColumnByAttrId(attrId);
24407
+ return this.getQuery().addColumn({
24408
+ column: newCol
24409
+ });
24297
24410
  };
24298
24411
  SortingBar.prototype.getDefaultColumnCaption = function (attr) {
24299
24412
  var format = this.options.titleElementFormat || this.options.attrElementFormat;
24300
- var model = this.getContext().getModel();
24413
+ var model = this.getModel();
24301
24414
  return model.getAttributeText(attr, format);
24302
24415
  };
24303
- SortingBar.prototype.addColumn = function (column) {
24304
- var query = this.getContext().getQuery();
24305
- if (!query) {
24306
- return;
24307
- }
24308
- column = this.checkColumn(column);
24309
- if (!column) {
24310
- return;
24311
- }
24312
- column = query.addColumn({
24313
- caption: column.caption,
24314
- attributeId: column.expr.value,
24315
- sorting: column.sorting,
24316
- sortIndex: column.sortIndex,
24317
- justsorted: true
24318
- });
24319
- query.fireChangedEvent({
24320
- part: QueryChangePart.SortingColumns,
24321
- action: QueryChangeAction.Add,
24322
- changee: column
24323
- });
24324
- return column;
24325
- };
24326
- SortingBar.prototype.checkColumn = function (col) {
24327
- var query = this.getContext().getQuery();
24328
- var columns = query.getColumns()
24329
- .concat(query.getJustSortedColumns());
24330
- var colJson = JSON.stringify(col.expr.saveToData());
24331
- for (var i = 0; i < columns.length; i++) {
24332
- var qcolJson = JSON.stringify(columns[i].expr.saveToData());
24333
- if (qcolJson === colJson) {
24334
- return null;
24335
- }
24336
- }
24337
- return col;
24338
- };
24339
24416
  SortingBar.prototype.renderColumn = function (column, elem) {
24340
24417
  var renderer = new ColumnRendererSB(this, column, elem);
24341
24418
  if (renderer) {
@@ -24344,14 +24421,6 @@ var SortingBar = /** @class */ (function (_super) {
24344
24421
  }
24345
24422
  return null;
24346
24423
  };
24347
- //adds one column to the bar on the specified position
24348
- SortingBar.prototype.addColumnElement = function (column) {
24349
- var newColBlock = this.renderColumn(column);
24350
- this.columnsBlock.appendChild(newColBlock);
24351
- if (this.options.columnRenderedCallback) {
24352
- this.options.columnRenderedCallback(newColBlock);
24353
- }
24354
- };
24355
24424
  SortingBar.prototype.clear = function () {
24356
24425
  this.slot.innerHTML = '';
24357
24426
  };