@easyquery/enterprise 7.2.4-beta03 → 7.2.4-rc02

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-rc02 (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
  }
@@ -15625,11 +15681,19 @@ var Query = /** @class */ (function () {
15625
15681
  this._enableAggregation = false;
15626
15682
  this.parentQuery = null;
15627
15683
  this.drillDowns = [];
15684
+ this.syncSortOrderWithColumnsOrder = true;
15685
+ if (options) {
15686
+ this.context = options.context;
15687
+ if (this.context) {
15688
+ this.syncSortOrderWithColumnsOrder = this.context.options.syncSortOrderWithColumnsOrder;
15689
+ }
15690
+ }
15628
15691
  this.eventEmitter = new public_api.EventEmitter(this);
15629
15692
  this.root = new Condition(this, CondTag.Group);
15630
15693
  this.extraConditions = new Condition(this, CondTag.Group);
15631
15694
  this.columns = new Array();
15632
- this.justsorted = new Array();
15695
+ //this.justsorted = new Array<QueryColumn>();
15696
+ this.sortedColumns = new Array();
15633
15697
  if (!this.id) {
15634
15698
  this.regenerateId();
15635
15699
  }
@@ -15719,7 +15783,7 @@ var Query = /** @class */ (function () {
15719
15783
  return hasChanged;
15720
15784
  };
15721
15785
  Query.prototype.createSubQuery = function () {
15722
- return new Query(this.model);
15786
+ return new Query(this.model, null, { context: this.context });
15723
15787
  };
15724
15788
  Query.prototype.useAggregation = function (settingsTuner, silent) {
15725
15789
  if (silent === void 0) { silent = false; }
@@ -15780,6 +15844,7 @@ var Query = /** @class */ (function () {
15780
15844
  });
15781
15845
  };
15782
15846
  Query.prototype.processQueryForAggregation = function (silent) {
15847
+ var _this = this;
15783
15848
  if (silent === void 0) { silent = false; }
15784
15849
  var aggrSettings = this.getAggregationSettings();
15785
15850
  var groups = aggrSettings.getGroups();
@@ -15793,19 +15858,21 @@ var Query = /** @class */ (function () {
15793
15858
  if (groupColIds.indexOf(col.id) >= 0) {
15794
15859
  groupedCols.push(col);
15795
15860
  }
15796
- else if (col.sorting != SortDirection.None) {
15861
+ else if (this.getColumnSorting(col) != SortDirection.None) {
15797
15862
  sortedCols.push(col);
15798
15863
  }
15799
15864
  }
15800
15865
  var sortIndex_1 = 0;
15801
15866
  groupedCols.forEach(function (col) {
15802
- if (col.sorting == SortDirection.None) {
15803
- col.sorting = SortDirection.Ascending;
15867
+ if (_this.getColumnSorting(col) == SortDirection.None) {
15868
+ _this.setColumnSorting(col, SortDirection.Ascending);
15804
15869
  }
15805
- col.sortIndex = sortIndex_1++;
15870
+ _this.setColumnSortIndex(col, sortIndex_1++);
15871
+ //col.sortIndex = sortIndex++;
15806
15872
  });
15807
15873
  sortedCols.forEach(function (col) {
15808
- col.sortIndex = sortIndex_1++;
15874
+ _this.setColumnSortIndex(col, sortIndex_1++);
15875
+ // col.sortIndex = sortIndex++;
15809
15876
  });
15810
15877
  if (!silent) {
15811
15878
  this.fireChangedEvent({
@@ -16036,12 +16103,14 @@ var Query = /** @class */ (function () {
16036
16103
  }
16037
16104
  this.name = data.name;
16038
16105
  this.description = data.desc;
16039
- this.justsorted = [];
16106
+ //this.justsorted = [];
16107
+ this.sortedColumns = [];
16040
16108
  if (data.justsortcols) {
16041
16109
  for (var i = 0; i < data.justsortcols.length; i++) {
16042
16110
  var newCol = this.createColumn(true);
16043
16111
  newCol.loadFromData(this.model, data.justsortcols[i]);
16044
- this.justsorted.push(newCol);
16112
+ //this.justsorted.push(newCol);
16113
+ this.addColumnToSorted(newCol);
16045
16114
  }
16046
16115
  }
16047
16116
  if (data.cols) {
@@ -16049,8 +16118,15 @@ var Query = /** @class */ (function () {
16049
16118
  var newCol = this.createColumn();
16050
16119
  newCol.loadFromData(this.model, data.cols[i]);
16051
16120
  this.columns.push(newCol);
16121
+ if (newCol._sorting != SortDirection.None) {
16122
+ this.addColumnToSorted(newCol);
16123
+ }
16052
16124
  }
16053
16125
  }
16126
+ this.sortedColumns.sort(function (col1, col2) {
16127
+ return col1._sortIndex - col2._sortIndex;
16128
+ });
16129
+ this.fixupSortingIndices();
16054
16130
  if (data.extraData) {
16055
16131
  this.extraData = data.extraData;
16056
16132
  }
@@ -16140,6 +16216,7 @@ var Query = /** @class */ (function () {
16140
16216
  */
16141
16217
  Query.prototype.toJSONData = function () {
16142
16218
  var _this = this;
16219
+ this.fixupSortingIndices();
16143
16220
  var obj = {
16144
16221
  modelId: this.model ? this.model.getId() : null,
16145
16222
  modelName: this.model ? this.model.getName() : null
@@ -16154,9 +16231,14 @@ var Query = /** @class */ (function () {
16154
16231
  obj.cols.push(this.columns[i].saveToData());
16155
16232
  }
16156
16233
  obj.justsortcols = [];
16157
- for (var i = 0; i < this.justsorted.length; i++) {
16158
- obj.justsortcols.push(this.justsorted[i].saveToData());
16159
- }
16234
+ // for (let i = 0; i < this.justsorted.length; i++) {
16235
+ // obj.justsortcols.push(this.justsorted[i].saveToData());
16236
+ // }
16237
+ this.sortedColumns.forEach(function (col) {
16238
+ if (col.isJustSorted()) {
16239
+ obj.justsortcols.push(col.saveToData());
16240
+ }
16241
+ });
16160
16242
  if (this.extraData) {
16161
16243
  obj.extraData = this.extraData;
16162
16244
  }
@@ -16229,7 +16311,8 @@ var Query = /** @class */ (function () {
16229
16311
  */
16230
16312
  Query.prototype.clearColumns = function () {
16231
16313
  this.columns = [];
16232
- this.justsorted = [];
16314
+ //this.justsorted = [];
16315
+ this.sortedColumns = [];
16233
16316
  };
16234
16317
  /**
16235
16318
  * Clears all conditions in query.
@@ -16321,31 +16404,34 @@ var Query = /** @class */ (function () {
16321
16404
  cols.pop();
16322
16405
  return cols;
16323
16406
  };
16407
+ Query.prototype.addColumnToSorted = function (col) {
16408
+ var colJson = JSON.stringify(col.expr.saveToData());
16409
+ var isUnique = true;
16410
+ this.sortedColumns.forEach(function (scol) {
16411
+ var qcolJson = JSON.stringify(scol.expr.saveToData());
16412
+ if (qcolJson === colJson) {
16413
+ isUnique = false;
16414
+ }
16415
+ });
16416
+ if (isUnique) {
16417
+ this.sortedColumns.push(col);
16418
+ }
16419
+ };
16324
16420
  /**
16325
16421
  * Get array of columns used only in sorting.
16326
16422
  * @retruns Columns.
16327
16423
  */
16328
16424
  Query.prototype.getJustSortedColumns = function () {
16329
- return this.justsorted;
16425
+ return this.sortedColumns.filter(function (col) {
16426
+ return col.isJustSorted();
16427
+ });
16330
16428
  };
16331
16429
  /**
16332
16430
  * Gets array of columns used in sorting
16333
16431
  * @retruns Columns
16334
16432
  */
16335
16433
  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;
16434
+ return this.sortedColumns;
16349
16435
  };
16350
16436
  /**
16351
16437
  * Gets Colummn sorting index.
@@ -16353,17 +16439,71 @@ var Query = /** @class */ (function () {
16353
16439
  * @retruns The index.
16354
16440
  */
16355
16441
  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);
16442
+ return this.sortedColumns.indexOf(col);
16443
+ };
16444
+ Query.prototype.setColumnSortIndex = function (col, index) {
16445
+ if (index < 0)
16446
+ return;
16447
+ var colIdx = this.getColumnSortIndex(col);
16448
+ if (colIdx < 0) {
16449
+ this.addColumnToSorted(col);
16450
+ colIdx = this.sortedColumns.length - 1;
16451
+ }
16452
+ public_api.utils.moveArrayItem(this.sortedColumns, colIdx, index);
16453
+ this.fixupSortingIndices();
16454
+ this.fireColumnsChangedEvent(QueryChangeAction.All);
16455
+ };
16456
+ Query.prototype.getColumnSorting = function (col) {
16457
+ var idx = this.getColumnSortIndex(col);
16458
+ if (idx >= 0) {
16459
+ return col._sorting != SortDirection.None ? col._sorting : SortDirection.Ascending;
16460
+ }
16461
+ else {
16462
+ return SortDirection.None;
16463
+ }
16464
+ };
16465
+ Query.prototype.setColumnSorting = function (col, direction) {
16466
+ var idx = this.getColumnSortIndex(col);
16467
+ col._sorting = direction;
16468
+ if (idx >= 0) {
16469
+ if (direction == SortDirection.None) {
16470
+ public_api.utils.removeArrayItem(this.sortedColumns, col);
16471
+ this.fixupSortingIndices();
16361
16472
  }
16362
- else {
16363
- return col.sortIndex;
16473
+ }
16474
+ else {
16475
+ if (direction != SortDirection.None) {
16476
+ this.addColumnToSorted(col);
16477
+ this.fixupSortingIndices();
16364
16478
  }
16365
16479
  }
16366
- return -1;
16480
+ this.adjustColumnsSorting();
16481
+ this.fireColumnsChangedEvent(QueryChangeAction.Modify, col, col.isJustSorted());
16482
+ };
16483
+ Query.prototype.fixupSortingIndices = function () {
16484
+ this.sortedColumns.forEach(function (col, index) {
16485
+ col._sortIndex = index;
16486
+ });
16487
+ };
16488
+ Query.prototype.adjustColumnsSorting = function () {
16489
+ var _this = this;
16490
+ if (!this.syncSortOrderWithColumnsOrder) {
16491
+ return;
16492
+ }
16493
+ if (this.getJustSortedColumns().length > 0) {
16494
+ return;
16495
+ }
16496
+ var idx = 0;
16497
+ this.columns.forEach(function (col) {
16498
+ if (col.sorting != SortDirection.None) {
16499
+ var colIdx = _this.getColumnSortIndex(col);
16500
+ if (colIdx >= 0) {
16501
+ public_api.utils.moveArrayItem(_this.sortedColumns, colIdx, idx);
16502
+ idx++;
16503
+ }
16504
+ }
16505
+ });
16506
+ this.fixupSortingIndices();
16367
16507
  };
16368
16508
  Query.prototype.createColumn = function (justsorted) {
16369
16509
  if (justsorted === void 0) { justsorted = false; }
@@ -16388,9 +16528,9 @@ var Query = /** @class */ (function () {
16388
16528
  * }});
16389
16529
  */
16390
16530
  Query.prototype.addColumn = function (descriptor, author) {
16391
- var columns = (descriptor.justsorted)
16392
- ? this.justsorted
16393
- : this.columns;
16531
+ // let columns = (descriptor.justsorted)
16532
+ // ? this.justsorted
16533
+ // : this.columns;
16394
16534
  var newColumn;
16395
16535
  if (descriptor.column) {
16396
16536
  newColumn = descriptor.column;
@@ -16452,17 +16592,22 @@ var Query = /** @class */ (function () {
16452
16592
  newColumn.expr.dataType = attr.dataType;
16453
16593
  }
16454
16594
  newColumn.caption = descriptor.caption || newColumn.caption;
16455
- newColumn.sorting = descriptor.sorting || SortDirection.None;
16456
- newColumn.sortIndex = descriptor.sortIndex || -1;
16595
+ newColumn._sorting = descriptor.sorting || SortDirection.None;
16596
+ newColumn._sortIndex = descriptor.sortIndex || -1;
16457
16597
  newColumn.enabled = public_api.utils.getIfDefined(descriptor.enabled, true);
16458
16598
  newColumn.setReadOnly(public_api.utils.getIfDefined(descriptor.readonly, false));
16459
16599
  }
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);
16600
+ var justsorted = descriptor.justsorted || (descriptor.column && descriptor.column.isJustSorted());
16601
+ if (!justsorted) {
16602
+ if (descriptor.index && descriptor.index >= 0 && descriptor.index < this.columns.length) {
16603
+ this.columns.splice(descriptor.index, 0, newColumn);
16604
+ }
16605
+ else {
16606
+ this.columns.push(newColumn);
16607
+ }
16465
16608
  }
16609
+ this.setColumnSorting(newColumn, newColumn._sorting);
16610
+ this.fireColumnsChangedEvent(QueryChangeAction.Add, newColumn, justsorted);
16466
16611
  return newColumn;
16467
16612
  };
16468
16613
  /**
@@ -16477,6 +16622,7 @@ var Query = /** @class */ (function () {
16477
16622
  * query.addColumn(column, 1)
16478
16623
  */
16479
16624
  Query.prototype.addColumnObj = function (column, index, author) {
16625
+ var _this = this;
16480
16626
  var columns = this.columns;
16481
16627
  if (typeof column.length == "undefined") {
16482
16628
  if (typeof index == "number") {
@@ -16485,6 +16631,10 @@ var Query = /** @class */ (function () {
16485
16631
  else {
16486
16632
  columns.push(column);
16487
16633
  }
16634
+ if (column.sorting != SortDirection.None) {
16635
+ this.addColumnToSorted(column);
16636
+ }
16637
+ this.fixupSortingIndices();
16488
16638
  }
16489
16639
  else {
16490
16640
  if (typeof index == "number") {
@@ -16493,6 +16643,12 @@ var Query = /** @class */ (function () {
16493
16643
  else {
16494
16644
  columns.push.apply(columns, [].concat(column));
16495
16645
  }
16646
+ column.forEach(function (col) {
16647
+ if (col.sorting != SortDirection.None) {
16648
+ _this.addColumnToSorted(col);
16649
+ }
16650
+ });
16651
+ this.fixupSortingIndices();
16496
16652
  }
16497
16653
  };
16498
16654
  /**
@@ -16565,6 +16721,7 @@ var Query = /** @class */ (function () {
16565
16721
  Query.prototype.moveColumn = function (index1, index2) {
16566
16722
  var columns = this.getColumns();
16567
16723
  public_api.utils.moveArrayItem(columns, index1, index2);
16724
+ this.adjustColumnsSorting();
16568
16725
  };
16569
16726
  /**
16570
16727
  * Removes the column.
@@ -16572,10 +16729,11 @@ var Query = /** @class */ (function () {
16572
16729
  * @param author The author
16573
16730
  */
16574
16731
  Query.prototype.removeColumn = function (column, author) {
16575
- var columns = (column.isJustSorted())
16576
- ? this.getJustSortedColumns()
16577
- : this.getColumns();
16578
- public_api.utils.removeArrayItem(columns, column);
16732
+ // const columns = (column.isJustSorted())
16733
+ // ? this.getJustSortedColumns()
16734
+ // : this.getColumns();
16735
+ public_api.utils.removeArrayItem(this.columns, column);
16736
+ public_api.utils.removeArrayItem(this.sortedColumns, column);
16579
16737
  };
16580
16738
  /**
16581
16739
  * Adds a condition group - a group of simple conditions (predicates) linked by AND or OR
@@ -16681,10 +16839,13 @@ var Query = /** @class */ (function () {
16681
16839
  }
16682
16840
  if (columns.length > 0) {
16683
16841
  removeFromArray(this.getColumns(), columns);
16842
+ removeFromArray(this.sortedColumns, columns);
16684
16843
  }
16685
16844
  if (justSortedColumns.length > 0) {
16686
- removeFromArray(this.getJustSortedColumns(), justSortedColumns);
16845
+ //removeFromArray(this.getJustSortedColumns(), justSortedColumns);
16846
+ removeFromArray(this.sortedColumns, justSortedColumns);
16687
16847
  }
16848
+ this.fixupSortingIndices();
16688
16849
  };
16689
16850
  /**
16690
16851
  * Fires process event.
@@ -16985,7 +17146,7 @@ var BrowserQueryStorage = /** @class */ (function () {
16985
17146
  BrowserQueryStorage.prototype.newQuery = function (options) {
16986
17147
  var _this = this;
16987
17148
  return new Promise(function (resolve, reject) {
16988
- var query = new Query(_this.context.getModel());
17149
+ var query = new Query(_this.context.getModel(), null, { context: _this.context });
16989
17150
  query.reset();
16990
17151
  query.setDefaultName();
16991
17152
  if (options) {
@@ -17263,7 +17424,7 @@ var EqQueryFileLoader = /** @class */ (function () {
17263
17424
  });
17264
17425
  var request = actionResult.getRequest();
17265
17426
  return actionResult.then(function (responseData) {
17266
- var blob = new Blob([JSON.stringify(responseData)]);
17427
+ var blob = new Blob([responseData]);
17267
17428
  var dispositionHeader = request.getXMLHttpRequest().getResponseHeader("Content-Disposition");
17268
17429
  var fileName = dispositionHeader
17269
17430
  ? dispositionHeader.match(/filename="(.*)"/)[1]
@@ -17440,7 +17601,7 @@ var EqServiceProvider = /** @class */ (function () {
17440
17601
  this.httpClient.defaultHeaders['x-eqjs-version'] = '7.2.0';
17441
17602
  this.modelResolver = function (_) { return new DataModel(); };
17442
17603
  this.modelStorageResolver = null;
17443
- this.queryResolver = function (context) { return new Query(context.getModel()); };
17604
+ this.queryResolver = function (context) { return new Query(context.getModel(), null, { context: context }); };
17444
17605
  this.modelLoaderResolver = function (context) { return new EqServerModelLoader(context); };
17445
17606
  this.queryStorageResolver = function (context) { return new BrowserQueryStorage(context); };
17446
17607
  this.querySynchronizerResolver = function (context) { return new EqServerQuerySynchronizer(context); };
@@ -17695,6 +17856,7 @@ var EqActionResult;
17695
17856
  })(EqActionResult || (EqActionResult = {}));
17696
17857
  //# sourceMappingURL=action.js.map
17697
17858
  ;// CONCATENATED MODULE: ../core/dist/lib/eqs/eqs_exporter.js
17859
+
17698
17860
  var EqServerExporter = /** @class */ (function () {
17699
17861
  function EqServerExporter(context) {
17700
17862
  this.context = context;
@@ -17710,7 +17872,8 @@ var EqServerExporter = /** @class */ (function () {
17710
17872
  var query = exportOptions.query || this.context.getQuery();
17711
17873
  var modelId = query.getModel().getId();
17712
17874
  var requestData = {
17713
- 'settings': exportOptions.settings
17875
+ 'settings': exportOptions.settings,
17876
+ 'chunk': EmptyChunk
17714
17877
  };
17715
17878
  if (typeof (exportOptions.queryId) !== 'undefined') {
17716
17879
  requestData.queryId = exportOptions.queryId;
@@ -17775,6 +17938,8 @@ var context_assign = (undefined && undefined.__assign) || function () {
17775
17938
 
17776
17939
 
17777
17940
 
17941
+
17942
+
17778
17943
  /**
17779
17944
  * Encapsulates all information about EasyQuery components on some webpage
17780
17945
  * and provides some basic operation over those components
@@ -17787,6 +17952,9 @@ var context_assign = (undefined && undefined.__assign) || function () {
17787
17952
  var EqContext = /** @class */ (function () {
17788
17953
  function EqContext() {
17789
17954
  var _this = this;
17955
+ this.options = {
17956
+ syncSortOrderWithColumnsOrder: true
17957
+ };
17790
17958
  this.servicesInitialized = false;
17791
17959
  this.internalListCache = {};
17792
17960
  this.loadModelOnStart = true;
@@ -17916,8 +18084,8 @@ var EqContext = /** @class */ (function () {
17916
18084
  return Array.from(this.exporters.keys());
17917
18085
  };
17918
18086
  EqContext.prototype.addDefaultExporters = function () {
17919
- this.registerServerExporter('csv', '');
17920
- this.registerServerExporter('excel-html', '');
18087
+ this.registerServerExporter('csv', 'arraybuffer');
18088
+ this.registerServerExporter('excel-html', 'arraybuffer');
17921
18089
  };
17922
18090
  EqContext.prototype.resolveEndpoint = function (endpointKey, options) {
17923
18091
  options = options || {};
@@ -17980,6 +18148,7 @@ var EqContext = /** @class */ (function () {
17980
18148
  if (!this.servicesInitialized)
17981
18149
  this.initStart();
17982
18150
  options = options || {};
18151
+ this.setOptions(options);
17983
18152
  if (typeof (options.debugMode) !== 'undefined') {
17984
18153
  this.debugMode = options.debugMode;
17985
18154
  }
@@ -18078,8 +18247,7 @@ var EqContext = /** @class */ (function () {
18078
18247
  this.exporters.clear();
18079
18248
  for (var _i = 0, _a = options.serverExporters; _i < _a.length; _i++) {
18080
18249
  var format = _a[_i];
18081
- var responseType = format == 'csv' || format == 'excel-html' ? '' : 'arraybuffer';
18082
- this.registerServerExporter(format, responseType);
18250
+ this.registerServerExporter(format, "arraybuffer");
18083
18251
  }
18084
18252
  }
18085
18253
  var query = this.getQuery();
@@ -18101,6 +18269,9 @@ var EqContext = /** @class */ (function () {
18101
18269
  this.fireEvent('ready');
18102
18270
  }
18103
18271
  };
18272
+ EqContext.prototype.setOptions = function (options) {
18273
+ public_api.utils.assignDeep(this.options, options);
18274
+ };
18104
18275
  Object.defineProperty(EqContext.prototype, "backendInfo", {
18105
18276
  get: function () {
18106
18277
  return this._backendInfo;
@@ -18558,6 +18729,7 @@ var EqContext = /** @class */ (function () {
18558
18729
  validate: false
18559
18730
  });
18560
18731
  }
18732
+ _this.limitCustomSqlColumns();
18561
18733
  _this.fireEvent('loadQuery');
18562
18734
  _this.endProcess({
18563
18735
  result: EqActionResult.Success,
@@ -19141,6 +19313,7 @@ var EqContext = /** @class */ (function () {
19141
19313
  EqContext.prototype.exportResult = function (options) {
19142
19314
  var _this = this;
19143
19315
  options = options || {};
19316
+ options.chunk = options.chunk || EmptyChunk;
19144
19317
  if (this.beforeExportResult) {
19145
19318
  this.beforeExportResult(this, options);
19146
19319
  }
@@ -19190,6 +19363,15 @@ var EqContext = /** @class */ (function () {
19190
19363
  }
19191
19364
  }
19192
19365
  };
19366
+ EqContext.prototype.limitCustomSqlColumns = function () {
19367
+ if (!this.options.allowCustomExpressions) {
19368
+ this.query.getColumns().forEach(function (col) {
19369
+ if (col.expr.tag === ExprTag.CustomSql) {
19370
+ col.enabled = false;
19371
+ }
19372
+ });
19373
+ }
19374
+ };
19193
19375
  return EqContext;
19194
19376
  }());
19195
19377
 
@@ -21409,10 +21591,20 @@ var ColumnRendererCP = /** @class */ (function () {
21409
21591
  enumerable: false,
21410
21592
  configurable: true
21411
21593
  });
21594
+ Object.defineProperty(ColumnRendererCP.prototype, "columnEnabled", {
21595
+ get: function () {
21596
+ return this.column.enabled;
21597
+ },
21598
+ set: function (value) {
21599
+ this.column.enabled = value;
21600
+ },
21601
+ enumerable: false,
21602
+ configurable: true
21603
+ });
21412
21604
  ColumnRendererCP.prototype.render = function () {
21413
21605
  var _this = this;
21414
21606
  this.baseAttr = this.getAttribute();
21415
- if (this.getButtonsToShow().indexOf("sorting") >= 0 && this.column.enabled) {
21607
+ if (this.getButtonsToShow().indexOf("sorting") >= 0 && this.columnEnabled) {
21416
21608
  this.sortingButton = this.renderSoringButton(this.column.sorting);
21417
21609
  if (this.column.sorting !== SortDirection.None) {
21418
21610
  this.sortingButton.style.display = 'block';
@@ -21482,12 +21674,12 @@ var ColumnRendererCP = /** @class */ (function () {
21482
21674
  }
21483
21675
  //end enable button
21484
21676
  //start aggr func button
21485
- if (_this.getButtonsToShow().indexOf("type") >= 0 && _this.column.enabled) {
21677
+ if (_this.getButtonsToShow().indexOf("type") >= 0 && _this.columnEnabled) {
21486
21678
  builder.addChildElement(_this.renderColumnTypeButton());
21487
21679
  }
21488
21680
  //end aggr func button
21489
21681
  //start format selector button
21490
- if (_this.getButtonsToShow().indexOf("format") >= 0 && _this.column.enabled) {
21682
+ if (_this.getButtonsToShow().indexOf("format") >= 0 && _this.columnEnabled) {
21491
21683
  builder.addChildElement(_this.renderColumnFormatButton());
21492
21684
  }
21493
21685
  //end format selector button
@@ -21700,9 +21892,9 @@ var ColumnRendererCP = /** @class */ (function () {
21700
21892
  .title(public_api.i18n.getText('CmdToggleEnable'))
21701
21893
  .attr('tabIndex', '0')
21702
21894
  .addClass("".concat(this.cssPrefix, "-colelement ").concat(this.cssPrefix, "-column-checkbox"))
21703
- .addClass("".concat(this.column.enabled ? 'enabled' : ''))
21895
+ .addClass("".concat(this.columnEnabled ? 'enabled' : ''))
21704
21896
  .on('click', function () {
21705
- _this.column.enabled = !_this.column.enabled;
21897
+ _this.columnEnabled = !_this.columnEnabled;
21706
21898
  _this.column.fireChangedEvent();
21707
21899
  return false;
21708
21900
  })
@@ -21758,8 +21950,8 @@ var ColumnRendererCP = /** @class */ (function () {
21758
21950
  };
21759
21951
  ColumnRendererCP.prototype.getClassesToAdd = function () {
21760
21952
  var result = "";
21761
- result += this.column.enabled ? '' : " ".concat(this.cssPrefix, "-disabled");
21762
- if (this.column.enabled) {
21953
+ result += this.columnEnabled ? '' : " ".concat(this.cssPrefix, "-disabled");
21954
+ if (this.columnEnabled) {
21763
21955
  result += this.column.isReadOnly() ? " ".concat(this.cssPrefix, "-readonly") : '';
21764
21956
  }
21765
21957
  result += this.column.isHidden() ? " ".concat(this.cssPrefix, "-hidden") : '';
@@ -21816,7 +22008,7 @@ var ColumnRendererCP = /** @class */ (function () {
21816
22008
  .addChild('div', function (b) { return b
21817
22009
  .addClass("".concat(utils/* eqCssPrefix */.YR, "-button"), "".concat(utils/* eqCssPrefix */.YR, "-column-button"), "".concat(utils/* eqCssPrefix */.YR, "-column-button-enable"))
21818
22010
  .title(public_api.i18n.getText('CmdToggleEnable'))
21819
- .addClass(_this.column.enabled ? 'enabled' : '')
22011
+ .addClass(_this.columnEnabled ? 'enabled' : '')
21820
22012
  .attr('tabIndex', '0')
21821
22013
  .on('click', function (evt) { return _this.buttonMenuHandler(ColumnAction.Enable, evt); }) //touchstart
21822
22014
  .on('keypress', function (evt) { if (evt.keyCode == 13) {
@@ -21824,7 +22016,7 @@ var ColumnRendererCP = /** @class */ (function () {
21824
22016
  } }); }).toDOM();
21825
22017
  };
21826
22018
  ColumnRendererCP.prototype.isEditable = function () {
21827
- return this.column.enabled && !this.column.isReadOnly();
22019
+ return this.columnEnabled && !this.column.isReadOnly();
21828
22020
  };
21829
22021
  ColumnRendererCP.prototype.changeFormatHandler = function (ev) {
21830
22022
  var _this = this;
@@ -21990,7 +22182,7 @@ var ColumnRendererCP = /** @class */ (function () {
21990
22182
  curQuery.fireColumnsChangedEvent(QueryChangeAction.Delete, this.column);
21991
22183
  break;
21992
22184
  case ColumnAction.Enable:
21993
- this.column.enabled = !this.column.enabled;
22185
+ this.columnEnabled = !this.columnEnabled;
21994
22186
  this.fireColumnChanged();
21995
22187
  break;
21996
22188
  case ColumnAction.Hidden:
@@ -22064,7 +22256,7 @@ var ColumnRendererCP = /** @class */ (function () {
22064
22256
  _this.buttonMenuHandler(action, evt);
22065
22257
  },
22066
22258
  itemFilterCallback: function (item) {
22067
- var result = _this.column.enabled || item.id === "__group" || item.id === "enable" || item.id === "delete";
22259
+ var result = _this.columnEnabled || item.id === "__group" || item.id === "enable" || item.id === "delete";
22068
22260
  return result;
22069
22261
  },
22070
22262
  menuClosedCallback: function () {
@@ -22157,7 +22349,7 @@ var ColumnRendererCP = /** @class */ (function () {
22157
22349
  ColumnRendererCP.prototype.getButtonMenuSelectedItems = function () {
22158
22350
  var _this = this;
22159
22351
  var arrSelected = [];
22160
- if (this.column.enabled) {
22352
+ if (this.columnEnabled) {
22161
22353
  arrSelected.push("enable");
22162
22354
  }
22163
22355
  ;
@@ -22573,13 +22765,6 @@ var CustomSqlColumnRendererCP = /** @class */ (function (_super) {
22573
22765
  _this.dataTypeMenu = null;
22574
22766
  return _this;
22575
22767
  }
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
22768
  CustomSqlColumnRendererCP.prototype.renderEnabledButton = function () {
22584
22769
  var elem = _super.prototype.renderEnabledButton.call(this);
22585
22770
  var child = elem.children[0];
@@ -23137,6 +23322,7 @@ var ColumnsPanel = /** @class */ (function (_super) {
23137
23322
  };
23138
23323
  ColumnsPanel.prototype.setOptions = function (options) {
23139
23324
  public_api.utils.assignDeep(this.options, options);
23325
+ this.getContext().options.allowCustomExpressions = options.allowCustomExpressions;
23140
23326
  if (browser_utils/* browserUtils.isMobileMode */.z.isMobileMode()) {
23141
23327
  this.options.buttons = ["menu"];
23142
23328
  this.options.showHeader = false;
@@ -23356,7 +23542,7 @@ var ColumnsPanel = /** @class */ (function (_super) {
23356
23542
  };
23357
23543
  ColumnsPanel.prototype.areCustomExpressionsAllowed = function () {
23358
23544
  var query = this.getQuery();
23359
- return query.isEx() && this.options.allowCustomExpressions;
23545
+ return query.isEx() && this.getContext().options.allowCustomExpressions;
23360
23546
  };
23361
23547
  ColumnsPanel.prototype.addAllColumnsToEntitiesList = function (list) {
23362
23548
  var _this = this;
@@ -23785,7 +23971,7 @@ var ColumnRendererCB = /** @class */ (function () {
23785
23971
  if (data.id == 'None' || data.id == "Ascending" || data.id == "Descending") {
23786
23972
  var query = _this.bar.getQuery();
23787
23973
  _this.column.sorting = strToSortDirection(data.id);
23788
- _this.column.sortIndex = query.getColumnSortIndex(_this.column);
23974
+ _this.column._sortIndex = query.getColumnSortIndex(_this.column);
23789
23975
  _this.fireColumnChanged();
23790
23976
  }
23791
23977
  else {
@@ -24340,10 +24526,15 @@ var ColumnsBar = /** @class */ (function (_super) {
24340
24526
  _this.hideLandingSlot();
24341
24527
  },
24342
24528
  onDrop: function (container, ev) {
24343
- var query = _this.getQuery();
24344
- var columns = query.getColumns();
24345
- var index = columns.indexOf(ev.data.column);
24346
- _this.moveColumnCore(index, _this.landingIndex);
24529
+ if (_this.landingIndex >= 0) {
24530
+ var query = _this.getQuery();
24531
+ var columns = query.getColumns();
24532
+ var index = columns.indexOf(ev.data.column);
24533
+ _this.moveColumnCore(index, _this.landingIndex);
24534
+ }
24535
+ else {
24536
+ ev.item.element.removeAttribute('style');
24537
+ }
24347
24538
  }
24348
24539
  });
24349
24540
  }
@@ -24976,6 +25167,7 @@ var ColumnRendererSB = /** @class */ (function () {
24976
25167
  configurable: true
24977
25168
  });
24978
25169
  ColumnRendererSB.prototype.render = function () {
25170
+ var _this = this;
24979
25171
  this.baseAttr = this.getAttribute();
24980
25172
  var builder = (0,lib_public_api.domel)('div');
24981
25173
  builder.data('id', this.column.id);
@@ -24985,6 +25177,23 @@ var ColumnRendererSB = /** @class */ (function () {
24985
25177
  .replaceChild(builder.toDOM(), this.element);
24986
25178
  }
24987
25179
  this.element = builder.toDOM();
25180
+ if (this.bar.options.allowDragDrop) {
25181
+ lib_public_api.eqDragManager.registerDraggableItem({
25182
+ element: this.element,
25183
+ scope: "entityAttrSortSB",
25184
+ beforeDragStart: function () { return _this.element.dispatchEvent((0,lib_public_api.createBrowserEvent)('mouseleave')); },
25185
+ onDragStart: function (ev) {
25186
+ _this.element.style.display = 'none';
25187
+ ev.dropEffect = lib_public_api.DropEffect.Allow;
25188
+ },
25189
+ onDragEnd: function (ev) {
25190
+ if (!ev.data.finishedSuccessfully) {
25191
+ _this.element.removeAttribute('style');
25192
+ }
25193
+ },
25194
+ data: { column: this.column }
25195
+ });
25196
+ }
24988
25197
  builder
24989
25198
  .addClass(this.getClassesToAdd())
24990
25199
  .addClass(browser_utils/* browserUtils.getMobileCssClass */.z.getMobileCssClass())
@@ -25087,10 +25296,13 @@ var ColumnRendererSB = /** @class */ (function () {
25087
25296
  }
25088
25297
  else {
25089
25298
  _this.column.sorting = strToSortDirection(data.id);
25090
- _this.column.sortIndex = query.getColumnSortIndex(_this.column);
25299
+ _this.column._sortIndex = query.getColumnSortIndex(_this.column);
25091
25300
  _this.fireColumnChanged();
25092
25301
  }
25093
25302
  }
25303
+ else {
25304
+ _this.bar.moveColumn(_this.column, data.id);
25305
+ }
25094
25306
  },
25095
25307
  menuClosedCallback: function () {
25096
25308
  _this.keepShowingButtons = false;
@@ -25149,6 +25361,7 @@ var SortingBar = /** @class */ (function (_super) {
25149
25361
  showAddRow: true,
25150
25362
  attrElementFormat: '{entity} {attr}',
25151
25363
  titleElementFormat: null,
25364
+ allowDragDrop: true,
25152
25365
  menuOptions: {
25153
25366
  showSearchBoxAfter: 30,
25154
25367
  searchBoxAutoFocus: true,
@@ -25160,8 +25373,17 @@ var SortingBar = /** @class */ (function (_super) {
25160
25373
  _this.sortMenuList = [
25161
25374
  { id: 'None', text: public_api.i18n.getText('CmdNotSorted') },
25162
25375
  { id: 'Ascending', text: public_api.i18n.getText('CmdAscending') },
25163
- { id: 'Descending', text: public_api.i18n.getText('CmdDescending') }
25376
+ { id: 'Descending', text: public_api.i18n.getText('CmdDescending') },
25377
+ { id: '---', text: '---' },
25378
+ { id: 'MoveTop', text: public_api.i18n.getText('CmdMoveToFirst') },
25379
+ { id: 'MoveUp', text: public_api.i18n.getText('CmdMoveToPrev') },
25380
+ { id: 'MoveDown', text: public_api.i18n.getText('CmdMoveToNext') },
25381
+ { id: 'MoveBottom', text: public_api.i18n.getText('CmdMoveToLast') }
25164
25382
  ];
25383
+ _this.landingSlot = (0,lib_public_api.domel)('div')
25384
+ .addClass("".concat(utils/* eqCssPrefix */.YR, "-highlight"))
25385
+ .toDOM();
25386
+ _this.landingIndex = -1;
25165
25387
  (0,lib_public_api.domel)(_this.slot)
25166
25388
  .addClass("".concat(_this.cssPrefix, "-panel"))
25167
25389
  .addClass(browser_utils/* browserUtils.getMobileCssClass */.z.getMobileCssClass());
@@ -25179,10 +25401,37 @@ var SortingBar = /** @class */ (function (_super) {
25179
25401
  return 'sortingBar';
25180
25402
  };
25181
25403
  SortingBar.prototype.init = function (context, options) {
25404
+ var _this = this;
25182
25405
  _super.prototype.init.call(this, context, options);
25183
25406
  this.setOptions(options);
25184
25407
  this.destroyCore();
25185
25408
  this.attachQueryObserver();
25409
+ lib_public_api.eqDragManager.removeDropContainer(this.slot);
25410
+ if (this.options.allowDragDrop) {
25411
+ lib_public_api.eqDragManager.registerDropContainer({
25412
+ element: this.slot,
25413
+ scopes: ["entityAttrSortSB"],
25414
+ onDragEnter: function (container, ev) {
25415
+ _this.showLandingSlot(ev.pageX, ev.pageY);
25416
+ },
25417
+ onDragOver: function (container, ev) {
25418
+ _this.showLandingSlot(ev.pageX, ev.pageY);
25419
+ },
25420
+ onDragLeave: function (container, ev) {
25421
+ ev.dropEffect = lib_public_api.DropEffect.Forbid;
25422
+ _this.hideLandingSlot();
25423
+ },
25424
+ onDrop: function (container, ev) {
25425
+ if (_this.landingIndex >= 0) {
25426
+ var query = _this.getQuery();
25427
+ query.setColumnSortIndex(ev.data.column, _this.landingIndex);
25428
+ }
25429
+ else {
25430
+ ev.item.element.removeAttribute('style');
25431
+ }
25432
+ }
25433
+ });
25434
+ }
25186
25435
  };
25187
25436
  SortingBar.prototype.setOptions = function (options) {
25188
25437
  public_api.utils.assignDeep(this.options, options);
@@ -25197,66 +25446,21 @@ var SortingBar = /** @class */ (function (_super) {
25197
25446
  && edata.part != QueryChangePart.Columns && edata.part != QueryChangePart.All)) {
25198
25447
  return;
25199
25448
  }
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
- }
25449
+ _this.refresh();
25249
25450
  });
25250
25451
  };
25251
25452
  SortingBar.prototype.detachQueryObserver = function () {
25252
25453
  if (this.queryEventCallbackId) {
25253
- var query = this.getContext().getQuery();
25454
+ var query = this.getQuery();
25254
25455
  query.removeChangedCallback(this.queryEventCallbackId);
25255
25456
  }
25256
25457
  };
25257
25458
  SortingBar.prototype.getQuery = function () {
25258
25459
  return this.getContext().getQuery();
25259
25460
  };
25461
+ SortingBar.prototype.getModel = function () {
25462
+ return this.getContext().getModel();
25463
+ };
25260
25464
  SortingBar.prototype.destroyCore = function () {
25261
25465
  this.detachQueryObserver();
25262
25466
  this.clear();
@@ -25294,7 +25498,7 @@ var SortingBar = /** @class */ (function (_super) {
25294
25498
  this.entitiesMenu.showMenu(menuOptions);
25295
25499
  };
25296
25500
  SortingBar.prototype.createEntitiesMenu = function () {
25297
- var model = this.getContext().getModel();
25501
+ var model = this.getModel();
25298
25502
  if (!model || model.isEmpty())
25299
25503
  return null;
25300
25504
  var menuId = this.slot.id;
@@ -25307,7 +25511,7 @@ var SortingBar = /** @class */ (function (_super) {
25307
25511
  this.entitiesMenu = new PopupMenu(options);
25308
25512
  };
25309
25513
  SortingBar.prototype.createSortMenu = function () {
25310
- var model = this.getContext().getModel();
25514
+ var model = this.getModel();
25311
25515
  if (!model || model.isEmpty())
25312
25516
  return null;
25313
25517
  var menuId = this.slot.id;
@@ -25344,8 +25548,8 @@ var SortingBar = /** @class */ (function (_super) {
25344
25548
  }
25345
25549
  (0,lib_public_api.domel)(this.slot)
25346
25550
  .addChildElement(this.columnsBlock);
25347
- var query = this.context.getQuery();
25348
- var columns = query.getColumns().concat(query.getJustSortedColumns());
25551
+ var query = this.getQuery();
25552
+ var columns = query.getSortedColumns(); // .getColumns().concat(query.getJustSortedColumns());
25349
25553
  columns.forEach(function (column, index) {
25350
25554
  var slot = _this.renderColumn(column);
25351
25555
  _this.columnsBlock.appendChild(slot);
@@ -25353,8 +25557,8 @@ var SortingBar = /** @class */ (function (_super) {
25353
25557
  };
25354
25558
  SortingBar.prototype.addNewColumn = function (attrId) {
25355
25559
  var _this = this;
25356
- var model = this.getContext().getModel();
25357
- var query = this.getContext().getQuery();
25560
+ var model = this.getModel();
25561
+ var query = this.getQuery();
25358
25562
  var getColumnByAttrId = function (attrid) {
25359
25563
  var attribute = model.getAttributeById(attrid);
25360
25564
  if (!attribute) {
@@ -25373,60 +25577,28 @@ var SortingBar = /** @class */ (function (_super) {
25373
25577
  }
25374
25578
  var column = query.createColumn(true);
25375
25579
  column.caption = _this.getDefaultColumnCaption(attribute);
25376
- column.sorting = SortDirection.Ascending;
25377
- column.sortIndex = _this.getQuery().getColumnSortIndex(column);
25580
+ column._sorting = SortDirection.Ascending;
25581
+ //column.sortIndex = this.getQuery().getColumnSortIndex(column);
25378
25582
  column.expr.tag = ExprTag.EntityAttribute;
25583
+ column.expr.dataType = attribute.dataType;
25379
25584
  //column.expr.id = attrid;
25380
25585
  column.expr.setValue(attrid, true);
25381
25586
  column.params.concat(attribute.params);
25382
25587
  return column;
25383
25588
  };
25384
- if (!this.getContext().getQuery()) {
25589
+ if (!this.getQuery()) {
25385
25590
  return;
25386
25591
  }
25387
- return this.addColumn(getColumnByAttrId(attrId));
25592
+ var newCol = getColumnByAttrId(attrId);
25593
+ return this.getQuery().addColumn({
25594
+ column: newCol
25595
+ });
25388
25596
  };
25389
25597
  SortingBar.prototype.getDefaultColumnCaption = function (attr) {
25390
25598
  var format = this.options.titleElementFormat || this.options.attrElementFormat;
25391
- var model = this.getContext().getModel();
25599
+ var model = this.getModel();
25392
25600
  return model.getAttributeText(attr, format);
25393
25601
  };
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
25602
  SortingBar.prototype.renderColumn = function (column, elem) {
25431
25603
  var renderer = new ColumnRendererSB(this, column, elem);
25432
25604
  if (renderer) {
@@ -25435,17 +25607,84 @@ var SortingBar = /** @class */ (function (_super) {
25435
25607
  }
25436
25608
  return null;
25437
25609
  };
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
25610
  SortingBar.prototype.clear = function () {
25447
25611
  this.slot.innerHTML = '';
25448
25612
  };
25613
+ SortingBar.prototype.moveColumn = function (column, direction) {
25614
+ var query = this.getQuery();
25615
+ var columns = query.getSortedColumns();
25616
+ var index = query.getColumnSortIndex(column);
25617
+ if (index >= 0) {
25618
+ switch (direction) {
25619
+ case 'MoveTop':
25620
+ query.setColumnSortIndex(column, 0);
25621
+ break;
25622
+ case 'MoveUp':
25623
+ query.setColumnSortIndex(column, index > 0 ? index - 1 : 0);
25624
+ break;
25625
+ case 'MoveDown':
25626
+ query.setColumnSortIndex(column, index < columns.length - 1 ? index + 1 : columns.length - 1);
25627
+ break;
25628
+ case 'MoveBottom':
25629
+ query.setColumnSortIndex(column, columns.length - 1);
25630
+ break;
25631
+ }
25632
+ ;
25633
+ }
25634
+ };
25635
+ SortingBar.prototype.showLandingSlot = function (pageX, pageY) {
25636
+ var elements = this.columnsBlock.querySelectorAll("[class*=".concat(this.cssPrefix, "-row]"));
25637
+ var columnSlots = [];
25638
+ for (var i = 0; i < elements.length; i++) {
25639
+ if (elements[i].style.display !== 'none') {
25640
+ columnSlots.push(elements[i]);
25641
+ }
25642
+ }
25643
+ if (columnSlots.length === 0) {
25644
+ this.landingIndex = 0;
25645
+ return;
25646
+ }
25647
+ var landingPos = (0,lib_public_api.getElementAbsolutePos)(this.landingSlot);
25648
+ if (pageX >= landingPos.x && pageX <= landingPos.x + this.landingSlot.offsetWidth
25649
+ && pageY >= landingPos.y && pageY <= landingPos.y + this.landingSlot.offsetHeight) {
25650
+ return;
25651
+ }
25652
+ var newLandingIndex = this.landingIndex;
25653
+ for (var i = 0; i < columnSlots.length; i++) {
25654
+ var colSlot = columnSlots[i];
25655
+ var absPos = (0,lib_public_api.getElementAbsolutePos)(colSlot);
25656
+ var colWidth = colSlot.offsetWidth;
25657
+ var colHeight = colSlot.offsetHeight;
25658
+ var paddingWidth = 0.2 * colWidth;
25659
+ var paddingHeight = 2;
25660
+ if (pageX >= absPos.x + paddingWidth && pageX <= absPos.x + colWidth - paddingWidth
25661
+ && pageY >= absPos.y + paddingHeight && pageY <= absPos.y + colHeight - paddingHeight) {
25662
+ if (pageX > landingPos.x)
25663
+ newLandingIndex = i + 1;
25664
+ else
25665
+ newLandingIndex = i;
25666
+ break;
25667
+ }
25668
+ }
25669
+ if (newLandingIndex != this.landingIndex || this.landingSlot.parentElement) {
25670
+ this.landingIndex = newLandingIndex;
25671
+ if (this.landingIndex <= 0) {
25672
+ this.columnsBlock.insertBefore(this.landingSlot, columnSlots[0]);
25673
+ }
25674
+ if (this.landingIndex < columnSlots.length) {
25675
+ this.columnsBlock.insertBefore(this.landingSlot, columnSlots[this.landingIndex]);
25676
+ }
25677
+ else {
25678
+ this.columnsBlock.appendChild(this.landingSlot);
25679
+ }
25680
+ }
25681
+ };
25682
+ SortingBar.prototype.hideLandingSlot = function () {
25683
+ this.landingIndex = -1;
25684
+ if (this.landingSlot.parentElement) {
25685
+ this.landingSlot.parentElement.removeChild(this.landingSlot);
25686
+ }
25687
+ };
25449
25688
  return SortingBar;
25450
25689
  }(Widget));
25451
25690
 
@@ -29345,7 +29584,8 @@ var ManageDrillDownWidget = /** @class */ (function (_super) {
29345
29584
  }
29346
29585
  }, null);
29347
29586
  this.ddQuery = new Query(model, null, {
29348
- parent: query
29587
+ parent: query,
29588
+ context: this.context
29349
29589
  });
29350
29590
  var dds = this.context.getQuery().getDrillDowns();
29351
29591
  if (dds.length) {
@@ -35793,14 +36033,14 @@ var query_ex_extends = (undefined && undefined.__extends) || (function () {
35793
36033
 
35794
36034
  var QueryEx = /** @class */ (function (_super) {
35795
36035
  query_ex_extends(QueryEx, _super);
35796
- function QueryEx(model) {
35797
- return _super.call(this, model) || this;
36036
+ function QueryEx(model, options) {
36037
+ return _super.call(this, model, null, options) || this;
35798
36038
  }
35799
36039
  QueryEx.prototype.isEx = function () {
35800
36040
  return lcv.__kt > 1;
35801
36041
  };
35802
36042
  QueryEx.prototype.createSubQuery = function () {
35803
- return new QueryEx(this.model);
36043
+ return new QueryEx(this.model, { context: this.context });
35804
36044
  };
35805
36045
  QueryEx.prototype.createCondition = function (tag) {
35806
36046
  if (tag === void 0) { tag = CondTag.Simple; }
@@ -36607,7 +36847,7 @@ EqContext.prototype.useEnterprise = function (keyOrInitCallback) {
36607
36847
  if (lcv.__kt > 1) {
36608
36848
  var services = _this.getServices();
36609
36849
  services.registerDataModelResolver(function (context) { return new DataModelEx(); });
36610
- services.registerQueryResolver(function (context) { return new QueryEx(context.getModel()); });
36850
+ services.registerQueryResolver(function (context) { return new QueryEx(context.getModel(), { context: context }); });
36611
36851
  services.registerQueryStorageResolver(function (context) { return new EqServerQueryStorage(context); });
36612
36852
  services.registerAggregatesCalculator(function (context) { return new DataTableAggregatesCalculator(context); });
36613
36853
  if (lcv.__kt === 2) {