@refinitiv-ui/efx-grid 6.0.128 → 6.0.129

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.
@@ -8966,6 +8966,35 @@ DataCache.prototype.cloneRowData = function (rid) {
8966
8966
  return values;
8967
8967
  };
8968
8968
 
8969
+ /**
8970
+ * @protected
8971
+ * @ignore
8972
+ * @param {string} fromRid
8973
+ * @param {string} toRid
8974
+ * @return {boolean}
8975
+ */
8976
+ DataCache.prototype._replaceRowId = function(fromRid, toRid) {
8977
+ let rows = this._rows;
8978
+ if(rows[fromRid]) {
8979
+ rows[toRid] = rows[fromRid];
8980
+ delete rows[fromRid];
8981
+ return true;
8982
+ }
8983
+ return false;
8984
+ };
8985
+ /**
8986
+ * @public
8987
+ * @ignore
8988
+ * @param {Object} ridPair
8989
+ */
8990
+ DataCache.prototype.replaceRowIds = function(ridPair) {
8991
+ if(typeof ridPair === "object") {
8992
+ for(let oldRid in ridPair) {
8993
+ this._replaceRowId(oldRid, ridPair[oldRid]);
8994
+ }
8995
+ }
8996
+ };
8997
+
8969
8998
  /** Deprecated. Built-in Data Service is deprecated due to the lack of flexibility.
8970
8999
  * @public
8971
9000
  * @ignore
@@ -10173,6 +10202,27 @@ SegmentCollection.prototype.getSegmentIds = function() {
10173
10202
  };
10174
10203
 
10175
10204
 
10205
+ /** @public
10206
+ * @param {Array.<string>} segmentIds
10207
+ * @param {boolean=} bool
10208
+ * @return {boolean} Returns true if there is any change. Otherwise, returns false
10209
+ */
10210
+ SegmentCollection.prototype.collapseSegments = function(segmentIds, bool) {
10211
+ if(this._segmentCount) {
10212
+ let dirty = 0;
10213
+ let len = segmentIds.length;
10214
+ for (let i = 0; i < len; i++) {
10215
+ let rowId = segmentIds[i];
10216
+ dirty |= this._segments[rowId].collapse(bool);
10217
+
10218
+ }
10219
+ if(dirty) {
10220
+ return true;
10221
+ }
10222
+ }
10223
+ return false;
10224
+ };
10225
+
10176
10226
  /** @public
10177
10227
  * @param {string} segmentId
10178
10228
  * @param {boolean=} bool
@@ -11412,6 +11462,45 @@ DataTable.prototype.swapRow = function(fromIndex, toIndex) { // No event is fire
11412
11462
  this._rids[toIndex] = rid;
11413
11463
  };
11414
11464
 
11465
+ /**
11466
+ * @protected
11467
+ * @override
11468
+ * @ignore
11469
+ * @param {string} fromRid
11470
+ * @param {string} toRid
11471
+ * @return {boolean}
11472
+ */
11473
+ DataTable.prototype._replaceRowId = function(fromRid, toRid) {
11474
+ let rids = this._rids;
11475
+ let idx = rids.indexOf(fromRid);
11476
+ if(idx >= 0) {
11477
+ rids[idx] = toRid;
11478
+ this._rows[toRid] = this._rows[fromRid];
11479
+ delete this._rows[fromRid];
11480
+ this._prevData[toRid] = this._prevData[fromRid];
11481
+ delete this._prevData[fromRid];
11482
+ return true;
11483
+ }
11484
+ return false;
11485
+ };
11486
+ /**
11487
+ * @public
11488
+ * @override
11489
+ * @ignore
11490
+ * @param {Object} ridPair
11491
+ */
11492
+ DataTable.prototype.replaceRowIds = function(ridPair) {
11493
+ if(typeof ridPair === "object") {
11494
+ let dirty = false;
11495
+ for(let oldRid in ridPair) {
11496
+ dirty |= this._replaceRowId(oldRid, ridPair[oldRid]);
11497
+ }
11498
+ if(dirty) {
11499
+ this.dispatchGlobalChange();
11500
+ }
11501
+ }
11502
+ };
11503
+
11415
11504
  /** @public
11416
11505
  * @function
11417
11506
  * @param {string} rid
@@ -11553,6 +11642,55 @@ DataTable.prototype.isFrozen = function() {
11553
11642
  return this._frozen;
11554
11643
  };
11555
11644
 
11645
+ /**
11646
+ * @public
11647
+ * @param {Array.<string>} rids
11648
+ * @param {boolean=} enabled
11649
+ * @return {boolean} Return true if there is any change
11650
+ */
11651
+ DataTable.prototype.setSegmentSeparators = function(rids, enabled) {
11652
+ let change = false;
11653
+ if (rids) {
11654
+ let len = rids.length;
11655
+ let segmentChanged = false;
11656
+ for (let i = 0; i < len; i++) {
11657
+ if(enabled !== false) {
11658
+ let rid = rids[i];
11659
+ if (!this._segments) {
11660
+ this._segments = new data_SegmentCollection();
11661
+ this._segments.addEventListener("subSegmentChanged", this._onSubSegmentChanged);
11662
+ }
11663
+ if(this._autoSegmentFilling) {
11664
+ let parentId = this._segments.getParentRowId(rid);
11665
+ if(parentId) {
11666
+ this._segments.removeSegmentChild(parentId, rid);
11667
+ }
11668
+ }
11669
+ segmentChanged = this._segments.addSegment(rid);
11670
+ } else if (this._segments) { // remove case
11671
+ let segment = this._segments.getSegment(rid);
11672
+ if(segment) {
11673
+ if(this._segments.removeSegment(rid)) {
11674
+ change = true;
11675
+ if(!this._segments.getSegmentCount()) {
11676
+ this._segments = null;
11677
+ }
11678
+ }
11679
+ }
11680
+ }
11681
+
11682
+ }
11683
+ if (enabled !== false && segmentChanged) {
11684
+ this._segments.calcSegmentOrder(this._rids);
11685
+ change = true;
11686
+ }
11687
+ if(change) {
11688
+ this.dispatchGlobalChange();
11689
+ }
11690
+ }
11691
+ return change;
11692
+
11693
+ };
11556
11694
 
