@easyquery/ui 7.2.4-rc01 → 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.
@@ -265,17 +265,16 @@
265
265
  color: white !important;
266
266
  }
267
267
 
268
- .eqv-button-execute {
268
+ .eqv-button-fetch {
269
269
  border-color: #237901;
270
- margin-top: 40px;
271
270
  }
272
271
 
273
- .eqv-button-execute:hover {
272
+ .eqv-button-fetch:hover {
274
273
  background-color: #237901;
275
274
  }
276
275
 
277
- /* sql panel */
278
- .eqv-sql-panel{
276
+ /* SQL panel */
277
+ .eqv-sql-panel {
279
278
  width: 25%;
280
279
  border: 1px solid #C4D6E5;
281
280
  background: white;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * EasyQuery.JS Community 7.2.4-rc01 (https://korzh.com/easyquery/javascript)
2
+ * EasyQuery.JS Community 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
@@ -14590,6 +14590,13 @@ var Query = /** @class */ (function () {
14590
14590
  this._enableAggregation = false;
14591
14591
  this.parentQuery = null;
14592
14592
  this.drillDowns = [];
14593
+ this.syncSortOrderWithColumnsOrder = true;
14594
+ if (options) {
14595
+ this.context = options.context;
14596
+ if (this.context) {
14597
+ this.syncSortOrderWithColumnsOrder = this.context.options.syncSortOrderWithColumnsOrder;
14598
+ }
14599
+ }
14593
14600
  this.eventEmitter = new public_api.EventEmitter(this);
14594
14601
  this.root = new Condition(this, CondTag.Group);
14595
14602
  this.extraConditions = new Condition(this, CondTag.Group);
@@ -14685,7 +14692,7 @@ var Query = /** @class */ (function () {
14685
14692
  return hasChanged;
14686
14693
  };
14687
14694
  Query.prototype.createSubQuery = function () {
14688
- return new Query(this.model);
14695
+ return new Query(this.model, null, { context: this.context });
14689
14696
  };
14690
14697
  Query.prototype.useAggregation = function (settingsTuner, silent) {
14691
14698
  if (silent === void 0) { silent = false; }
@@ -15026,7 +15033,7 @@ var Query = /** @class */ (function () {
15026
15033
  }
15027
15034
  }
15028
15035
  this.sortedColumns.sort(function (col1, col2) {
15029
- return col1.sortIndex - col2.sortIndex;
15036
+ return col1._sortIndex - col2._sortIndex;
15030
15037
  });
15031
15038
  this.fixupSortingIndices();
15032
15039
  if (data.extraData) {
@@ -15353,6 +15360,7 @@ var Query = /** @class */ (function () {
15353
15360
  }
15354
15361
  public_api.utils.moveArrayItem(this.sortedColumns, colIdx, index);
15355
15362
  this.fixupSortingIndices();
15363
+ this.fireColumnsChangedEvent(QueryChangeAction.All);
15356
15364
  };
15357
15365
  Query.prototype.getColumnSorting = function (col) {
15358
15366
  var idx = this.getColumnSortIndex(col);
@@ -15378,12 +15386,34 @@ var Query = /** @class */ (function () {
15378
15386
  this.fixupSortingIndices();
15379
15387
  }
15380
15388
  }
15389
+ this.adjustColumnsSorting();
15390
+ this.fireColumnsChangedEvent(QueryChangeAction.Modify, col, col.isJustSorted());
15381
15391
  };
15382
15392
  Query.prototype.fixupSortingIndices = function () {
15383
15393
  this.sortedColumns.forEach(function (col, index) {
15384
15394
  col._sortIndex = index;
15385
15395
  });
15386
15396
  };
15397
+ Query.prototype.adjustColumnsSorting = function () {
15398
+ var _this = this;
15399
+ if (!this.syncSortOrderWithColumnsOrder) {
15400
+ return;
15401
+ }
15402
+ if (this.getJustSortedColumns().length > 0) {
15403
+ return;
15404
+ }
15405
+ var idx = 0;
15406
+ this.columns.forEach(function (col) {
15407
+ if (col.sorting != SortDirection.None) {
15408
+ var colIdx = _this.getColumnSortIndex(col);
15409
+ if (colIdx >= 0) {
15410
+ public_api.utils.moveArrayItem(_this.sortedColumns, colIdx, idx);
15411
+ idx++;
15412
+ }
15413
+ }
15414
+ });
15415
+ this.fixupSortingIndices();
15416
+ };
15387
15417
  Query.prototype.createColumn = function (justsorted) {
15388
15418
  if (justsorted === void 0) { justsorted = false; }
15389
15419
  return new QueryColumn(this, justsorted);
@@ -15600,6 +15630,7 @@ var Query = /** @class */ (function () {
15600
15630
  Query.prototype.moveColumn = function (index1, index2) {
15601
15631
  var columns = this.getColumns();
15602
15632
  public_api.utils.moveArrayItem(columns, index1, index2);
15633
+ this.adjustColumnsSorting();
15603
15634
  };
15604
15635
  /**
15605
15636
  * Removes the column.
@@ -16024,7 +16055,7 @@ var BrowserQueryStorage = /** @class */ (function () {
16024
16055
  BrowserQueryStorage.prototype.newQuery = function (options) {
16025
16056
  var _this = this;
16026
16057
  return new Promise(function (resolve, reject) {
16027
- var query = new Query(_this.context.getModel());
16058
+ var query = new Query(_this.context.getModel(), null, { context: _this.context });
16028
16059
  query.reset();
16029
16060
  query.setDefaultName();
16030
16061
  if (options) {
@@ -16479,7 +16510,7 @@ var EqServiceProvider = /** @class */ (function () {
16479
16510
  this.httpClient.defaultHeaders['x-eqjs-version'] = '7.2.0';
16480
16511
  this.modelResolver = function (_) { return new DataModel(); };
16481
16512
  this.modelStorageResolver = null;
16482
- this.queryResolver = function (context) { return new Query(context.getModel()); };
16513
+ this.queryResolver = function (context) { return new Query(context.getModel(), null, { context: context }); };
16483
16514
  this.modelLoaderResolver = function (context) { return new EqServerModelLoader(context); };
16484
16515
  this.queryStorageResolver = function (context) { return new BrowserQueryStorage(context); };
16485
16516
  this.querySynchronizerResolver = function (context) { return new EqServerQuerySynchronizer(context); };
@@ -16830,7 +16861,9 @@ var context_assign = (undefined && undefined.__assign) || function () {
16830
16861
  var EqContext = /** @class */ (function () {
16831
16862
  function EqContext() {
16832
16863
  var _this = this;
16833
- this.options = {};
16864
+ this.options = {
16865
+ syncSortOrderWithColumnsOrder: true
16866
+ };
16834
16867
  this.servicesInitialized = false;
16835
16868
  this.internalListCache = {};
16836
16869
  this.loadModelOnStart = true;
@@ -16960,8 +16993,8 @@ var EqContext = /** @class */ (function () {
16960
16993
  return Array.from(this.exporters.keys());
16961
16994
  };
16962
16995
  EqContext.prototype.addDefaultExporters = function () {
16963
- this.registerServerExporter('csv', '');
16964
- this.registerServerExporter('excel-html', '');
16996
+ this.registerServerExporter('csv', 'arraybuffer');
16997
+ this.registerServerExporter('excel-html', 'arraybuffer');
16965
16998
  };
16966
16999
  EqContext.prototype.resolveEndpoint = function (endpointKey, options) {
16967
17000
  options = options || {};
@@ -17123,8 +17156,7 @@ var EqContext = /** @class */ (function () {
17123
17156
  this.exporters.clear();
17124
17157
  for (var _i = 0, _a = options.serverExporters; _i < _a.length; _i++) {
17125
17158
  var format = _a[_i];
17126
- var responseType = format == 'csv' || format == 'excel-html' ? '' : 'arraybuffer';
17127
- this.registerServerExporter(format, responseType);
17159
+ this.registerServerExporter(format, "arraybuffer");
17128
17160
  }
17129
17161
  }
17130
17162
  var query = this.getQuery();
@@ -22848,7 +22880,7 @@ var ColumnRendererCB = /** @class */ (function () {
22848
22880
  if (data.id == 'None' || data.id == "Ascending" || data.id == "Descending") {
22849
22881
  var query = _this.bar.getQuery();
22850
22882
  _this.column.sorting = strToSortDirection(data.id);
22851
- _this.column.sortIndex = query.getColumnSortIndex(_this.column);
22883
+ _this.column._sortIndex = query.getColumnSortIndex(_this.column);
22852
22884
  _this.fireColumnChanged();
22853
22885
  }
22854
22886
  else {
@@ -23403,10 +23435,15 @@ var ColumnsBar = /** @class */ (function (_super) {
23403
23435
  _this.hideLandingSlot();
23404
23436
  },
23405
23437
  onDrop: function (container, ev) {
23406
- var query = _this.getQuery();
23407
- var columns = query.getColumns();
23408
- var index = columns.indexOf(ev.data.column);
23409
- _this.moveColumnCore(index, _this.landingIndex);
23438
+ if (_this.landingIndex >= 0) {
23439
+ var query = _this.getQuery();
23440
+ var columns = query.getColumns();
23441
+ var index = columns.indexOf(ev.data.column);
23442
+ _this.moveColumnCore(index, _this.landingIndex);
23443
+ }
23444
+ else {
23445
+ ev.item.element.removeAttribute('style');
23446
+ }
23410
23447
  }
23411
23448
  });
23412
23449
  }
@@ -24039,6 +24076,7 @@ var ColumnRendererSB = /** @class */ (function () {
24039
24076
  configurable: true
24040
24077
  });
24041
24078
  ColumnRendererSB.prototype.render = function () {
24079
+ var _this = this;
24042
24080
  this.baseAttr = this.getAttribute();
24043
24081
  var builder = (0,lib_public_api.domel)('div');
24044
24082
  builder.data('id', this.column.id);
@@ -24048,6 +24086,23 @@ var ColumnRendererSB = /** @class */ (function () {
24048
24086
  .replaceChild(builder.toDOM(), this.element);
24049
24087
  }
24050
24088
  this.element = builder.toDOM();
24089
+ if (this.bar.options.allowDragDrop) {
24090
+ lib_public_api.eqDragManager.registerDraggableItem({
24091
+ element: this.element,
24092
+ scope: "entityAttrSortSB",
24093
+ beforeDragStart: function () { return _this.element.dispatchEvent((0,lib_public_api.createBrowserEvent)('mouseleave')); },
24094
+ onDragStart: function (ev) {
24095
+ _this.element.style.display = 'none';
24096
+ ev.dropEffect = lib_public_api.DropEffect.Allow;
24097
+ },
24098
+ onDragEnd: function (ev) {
24099
+ if (!ev.data.finishedSuccessfully) {
24100
+ _this.element.removeAttribute('style');
24101
+ }
24102
+ },
24103
+ data: { column: this.column }
24104
+ });
24105
+ }
24051
24106
  builder
24052
24107
  .addClass(this.getClassesToAdd())
24053
24108
  .addClass(browser_utils/* browserUtils.getMobileCssClass */.z.getMobileCssClass())
@@ -24150,10 +24205,13 @@ var ColumnRendererSB = /** @class */ (function () {
24150
24205
  }
24151
24206
  else {
24152
24207
  _this.column.sorting = strToSortDirection(data.id);
24153
- _this.column.sortIndex = query.getColumnSortIndex(_this.column);
24208
+ _this.column._sortIndex = query.getColumnSortIndex(_this.column);
24154
24209
  _this.fireColumnChanged();
24155
24210
  }
24156
24211
  }
24212
+ else {
24213
+ _this.bar.moveColumn(_this.column, data.id);
24214
+ }
24157
24215
  },
24158
24216
  menuClosedCallback: function () {
24159
24217
  _this.keepShowingButtons = false;
@@ -24212,6 +24270,7 @@ var SortingBar = /** @class */ (function (_super) {
24212
24270
  showAddRow: true,
24213
24271
  attrElementFormat: '{entity} {attr}',
24214
24272
  titleElementFormat: null,
24273
+ allowDragDrop: true,
24215
24274
  menuOptions: {
24216
24275
  showSearchBoxAfter: 30,
24217
24276
  searchBoxAutoFocus: true,
@@ -24223,8 +24282,17 @@ var SortingBar = /** @class */ (function (_super) {
24223
24282
  _this.sortMenuList = [
24224
24283
  { id: 'None', text: public_api.i18n.getText('CmdNotSorted') },
24225
24284
  { id: 'Ascending', text: public_api.i18n.getText('CmdAscending') },
24226
- { id: 'Descending', text: public_api.i18n.getText('CmdDescending') }
24285
+ { id: 'Descending', text: public_api.i18n.getText('CmdDescending') },
24286
+ { id: '---', text: '---' },
24287
+ { id: 'MoveTop', text: public_api.i18n.getText('CmdMoveToFirst') },
24288
+ { id: 'MoveUp', text: public_api.i18n.getText('CmdMoveToPrev') },
24289
+ { id: 'MoveDown', text: public_api.i18n.getText('CmdMoveToNext') },
24290
+ { id: 'MoveBottom', text: public_api.i18n.getText('CmdMoveToLast') }
24227
24291
  ];
24292
+ _this.landingSlot = (0,lib_public_api.domel)('div')
24293
+ .addClass("".concat(utils/* eqCssPrefix */.YR, "-highlight"))
24294
+ .toDOM();
24295
+ _this.landingIndex = -1;
24228
24296
  (0,lib_public_api.domel)(_this.slot)
24229
24297
  .addClass("".concat(_this.cssPrefix, "-panel"))
24230
24298
  .addClass(browser_utils/* browserUtils.getMobileCssClass */.z.getMobileCssClass());
@@ -24242,10 +24310,37 @@ var SortingBar = /** @class */ (function (_super) {
24242
24310
  return 'sortingBar';
24243
24311
  };
24244
24312
  SortingBar.prototype.init = function (context, options) {
24313
+ var _this = this;
24245
24314
  _super.prototype.init.call(this, context, options);
24246
24315
  this.setOptions(options);
24247
24316
  this.destroyCore();
24248
24317
  this.attachQueryObserver();
24318
+ lib_public_api.eqDragManager.removeDropContainer(this.slot);
24319
+ if (this.options.allowDragDrop) {
24320
+ lib_public_api.eqDragManager.registerDropContainer({
24321
+ element: this.slot,
24322
+ scopes: ["entityAttrSortSB"],
24323
+ onDragEnter: function (container, ev) {
24324
+ _this.showLandingSlot(ev.pageX, ev.pageY);
24325
+ },
24326
+ onDragOver: function (container, ev) {
24327
+ _this.showLandingSlot(ev.pageX, ev.pageY);
24328
+ },
24329
+ onDragLeave: function (container, ev) {
24330
+ ev.dropEffect = lib_public_api.DropEffect.Forbid;
24331
+ _this.hideLandingSlot();
24332
+ },
24333
+ onDrop: function (container, ev) {
24334
+ if (_this.landingIndex >= 0) {
24335
+ var query = _this.getQuery();
24336
+ query.setColumnSortIndex(ev.data.column, _this.landingIndex);
24337
+ }
24338
+ else {
24339
+ ev.item.element.removeAttribute('style');
24340
+ }
24341
+ }
24342
+ });
24343
+ }
24249
24344
  };
24250
24345
  SortingBar.prototype.setOptions = function (options) {
24251
24346
  public_api.utils.assignDeep(this.options, options);
@@ -24424,6 +24519,81 @@ var SortingBar = /** @class */ (function (_super) {
24424
24519
  SortingBar.prototype.clear = function () {
24425
24520
  this.slot.innerHTML = '';
24426
24521
  };
24522
+ SortingBar.prototype.moveColumn = function (column, direction) {
24523
+ var query = this.getQuery();
24524
+ var columns = query.getSortedColumns();
24525
+ var index = query.getColumnSortIndex(column);
24526
+ if (index >= 0) {
24527
+ switch (direction) {
24528
+ case 'MoveTop':
24529
+ query.setColumnSortIndex(column, 0);
24530
+ break;
24531
+ case 'MoveUp':
24532
+ query.setColumnSortIndex(column, index > 0 ? index - 1 : 0);
24533
+ break;
24534
+ case 'MoveDown':
24535
+ query.setColumnSortIndex(column, index < columns.length - 1 ? index + 1 : columns.length - 1);
24536
+ break;
24537
+ case 'MoveBottom':
24538
+ query.setColumnSortIndex(column, columns.length - 1);
24539
+ break;
24540
+ }
24541
+ ;
24542
+ }
24543
+ };
24544
+ SortingBar.prototype.showLandingSlot = function (pageX, pageY) {
24545
+ var elements = this.columnsBlock.querySelectorAll("[class*=".concat(this.cssPrefix, "-row]"));
24546
+ var columnSlots = [];
24547
+ for (var i = 0; i < elements.length; i++) {
24548
+ if (elements[i].style.display !== 'none') {
24549
+ columnSlots.push(elements[i]);
24550
+ }
24551
+ }
24552
+ if (columnSlots.length === 0) {
24553
+ this.landingIndex = 0;
24554
+ return;
24555
+ }
24556
+ var landingPos = (0,lib_public_api.getElementAbsolutePos)(this.landingSlot);
24557
+ if (pageX >= landingPos.x && pageX <= landingPos.x + this.landingSlot.offsetWidth
24558
+ && pageY >= landingPos.y && pageY <= landingPos.y + this.landingSlot.offsetHeight) {
24559
+ return;
24560
+ }
24561
+ var newLandingIndex = this.landingIndex;
24562
+ for (var i = 0; i < columnSlots.length; i++) {
24563
+ var colSlot = columnSlots[i];
24564
+ var absPos = (0,lib_public_api.getElementAbsolutePos)(colSlot);
24565
+ var colWidth = colSlot.offsetWidth;
24566
+ var colHeight = colSlot.offsetHeight;
24567
+ var paddingWidth = 0.2 * colWidth;
24568
+ var paddingHeight = 2;
24569
+ if (pageX >= absPos.x + paddingWidth && pageX <= absPos.x + colWidth - paddingWidth
24570
+ && pageY >= absPos.y + paddingHeight && pageY <= absPos.y + colHeight - paddingHeight) {
24571
+ if (pageX > landingPos.x)
24572
+ newLandingIndex = i + 1;
24573
+ else
24574
+ newLandingIndex = i;
24575
+ break;
24576
+ }
24577
+ }
24578
+ if (newLandingIndex != this.landingIndex || this.landingSlot.parentElement) {
24579
+ this.landingIndex = newLandingIndex;
24580
+ if (this.landingIndex <= 0) {
24581
+ this.columnsBlock.insertBefore(this.landingSlot, columnSlots[0]);
24582
+ }
24583
+ if (this.landingIndex < columnSlots.length) {
24584
+ this.columnsBlock.insertBefore(this.landingSlot, columnSlots[this.landingIndex]);
24585
+ }
24586
+ else {
24587
+ this.columnsBlock.appendChild(this.landingSlot);
24588
+ }
24589
+ }
24590
+ };
24591
+ SortingBar.prototype.hideLandingSlot = function () {
24592
+ this.landingIndex = -1;
24593
+ if (this.landingSlot.parentElement) {
24594
+ this.landingSlot.parentElement.removeChild(this.landingSlot);
24595
+ }
24596
+ };
24427
24597
  return SortingBar;
24428
24598
  }(Widget));
24429
24599
 
@@ -28323,7 +28493,8 @@ var ManageDrillDownWidget = /** @class */ (function (_super) {
28323
28493
  }
28324
28494
  }, null);
28325
28495
  this.ddQuery = new Query(model, null, {
28326
- parent: query
28496
+ parent: query,
28497
+ context: this.context
28327
28498
  });
28328
28499
  var dds = this.context.getQuery().getDrillDowns();
28329
28500
  if (dds.length) {