@refinitiv-ui/efx-grid 6.0.153 → 6.0.155

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.
@@ -13388,7 +13388,7 @@ Segment.prototype.getChildCount = function() {
13388
13388
  */
13389
13389
  Segment.prototype.markCollapsingStateDirty = function() {
13390
13390
  // A segment can have a child and/or autogenerated segment (subsegment) to not be considered as empty.
13391
- if(this._childIds.length || this._subSegDef) {
13391
+ if(this._childIds.length || this._subSegDef) {
13392
13392
  this._shared.dirtyCollapsingState = true;
13393
13393
  }
13394
13394
  };
@@ -13782,6 +13782,83 @@ Segment.prototype.getSubSegmentName = function(row) {
13782
13782
  }
13783
13783
  return this._subSegName;
13784
13784
  };
13785
+ /**
13786
+ * @private
13787
+ * @param {!Segment} segment
13788
+ * @returns {string}
13789
+ */
13790
+ let _toSegmentId = function(segment) {
13791
+ return segment.getId();
13792
+ };
13793
+ /**
13794
+ * @public
13795
+ * @param {!Function} comparer
13796
+ * @returns {boolean} Returns true if there is any change
13797
+ */
13798
+ Segment.prototype.sortSegments = function(comparer) {
13799
+ if(!comparer || this.hasSubSegments()) {
13800
+ return false;
13801
+ }
13802
+
13803
+ let segmentList = [];
13804
+ let rids = [];
13805
+ let childIds = this._childIds;
13806
+ let childCount = childIds.length;
13807
+ let segments = this._shared.segments;
13808
+ for(let i = 0; i < childCount; ++i) {
13809
+ let childId = childIds[i];
13810
+ let childSegment = segments[childId];
13811
+ if(childSegment) {
13812
+ segmentList.push(childSegment);
13813
+ } else {
13814
+ rids.push(childId);
13815
+ }
13816
+ }
13817
+ if(segmentList.length < 2) {
13818
+ return false;
13819
+ }
13820
+ segmentList.sort(comparer);
13821
+ this._childIds = rids.concat(segmentList.map(_toSegmentId));
13822
+ return true;
13823
+ };
13824
+ /** Get segment id and ids of children, including nested segments, but excluding sub segments
13825
+ * @public
13826
+ * @param {Array.<string>} ary
13827
+ * @return {!Array.<string>}
13828
+ */
13829
+ Segment.prototype.getFlattenTreeIds = function(ary) {
13830
+ if(!ary) {
13831
+ ary = [];
13832
+ }
13833
+
13834
+ if(!this._subSegment) { // Sub segments are excluded from tree
13835
+ ary.push(this._rid);
13836
+ }
13837
+ let i;
13838
+ let segmentNames = this._subSegNames;
13839
+ if(segmentNames) { // Classified segment
13840
+ let segmentCount = segmentNames.length;
13841
+ let segmentMap = this._subSegMap;
13842
+ for(i = 0; i < segmentCount; ++i) {
13843
+ segmentMap[segmentNames[i]].getFlattenTreeIds(ary);
13844
+ }
13845
+ } else {
13846
+ let childIds = this._childIds;
13847
+ let childCount = childIds.length;
13848
+ let segments = this._shared.segments;
13849
+ for(i = 0; i < childCount; ++i) {
13850
+ let childId = childIds[i];
13851
+ let childSegment = segments[childId];
13852
+ if(childSegment) {
13853
+ childSegment.getFlattenTreeIds(ary);
13854
+ } else {
13855
+ ary.push(childId);
13856
+ }
13857
+ }
13858
+ }
13859
+
13860
+ return ary;
13861
+ };
13785
13862
 
13786
13863
  /** @public
13787
13864
  * @param {boolean=} bool
@@ -14189,6 +14266,23 @@ SegmentCollection.prototype.getSegments = function() {
14189
14266
  SegmentCollection.prototype.getSegmentIds = function() {
14190
14267
  return Object.keys(this._segments);
14191
14268
  };
14269
+ /** @public
14270
+ * @param {!Function} comparer
14271
+ * @return {!Array.<Segment>}
14272
+ */
14273
+ SegmentCollection.prototype.sortSegments = function(comparer) {
14274
+ let rootSegments = [];
14275
+ let segmentSeparators = this._segments;
14276
+ for(let rid in segmentSeparators) {
14277
+ let segment = segmentSeparators[rid];
14278
+ segment.sortSegments(comparer);
14279
+ if(segment.isRootSegment()) {
14280
+ rootSegments.push(segment);
14281
+ }
14282
+ }
14283
+ rootSegments.sort(comparer);
14284
+ return rootSegments;
14285
+ };
14192
14286
 
14193
14287
 
14194
14288
  /** @public
@@ -15596,7 +15690,7 @@ DataTable.prototype.getSortingLogics = function() {
15596
15690
  };
15597
15691
  /** @public
15598
15692
  * @param {string|Array.<string>} cid Column id
15599
- * @param {string|number|Array.<string|number>=} sortOrders "a"|"d"|"n"
15693
+ * @param {(string|number|Array.<string|number>)=} sortOrders "a"|"d"|"n"
15600
15694
  * @param {DataTable.SortLogic=} customComparer
15601
15695
  * @param {*=} contextObj Context object that will be provided as the forth parameter of the given comparer method
15602
15696
  * @return {boolean} Return true if there is any change, otherwise false
@@ -16106,50 +16200,51 @@ DataTable.prototype.getSegmentChildIds = function(segmentId) {
16106
16200
  }
16107
16201
  return null;
16108
16202
  };
16203
+ /**
16204
+ * @private
16205
+ * @param {(Array|number)} sortOrder
16206
+ * @param {*} context
16207
+ */
16208
+ DataTable.prototype._setSegmentSortContext = function (sortOrder, context) {
16209
+ this._segmentSortOrder = sortOrder;
16210
+ this._segmentSortContext = context;
16211
+ };
16109
16212
  /** Sort all of existing segments by multiple sort logics
16110
16213
  * @public
16111
16214
  * @param {Function|Array.<Function>|Object} sortLogics
16112
- * @param {Array.<number>=} sortOrders
16215
+ * @param {Array.<number|string>=} sortOrders
16113
16216
  * @param {Array.<string>=} cids
16114
16217
  * @return {boolean}
16115
16218
  */
16116
16219
  DataTable.prototype.sortSeparators = function (sortLogics, sortOrders, cids) {
16117
- let dirty = false;
16118
16220
  if(!this._segments){
16119
16221
  return false;
16120
16222
  }
16121
16223
  if(typeof sortLogics === "function"){
16224
+ this._setSegmentSortContext(DataTable._getSortOrder(sortOrders), cids);
16122
16225
  return this.sortSegments(sortLogics);
16123
16226
  }
16227
+ if(!cids) {
16228
+ return false;
16229
+ }
16124
16230
  let sortingDefs = DataTable._buildSortContext(
16125
16231
  [],
16126
16232
  cids,
16127
16233
  sortOrders,
16128
- sortLogics
16234
+ sortLogics || this._compMap
16129
16235
  );
16130
- let defCount = sortingDefs ? sortingDefs.length : 0;
16131
- if(!defCount){
16132
- return dirty;
16133
- }
16134
-
16135
- let sortOrder = 0;
16136
- let sortLogic, sortContext;
16236
+ let defCount = sortingDefs.length;
16237
+ let sortLogic = null;
16137
16238
  if(defCount > 1) {
16138
16239
  sortLogic = DataTable._multiColumnSeparatorCompareLogic;
16139
- sortContext = sortingDefs;
16140
- sortOrder = 1; // sortOrder is not used by _multiColumnSeparatorCompareLogic
16141
- } else { // Single level sorting
16240
+ this._setSegmentSortContext(1, sortingDefs);
16241
+ } else if(defCount === 1) { // Single level sorting
16142
16242
  sortLogic = DataTable._singleColumnSeparatorCompareLogic;
16143
- sortContext = sortingDefs[0];
16144
- sortOrder = /** @type{number} */(sortContext[3]);
16243
+ this._setSegmentSortContext(sortingDefs[0][3], sortingDefs[0]); // sortOrder and context
16244
+ } else {
16245
+ return false;
16145
16246
  }
16146
- this._segmentSortOrder = sortOrder;
16147
- this._segmentSortContext = sortContext;
16148
- dirty = this.sortSegments(sortLogic);
16149
- this._segmentSortOrder = 0;
16150
- this._segmentSortContext = null;
16151
-
16152
- return dirty;
16247
+ return this.sortSegments(sortLogic);
16153
16248
  };
16154
16249
  /** Sort all of existing segments by given compare function
16155
16250
  * @public
@@ -16164,40 +16259,33 @@ DataTable.prototype.sortSegments = function (compare) {
16164
16259
  this._segments.calcSegmentOrder(this._rids);
16165
16260
  return false;
16166
16261
  }
16167
- let rids = this._rids;
16168
- let segments = this._segments;
16169
- let segmentCount = segments.getSegmentCount();
16170
- let segmentList = [];
16171
- let origOrder = [];
16172
- let itemCount = 0;
16173
- let rowCount = rids.length;
16174
- let rid = "";
16175
- let segment = null;
16176
- let i;
16177
- for(i = 0; i < rowCount; ++i) {
16178
- rid = rids[i];
16179
- segment = segments.getSegment(rid);
16180
- if(segment) {
16181
- origOrder.push(i);
16182
- segmentList.push(segment);
16183
- if(++itemCount >= segmentCount) {
16184
- break;
16185
- }
16186
- }
16187
- }
16188
16262
 
16189
16263
  this._userSegmentComparer = compare;
16190
- segmentList.sort(this._bySegmentSeparator);
16264
+
16265
+ let segments = this._segments;
16266
+ let rootSegments = segments.sortSegments(this._bySegmentSeparator);
16267
+
16191
16268
  this._userSegmentComparer = null;
16269
+ this._setSegmentSortContext(0, null);
16192
16270
 
16271
+ let rids = this._rids;
16272
+ let origRids = rids.slice();
16273
+ let rowCount = rids.length;
16274
+ rids.length = 0;
16275
+
16276
+ let segmentCount = 0;
16193
16277
  let dirty = false;
16194
- for(i = 0; i < itemCount; ++i) {
16195
- let idx = origOrder[i];
16196
- rid = rids[idx];
16197
- segment = segmentList[i];
16198
- let newRid = segment.getId();
16199
- if(rid !== newRid) {
16200
- rids[idx] = newRid;
16278
+ for(let i = 0; i < rowCount; ++i) {
16279
+ let rid = origRids[i];
16280
+ let segment = segments.getSegment(rid);
16281
+ if(segment) {
16282
+ if(segment.isRootSegment()) {
16283
+ rootSegments[segmentCount++].getFlattenTreeIds(rids);
16284
+ }
16285
+ } else if(!segments.getParentRowId(rid)) {
16286
+ rids.push(rid);
16287
+ }
16288
+ if(rid !== rids[i]) {
16201
16289
  dirty = true;
16202
16290
  }
16203
16291
  }
@@ -16206,9 +16294,8 @@ DataTable.prototype.sortSegments = function (compare) {
16206
16294
  this._segments.calcSegmentOrder(rids);
16207
16295
  this._sort(null);
16208
16296
  this._dispatchPositionChange();
16209
- return true;
16210
16297
  }
16211
- return false;
16298
+ return dirty;
16212
16299
  };
16213
16300
  /** Sort all of existing segments by given compare function
16214
16301
  * @private
@@ -16491,7 +16578,7 @@ DataTable._positionChangeArg = {"globalChange": true, "positionChangeOnly": true
16491
16578
  * @function
16492
16579
  * @public
16493
16580
  * @ignore
16494
- * @param {Array.<Array>} out_defs Output object. Array is used to optimize property accessing time.
16581
+ * @param {!Array.<Array>} out_defs Output object. Array is used to optimize property accessing time.
16495
16582
  * @param {string|Array.<string>} cids
16496
16583
  * @param {string|number|Array.<string|number>=} sortOrders
16497
16584
  * @param {Function|Array.<Function>|Object.<string, DataTable.SortLogic>=} logics
@@ -21530,10 +21617,22 @@ DataView.prototype.getSegmentChildIds = function(segmentRef) {
21530
21617
  /** Sort all of existing segments by multiple sort logics
21531
21618
  * @public
21532
21619
  * @param {Function|Array.<Function>|Object} sortLogics
21533
- * @param {Array.<number>=} sortOrders
21534
- * @param {Array.<string>=} cids
21620
+ * @param {(number|Array.<number>)=} sortOrders
21621
+ * @param {(string|Array.<string>)=} cids
21535
21622
  */
21536
21623
  DataView.prototype.sortSeparators = function (sortLogics, sortOrders, cids) {
21624
+ let sortingDefs = this._sortingDefs;
21625
+ if(sortingDefs.length) {
21626
+ if(!cids) {
21627
+ cids = sortingDefs[0][0]; // field
21628
+ }
21629
+ if(!sortOrders) {
21630
+ sortOrders = sortingDefs[0][3];
21631
+ }
21632
+ } else if(!sortLogics) {
21633
+ return;
21634
+ }
21635
+
21537
21636
  this._dt.sortSeparators(sortLogics, sortOrders, cids);
21538
21637
  };
21539
21638
  /** Sort all of existing segments by given compare function
@@ -26188,7 +26287,7 @@ Core_Core.prototype._hasPendingRowChange = false;
26188
26287
  * @return {string}
26189
26288
  */
26190
26289
  Core_Core.getVersion = function () {
26191
- return "5.1.139";
26290
+ return "5.1.140";
26192
26291
  };
26193
26292
  /** {@link ElementWrapper#dispose}
26194
26293
  * @override