@refinitiv-ui/efx-grid 6.0.67 → 6.0.69

Sign up to get free protection for your applications and to get access to all the features.
package/lib/grid/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import {Grid} from "./lib/efx-grid.js";
2
2
  export {Grid}
3
- window.EFX_GRID = { version: "6.0.67" };
3
+ window.EFX_GRID = { version: "6.0.69" };
@@ -14756,7 +14756,7 @@ FieldDefinition.isRealTimeField = function(field) {
14756
14756
  * @return {boolean}
14757
14757
  */
14758
14758
  FieldDefinition.isTimeSeriesChild = function(field) {
14759
- return FieldDefinition.getFieldProperty(field, "timeSeriesChild") ? true : false;
14759
+ return FieldDefinition.getFieldProperty(field, "timeSeriesParent") ? true : false;
14760
14760
  };
14761
14761
 
14762
14762
  /** @public
@@ -14784,12 +14784,12 @@ FieldDefinition.isTimeSeries = function (field) {
14784
14784
  [\w]+ => any field with string and value
14785
14785
  [\(] => open bucket (
14786
14786
  [\w\-\=\,]* => any property name and follow by = EX. SDATE=2011-11-11, PRIOD=123123
14787
- EDATE\=+ => EDATE in bucket
14787
+ (?:EDATE|SDATE ) => non-capturing group match EDATE or SDATE
14788
14788
  [\w\-\=\,]+ => another propertie param
14789
14789
  [\)]$ => end with only )
14790
14790
  i => for match both upper and lower cases
14791
14791
  */
14792
- var timeSeriesRegex = /^TR.[\w]+[\(][\w\-\=\,]*EDATE\=+[\w\-\=\,]+[\)]$/i;
14792
+ var timeSeriesRegex = /^TR\.[\w]+\([\w\-\=\,]*(?:EDATE|SDATE)\=+[\w\-\=\,]*[ \w]*\)$/i;
14793
14793
  return timeSeriesRegex.test(field);
14794
14794
  };
14795
14795
 
