@refinitiv-ui/efx-grid 6.0.48 → 6.0.50

Sign up to get free protection for your applications and to get access to all the features.
@@ -13778,6 +13778,12 @@ Segment.prototype.getChildIds = function() {
13778
13778
  return this._childCount ? Object.keys(this._children) : [];
13779
13779
  };
13780
13780
  /** @public
13781
+ * @return {!Object}
13782
+ */
13783
+ Segment.prototype.getChildren = function() {
13784
+ return this._children;
13785
+ };
13786
+ /** @public
13781
13787
  * @return {number}
13782
13788
  */
13783
13789
  Segment.prototype.getChildCount = function() {
@@ -18893,6 +18899,8 @@ var DataView = function(source) {
18893
18899
  t._onRefreshTimeout = t._onRefreshTimeout.bind(t);
18894
18900
  t._updateWrapCount = t._updateWrapCount.bind(t);
18895
18901
 
18902
+ t._byRemovalMap = t._byRemovalMap.bind(t);
18903
+
18896
18904
  t._rids = [];
18897
18905
  t._sortingDefs = [];
18898
18906
  t._columnStats = {};
@@ -18946,6 +18954,15 @@ DataView.prototype._hiddenRids = null;
18946
18954
  * @type {Object.<string, boolean>}
18947
18955
  */
18948
18956
  DataView.prototype._collapsedRids = null; // for segmentation
18957
+ /** @private
18958
+ * @type {Object.<string, number>}
18959
+ */
18960
+ DataView.prototype._excludedRids = null;
18961
+ /** @private
18962
+ * @type {boolean}
18963
+ */
18964
+ DataView.prototype._emptySegmentFiltering = false;
18965
+
18949
18966
  /** @private
18950
18967
  * @type {Object.<string, number>}
18951
18968
  */
@@ -19642,8 +19659,6 @@ DataView.prototype.hideRow = function(rId, hidden) {
19642
19659
  */
19643
19660
  DataView.prototype.hideRows = function(rowRefs, hidden) {
19644
19661
  hidden = hidden !== false;
19645
- var dirty = false;
19646
- var rids = this._toRowIds(rowRefs);
19647
19662
  var hiddenRids = this._hiddenRids;
19648
19663
 
19649
19664
  if(hidden){
@@ -19654,11 +19669,19 @@ DataView.prototype.hideRows = function(rowRefs, hidden) {
19654
19669
  return; // All rows are visible
19655
19670
  }
19656
19671
 
19672
+ var rids = this._toRowIds(rowRefs);
19673
+ var dirty = false;
19674
+
19657
19675
  for(var i = rids.length; --i >= 0;) {
19658
19676
  var rid = rids[i];
19659
19677
  if(rid) { // undefined, null, and an empty string value are not a valid row id
19660
- if(!!hiddenRids[rid] !== hidden) {
19661
- hiddenRids[rid] = hidden;
19678
+ if(hidden) {
19679
+ if(!hiddenRids[rid]) {
19680
+ hiddenRids[rid] = true;
19681
+ dirty = true;
19682
+ }
19683
+ } else if(hiddenRids[rid]) {
19684
+ delete hiddenRids[rid];
19662
19685
  dirty = true;
19663
19686
  }
19664
19687
  }
@@ -19667,11 +19690,9 @@ DataView.prototype.hideRows = function(rowRefs, hidden) {
19667
19690
  if(dirty) {
19668
19691
  if(!hidden) {
19669
19692
  var hasHiddenRow = false;
19670
- for(var key in hiddenRids) {
19671
- if(hiddenRids[key]) {
19672
- hasHiddenRow = true;
19673
- break;
19674
- }
19693
+ for(var key in hiddenRids) { // eslint-disable-line
19694
+ hasHiddenRow = true;
19695
+ break;
19675
19696
  }
19676
19697
  if(!hasHiddenRow) {
19677
19698
  hiddenRids = this._hiddenRids = null;
@@ -19679,6 +19700,7 @@ DataView.prototype.hideRows = function(rowRefs, hidden) {
19679
19700
  }
19680
19701
  this._refreshAndNotify(); // Very slow
19681
19702
  }
19703
+
19682
19704
  };
19683
19705
  /**
19684
19706
  * Show/hide rows in the data view
@@ -19760,23 +19782,14 @@ DataView.prototype.filterOut = function(cid, value) {
19760
19782
  */
19761
19783
  DataView.prototype.filterInOnce = function(cid, value, opt_filteringOut) {
19762
19784
  var checker = this._getFilterLogic(cid, value);
19763
- if(!checker) { return; }
19764
-
19765
- var filteringOut = (opt_filteringOut === true);
19766
- var rids = this._rids;
19767
- var dt = this._dt;
19768
19785
  var removalMap = {};
19769
- var totalRem = 0;
19770
- var len = rids.length;
19771
- for(var i = len; --i >= 0;) {
19772
- var rid = rids[i];
19773
- var values = dt.getRowData(rid);
19774
- if (!values || checker(rid, values) === filteringOut) {
19775
- removalMap[rid] = true;
19776
- ++totalRem;
19777
- }
19786
+ if(!this._getRemovalMap(
19787
+ removalMap,
19788
+ checker,
19789
+ (opt_filteringOut === true)
19790
+ )) {
19791
+ return;
19778
19792
  }
19779
- if(totalRem <= 0) { return; }
19780
19793
 
19781
19794
  var firstChange = this._removeRowIds(removalMap);
19782
19795
 
@@ -19799,13 +19812,13 @@ DataView.prototype.filterOutOnce = function(cid, value) {
19799
19812
  this.filterInOnce(cid, value, true);
19800
19813
  };
19801
19814
  /** @private
19802
- * @param {!Object.<string, *>} removalMap
19815
+ * @param {!Object} removalMap
19803
19816
  * @return {number}
19804
19817
  */
19805
19818
  DataView.prototype._removeRowIds = function(removalMap) {
19806
- var firstChange = this._removeArrayItems(this._rids, removalMap);
19819
+ var firstChange = DataView._removeArrayItems(this._rids, removalMap);
19807
19820
  if(this._groupView) {
19808
- firstChange = this._removeArrayItems(this._groupView, removalMap);
19821
+ firstChange = DataView._removeArrayItems(this._groupView, removalMap);
19809
19822
  }
19810
19823
 
19811
19824
  if(this._groupMembers) {
@@ -19816,6 +19829,7 @@ DataView.prototype._removeRowIds = function(removalMap) {
19816
19829
  }
19817
19830
  }
19818
19831
  return firstChange;
19832
+
19819
19833
  };
19820
19834
  /** @public
19821
19835
  * @fires DataView#pageCountChanged
@@ -21383,7 +21397,19 @@ DataView.prototype.sortSeparators = function (sortLogics, sortOrders, cids) {
21383
21397
  DataView.prototype.sortSegments = function (compare) {
21384
21398
  this._dt.sortSegments(compare);
21385
21399
  };
21386
-
21400
+ /** Automatically hide empty segment when all of its member are filtered out. An empty segment will not be hidden, if there is no active filter. Collapsed segment does not count as filtering.
21401
+ * @public
21402
+ * @param {boolean=} enabled
21403
+ */
21404
+ DataView.prototype.enableEmptySegmentFiltering = function (enabled) {
21405
+ enabled = enabled !== false;
21406
+ if(this._emptySegmentFiltering !== enabled) {
21407
+ this._emptySegmentFiltering = enabled;
21408
+ if(this._userFilter) {
21409
+ this._refreshAndNotify();
21410
+ }
21411
+ }
21412
+ };
21387
21413
  /**
21388
21414
  * @public
21389
21415
  * @param {string|number} segmentRef Row id or row index
@@ -21543,26 +21569,35 @@ DataView.prototype._updateRowIds = function(opt_rowIds) {
21543
21569
  // Perform the following sequences: parent view cloning >> row hiding >> row filtering >> row grouping >> sorting >> paging
21544
21570
  this._rids = opt_rowIds || this._parent.getAllRowIds(); // Get all data ids
21545
21571
 
21546
- if(this._hiddenRids) {
21547
- this._removeArrayItems(this._rids, this._hiddenRids);
21548
- }
21572
+ this._dispatch("beforeFiltering", {});
21573
+
21574
+ this._excludedRids = {};
21575
+ var exclusionCount = 0;
21576
+ exclusionCount += DataView._copyObjectKeys(this._excludedRids, this._hiddenRids);
21577
+
21578
+ // Segment separators should not be filtered out (hidden)
21549
21579
  var segments = this._dt._getSegmentSeparators();
21580
+ var filterExceptions = segments ? segments.getSegments() : null;
21581
+ var userRemoval = this._getRemovalMap(this._excludedRids, this._userFilter, this._filteringOut, filterExceptions);
21582
+ exclusionCount += userRemoval;
21583
+
21550
21584
  this._collapsedRids = null;
21551
- var filterExceptions = null;
21552
21585
  if(segments) {
21553
- filterExceptions = segments.getSegments(); // Segment separators should not be filtered out (hidden)
21554
- var collapsedRows = this._collapsedRids = segments.getCollapsedRows(); // Children of collapsed segments must be filtered out (hidden)
21555
- if(collapsedRows) {
21556
- this._removeArrayItems(this._rids, collapsedRows);
21586
+ if(userRemoval && this._emptySegmentFiltering) {
21587
+ exclusionCount += this._getEmptySegments(this._excludedRids, filterExceptions);
21557
21588
  }
21589
+ this._collapsedRids = segments.getCollapsedRows();
21590
+ // Children of collapsed segments must be filtered out (hidden)
21591
+ exclusionCount += DataView._copyObjectKeys(this._excludedRids, this._collapsedRids);
21558
21592
  }
21559
21593
 
21560
- this._dispatch("beforeFiltering", {});
21561
- this._quickFilter(this._userFilter, this._filteringOut, filterExceptions);
21562
-
21563
- if(this._groupLevel > 0 && !opt_rowIds) {
21564
- this._quickFilter(this._groupFilterLogic, false); // Filter In
21594
+ if(this._groupLevel > 0 && !opt_rowIds) { // WARNING: The line below is quite slow
21595
+ exclusionCount += this._getRemovalMap(this._excludedRids, this._groupFilterLogic, false); // Filter In
21596
+ }
21597
+ if(exclusionCount) {
21598
+ this._rids = this._rids.filter(this._byRemovalMap);
21565
21599
  }
21600
+ this._excludedRids = null;
21566
21601
 
21567
21602
  if(this._groupMembers) { // Has grouping
21568
21603
  this._populateGroups(); // View will be properly re-populate inside _populateGroups()
@@ -21834,9 +21869,9 @@ DataView.prototype._onRowUpdated = function(e) { // onUpdate
21834
21869
 
21835
21870
  if(this._groupLevel > 0) {
21836
21871
  if(processingFlag === 1) { // The row is moved to the other group
21837
- if(this._removeArrayItem(this._rids, rid) >= 0) {
21872
+ if(DataView._removeArrayItem(this._rids, rid) >= 0) {
21838
21873
  if(this._groupView) {
21839
- this._removeArrayItem(this._groupView, rid);
21874
+ DataView._removeArrayItem(this._groupView, rid);
21840
21875
  }
21841
21876
  }
21842
21877
  if(this._shared.multiGroupRow) {
@@ -22036,34 +22071,31 @@ DataView.prototype._getRowIndex = function(rids, opt_nextRid, opt_fallback) {
22036
22071
  * @returns {number}
22037
22072
  */
22038
22073
  DataView.prototype._removeDataRow = function(rid) {
22039
- var at = this._removeArrayItem(this._rids, rid);
22074
+ var at = DataView._removeArrayItem(this._rids, rid);
22040
22075
  if(this._groupView && at >= 0) {
22041
- at = this._removeArrayItem(this._groupView, rid);
22076
+ at = DataView._removeArrayItem(this._groupView, rid);
22042
22077
  }
22043
22078
  return at;
22044
22079
  };
22045
22080
  /** @private
22046
- * @param {Array} ary
22081
+ * @param {!Array} ary
22047
22082
  * @param {*} item
22048
22083
  * @return {number} Index of the removed item
22049
22084
  */
22050
- DataView.prototype._removeArrayItem = function(ary, item) {
22051
- var len = ary.length;
22052
- for(var i = 0; i < len; ++i) {
22053
- if(ary[i] === item) {
22054
- ary.splice(i, 1);
22055
- return i;
22056
- }
22085
+ DataView._removeArrayItem = function(ary, item) {
22086
+ var at = ary.indexOf(item);
22087
+ if(at >= 0) {
22088
+ ary.splice(at, 1);
22057
22089
  }
22058
- return -1;
22090
+ return at;
22059
22091
  };
22060
22092
  /** Remove multiple array items
22061
22093
  * @private
22062
22094
  * @param {Array.<string>} ary
22063
- * @param {Object.<string, *>} items
22095
+ * @param {Object} items
22064
22096
  * @return {number} First item index that is being removed. NaN if no item is removed
22065
22097
  */
22066
- DataView.prototype._removeArrayItems = function(ary, items) {
22098
+ DataView._removeArrayItems = function(ary, items) {
22067
22099
  var f = NaN;
22068
22100
  var c = 0;
22069
22101
  for(var i = ary.length; --i >= 0;) {
@@ -22081,6 +22113,24 @@ DataView.prototype._removeArrayItems = function(ary, items) {
22081
22113
  }
22082
22114
  return f;
22083
22115
  };
22116
+ /** @private
22117
+ * @param {Object} baseObj
22118
+ * @param {Object} masterObj
22119
+ * @returns {number}
22120
+ */
22121
+ DataView._copyObjectKeys = function(baseObj, masterObj) {
22122
+ if(masterObj) {
22123
+ var count = 0;
22124
+
22125
+ for(var key in masterObj) {
22126
+ baseObj[key] = 1;
22127
+ ++count; // WARNING: duplicated key can be counted more than once
22128
+ }
22129
+ return count;
22130
+ }
22131
+ return 0;
22132
+ };
22133
+
22084
22134
  /** @private
22085
22135
  * @param {string|null} rid
22086
22136
  * @param {Object} rowData
@@ -22115,9 +22165,6 @@ DataView.prototype.isRowFiltered = function(rid, rowData) {
22115
22165
  return true;
22116
22166
  }
22117
22167
  }
22118
- if(this.isSegmentSeparator(rid)) {
22119
- return false; // Segment separator cannot be filtered
22120
- }
22121
22168
  if(this._collapsedRids) {
22122
22169
  if(this._collapsedRids[rid]) {
22123
22170
  return true;
@@ -22159,41 +22206,92 @@ DataView.prototype._sort = function() {
22159
22206
  };
22160
22207
 
22161
22208
  /** @private
22209
+ * @param {string} rid
22210
+ * @returns {boolean}
22211
+ */
22212
+ DataView.prototype._byRemovalMap = function(rid) {
22213
+ return !this._excludedRids[rid];
22214
+ };
22215
+ /** @private
22216
+ * @param {Object} removalMap
22162
22217
  * @param {Function} checker
22163
22218
  * @param {boolean} filteringOut
22164
22219
  * @param {Object=} exceptions
22220
+ * @returns {number} Number of rids that would be filtered out
22165
22221
  */
22166
- DataView.prototype._quickFilter = function(checker, filteringOut, exceptions) {
22222
+ DataView.prototype._getRemovalMap = function(removalMap, checker, filteringOut, exceptions) {
22167
22223
  if(!checker) {
22168
- return;
22224
+ return 0;
22169
22225
  }
22170
22226
 
22171
22227
  var rids = this._rids; // Make local variable to speed up the process
22172
- var len = rids.length;
22173
22228
  var dt = this._dt;
22174
- var spliceCount = 0;
22175
- for(var i = len; --i >= 0;) {
22176
- var rid = rids[i];
22177
- var removed = false;
22178
- if(!exceptions || !exceptions[rid]) {
22179
- var values = dt.getRowData(rid);
22229
+ var count = 0;
22230
+ var rid, i, values;
22231
+ var len = rids.length;
22232
+
22233
+ if(exceptions) {
22234
+ for(i = len; --i >= 0;) {
22235
+ rid = rids[i];
22236
+ if(!exceptions[rid]) {
22237
+ values = dt.getRowData(rid);
22238
+ if (values) {
22239
+ if(checker(rid, values) === filteringOut) {
22240
+ removalMap[rid] = 1;
22241
+ ++count;
22242
+ }
22243
+ } else {
22244
+ removalMap[rid] = 1;
22245
+ ++count;
22246
+ }
22247
+ }
22248
+ }
22249
+ } else {
22250
+ for(i = len; --i >= 0;) {
22251
+ rid = rids[i];
22252
+ values = dt.getRowData(rid);
22180
22253
  if (values) {
22181
- removed = checker(rid, values) === filteringOut;
22254
+ if(checker(rid, values) === filteringOut) {
22255
+ removalMap[rid] = 1;
22256
+ ++count;
22257
+ }
22182
22258
  } else {
22183
- removed = true;
22259
+ removalMap[rid] = 1;
22260
+ ++count;
22184
22261
  }
22185
22262
  }
22186
- if(removed) {
22187
- ++spliceCount;
22188
- } else if(spliceCount > 0) {
22189
- rids.splice(i + 1, spliceCount);
22190
- spliceCount = 0;
22191
- }
22192
22263
  }
22193
- if(spliceCount > 0) {
22194
- rids.splice(0, spliceCount);
22264
+ return count;
22265
+ };
22266
+ /** @private
22267
+ * @param {Object} removalMap
22268
+ * @param {Object} segmentRids
22269
+ * @returns {number} Number of rids that would be filtered out
22270
+ */
22271
+ DataView.prototype._getEmptySegments = function(removalMap, segmentRids) {
22272
+ var segments = this._dt._getSegmentSeparators();
22273
+ var count = 0;
22274
+ for(var segmentId in segmentRids) {
22275
+ var segment = segments.getSegment(segmentId);
22276
+ if(segment) {
22277
+ var chdr = segment.getChildren();
22278
+ var emptySegment = true;
22279
+ for(var childId in chdr) {
22280
+ if(!removalMap[childId]) {
22281
+ emptySegment = false;
22282
+ break;
22283
+ }
22284
+ }
22285
+ if(emptySegment) {
22286
+ removalMap[segmentId] = 1;
22287
+ ++count;
22288
+ }
22289
+ }
22195
22290
  }
22291
+
22292
+ return count;
22196
22293
  };
22294
+
22197
22295
  /** @private
22198
22296
  * @param {string|Function|undefined} cid
22199
22297
  * @param {*} value
@@ -22472,13 +22570,13 @@ DataView.prototype._removeGroupMember = function (groupIndex, groupId) {
22472
22570
  };
22473
22571
  /** @private
22474
22572
  * @param {string} cid
22475
- * @param {Object.<string, *>} values
22573
+ * @param {Object} values
22476
22574
  * @return {Array.<string>}
22477
22575
  */
22478
22576
  DataView.prototype._defaultGroupCriteria = function(cid, values) {
22479
22577
  var val = values[cid];
22480
22578
  if(Array.isArray(val)) {
22481
- return val.map(function(data) {
22579
+ return val.map(function(data) { // TODO: this is very slow
22482
22580
  return data + "";
22483
22581
  });
22484
22582
  } else {
@@ -22487,11 +22585,11 @@ DataView.prototype._defaultGroupCriteria = function(cid, values) {
22487
22585
  };
22488
22586
  /** @private
22489
22587
  * @param {string|null} rid
22490
- * @param {Object.<string, *>} values
22588
+ * @param {Object} values
22491
22589
  * @return {boolean}
22492
22590
  */
22493
22591
  DataView.prototype._groupFilterLogic = function(rid, values) {
22494
- var gids = this._groupCriteria[this._groupLevel - 1](values);
22592
+ var gids = this._groupCriteria[this._groupLevel - 1](values); // TODO: this is very slow
22495
22593
  return gids.indexOf(this._groupId) >= 0;
22496
22594
  };
22497
22595
 
@@ -25931,7 +26029,7 @@ Core_Core.prototype._batches = null;
25931
26029
  * @return {string}
25932
26030
  */
25933
26031
  Core_Core.getVersion = function () {
25934
- return "5.1.67";
26032
+ return "5.1.69";
25935
26033
  };
25936
26034
  /** {@link ElementWrapper#dispose}
25937
26035
  * @override
@@ -30325,13 +30423,10 @@ Core_Core.prototype._onSectionDataChanged = function (e) {
30325
30423
  for (var r = fromR; r < toR; ++r) {
30326
30424
  if(hasDataView) {
30327
30425
  var rowData = rowDataCollection[r];
30328
- if(!rowData) { // This is a header row
30329
- continue;
30330
- }
30331
30426
 
30332
30427
  e["rowData"] = rowData;
30333
30428
  e["rowId"] = rids[r];
30334
- e["dataValue"] = rowData[cid];
30429
+ e["dataValue"] = rowData ? rowData[cid] : null;
30335
30430
  }
30336
30431
  e["rowIndex"] = r;
30337
30432
  e["cell"] = section["getCell"](c, r, false); // Accessing cell by using bracket allows extenal object to mock Section
@@ -32070,7 +32165,7 @@ SortableTitlePlugin.prototype.sortColumns = function (sortOptions, opt_arg) {
32070
32165
  opt["sortOrder"] || opt["order"]
32071
32166
  );
32072
32167
  if (state) {
32073
- states[i] = state;
32168
+ states.push(state);
32074
32169
  }
32075
32170
  }
32076
32171
  this._sortColumn(states, opt_arg);