@refinitiv-ui/efx-grid 6.0.46 → 6.0.47

Sign up to get free protection for your applications and to get access to all the features.
@@ -112,6 +112,8 @@ declare class DataTable extends DataCache {
112
112
 
113
113
  public getSegmentChildIds(segmentId: string): (string)[]|null;
114
114
 
115
+ public sortSeparators(sortLogics: ((...params: any[]) => any)|(((...params: any[]) => any))[]|null, sortOrders: (number)[]|null, cids: (string)[]|null): boolean;
116
+
115
117
  public sortSegments(compare: ((...params: any[]) => any)|null): boolean;
116
118
 
117
119
  public setClassificationSource(dc: DataCache|null): void;
@@ -76,6 +76,14 @@ DataTable.prototype._removedRows = null;
76
76
  */
77
77
  DataTable.prototype._userSegmentComparer = null;
78
78
  /** @private
79
+ * @type {number}
80
+ */
81
+ DataTable.prototype._segmentSortOrder = 0;
82
+ /** @private
83
+ * @type {*}
84
+ */
85
+ DataTable.prototype._segmentSortContext = null;
86
+ /** @private
79
87
  * @type {Object.<string, Object>}
80
88
  */
81
89
  DataTable.prototype._clsSource = null;
@@ -1248,6 +1256,51 @@ DataTable.prototype.getSegmentChildIds = function(segmentId) {
1248
1256
  }
1249
1257
  return null;
1250
1258
  };
1259
+ /** Sort all of existing segments by multiple sort logics
1260
+ * @public
1261
+ * @param {Function|Array.<Function>} sortLogics
1262
+ * @param {Array.<number>} sortOrders
1263
+ * @param {Array.<string>} cids
1264
+ * @return {boolean}
1265
+ */
1266
+ DataTable.prototype.sortSeparators = function (sortLogics, sortOrders, cids) {
1267
+ var dirty = false;
1268
+ if(!this._segments){
1269
+ return false;
1270
+ }
1271
+ if(typeof sortLogics === "function"){
1272
+ return this.sortSegments(sortLogics);
1273
+ }
1274
+ var sortingDefs = DataTable._buildSortContext(
1275
+ [],
1276
+ cids,
1277
+ sortOrders,
1278
+ sortLogics
1279
+ );
1280
+ var defCount = sortingDefs ? sortingDefs.length : 0;
1281
+ if(!defCount){
1282
+ return dirty;
1283
+ }
1284
+
1285
+ var sortOrder = 0;
1286
+ var sortLogic, sortContext;
1287
+ if(defCount > 1) {
1288
+ sortLogic = DataTable._multiColumnSeparatorCompareLogic;
1289
+ sortContext = sortingDefs;
1290
+ sortOrder = 1; // sortOrder is not used by _multiColumnSeparatorCompareLogic
1291
+ } else { // Single level sorting
1292
+ sortLogic = DataTable._singleColumnSeparatorCompareLogic;
1293
+ sortContext = sortingDefs[0];
1294
+ sortOrder = /** @type{number} */(sortContext[3]);
1295
+ }
1296
+ this._segmentSortOrder = sortOrder;
1297
+ this._segmentSortContext = sortContext;
1298
+ dirty = this.sortSegments(sortLogic);
1299
+ this._segmentSortOrder = 0;
1300
+ this._segmentSortContext = null;
1301
+
1302
+ return dirty;
1303
+ };
1251
1304
  /** Sort all of existing segments by given compare function
1252
1305
  * @public
1253
1306
  * @param {Function} compare
@@ -1316,7 +1369,9 @@ DataTable.prototype.sortSegments = function (compare) {
1316
1369
  DataTable.prototype._bySegmentSeparator = function (segmentA, segmentB) {
1317
1370
  return /** @type{number} */(this._userSegmentComparer(
1318
1371
  this.getRowData(segmentA.getId()),
1319
- this.getRowData(segmentB.getId())
1372
+ this.getRowData(segmentB.getId()),
1373
+ this._segmentSortOrder,
1374
+ this._segmentSortContext
1320
1375
  ));
1321
1376
  };
1322
1377
 
@@ -1657,6 +1712,47 @@ DataTable._singleColumnCompareLogic = function(a, b, order, sortingDef) {
1657
1712
  sortingDef[4] // Context object
1658
1713
  ));
1659
1714
  };