@@ -15181,7 +15181,6 @@ var ColumnDefinition = function(columnOption, hostGrid) {
15181
15181
  this._classes = [];
15182
15182
  this._requiredFields = [];
15183
15183
  this._children = [];
15184
- this._parent = [];
15185
15184
 
15186
15185
  if(columnOption) {
15187
15186
  if(columnOption["parent"]) { // WARNING: This assume time series child, when have a parent
@@ -16087,8 +16086,9 @@ ColumnDefinition.prototype._setField = function(field, columnOption) {
16087
16086
  // We need to cache time series in field definition for improve performance of checking methond
16088
16087
  js_FieldDefinition.setFieldProperty(field, "timeSeries", js_FieldDefinition.isTimeSeries(field) ? true : false);
16089
16088
 
16090
- if(columnOption && columnOption["parent"]) {
16091
- js_FieldDefinition.setFieldProperty(field, "timeSeriesChild", true);
16089
+ var parentColDef = columnOption["parent"];
16090
+ if(columnOption && parentColDef) {
16091
+ js_FieldDefinition.setFieldProperty(field, "timeSeriesParent", parentColDef.getField());
16092
16092
  }
16093
16093
 
16094
16094
  this._updateContext("field", field);
@@ -16264,6 +16264,43 @@ SnapshotFiller.prototype.setRTK = function (rtk) {
16264
16264
  this._rtk = rtk;
16265
16265
  };
16266
16266
 
16267
+ /**
16268
+ * @public
16269
+ * @type {Object}
16270
+ */
16271
+ SnapshotFiller._mockAdc = null;
16272
+
16273
+ /**
16274
+ * @public
16275
+ * @param {string} str
16276
+ * @param {*} value
16277
+ */
16278
+ SnapshotFiller.setMockAdc = function(str, value) {
16279
+ if(!SnapshotFiller._mockAdc) {
16280
+ SnapshotFiller._mockAdc = {};
16281
+ }
16282
+ SnapshotFiller._mockAdc[str] = value;
16283
+ };
16284
+
16285
+ /**
16286
+ * @public
16287
+ * @param {string} str
16288
+ * @return {*}
16289
+ */
16290
+ SnapshotFiller.getMockAdc = function(str) {
16291
+ if(!SnapshotFiller._mockAdc) {
16292
+ return null;
16293
+ }
16294
+ return SnapshotFiller._mockAdc[str];
16295
+ };
16296
+
16297
+ /**
16298
+ * @public
16299
+ */
16300
+ SnapshotFiller.clearMockAdc = function() {
16301
+ SnapshotFiller._mockAdc = null;
16302
+ }
16303
+
16267
16304
  /** @public
16268
16305
  * @param {Grid~ADCOptions} adcOptions ADC requesting level parameter options
16269
16306
  */
@@ -16429,12 +16466,19 @@ SnapshotFiller.prototype._onRequest = function () {
16429
16466
  "output": "Col,date|,Row,In|,va,T,NoEmptyTickers" // For customize output server, for more information please visit "https://confluence.refinitiv.com/display/ADC/Data+Cloud+Output+Format"
16430
16467
  };
16431
16468
  onSuccess = this._onRTKTimeSeriesSuccess.bind(this, timeSeriesFields);
16432
- this._rtk.Data.Adc
16469
+ var responseMockAdc = SnapshotFiller.getMockAdc(payload.formula);
16470
+ if(responseMockAdc) {
16471
+ setTimeout(function() {
16472
+ onSuccess(responseMockAdc);
16473
+ }, 10); // Mock Async operation
16474
+ } else {
16475
+ this._rtk.Data.Adc
16433
16476
  .request(payload)
16434
16477
  .then(onSuccess)
16435
16478
  .catch(function (err) {
16436
16479
  console.log(err);
16437
16480
  });
16481
+ }
16438
16482
  }
16439
16483
 
16440
16484
  // Request normal adc field
@@ -16635,61 +16679,66 @@ SnapshotFiller.prototype._onRTKTimeSeriesSuccess = function (fields, serverResul
16635
16679
  if (!Array.isArray(data2D) || !Array.isArray(svHeaders)) {
16636
16680
  return; // TODO: Return Promise.reject(errMsg);
16637
16681
  }
16638
-
16639
- var headerLen = svHeaders.length;
16640
-
16641
- var headerDates = [];
16642
- var i, j;
16643
-
16644
- for (i = 2; i < headerLen; i++) { // Start with 2 (Skip instrunment and date header)
16645
- headerDates.push(svHeaders[i].v);
16646
- }
16647
-
16648
- var ric, j, field;
16649
- var len = data2D.length;
16650
- var ricMap = {};
16651
- var childrenFieldToParent = {};
16652
-
16682
+ // Extract header dates
16683
+ var headerDates = svHeaders.slice(2).map(header => header.v);
16684
+ // Create necessary variables
16653
16685
  var fileNameToTSField = {};
16654
16686
  var count = 0;
16655
- for (let i = 1; i < len; i++) {
16687
+ // Convert map to fieldMap
16688
+ var data2DLength = data2D.length;
16689
+ for (var i = 1; i < data2DLength; i++) {
16656
16690
  var dataRow = data2D[i];
16657
16691
  var fieldName = dataRow[1];
16658
- if(!fileNameToTSField[fieldName]) {
16692
+ if (!fileNameToTSField[fieldName]) {
16659
16693
  fileNameToTSField[fieldName] = fields[count++];
16660
- }
16694
+ }
16661
16695
  }
16662
-
16663
- // TODO: Freeze the data view before setting multiple data
16664
- for (i = 1; i < len; i++) { // to skip column header index, use i = 1
16696
+ // Process data and populate ricMap and childrenFieldToParent
16697
+ var ricMap = {};
16698
+ var childrenFieldToParent = {};
16699
+ for (var i = 1; i < data2DLength; i++) {
16665
16700
  var dataRow = data2D[i];
16666
- ric = dataRow[0];
16667
- var fieldName = dataRow[1]; // ex. PRICECLOSE
16668
- if(!ricMap[ric]) {
16701
+ var ric = dataRow[0];
16702
+ var fieldName = dataRow[1];
16703
+
16704
+ if (!ricMap[ric]) {
16669
16705
  ricMap[ric] = {};
16670
16706
  }
16671
16707
  var snapData = ricMap[ric];
16672
- for (var k = 0; k < headerDates.length; k++) {
16673
- field = fileNameToTSField[fieldName].replace("TR.", "") + "_" + headerDates[k]; // TODO: make support time series field definition cache
16674
- childrenFieldToParent[field] = fileNameToTSField[fieldName];
16675
- snapData[field] = dataRow[2 + k]; // Start with field value
16708
+ if (headerDates.length === 1) {
16709
+ // Time series with only 1 column, it will be a normal adc field
16710
+ snapData[fileNameToTSField[fieldName]] = dataRow[2];
16711
+ } else {
16712
+ // Multiple columns, it will be a time series field
16713
+ for (var k = 0; k < headerDates.length; k++) {
16714
+ var field = fileNameToTSField[fieldName].replace("TR.", "") + "_" + headerDates[k];
16715
+ var celLData = dataRow[2 + k];
16716
+ if(celLData !== null) {
16717
+ childrenFieldToParent[field] = fileNameToTSField[fieldName];
16718
+ snapData[field] = celLData;
16719
+ }
16720
+ }
16676
16721
  }
16677
16722
  }
16678
16723
 
16679
- // return result only ric that has update data
16724
+ // Return result only for ric that has updated data
16680
16725
  var dataMapping = {};
16681
- for (ric in ricMap) {
16726
+ for (var ric in ricMap) {
16682
16727
  var obj = ricMap[ric];
16683
16728
  if (!isEmptyObject(obj)) {
16684
16729
  dataMapping[ric] = obj;
16685
16730
  }
16686
16731
  }
16687
16732
 
16688
- this._dispatch("dataChanged", {
16733
+ // Dispatch events based on the header length
16734
+ var eventData = {
16689
16735
  data: dataMapping,
16690
- timeSeries: true,
16691
- childrenFieldToParent: childrenFieldToParent
16692
- });
16736
+ };
16737
+ if (headerDates.length > 1) {
16738
+ eventData.timeSeries = true;
16739
+ eventData.childrenFieldToParent = childrenFieldToParent;
16740
+ }
16741
+ this._dispatch("dataChanged", eventData);
16693
16742
  };
16694
16743
 
16695
16744
 
@@ -29082,6 +29131,10 @@ DataView.prototype._excludedRids = null;
29082
29131
  * @type {boolean}
29083
29132
  */
29084
29133
  DataView.prototype._emptySegmentFiltering = false;
29134
+ /** @private
29135
+ * @type {boolean}
29136
+ */
29137
+ DataView.prototype._separatorFiltering = false;
29085
29138
 
29086
29139
  /** @private
29087
29140
  * @type {Object.<string, number>}
@@ -31517,7 +31570,7 @@ DataView.prototype.sortSeparators = function (sortLogics, sortOrders, cids) {
31517
31570
  DataView.prototype.sortSegments = function (compare) {
31518
31571
  this._dt.sortSegments(compare);
31519
31572
  };
31520
- /** 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.
31573
+ /** 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. A segment with no child is treated the same way as an empty segment.
31521
31574
  * @public
31522
31575
  * @param {boolean=} enabled
31523
31576
  */
@@ -31530,6 +31583,19 @@ DataView.prototype.enableEmptySegmentFiltering = function (enabled) {
31530
31583
  }
31531
31584
  }
31532
31585
  };
31586
+ /** Allow filtering of segment separators as if they were normal rows. Note that even if a separator row is filtered out, its child row may remain in the view and not be filtered out.
31587
+ * @public
31588
+ * @param {boolean=} enabled
31589
+ */
31590
+ DataView.prototype.enableSeparatorFiltering = function (enabled) {
31591
+ enabled = enabled !== false;
31592
+ if(this._separatorFiltering !== enabled) {
31593
+ this._separatorFiltering = enabled;
31594
+ if(this._userFilter) {
31595
+ this._refreshAndNotify();
31596
+ }
31597
+ }
31598
+ };
31533
31599
  /**
31534
31600
  * @public
31535
31601
  * @param {string|number} segmentRef Row id or row index
@@ -31697,14 +31763,19 @@ DataView.prototype._updateRowIds = function(opt_rowIds) {
31697
31763
 
31698
31764
  // Segment separators should not be filtered out (hidden)
31699
31765
  var segments = this._dt._getSegmentSeparators();
31700
- var filterExceptions = segments ? segments.getSegments() : null;
31701
- var userRemoval = this._getRemovalMap(this._excludedRids, this._userFilter, this._filteringOut, filterExceptions);
31766
+ var segmentIds = segments ? segments.getSegments() : null;
31767
+ var userRemoval = this._getRemovalMap(
31768
+ this._excludedRids,
31769
+ this._userFilter,
31770
+ this._filteringOut,
31771
+ this._separatorFiltering ? null : segmentIds
31772
+ );
31702
31773
  exclusionCount += userRemoval;
31703
31774
 
31704
31775
  this._collapsedRids = null;
31705
31776
  if(segments) {
31706
31777
  if(userRemoval && this._emptySegmentFiltering) {
31707
- exclusionCount += this._getEmptySegments(this._excludedRids, filterExceptions);
31778
+ exclusionCount += this._getEmptySegments(this._excludedRids, segmentIds);
31708
31779
  }
31709
31780
  this._collapsedRids = segments.getCollapsedRows();
31710
31781
  // Children of collapsed segments must be filtered out (hidden)
@@ -36149,7 +36220,7 @@ Core.prototype._batches = null;
36149
36220
  * @return {string}
36150
36221
  */
36151
36222
  Core.getVersion = function () {
36152
- return "5.1.76";
36223
+ return "5.1.77";
36153
36224
  };
36154
36225
  /** {@link ElementWrapper#dispose}
36155
36226
  * @override
@@ -45327,7 +45398,7 @@ Grid.prototype.getConfigObject = function (gridOptions) {
45327
45398
  }
45328
45399
 
45329
45400
 
45330
- var i, len;
45401
+ var i, len, prevTimeSeriesField;
45331
45402
  len = this.getColumnCount();
45332
45403
  for (i = 0; i < len; ++i) {
45333
45404
  var column = columns[i];
@@ -45337,9 +45408,19 @@ Grid.prototype.getConfigObject = function (gridOptions) {
45337
45408
  var colDef = this.getColumnDefinition(i);
45338
45409
  // TODO: Update width and scalability changed by the extensions
45339
45410
  colDef.getConfigObject(column);
45340
- }
45411
+ var parentField = js_FieldDefinition.getFieldProperty(colDef.getField(), "timeSeriesParent");
45412
+ if(parentField && !prevTimeSeriesField) { // Assume first column of time series child to convert to time series parent
45413
+ prevTimeSeriesField = parentField;
45414
+ column.field = parentField;
45415
+ delete column.name; // WARNING: Name of child should be retained
45416
+ delete column.autoGenerated; // Convert to parent time series field
45417
+ }
45341
45418
 
45342
- obj.columns = columns = columns.filter(_byNonAutoGeneratedColumn);
45419
+ if(!parentField && prevTimeSeriesField) { // Handled duplicate parent time series field in difference position of column
45420
+ prevTimeSeriesField = null;
45421
+ }
45422
+ }
45423
+ obj.columns = columns = columns.filter(_byNonAutoGeneratedColumn); // Time series child will be filtered out
45343
45424
 
45344
45425
  if(this._topNode.style.overflow === "") {
45345
45426
  obj["scrollbar"] = false;
@@ -45594,52 +45675,49 @@ Grid.prototype.insertColumn = function (columnOption, idx) {
45594
45675
  this._grid.insertColumn(idx, configObj); // columnAdded is fired
45595
45676
  };
45596
45677
 
45597
- /** @private
45678
+ /**
45679
+ * @private
45598
45680
  * @param {Object} e snapshort change event object
45599
45681
  */
45600
45682
  Grid.prototype._updateTimeSeriesFields = function (e) {
45601
- var snapShortData = e.data;
45602
- var childFields;
45603
- for (var ric in snapShortData) {
45604
- childFields = snapShortData[ric];
45605
- this.setRicData(ric, snapShortData[ric]);
45683
+ var childField;
45684
+ var snapShotData = e.data;
45685
+ var childFields = {};
45686
+ for (var ric in snapShotData) {
45687
+ // childFields = snapShotData[ric];
45688
+ for (childField in snapShotData[ric]) {
45689
+ childFields[childField] = true; // Merge child fields to parent (Don't truth each ric it will be have some empty data)
45690
+ }
45691
+ this.setRicData(ric, snapShotData[ric]); // update cell data if exist
45606
45692
  }
45607
45693
  var parentField, field, colIndex, parentColDef, childColIndex;
45608
-
45609
- var firstField;
45610
- for (field in childFields) {
45611
- firstField = field;
45612
- break;
45613
- }
45614
-
45615
- parentField = e.childrenFieldToParent[firstField];
45616
- colIndex = this.getColumnIndex(parentField);
45617
- this._grid.setColumnVisibility(colIndex);
45618
- parentColDef = this._getColumnDefinition(colIndex);
45619
-
45620
-
45621
- var children = parentColDef.getChildren();
45622
- var i, len, childDef, childField;
45623
- len = children.length;
45624
- if(len > 0){
45625
- for (i = 0; i < len; i++) {
45626
- childDef = children[i];
45627
- childField = childDef.getField();
45628
- if(!childFields[childField]) {
45629
- this.removeColumn(childField);
45630
- }
45694
+ var parentMap = {}; // map parent time series field and their first child
45695
+ for (field in childFields) { // Warning: data change can be differ time series child field
45696
+ parentField = e.childrenFieldToParent[field];
45697
+ if(!parentMap[parentField]) {
45698
+ parentMap[parentField] = [field];
45699
+ } else {
45700
+ parentMap[parentField].push(field);
45631
45701
  }
45632
45702
  }
45633
45703
 
45634
- for (childField in childFields) {
45635
- parentField = e.childrenFieldToParent[childField];
45704
+ for (parentField in parentMap) { // WARNING: one dataChanged event can be multiple fields
45705
+ var childrenField = parentMap[parentField];
45636
45706
  colIndex = this.getColumnIndex(parentField);
45637
45707
  parentColDef = this._getColumnDefinition(colIndex);
45638
- childColIndex = this.getColumnIndex(childField);
45639
- if(childColIndex < 0) { // not found column index in view tried to clone from parent
45640
- this._cloneTimeSeriesColumn(parentColDef, childField, colIndex);
45641
- js_FieldDefinition.addTimeSeriesChild(parentField, childField);
45708
+ var i, len;
45709
+ len = childrenField.length;
45710
+ for (i = 0; i < len; i++) {
45711
+ childField = childrenField[i];
45712
+ childColIndex = this.getColumnIndex(childField);
45713
+ if(childColIndex < 0) { // not found column index in view tried to clone from parent
45714
+ colIndex = this.getColumnIndex(parentField);
45715
+ parentColDef = this._getColumnDefinition(colIndex);
45716
+ this._cloneTimeSeriesColumn(parentColDef, childField, colIndex);
45717
+ js_FieldDefinition.addTimeSeriesChild(parentField, childField); // TODO: time series child can be difference of response even if the input is the same, It should be dynamic add/remove fields
45718
+ }
45642
45719
  }
45720
+ this.removeColumn(parentField);
45643
45721
  }
45644
45722
 
45645
45723
  };
@@ -45659,12 +45737,12 @@ Grid.prototype._populateTimeSeriesChildren = function (colDef) {
45659
45737
  for (i = 0; i < colDefs.length; i++) {
45660
45738
  colDef = colDefs[i];
45661
45739
  idx = this.getColumnIndex(colDef);
45662
- this._grid.setColumnVisibility(idx); // hide parent field
45663
45740
 
45664
45741
  if(!colDef) {
45665
45742
  continue;
45666
45743
  }
45667
- var childFields = js_FieldDefinition.getTimeSeriesChildren(colDef.getField());
45744
+ var parentField = colDef.getField();
45745
+ var childFields = js_FieldDefinition.getTimeSeriesChildren(parentField);
45668
45746
  if(!childFields) { // not found time series field
45669
45747
  return;
45670
45748
  }
@@ -45689,18 +45767,14 @@ Grid.prototype._populateTimeSeriesChildren = function (colDef) {
45689
45767
  * @param {number} idx index of insertion column
45690
45768
  */
45691
45769
  Grid.prototype._cloneTimeSeriesColumn = function (parentColDef, childField, idx) {
45692
- var parentConfig, columnOption, obj, key;
45770
+ var parentConfig, columnOption;
45693
45771
  parentConfig = parentColDef.getConfigObject();
45694
- obj = {};
45695
- for (key in parentConfig) {
45696
- if(key !== "hidden") {
45697
- obj[key] = parentConfig[key];
45698
- }
45699
- }
45700
- columnOption = cloneObject(obj);
45772
+ columnOption = cloneObject(parentConfig);
45701
45773
  columnOption["field"] = childField.replace("TR.", ""); // We need to remove the 'TR' prefix from the field to avoid confusion with time series fields.
45702
45774
  columnOption["name"] = childField.split("_")[1].split("T")[0]; // Currently, response server format utc date ex "2022-11-23T00:00:00"
45703
45775
  columnOption["parent"] = parentColDef;
45776
+ columnOption["timeSeriesName"] = parentColDef.getName();
45777
+ columnOption["timeSeriesId"] = parentColDef.getId();
45704
45778
  this.insertColumn(columnOption, idx++);
45705
45779
 
45706
45780
  };
@@ -45766,10 +45840,6 @@ Grid.prototype.replaceColumn = function (columnOption, colRef) {
45766
45840
  }
45767
45841
 
45768
45842
  var colDef = this.getColumnDefinition(colIndex);
45769
- if(colDef && colDef.getChildren().length > 0) { // Parent time series field doesn't provide hidden property
45770
- colConfig["hidden"] = false;
45771
- }
45772
-
45773
45843
  if(colDef && colConfig.id == null) {
45774
45844
  colConfig.id = colDef.getId(); // retain ID
45775
45845
  }
@@ -46105,18 +46175,6 @@ Grid.prototype.removeColumn = function(colRef) {
46105
46175
  }
46106
46176
 
46107
46177
  var colDef = this.getColumnDefinition(colIndex);
46108
- var children = colDef.getChildren();
46109
- if(children) {
46110
- var len = children.length;
46111
- if(len > 0) { // remove time series child
46112
- var i, childDef;
46113
- for (i = 0; i < len; i++) {
46114
- childDef = children[i];
46115
- this.removeColumn(childDef);
46116
- }
46117
- colIndex = this.getColumnIndex(colRef); // children in parent will be remove the parent should be get new index
46118
- }
46119
- }
46120
46178
 
46121
46179
  if(!colDef.isRealTimeField()) {
46122
46180
  if(this._dc) {
@@ -46249,18 +46307,7 @@ Grid.prototype.hideColumn = function(colRef, hidden) {
46249
46307
  if(colIndex < 0) { // not found
46250
46308
  return;
46251
46309
  }
46252
- var colDef = this.getColumnDefinition(colIndex);
46253
- var children = colDef.getChildren();
46254
- var len = children.length;
46255
- if(len > 0) { // remove time series child, and parent shouldn't unHide
46256
- var i, childDef;
46257
- for (i = 0; i < len; i++) {
46258
- childDef = children[i];
46259
- this.hideColumn(childDef, hidden);
46260
- }
46261
- } else {
46262
- this._grid.hideColumn(colIndex, hidden);
46263
- }
46310
+ this._grid.hideColumn(colIndex, hidden);
46264
46311
 
46265
46312
  };
46266
46313
  /** Hide multiple columns at once. The hidden columns still occupy the same index.