11557
11695
  /**
11558
11696
  * @public
@@ -11579,7 +11717,7 @@ DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
11579
11717
  this._segments.calcSegmentOrder(this._rids);
11580
11718
  change = true;
11581
11719
  }
11582
- } else if(this._segments) {
11720
+ } else if(this._segments) { // mean remove separator
11583
11721
  let segment = this._segments.getSegment(rid);
11584
11722
  if(segment) {
11585
11723
  memberCount = segment.getChildCount();
@@ -11805,6 +11943,34 @@ DataTable.prototype.addSegmentChildren = function(segmentId, rids, dataIds) {
11805
11943
  }
11806
11944
  return false;
11807
11945
  };
11946
+
11947
+ /** @public
11948
+ * @param {Array.<Object>} segmentArr Segment array that contain "segmentId", "rowIds" to set segment children
11949
+ * @return {boolean} Return true if there is any change
11950
+ */
11951
+ DataTable.prototype.setSegmentChildren = function(segmentArr) {
11952
+ if(!this._segments) {
11953
+ return false;
11954
+ }
11955
+ this.removeAllSegmentChildren();
11956
+ let len = segmentArr.length;
11957
+ let dirty;
11958
+ for (let i = 0; i < len; i++) {
11959
+ let obj = segmentArr[i];
11960
+ if(this._segments.addSegmentChildren(obj.segmentId, obj.rowIds)) {
11961
+ dirty = true;
11962
+ }
11963
+ }
11964
+ if(dirty) {
11965
+ this._sort(null);
11966
+ this._dispatchPositionChange(); // Force rerendering, even if there is no position change
11967
+
11968
+ this.requestClassifying();
11969
+ return true;
11970
+ }
11971
+
11972
+ return false;
11973
+ };
11808
11974
  /** @public
11809
11975
  * @param {string} segmentId Row id
11810
11976
  * @param {string} rid Row id
@@ -31421,6 +31587,23 @@ DataView.prototype.synchronizeRowOrder = function() {
31421
31587
  this._dt._sort(this._sortingDefs);
31422
31588
  }
31423
31589
  };
31590
+ /**
31591
+ * @public
31592
+ * @param {Array<string>} rowIds
31593
+ * @param {boolean=} enabled
31594
+ * @return {boolean} Return true if there is any change
31595
+ */
31596
+ DataView.prototype.setSegmentSeparators = function(rowIds, enabled) {
31597
+ if(rowIds) {
31598
+ enabled = enabled !== false;
31599
+ if(enabled) {
31600
+ this.synchronizeRowOrder();
31601
+ }
31602
+ // TODO: Force expanding of segment before unsetting segment separator
31603
+ return this._dt.setSegmentSeparators(rowIds, enabled);
31604
+ }
31605
+ return false;
31606
+ };
31424
31607
  /** Set visible row as segment separator (hidden or filtered rows cannot be a segment separator)
31425
31608
  * @public
31426
31609
  * @param {string|number} rowRef Row id or row index
@@ -31521,6 +31704,22 @@ DataView.prototype.collapseSegment = function(rowRef, collapsed) {
31521
31704
  return false;
31522
31705
  };
31523
31706
  /** @public
31707
+ * @param {Array<string|number>} rowIds
31708
+ * @param {boolean=} collapsed
31709
+ * @return {boolean} Return true if there is any change
31710
+ */
31711
+ DataView.prototype.collapseSegments = function(rowIds, collapsed) {
31712
+ collapsed = collapsed !== false;
31713
+ let segments = this._dt._getSegmentSeparators();
31714
+ if(segments) {
31715
+ if(segments.collapseSegments(rowIds, collapsed)) {
31716
+ this._refreshAndNotify(); // dispatch global change event
31717
+ return true;
31718
+ }
31719
+ }
31720
+ return false;
31721
+ };
31722
+ /** @public
31524
31723
  * @param {string|number} rowRef Row id or row index
31525
31724
  * @param {boolean=} expanded
31526
31725
  * @return {boolean} Return true if there is any change
@@ -31599,6 +31798,16 @@ DataView.prototype.addSegmentChildren = function(segmentRef, rowRefs, dataIds) {
31599
31798
  return false;
31600
31799
  };
31601
31800
  /** @public
31801
+ * @param {Array<Object>} segmentArr Segment array that contain "segmentId", "rowIds" to set segment children
31802
+ * @return {boolean} Return true if there is any change
31803
+ */
31804
+ DataView.prototype.setSegmentChildren = function(segmentArr) {
31805
+ if(this._dt._getSegmentSeparators()) {
31806
+ return this._dt.setSegmentChildren(segmentArr);
31807
+ }
31808
+ return false;
31809
+ };
31810
+ /** @public
31602
31811
  * @param {string|number} segmentRef Row id or row index
31603
31812
  * @param {string|number} rowRef Row id, row index
31604
31813
  * @return {boolean} Return true if there is any change
@@ -36302,7 +36511,7 @@ Core.prototype._hasPendingRowChange = false;
36302
36511
  * @return {string}
36303
36512
  */