1715
+ /** Performance is extremely vital in this method
1716
+ * @public
1717
+ * @ignore
1718
+ * @function
1719
+ * @param {*} a
1720
+ * @param {*} b
1721
+ * @param {number} order Not used by in this method
1722
+ * @param {Array.<Array>} sortingDefs
1723
+ * @return {number}
1724
+ */
1725
+ DataTable._multiColumnSeparatorCompareLogic = function(a, b, order, sortingDefs) {
1726
+ var count = sortingDefs.length;
1727
+ var result = 0;
1728
+ for(var c = 0; c < count; ++c) {
1729
+ var sortingDef = sortingDefs[c];
1730
+ result = DataTable._singleColumnSeparatorCompareLogic(a, b, sortingDef[3], sortingDef);
1731
+ if(result) {
1732
+ return result;
1733
+ }
1734
+ }
1735
+ return result;
1736
+ };
1737
+ /** Performance is extremely vital in this method
1738
+ * @public
1739
+ * @ignore
1740
+ * @function
1741
+ * @param {*} a
1742
+ * @param {*} b
1743
+ * @param {number} order
1744
+ * @param {Array} sortingDef
1745
+ * @return {number}
1746
+ */
1747
+ DataTable._singleColumnSeparatorCompareLogic = function(a, b, order, sortingDef) {
1748
+ var key = /** @type{string} */(sortingDef[0]);
1749
+ return /** @type{number} */(sortingDef[2](
1750
+ a[key], // Value1
1751
+ b[key], // Value2
1752
+ order, // Sort order (3)
1753
+ sortingDef[4] // Context object
1754
+ ));
1755
+ };
1660
1756
  /** @public
1661
1757
  * @function
1662
1758
  * @ignore
@@ -272,6 +272,8 @@ declare class DataView extends EventDispatcher {
272
272
 
273
273
  public getSegmentChildIds(segmentRef: string|number|null): (string)[]|null;
274
274
 
275
+ public sortSeparators(sortLogics: (((...params: any[]) => any))[]|null, sortOrders: (number)[]|null, cids: (string)[]|null): void;
276
+
275
277
  public sortSegments(compare: ((...params: any[]) => any)|null): void;
276
278
 
277
279
  public enableEmptySegmentFiltering(enabled?: boolean|null): void;
@@ -2548,6 +2548,15 @@ DataView.prototype.getSegmentIds = function() {
2548
2548
  DataView.prototype.getSegmentChildIds = function(segmentRef) {
2549
2549
  return this._dt.getSegmentChildIds(this._toRowId(segmentRef));
2550
2550
  };
2551
+ /** Sort all of existing segments by multiple sort logics
2552
+ * @public
2553
+ * @param {Array.<Function>} sortLogics
2554
+ * @param {Array.<number>} sortOrders
2555
+ * @param {Array.<string>} cids
2556
+ */
2557
+ DataView.prototype.sortSeparators = function (sortLogics, sortOrders, cids) {
2558
+ this._dt.sortSeparators(sortLogics, sortOrders, cids);
2559
+ };
2551
2560
  /** Sort all of existing segments by given compare function
2552
2561
  * @public
2553
2562
  * @param {Function} compare
@@ -554,7 +554,7 @@ Core.prototype._batches = null;
554
554
  * @return {string}
555
555
  */
556
556
  Core.getVersion = function () {
557
- return "5.1.65";
557
+ return "5.1.66";
558
558
  };
559
559
  /** {@link ElementWrapper#dispose}
560
560
  * @override
@@ -135,6 +135,8 @@ declare class SortableTitlePlugin extends EventDispatcher {
135
135
 
136
136
  public clearAllColumnSortingSequences(): void;
137
137
 
138
+ public sortSeparators(comparer: ((...params: any[]) => any)|null): void;
139
+
138
140
  }
139
141
 
140
142
  declare function len(disabled?: boolean|null): void;
@@ -1358,6 +1358,28 @@ SortableTitlePlugin.prototype.setSortingSequence = function (sequence, colRef) {
1358
1358
  SortableTitlePlugin.prototype.clearAllColumnSortingSequences = function () {
1359
1359
  this._sortingSequenceMap = null;
1360
1360
  };
1361
+ /** @public
1362
+ * @description Sorting all separators according to compare function. If compare function is not specified, separators will will be sort by current sorting states.
1363
+ * @param {Function} comparer Compare function
1364
+ */
1365
+ SortableTitlePlugin.prototype.sortSeparators = function (comparer) {
1366
+ var host = this._hosts[0];
1367
+ var dv = host.getDataSource();
1368
+ if(comparer){
1369
+ dv.sortSeparators(comparer);
1370
+ } else {
1371
+ var sortLogics = dv.getSortingLogics();
1372
+ var sortOrders = [];
1373
+ var sortFields = [];
1374
+ var sortStateCount = this._sortStates.length;
1375
+ for(var i = 0; i < sortStateCount; i++){
1376
+ var sortState = this._sortStates[i];
1377
+ sortOrders.push(sortState["sortOrder"]);
1378
+ sortFields.push(sortState["field"]);
1379
+ }
1380
+ dv.sortSeparators(sortLogics, sortOrders, sortFields);
1381
+ }
1382
+ };
1361
1383
 
1362
1384
 
1363
1385
  /** @private
package/lib/grid/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import {Grid} from "./lib/efx-grid.js";
2
2
  export {Grid}
3
- window.EFX_GRID = { version: "6.0.46" };
3
+ window.EFX_GRID = { version: "6.0.47" };
@@ -112,6 +112,8 @@ declare class DataTable extends DataCache {
112
112
 
113
113
  public getSegmentChildIds(segmentId: string): (string)[]|null;
114
114
 
115
+ public sortSeparators(sortLogics: ((...params: any[]) => any)|(((...params: any[]) => any))[]|null, sortOrders: (number)[]|null, cids: (string)[]|null): boolean;
116
+
115
117
  public sortSegments(compare: ((...params: any[]) => any)|null): boolean;
116
118
 
117
119
  public setClassificationSource(dc: DataCache|null): void;
@@ -272,6 +272,8 @@ declare class DataView extends EventDispatcher {
272
272
 
273
273
  public getSegmentChildIds(segmentRef: string|number|null): (string)[]|null;
274
274
 
275
+ public sortSeparators(sortLogics: (((...params: any[]) => any))[]|null, sortOrders: (number)[]|null, cids: (string)[]|null): void;
276
+
275
277
  public sortSegments(compare: ((...params: any[]) => any)|null): void;
276
278
 
277
279
  public enableEmptySegmentFiltering(enabled?: boolean|null): void;
@@ -135,6 +135,8 @@ declare class SortableTitlePlugin extends EventDispatcher {
135
135
 
136
136
  public clearAllColumnSortingSequences(): void;
137
137
 
138
+ public sortSeparators(comparer: ((...params: any[]) => any)|null): void;
139
+
138
140
  }
139
141
 
140
142
  declare function len(disabled?: boolean|null): void;
package/package.json CHANGED
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "version": "6.0.46"
69
+ "version": "6.0.47"
70
70
  }