@refinitiv-ui/efx-grid 6.0.128 → 6.0.130

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/lib/core/dist/core.js +258 -20
  2. package/lib/core/dist/core.min.js +1 -1
  3. package/lib/core/es6/data/DataCache.js +29 -0
  4. package/lib/core/es6/data/DataTable.d.ts +4 -0
  5. package/lib/core/es6/data/DataTable.js +117 -1
  6. package/lib/core/es6/data/DataView.d.ts +6 -0
  7. package/lib/core/es6/data/DataView.js +43 -0
  8. package/lib/core/es6/data/SegmentCollection.d.ts +2 -0
  9. package/lib/core/es6/data/SegmentCollection.js +21 -0
  10. package/lib/core/es6/grid/Core.js +39 -10
  11. package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +9 -9
  12. package/lib/grid/index.js +1 -1
  13. package/lib/row-segmenting/es6/RowSegmenting.d.ts +6 -0
  14. package/lib/row-segmenting/es6/RowSegmenting.js +62 -11
  15. package/lib/rt-grid/dist/rt-grid.js +337 -55
  16. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  17. package/lib/rt-grid/es6/DataConnector.js +1 -1
  18. package/lib/rt-grid/es6/Grid.d.ts +2 -0
  19. package/lib/rt-grid/es6/Grid.js +90 -23
  20. package/lib/rt-grid/es6/RowDefinition.d.ts +1 -1
  21. package/lib/rt-grid/es6/RowDefinition.js +26 -20
  22. package/lib/tr-grid-cell-selection/es6/CellSelection.d.ts +3 -2
  23. package/lib/tr-grid-cell-selection/es6/CellSelection.js +1100 -1124
  24. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +2 -1
  25. package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +8 -2
  26. package/lib/tr-grid-row-filtering/es6/RowFiltering.js +2 -2
  27. package/lib/types/es6/CellSelection.d.ts +3 -2
  28. package/lib/types/es6/ColumnGrouping.d.ts +2 -1
  29. package/lib/types/es6/Core/data/DataTable.d.ts +4 -0
  30. package/lib/types/es6/Core/data/DataView.d.ts +6 -0
  31. package/lib/types/es6/Core/data/SegmentCollection.d.ts +2 -0
  32. package/lib/types/es6/RealtimeGrid/Grid.d.ts +2 -0
  33. package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +1 -1
  34. package/lib/types/es6/RowSegmenting.d.ts +6 -0
  35. package/lib/versions.json +6 -6
  36. package/package.json +1 -1
@@ -31,7 +31,7 @@ DataConnector.prototype._fieldChangedConflator = null;
31
31
  * @private
32
32
  */
33
33
  DataConnector.prototype._ricChangedConflator = null;
34
- /** @type {Object.<string, RowDefinition>}
34
+ /** @type {Object.<string, Array.<RowDefinition>>}
35
35
  * @private
36
36
  */
37
37
  DataConnector.prototype._rowDefMap = null;