36304
36513
  Core.getVersion = function () {
36305
- return "5.1.125";
36514
+ return "5.1.129";
36306
36515
  };
36307
36516
  /** {@link ElementWrapper#dispose}
36308
36517
  * @override
@@ -42177,7 +42386,7 @@ DataConnector.prototype._fieldChangedConflator = null;
42177
42386
  * @private
42178
42387
  */
42179
42388
  DataConnector.prototype._ricChangedConflator = null;
42180
- /** @type {Object.<string, RowDefinition>}
42389
+ /** @type {Object.<string, Array.<RowDefinition>>}
42181
42390
  * @private
42182
42391
  */
42183
42392
  DataConnector.prototype._rowDefMap = null;
@@ -43467,7 +43676,15 @@ SortableTitlePlugin.prototype.isSorting = function () {
43467
43676
  * @fires SortableTitlePlugin#columnSorted
43468
43677
  */
43469
43678
  SortableTitlePlugin.prototype.sortColumn = function (colRef, sortOrder, opt_arg) {
43470
- this._sortColumn(this._prepareSorting(colRef, sortOrder), opt_arg);
43679
+ let sortOptions = this._prepareSorting(colRef, sortOrder);
43680
+ this._sortColumn(sortOptions, opt_arg);
43681
+ if (opt_arg && opt_arg["isUserAction"]) { // Currently, the 'isUserAction' flag is triggered by a user clicking on the title and clicking the filter dialog. TODO: preClicked should be firing too.
43682
+ let ce = {};
43683
+ ce["colIndex"] = sortOptions.colIndex;
43684
+ ce["sortOrder"] = this.getSortOrder(sortOptions.colIndex);
43685
+ ce["dataColumnName"] = this.getColumnSortingField(sortOptions.colIndex); // This should be deprecated
43686
+ this._dispatch("clicked", ce);
43687
+ }
43471
43688
  };
43472
43689
 
43473
43690
  /** Sort multiple columns at once
@@ -43866,14 +44083,6 @@ SortableTitlePlugin.prototype._proceedSorting = function (hitObj) {
43866
44083
  if(grid && grid["focus"]) {
43867
44084
  grid["focus"]();
43868
44085
  }
43869
-
43870
- if (this._hasListener("clicked")) {
43871
- let ce = {};
43872
- ce["colIndex"] = colIndex;
43873
- ce["sortOrder"] = this.getSortOrder(colIndex);
43874
- ce["dataColumnName"] = this.getColumnSortingField(colIndex); // This should be deprecated
43875
- this._dispatch("clicked", ce);
43876
- }
43877
44086
  }
43878
44087
  };
43879
44088
 
@@ -45136,6 +45345,10 @@ Grid.prototype._formulaConflator = null;
45136
45345
  */
45137
45346
  Grid.prototype._chainConflator = null;
45138
45347
  /** @private
45348
+ * @type {Object}
45349
+ */
45350
+ Grid.prototype._constituentMap = null;
45351
+ /** @private
45139
45352
  * @type {number}
45140
45353
  */
45141
45354
  Grid.prototype._clientWidth = NaN;
@@ -47306,6 +47519,7 @@ Grid.prototype.removeAllRows = function() {
47306
47519
  this._dcConflator.reset();
47307
47520
  this._formulaConflator.reset();
47308
47521
  this._chainConflator.reset();
47522
+ this._constituentMap = null;
47309
47523
  this._connector.removeAllRics();
47310
47524
 
47311
47525
  // TODO: This logic should also be in the core grid
@@ -48205,15 +48419,15 @@ Grid.prototype._onQuote2PostUpdate = function (e) {
48205
48419
  * @param {Object} e
48206
48420
  */
48207
48421
  Grid.prototype._onQ2DataChanged = function (e) {
48208
- let subId = e["subId"];
48209
- let rowDef = this._getRowDefinitionById(subId);
48422
+ let rowDef = this._getRowDefinitionById(e["subId"]);
48210
48423
  if(!rowDef) {
48211
48424
  return; // WARNING: This should not be happened because row has been removed but the data is still received
48212
48425
  }
48213
48426
 
48427
+ let ric = e["ric"];
48214
48428
  let values = e["values"];
48215
48429
  if (values) {
48216
- let ric = e["ric"];
48430
+ let duplicateRics = null;
48217
48431
  if(rowDef.verifyConstituent(ric)) {
48218
48432
  let parentDef = rowDef;
48219
48433
  let childDef = parentDef.getConstituent(ric);
@@ -48224,15 +48438,28 @@ Grid.prototype._onQ2DataChanged = function (e) {
48224
48438
  if(!childDef) {
48225
48439
  return; // Parent chain is not alive
48226
48440
  }
48441
+ duplicateRics = this._connector.getRowDefByRic(ric);
48227
48442
  this._connector.addRic(childDef); // TODO: JET/RTK should not re-subscribe this
48443
+ if(!this._constituentMap) {
48444
+ this._constituentMap = {};
48445
+ }
48446
+ this._constituentMap[childDef.getRowId()] = childDef;
48228
48447
  this._registerConstituents(childDef);
48229
48448
  }
48230
48449
  }
48231
48450
 
48451
+ if(duplicateRics && duplicateRics.length) {
48452
+ let duplicateRic = duplicateRics[0];
48453
+ duplicateRic.cloneRowData(values, values);
48454
+ }
48455
+
48232
48456
  rowDef.setRowData(values); // Trigger data changes
48233
- } else if(rowDef.isConstituent()) { // Subscription and its parent has been removed by Real-time provider
48234
- rowDef.setParent(null); // Manually remove child reference from its parent
48235
- this._removeRow(rowDef);
48457
+ } else { // The constituent is requested to be removed by the real-time data provider
48458
+ let childDef = rowDef.getConstituent(ric); // WARNING: normal ric and its delayed version must match with the one first given
48459
+ if(childDef) {
48460
+ childDef.setParent(null); // Manually remove child reference from its parent
48461
+ this._removeRow(childDef);
48462
+ }
48236
48463
  }
48237
48464
  };
48238
48465
 
@@ -48243,6 +48470,9 @@ Grid.prototype._registerConstituents = function(rowDef) {
48243
48470
  if(this._chainConflator.conflate(rowDef)) {
48244
48471
  return;
48245
48472
  }
48473
+
48474
+ this._constituentMap = null;
48475
+
48246
48476
  let view = this._dv;
48247
48477
  let dt = view ? view.getDataSource() : null;
48248
48478
  if(!dt) {
@@ -48552,14 +48782,21 @@ Grid.prototype._onDataComposed = function(e) {
48552
48782
  return; // Cannot do data composition if there is no change in data
48553
48783
  }
48554
48784
 
48555
- let rowData = e["rowData"];
48556
- if(!rowData) {
48785
+ if(!e["rowData"]) {
48557
48786
  return; // Row could already be removed or global change event is sent
48558
48787
  }
48559
48788
 
48560
- let rowDef = this._getRowDefinitionById(e["rid"]);
48789
+ let rowId = e["rid"];
48790
+ let rowDef = this._getRowDefinitionById(rowId);
48561
48791
  if(!rowDef) {
48562
- return; // Somehow the given row id is invalid
48792
+ rowDef = this._constituentMap ? this._constituentMap[rowId] : null; // Row def could be in pending for adding to view
48793
+ if(!rowDef) {
48794
+ return; // Somehow the given row id is invalid
48795
+ }
48796
+ if(rowDef.isDisposed()) {
48797
+ this._constituentMap[rowId] = null;
48798
+ return;
48799
+ }
48563
48800
  }
48564
48801
 
48565
48802
  if(this._autoDateConversion) { // auto data conversion
@@ -49133,7 +49370,8 @@ Grid.prototype._onTabNavigation = function(e) {
49133
49370
  */
49134
49371
  Grid.prototype._getEventHandlers = function() {
49135
49372
  return {
49136
- "tabNavigation": this._onTabNavigation
49373
+ "tabNavigation": this._onTabNavigation,
49374
+ "q2DataChanged": this._onQ2DataChanged
49137
49375
  };
49138
49376
  };
49139
49377