@refinitiv-ui/efx-grid 6.0.127 → 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
@@ -13249,7 +13415,10 @@ RowDefinition.prototype.setDataSource = function(dataSource, subs) {
13249
13415
  this._dc = dataSource || null;
13250
13416
 
13251
13417
  if(this._dc) {
13252
- this.setRowData(_cloneObject(this._staticValues)); // Trigger data change
13418
+ this.setRowData({}); // Trigger data change
13419
+ if(this._staticValues) {
13420
+ this.setRowData(this._staticValues); // Trigger dataComposed and add updates
13421
+ }
13253
13422
  }
13254
13423
 
13255
13424
  this._subs = subs || null;
@@ -13375,9 +13544,14 @@ RowDefinition.prototype.setRowData = function(data) {
13375
13544
  /** @public
13376
13545
  */
13377
13546
  RowDefinition.prototype.resetRowData = function() {
13378
- if(this._dc) {
13379
- this._dc.setRowData(this._rowId, null);
13380
- this._dc.setRowData(this._rowId, _cloneObject(this._staticValues)); // Row data is guaranteed to be existed
13547
+ let dc = this._dc;
13548
+ if(dc) {
13549
+ let rowId = this._rowId;
13550
+ dc.setRowData(rowId, null);
13551
+ dc.setRowData(rowId, {}); // Row data is guaranteed to be existed
13552
+ if(this._staticValues) {
13553
+ dc.setRowData(rowId, this._staticValues); // Trigger dataComposed and add updates
13554
+ }
13381
13555
  }
13382
13556
  };
13383
13557
  /** @public
@@ -31413,6 +31587,23 @@ DataView.prototype.synchronizeRowOrder = function() {
31413
31587
  this._dt._sort(this._sortingDefs);
31414
31588
  }
31415
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
+ };
31416
31607
  /** Set visible row as segment separator (hidden or filtered rows cannot be a segment separator)
31417
31608
  * @public
31418
31609
  * @param {string|number} rowRef Row id or row index
@@ -31513,6 +31704,22 @@ DataView.prototype.collapseSegment = function(rowRef, collapsed) {
31513
31704
  return false;
31514
31705
  };
31515
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
31516
31723
  * @param {string|number} rowRef Row id or row index
31517
31724
  * @param {boolean=} expanded
31518
31725
  * @return {boolean} Return true if there is any change
@@ -31591,6 +31798,16 @@ DataView.prototype.addSegmentChildren = function(segmentRef, rowRefs, dataIds) {
31591
31798
  return false;
31592
31799
  };
31593
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
31594
31811
  * @param {string|number} segmentRef Row id or row index
31595
31812
  * @param {string|number} rowRef Row id, row index
31596
31813
  * @return {boolean} Return true if there is any change
@@ -36294,7 +36511,7 @@ Core.prototype._hasPendingRowChange = false;
36294
36511
  * @return {string}
36295
36512
  */
36296
36513
  Core.getVersion = function () {
36297
- return "5.1.125";
36514
+ return "5.1.129";
36298
36515
  };
36299
36516
  /** {@link ElementWrapper#dispose}
36300
36517
  * @override
@@ -42169,7 +42386,7 @@ DataConnector.prototype._fieldChangedConflator = null;
42169
42386
  * @private
42170
42387
  */
42171
42388
  DataConnector.prototype._ricChangedConflator = null;
42172
- /** @type {Object.<string, RowDefinition>}
42389
+ /** @type {Object.<string, Array.<RowDefinition>>}
42173
42390
  * @private
42174
42391
  */
42175
42392
  DataConnector.prototype._rowDefMap = null;
@@ -43459,7 +43676,15 @@ SortableTitlePlugin.prototype.isSorting = function () {
43459
43676
  * @fires SortableTitlePlugin#columnSorted
43460
43677
  */
43461
43678
  SortableTitlePlugin.prototype.sortColumn = function (colRef, sortOrder, opt_arg) {
43462
- 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
+ }
43463
43688
  };
43464
43689
 
43465
43690
  /** Sort multiple columns at once
@@ -43858,14 +44083,6 @@ SortableTitlePlugin.prototype._proceedSorting = function (hitObj) {
43858
44083
  if(grid && grid["focus"]) {
43859
44084
  grid["focus"]();
43860
44085
  }
43861
-
43862
- if (this._hasListener("clicked")) {
43863
- let ce = {};
43864
- ce["colIndex"] = colIndex;
43865
- ce["sortOrder"] = this.getSortOrder(colIndex);
43866
- ce["dataColumnName"] = this.getColumnSortingField(colIndex); // This should be deprecated
43867
- this._dispatch("clicked", ce);
43868
- }
43869
44086
  }
43870
44087
  };
43871
44088
 
@@ -45128,6 +45345,10 @@ Grid.prototype._formulaConflator = null;
45128
45345
  */
45129
45346
  Grid.prototype._chainConflator = null;
45130
45347
  /** @private
45348
+ * @type {Object}
45349
+ */
45350
+ Grid.prototype._constituentMap = null;
45351
+ /** @private
45131
45352
  * @type {number}
45132
45353
  */
45133
45354
  Grid.prototype._clientWidth = NaN;
@@ -46974,10 +47195,10 @@ Grid.prototype.insertRow = function(rowOption, rowRef) {
46974
47195
  }
46975
47196
  }
46976
47197
  let rowDef = new RowDefinition(rowOption);
47198
+ rowDef.registerToView(this._dv, this._getRowId(rowRef));
46977
47199
  rowDef.setDataSource(this._dc, this._subs); // This could also subscribe chain index/ric to JET/RTK
46978
47200
  this._initDuplicateRicData(rowDef);
46979
47201
 
46980
- rowDef.registerToView(this._dv, this._getRowId(rowRef));
46981
47202
  if(rowOption && rowOption["hidden"]) {
46982
47203
  this._dv.hideRow(rowDef.getRowId()); // Try to obtain rowId in rowDef since rowId is not assigned when new rows are created.
46983
47204
  }
@@ -47298,6 +47519,7 @@ Grid.prototype.removeAllRows = function() {
47298
47519
  this._dcConflator.reset();
47299
47520
  this._formulaConflator.reset();
47300
47521
  this._chainConflator.reset();
47522
+ this._constituentMap = null;
47301
47523
  this._connector.removeAllRics();
47302
47524
 
47303
47525
  // TODO: This logic should also be in the core grid
@@ -48197,15 +48419,15 @@ Grid.prototype._onQuote2PostUpdate = function (e) {
48197
48419
  * @param {Object} e
48198
48420
  */
48199
48421
  Grid.prototype._onQ2DataChanged = function (e) {
48200
- let subId = e["subId"];
48201
- let rowDef = this._getRowDefinitionById(subId);
48422
+ let rowDef = this._getRowDefinitionById(e["subId"]);
48202
48423
  if(!rowDef) {
48203
48424
  return; // WARNING: This should not be happened because row has been removed but the data is still received
48204
48425
  }
48205
48426
 
48427
+ let ric = e["ric"];
48206
48428
  let values = e["values"];
48207
48429
  if (values) {
48208
- let ric = e["ric"];
48430
+ let duplicateRics = null;
48209
48431
  if(rowDef.verifyConstituent(ric)) {
48210
48432
  let parentDef = rowDef;
48211
48433
  let childDef = parentDef.getConstituent(ric);
@@ -48216,15 +48438,28 @@ Grid.prototype._onQ2DataChanged = function (e) {
48216
48438
  if(!childDef) {
48217
48439
  return; // Parent chain is not alive
48218
48440
  }
48441
+ duplicateRics = this._connector.getRowDefByRic(ric);
48219
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;
48220
48447
  this._registerConstituents(childDef);
48221
48448
  }
48222
48449
  }
48223
48450
 
48451
+ if(duplicateRics && duplicateRics.length) {
48452
+ let duplicateRic = duplicateRics[0];
48453
+ duplicateRic.cloneRowData(values, values);
48454
+ }
48455
+
48224
48456
  rowDef.setRowData(values); // Trigger data changes
48225
- } else if(rowDef.isConstituent()) { // Subscription and its parent has been removed by Real-time provider
48226
- rowDef.setParent(null); // Manually remove child reference from its parent
48227
- 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
+ }
48228
48463
  }
48229
48464
  };
48230
48465
 
@@ -48235,6 +48470,9 @@ Grid.prototype._registerConstituents = function(rowDef) {
48235
48470
  if(this._chainConflator.conflate(rowDef)) {
48236
48471
  return;
48237
48472
  }
48473
+
48474
+ this._constituentMap = null;
48475
+
48238
48476
  let view = this._dv;
48239
48477
  let dt = view ? view.getDataSource() : null;
48240
48478
  if(!dt) {
@@ -48544,17 +48782,21 @@ Grid.prototype._onDataComposed = function(e) {
48544
48782
  return; // Cannot do data composition if there is no change in data
48545
48783
  }
48546
48784
 
48547
- let rowData = e["rowData"];
48548
- if(!rowData) {
48785
+ if(!e["rowData"]) {
48549
48786
  return; // Row could already be removed or global change event is sent
48550
48787
  }
48551
48788
 
48552
- let rowDef = rowData[ROW_DEF];
48789
+ let rowId = e["rid"];
48790
+ let rowDef = this._getRowDefinitionById(rowId);
48553
48791
  if(!rowDef) {
48554
- return;
48555
- }
48556
- if(!rowDef.getDataSource()) {
48557
- return; // Somehow, rowDef is invalid and doesn't have data source
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
+ }
48558
48800
  }
48559
48801
 
48560
48802
  if(this._autoDateConversion) { // auto data conversion
@@ -48615,8 +48857,8 @@ Grid.prototype._onSubSegmentChanged = function(e) {
48615
48857
  rowDef = new RowDefinition({
48616
48858
  "segmentId": segmentId // WARNING: This could cause row id duplication
48617
48859
  });
48618
- rowDef.setDataSource(this._dc); // auto generated row does not require a subscription
48619
48860
  rowDef.registerToView(this._dv);
48861
+ rowDef.setDataSource(this._dc); // auto generated row does not require a subscription
48620
48862
  }
48621
48863
  };
48622
48864
 
@@ -49128,7 +49370,8 @@ Grid.prototype._onTabNavigation = function(e) {
49128
49370
  */
49129
49371
  Grid.prototype._getEventHandlers = function() {
49130
49372
  return {
49131
- "tabNavigation": this._onTabNavigation
49373
+ "tabNavigation": this._onTabNavigation,
49374
+ "q2DataChanged": this._onQ2DataChanged
49132
49375
  };
49133
49376
  };
49134
49377