@@ -258,6 +258,8 @@ declare class Grid extends EventDispatcher {
258
258
 
259
259
  public hasRic(): boolean;
260
260
 
261
+ public getRic(rowRef?: (string|number)|null): string;
262
+
261
263
  public setRowData(rowRef: Grid.RowReference|null, values: any): void;
262
264
 
263
265
  public setStaticRowData(rowRef: Grid.RowReference|null, values: any): void;
@@ -175,6 +175,14 @@ import { ElementWrapper } from "../../core/es6/grid/components/ElementWrapper.js
175
175
  * @description Fired only when a row will be removed through Grid's API and before occurring of the actual removal
176
176
  */
177
177
 
178
+ /** @event Grid#beforeUnlinked
179
+ * @description Trigger before unlinking a chain row.
180
+ * @type {Object}
181
+ * @property {RowDefinition} chain An row definition object of a chain row.
182
+ * @property {boolean} collapsed Collapsing state of a chain row.
183
+ * @property {Object} ridMap A map of constituent rics and row ids used to customize row ids.
184
+ */
185
+
178
186
  /** @private
179
187
  * @param {RowDefinition} rowDef
180
188
  * @return {Object}
@@ -524,6 +532,10 @@ Grid.prototype._formulaConflator = null;
524
532
  */
525
533
  Grid.prototype._chainConflator = null;
526
534
  /** @private
535
+ * @type {Object}
536
+ */
537
+ Grid.prototype._constituentMap = null;
538
+ /** @private
527
539
  * @type {number}
528
540
  */
529
541
  Grid.prototype._clientWidth = NaN;
@@ -605,11 +617,6 @@ Grid.prototype._topSection = true;
605
617
  * @private
606
618
  */
607
619
  Grid.prototype._focusingArgs = null;
608
- /** @type {boolean}
609
- * @private
610
- */
611
- Grid.prototype._unlinking = false;
612
-
613
620
 
614
621
  /** @public
615
622
  */
@@ -2694,6 +2701,7 @@ Grid.prototype.removeAllRows = function() {
2694
2701
  this._dcConflator.reset();
2695
2702
  this._formulaConflator.reset();
2696
2703
  this._chainConflator.reset();
2704
+ this._constituentMap = null;
2697
2705
  this._connector.removeAllRics();
2698
2706
 
2699
2707
  // TODO: This logic should also be in the core grid
@@ -2837,13 +2845,41 @@ Grid.prototype.unlinkChain = function(rowRef) {
2837
2845
  return;
2838
2846
  }
2839
2847
 
2840
- this._unlinking = true;
2841
-
2842
2848
  let childRowDefs = rowDef.getDescendants(); // TODO: Support nested child
2843
2849
  if(childRowDefs) {
2844
- if(rowDef.isChainExpanded()) {
2845
- for(let i = 0; i < childRowDefs.length; i++) {
2846
- childRowDefs[i].toRealTimeRow();
2850
+ let len = childRowDefs.length;
2851
+ let ridMap = {};
2852
+ for(let i = 0; i < len; i++) {
2853
+ ridMap[childRowDefs[i].getRic()] = "";
2854
+ }
2855
+ let collapsed = rowDef.isChainCollapsed();
2856
+ let args = {
2857
+ chain: rowDef,
2858
+ collapsed: collapsed,
2859
+ ridMap: ridMap
2860
+ };
2861
+ this._dispatch("beforeUnlinked", args);
2862
+
2863
+ if(!collapsed) {
2864
+ let rowIdChanged = false;
2865
+ let ridPair = {};
2866
+ for(let i = 0; i < len; i++) {
2867
+ let childRowDef = childRowDefs[i];
2868
+ let mappedRowId = ridMap[childRowDef.getRic()];
2869
+ if(mappedRowId) {
2870
+ if(mappedRowId.match(RowDefinition.ROW_ID_PATTERN)) {
2871
+ console.warn("Please change the rowId format to avoid duplicated rows' id causing unexpected behavior.");
2872
+ mappedRowId = "";
2873
+ } else {
2874
+ rowIdChanged = true;
2875
+ ridPair[childRowDef.getRowId()] = mappedRowId;
2876
+ }
2877
+ }
2878
+ childRowDef.toRealTimeRow(mappedRowId);
2879
+ }
2880
+ if(rowIdChanged) {
2881
+ this._dc.replaceRowIds(ridPair);
2882
+ this._dt.replaceRowIds(ridPair);
2847
2883
  }
2848
2884
  } else {
2849
2885
  this._removeConstituentRows(childRowDefs);
@@ -2851,8 +2887,6 @@ Grid.prototype.unlinkChain = function(rowRef) {
2851
2887
  }
2852
2888
 
2853
2889
  rowDef.unlinkChain();
2854
-
2855
- this._unlinking = false;
2856
2890
  };
2857
2891
 
2858
2892
  /** Alias to setRic
@@ -3166,6 +3200,15 @@ Grid.prototype.getAllRics = function() {
3166
3200
  Grid.prototype.hasRic = function() {
3167
3201
  return this._connector.hasRic();
3168
3202
  };
3203
+ /** Returns RIC of given row reference.
3204
+ * @public
3205
+ * @param {(string|number)=} rowRef
3206
+ * @return {string}
3207
+ */
3208
+ Grid.prototype.getRic = function(rowRef) {
3209
+ let rowDef = this.getRowDefinition(rowRef);
3210
+ return rowDef.getRic();
3211
+ };
3169
3212
  /** A shorthand to set row data based on index of the specified row. It is better to keep rowDefinition object for updating data directly as row index can be changed by sorting and filtering.
3170
3213
  * @public
3171
3214
  * @param {Grid~RowReference} rowRef
@@ -3593,15 +3636,15 @@ Grid.prototype._onQuote2PostUpdate = function (e) {
3593
3636
  * @param {Object} e
3594
3637
  */
3595
3638
  Grid.prototype._onQ2DataChanged = function (e) {
3596
- let subId = e["subId"];
3597
- let rowDef = this._getRowDefinitionById(subId);
3639
+ let rowDef = this._getRowDefinitionById(e["subId"]);
3598
3640
  if(!rowDef) {
3599
3641
  return; // WARNING: This should not be happened because row has been removed but the data is still received
3600
3642
  }
3601
3643
 
3644
+ let ric = e["ric"];
3602
3645
  let values = e["values"];
3603
3646
  if (values) {
3604
- let ric = e["ric"];
3647
+ let duplicateRics = null;
3605
3648
  if(rowDef.verifyConstituent(ric)) {
3606
3649
  let parentDef = rowDef;
3607
3650
  let childDef = parentDef.getConstituent(ric);
@@ -3612,15 +3655,28 @@ Grid.prototype._onQ2DataChanged = function (e) {
3612
3655
  if(!childDef) {
3613
3656
  return; // Parent chain is not alive
3614
3657
  }
3658
+ duplicateRics = this._connector.getRowDefByRic(ric);
3615
3659
  this._connector.addRic(childDef); // TODO: JET/RTK should not re-subscribe this
3660
+ if(!this._constituentMap) {
3661
+ this._constituentMap = {};
3662
+ }
3663
+ this._constituentMap[childDef.getRowId()] = childDef;
3616
3664
  this._registerConstituents(childDef);
3617
3665
  }
3618
3666
  }
3619
3667
 
3668
+ if(duplicateRics && duplicateRics.length) {
3669
+ let duplicateRic = duplicateRics[0];
3670
+ duplicateRic.cloneRowData(values, values);
3671
+ }
3672
+
3620
3673
  rowDef.setRowData(values); // Trigger data changes
3621
- } else if(rowDef.isConstituent()) { // Subscription and its parent has been removed by Real-time provider
3622
- rowDef.setParent(null); // Manually remove child reference from its parent
3623
- this._removeRow(rowDef);
3674
+ } else { // The constituent is requested to be removed by the real-time data provider
3675
+ let childDef = rowDef.getConstituent(ric); // WARNING: normal ric and its delayed version must match with the one first given
3676
+ if(childDef) {
3677
+ childDef.setParent(null); // Manually remove child reference from its parent
3678
+ this._removeRow(childDef);
3679
+ }
3624
3680
  }
3625
3681
  };
3626
3682
 
@@ -3631,6 +3687,9 @@ Grid.prototype._registerConstituents = function(rowDef) {
3631
3687
  if(this._chainConflator.conflate(rowDef)) {
3632
3688
  return;
3633
3689
  }
3690
+
3691
+ this._constituentMap = null;
3692
+
3634
3693
  let view = this._dv;
3635
3694
  let dt = view ? view.getDataSource() : null;
3636
3695
  if(!dt) {
@@ -3940,14 +3999,21 @@ Grid.prototype._onDataComposed = function(e) {
3940
3999
  return; // Cannot do data composition if there is no change in data
3941
4000
  }
3942
4001
 
3943
- let rowData = e["rowData"];
3944
- if(!rowData) {
4002
+ if(!e["rowData"]) {
3945
4003
  return; // Row could already be removed or global change event is sent
3946
4004
  }
3947
4005
 
3948
- let rowDef = this._getRowDefinitionById(e["rid"]);
4006
+ let rowId = e["rid"];
4007
+ let rowDef = this._getRowDefinitionById(rowId);
3949
4008
  if(!rowDef) {
3950
- return; // Somehow the given row id is invalid
4009
+ rowDef = this._constituentMap ? this._constituentMap[rowId] : null; // Row def could be in pending for adding to view
4010
+ if(!rowDef) {
4011
+ return; // Somehow the given row id is invalid
4012
+ }
4013
+ if(rowDef.isDisposed()) {
4014
+ this._constituentMap[rowId] = null;
4015
+ return;
4016
+ }
3951
4017
  }
3952
4018
 
3953
4019
  if(this._autoDateConversion) { // auto data conversion
@@ -4521,7 +4587,8 @@ Grid.prototype._onTabNavigation = function(e) {
4521
4587
  */
4522
4588
  Grid.prototype._getEventHandlers = function() {
4523
4589
  return {
4524
- "tabNavigation": this._onTabNavigation
4590
+ "tabNavigation": this._onTabNavigation,
4591
+ "q2DataChanged": this._onQ2DataChanged
4525
4592
  };
4526
4593
  };
4527
4594
 
@@ -102,7 +102,7 @@ declare class RowDefinition {
102
102
 
103
103
  public subscribeForUpdates(subs?: any): boolean;
104
104
 
105
- public unsubscribeForUpdates(): null;
105
+ public unsubscribeForUpdates(keepData?: boolean|null): null;
106
106
 
107
107
  public isSubscribing(): boolean;
108
108
 
@@ -48,12 +48,6 @@ const ROW_TYPES = {
48
48
  GROUP_MEMBER: "GROUP_MEMBER"
49
49
  };
50
50
 
51
- /** @type {RegExp}
52
- * @private
53
- * @const
54
- */
55
- const ROW_ID_PATTERN = /^_[^_]+_$/;
56
-
57
51
  /** @private
58
52
  * @function
59
53
  * @param {Object} obj
@@ -98,6 +92,11 @@ RowDefinition._runningId = 0;
98
92
  * @private
99
93
  */
100
94
  RowDefinition._childDataField = "CHILD_VALUES";
95
+ /** @type {RegExp}
96
+ * @private
97
+ * @const
98
+ */
99
+ RowDefinition.ROW_ID_PATTERN = /^_[^_]+_$/;
101
100
  //#region Private Members
102
101
  /** @type {string}
103
102
  * @private
@@ -253,7 +252,7 @@ RowDefinition.prototype.initialize = function(rowOptions) {
253
252
  if(!this._autoGenerated) {
254
253
  let userRowId = rowOptions["rowId"];
255
254
  if(userRowId && typeof userRowId === "string") {
256
- if(userRowId.match(ROW_ID_PATTERN)) {
255
+ if(userRowId.match(RowDefinition.ROW_ID_PATTERN)) {
257
256
  console.warn("Please change the rowId format to avoid duplicated rows' id causing unexpected behavior.");
258
257
  } else {
259
258
  this._rowId = userRowId;
@@ -904,12 +903,7 @@ RowDefinition.prototype.isRealTimeRow = function() {
904
903
  * @return {boolean} If a subscription is made, return true.
905
904
  */
906
905
  RowDefinition.prototype.subscribeForUpdates = function(subs) {
907
- if(subs) {
908
- this._subs = subs;
909
- } else {
910
- subs = this._subs;
911
- }
912
- if(!subs) {
906
+ if(!(subs || this._subs)) {
913
907
  return false;
914
908
  }
915
909
  if(!this.isRealTimeRow() && !this.getPermId()) {
@@ -917,7 +911,11 @@ RowDefinition.prototype.subscribeForUpdates = function(subs) {
917
911
  }
918
912
  // TODO: Check if the same subscription is being made.
919
913
  this.unsubscribeForUpdates();
920
-
914
+ if(subs) {
915
+ this._subs = subs;
916
+ } else {
917
+ subs = this._subs;
918
+ }
921
919
  if(this.isChain()) {
922
920
  let symbol = this._chainRic;
923
921
  if(!symbol){
@@ -941,14 +939,17 @@ RowDefinition.prototype.subscribeForUpdates = function(subs) {
941
939
  };
942
940
  /** Unsubscribe existing real-time data service. Static data is maintained
943
941
  * @public
942
+ * @param {boolean=} keepData
944
943
  * @returns {null} Always return null
945
944
  */
946
- RowDefinition.prototype.unsubscribeForUpdates = function() {
945
+ RowDefinition.prototype.unsubscribeForUpdates = function(keepData) {
947
946
  if(this.isSubscribing()) { // Only normal real-time rows and chains have both subId and subscription object
948
947
  this._subs["removeSubscription"](this._subId);
949
948
  this._subId = "";
950
- this.resetUpdates();
951
- this.resetRowData(); // Real-time data is removed while static data is maintained
949
+ if(!keepData) {
950
+ this.resetUpdates();
951
+ this.resetRowData(); // Real-time data is removed while static data is maintained
952
+ }
952
953
  }
953
954
  return null;
954
955
  };
@@ -1167,8 +1168,9 @@ RowDefinition.prototype.addConstituent = function(ric) {
1167
1168
  /** Used to convert autogenerated row to regular real-time row
1168
1169
  * @public
1169
1170
  * @ignore
1171
+ * @param {string=} userRowId
1170
1172
  */
1171
- RowDefinition.prototype.toRealTimeRow = function() {
1173
+ RowDefinition.prototype.toRealTimeRow = function(userRowId) {
1172
1174
  if(!this.isConstituent()) {
1173
1175
  return; // Only a constituent can be converted to a real-time row
1174
1176
  }
@@ -1179,7 +1181,11 @@ RowDefinition.prototype.toRealTimeRow = function() {
1179
1181
  this._parent = null;
1180
1182
  this._depthLevel = 0;
1181
1183
 
1182
- this.resetRowData(); // WARNING: existing real-time data is lost after this line
1184
+ if(userRowId) {
1185
+ this._rowId = userRowId;
1186
+ this._userId = true;
1187
+ }
1188
+
1183
1189
  this.subscribeForUpdates(subs); // Static data remains intact
1184
1190
  };
1185
1191
 
@@ -1190,7 +1196,7 @@ RowDefinition.prototype.unlinkChain = function() {
1190
1196
  return;
1191
1197
  }
1192
1198
 
1193
- this.unsubscribeForUpdates(); // Static data remains intact
1199
+ this.unsubscribeForUpdates(true); // Static data remains intact
1194
1200
 
1195
1201
  let view = this._view;
1196
1202
  if(view) {
@@ -2,7 +2,7 @@ import { Ext } from "../../tr-grid-util/es6/Ext.js";
2
2
  import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
3
3
  import { MouseDownTrait } from "../../tr-grid-util/es6/MouseDownTrait.js";
4
4
  import { EventDispatcher } from "../../tr-grid-util/es6/EventDispatcher.js";
5
- import { isIE, cloneObject, prepareTSVContent } from "../../tr-grid-util/es6/Util.js";
5
+ import { cloneObject, prepareTSVContent } from "../../tr-grid-util/es6/Util.js";
6
6
  import { ElfUtil } from "../../tr-grid-util/es6/ElfUtil.js";
7
7
  import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
8
8
 
@@ -16,7 +16,8 @@ declare namespace CellSelectionPlugin {
16
16
  selectionChanged?: ((...params: any[]) => any)|null,
17
17
  copy?: ((...params: any[]) => any)|null,
18
18
  beforeMouseDown?: ((...params: any[]) => any)|null,
19
- selectableSections?: any[]|null
19
+ selectableSections?: any[]|null,
20
+ copyDisabled?: boolean|null
20
21
  };
21
22
 
22
23
  }