@refinitiv-ui/efx-grid 6.0.22 → 6.0.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -89,7 +89,7 @@ declare class ColumnDefinition {
89
89
 
90
90
  public isRealTimeField(): boolean;
91
91
 
92
- public isTimeSeriesField(): boolean;
92
+ public isTimeSeries(): boolean;
93
93
 
94
94
  public isFormulaField(): boolean;
95
95
 
@@ -213,10 +213,6 @@ ColumnDefinition.prototype._eventArg;
213
213
  /** @type {boolean}
214
214
  * @private
215
215
  */
216
- ColumnDefinition.prototype._realTimeField = false;
217
- /** @type {boolean}
218
- * @private
219
- */
220
216
  ColumnDefinition.prototype._autoGenerated = false;
221
217
 
222
218
  /** @type {!Array.<string>}
@@ -263,10 +259,6 @@ ColumnDefinition.prototype._parent = null;
263
259
  * @private
264
260
  */
265
261
  ColumnDefinition.prototype._children = null;
266
- /** @type {boolean}
267
- * @private
268
- */
269
- ColumnDefinition.prototype._timeSeriesField = false;
270
262
  /** @type {Object}
271
263
  * @private
272
264
  */
@@ -353,7 +345,7 @@ ColumnDefinition.prototype.initialize = function(columnOption) {
353
345
  }
354
346
  }
355
347
 
356
- this._setField(field, columnOption["formula"]); // Perform some field manipulation
348
+ this._setField(field, columnOption); // Perform some field manipulation
357
349
 
358
350
  val = columnOption["name"] || columnOption["title"]; // title is migrated from Composite Grid
359
351
  if(val != null) { // Name can be empty string
@@ -368,7 +360,7 @@ ColumnDefinition.prototype.initialize = function(columnOption) {
368
360
 
369
361
  val = columnOption["notRealTimeField"];
370
362
  if(val != null) {
371
- this._realTimeField = !val;
363
+ FieldDefinition.setFieldProperty(field, "IsRealtimeField", !val);
372
364
  }
373
365
 
374
366
  val = columnOption["tooltip"];
@@ -585,17 +577,13 @@ ColumnDefinition.prototype.getAllFields = function() {
585
577
  * @return {boolean}
586
578
  */
587
579
  ColumnDefinition.prototype.isRealTimeField = function() {
588
- // TODO: Simplify this logic
589
- if(this._field && this._realTimeField && !this._formula) {
590
- return ColumnDefinition.isRealTimeField(this._field);
591
- }
592
- return false;
580
+ return FieldDefinition.isRealTimeField(this._field);
593
581
  };
594
582
  /** @public
595
583
  * @return {boolean}
596
584
  */
597
- ColumnDefinition.prototype.isTimeSeriesField = function() {
598
- return this._timeSeriesField;
585
+ ColumnDefinition.prototype.isTimeSeries = function() {
586
+ return FieldDefinition.isTimeSeries(this._field);
599
587
  };
600
588
  /** @public
601
589
  * @return {boolean}
@@ -608,27 +596,21 @@ ColumnDefinition.prototype.isFormulaField = function() {
608
596
  * @return {boolean}
609
597
  */
610
598
  ColumnDefinition.isFormulaField = function(field) {
611
- return field.charAt(0) === "=";
599
+ return FieldDefinition.isFormula(field);
612
600
  };
613
601
  /** @public
614
602
  * @param {string} field
615
603
  * @return {boolean}
616
604
  */
617
605
  ColumnDefinition.isAdcField = function(field) {
618
- return field.indexOf("TR.") === 0;
606
+ return FieldDefinition.isAdc(field);
619
607
  };
620
608
  /** @public
621
609
  * @param {string} field
622
610
  * @return {boolean}
623
611
  */
624
612
  ColumnDefinition.isRealTimeField = function(field) {
625
- if(field) {
626
- if(!ColumnDefinition.isFormulaField(field)) {
627
- return !ColumnDefinition.isAdcField(field);
628
- }
629
- }
630
-
631
- return false;
613
+ return FieldDefinition.isRealTimeField(field);
632
614
  };
633
615
  /** @public
634
616
  * @function
@@ -753,8 +735,10 @@ ColumnDefinition.prototype.getConfigObject = function(colOptions) {
753
735
  obj["name"] = this._name;
754
736
  }
755
737
 
756
- if(!this._realTimeField) {
757
- obj["notRealTimeField"] = true;
738
+ // The 'IsRealtimeField' property will only be set if the user sets 'notRealTimeField' in the column options. It will be returned if the user has this option enabled, otherwise it will not be returned
739
+ value = FieldDefinition.getFieldProperty(this._field, "IsRealtimeField") === false;
740
+ if(value) {
741
+ obj["notRealTimeField"] = value;
758
742
  }
759
743
 
760
744
  if(this._tooltip != null) {
@@ -975,7 +959,7 @@ ColumnDefinition.prototype.setSorter = function(func) {
975
959
  */
976
960
  ColumnDefinition.prototype.isRowSorting = function() {
977
961
  if(this._rowSorting == null) {
978
- return !this._realTimeField;
962
+ return !FieldDefinition.getFieldProperty(this._field, "IsRealtimeField");
979
963
  }
980
964
  return this._rowSorting ? true : false;
981
965
  };
@@ -998,9 +982,9 @@ ColumnDefinition.prototype.setName = function(str) {
998
982
 
999
983
  /** @private
1000
984
  * @param {string|null=} field
1001
- * @param {string} formulaStr
985
+ * @param {ColumnDefinition~Options=} columnOption
1002
986
  */
1003
- ColumnDefinition.prototype._setField = function(field, formulaStr) {
987
+ ColumnDefinition.prototype._setField = function(field, columnOption) {
1004
988
  var defaultField = (field == null); // undefined or null
1005
989
  if(!field) {
1006
990
  field = "";
@@ -1008,6 +992,7 @@ ColumnDefinition.prototype._setField = function(field, formulaStr) {
1008
992
  // Trim white spaces -- equivalent to String.trim(), which is not support in IE8
1009
993
  field = field.replace(/^\s+|\s+$/gm, "");
1010
994
 
995
+ var formulaStr = columnOption["formula"];
1011
996
  if(this._fnEngine) {
1012
997
  var uppercasedF = field.toUpperCase(); // For comparison only
1013
998
  var predefinedF = formulaStr || PredefinedFormula.get(uppercasedF);
@@ -1035,13 +1020,13 @@ ColumnDefinition.prototype._setField = function(field, formulaStr) {
1035
1020
  this._field = field;
1036
1021
  this._name = field;
1037
1022
  this._emptyField = false;
1038
- this._realTimeField = field ? true : false;
1039
1023
  }
1040
1024
 
1041
- if(FieldDefinition.isTimeSeriesField(field)) {
1042
- // children will be clone the config from parent too
1043
- this._realTimeField = false;
1044
- this._timeSeriesField = true;
1025
+ // We need to cache time series in field definition for improve performance of checking methond
1026
+ FieldDefinition.setFieldProperty(field, "timeSeries", FieldDefinition.isTimeSeries(field) ? true : false);
1027
+
1028
+ if(columnOption["parent"]) {
1029
+ FieldDefinition.setFieldProperty(field, "timeSeriesChild", true);
1045
1030
  }
1046
1031
 
1047
1032
  this._isDefaultName = true;
@@ -18,7 +18,13 @@ declare namespace FieldDefinition {
18
18
 
19
19
  function setFieldCaching(caching: boolean): void;
20
20
 
21
- function isTimeSeriesField(field: string): boolean;
21
+ function isFormula(field: string): boolean;
22
+
23
+ function isAdc(field: string): boolean;
24
+
25
+ function isRealTimeField(field: string): boolean;
26
+
27
+ function isTimeSeries(field: string): boolean;
22
28
 
23
29
  }
24
30
 
@@ -57,7 +57,7 @@ var FieldDefinition = {};
57
57
  FieldDefinition._defs = {
58
58
  "X_RIC_NAME": {
59
59
  name: "RIC",
60
- notRealTimeField: true,
60
+ IsRealtimeField: false,
61
61
  width: 100,
62
62
  binding: xRicNameRenderer,
63
63
  sortLogic: xRicNameSorter
@@ -195,7 +195,13 @@ FieldDefinition._loadingField = {};
195
195
  * @param {Object} def
196
196
  */
197
197
  FieldDefinition.set = function(field, def) {
198
- FieldDefinition._defs[field] = def || null;
198
+ if (!FieldDefinition._defs[field]) {
199
+ FieldDefinition._defs[field] = def;
200
+ } else {
201
+ for (var key in def) {
202
+ FieldDefinition._defs[field][key] = def[key];
203
+ }
204
+ }
199
205
  };
200
206
  /** @public
201
207
  * @function
@@ -252,11 +258,64 @@ FieldDefinition.setFieldCaching = function (caching) {
252
258
  FieldDefinition._caching = caching;
253
259
  };
254
260
 
261
+ /** @public
262
+ * @param {string} field
263
+ * @return {boolean}
264
+ */
265
+ FieldDefinition.isFormula = function(field) {
266
+ return field.charAt(0) === "=";
267
+ };
268
+ /** @public
269
+ * @param {string} field
270
+ * @return {boolean}
271
+ */
272
+ FieldDefinition.isAdc = function(field) {
273
+ return field.indexOf("TR.") === 0;
274
+ };
275
+
276
+ /** @public
277
+ * @param {string} field
278
+ * @return {boolean}
279
+ */
280
+ FieldDefinition.isRealTimeField = function(field) {
281
+ if (!field) {
282
+ return false;
283
+ }
284
+
285
+ if(FieldDefinition.isAdc(field)) {
286
+ return false;
287
+ }
288
+
289
+ if(FieldDefinition.isFormula(field)) {
290
+ return false;
291
+ }
292
+
293
+ if(FieldDefinition.getFieldProperty(field, "timeSeriesChild")) {
294
+ return false;
295
+ }
296
+
297
+ if(FieldDefinition.isTimeSeries(field)) {
298
+ return false;
299
+ }
300
+
301
+ return FieldDefinition.getFieldProperty(field, "IsRealtimeField") !== false;
302
+ };
303
+
255
304
  /** @public
256
305
  * @param {string} field
257
306
  * @return {boolean}=true if field is time series field
258
307
  */
259
- FieldDefinition.isTimeSeriesField = function (field) {
308
+ FieldDefinition.isTimeSeries = function (field) {
309
+ if (!field) {
310
+ return false;
311
+ }
312
+
313
+ // We can check time series using a cache to avoid duplicating checks in regular expressions.
314
+ var timeSeriesField = FieldDefinition.getFieldProperty(field, "timeSeries");
315
+ if (timeSeriesField != null) {
316
+ return timeSeriesField;
317
+ }
318
+
260
319
  /*
261
320
  ^TR. => start with TR.
262
321
  [\w]+ => any field with string and value
@@ -265,9 +324,39 @@ FieldDefinition.isTimeSeriesField = function (field) {
265
324
  EDATE\=+ => EDATE in bucket
266
325
  [\w\-\=\,]+ => another propertie param
267
326
  [\)]$ => end with only )
327
+ i => for match both upper and lower cases
268
328
  */
329
+ var timeSeriesRegex = /^TR.[\w]+[\(][\w\-\=\,]*EDATE\=+[\w\-\=\,]+[\)]$/i;
330
+ return timeSeriesRegex.test(field);
331
+ };
269
332
 
270
- return !!field.toUpperCase().match(/^TR.[\w]+[\(][\w\-\=\,]*EDATE\=+[\w\-\=\,]+[\)]$/g);
333
+ /**
334
+ * Set property value into field definition
335
+ * @private
336
+ * @param {string} field field definition
337
+ * @param {string} propertyName
338
+ * @param {*} value
339
+ */
340
+ FieldDefinition.setFieldProperty = function(field, propertyName, value) {
341
+ if(!FieldDefinition._defs[field]) {
342
+ FieldDefinition._defs[field] = {};
343
+ }
344
+ FieldDefinition._defs[field][propertyName] = value;
345
+ };
346
+
347
+ /**
348
+ * Set property value into field definition
349
+ * @private
350
+ * @param {string} field field definition
351
+ * @param {string} propertyName
352
+ * @return {*}
353
+ */
354
+ FieldDefinition.getFieldProperty = function(field, propertyName) {
355
+ var fieldDef = FieldDefinition._defs[field];
356
+ if(fieldDef) {
357
+ return fieldDef[propertyName];
358
+ }
359
+ return null;
271
360
  };
272
361
 
273
362
  /** to get more info about field via synapse service
@@ -281,8 +281,7 @@ var Grid = function(placeholder, config) {
281
281
  t._recalculateFormulas = t._recalculateFormulas.bind(t);
282
282
  t._updateStreamingData = t._updateStreamingData.bind(t);
283
283
  t.updateColumnTitle = t.updateColumnTitle.bind(t);
284
- t._insertTimeSeriesChildren = t._insertTimeSeriesChildren.bind(t);
285
-
284
+ t._populateTimeSeriesChildren = t._populateTimeSeriesChildren.bind(t);
286
285
 
287
286
  t._onPostSectionDataBinding = t._onPostSectionDataBinding.bind(t);
288
287
  t._asyncClearDataUpdates = t._asyncClearDataUpdates.bind(t);
@@ -306,7 +305,7 @@ var Grid = function(placeholder, config) {
306
305
  t._formulaConflator = new Conflator(300, t._onFormulaDataChanged);
307
306
  t._chainConflator = new Conflator(100, t._addMemberOfChain);
308
307
  t._columnTitleConflator = new Conflator(0, t.updateColumnTitle);
309
- t._timeSeriesChildConflator = new Conflator(0, t._insertTimeSeriesChildren);
308
+ t._timeSeriesChildConflator = new Conflator(0, t._populateTimeSeriesChildren);
310
309
 
311
310
 
312
311
  t._defaultColumnOptions = {};
@@ -1264,7 +1263,7 @@ Grid.prototype._onFieldAdded = function(e) {
1264
1263
 
1265
1264
  // JET
1266
1265
  if (this._subs) {
1267
- var realtimeFields = addedFields.filter(ColumnDefinition.isRealTimeField);
1266
+ var realtimeFields = addedFields.filter(FieldDefinition.isRealTimeField);
1268
1267
  this._subs["addFields"](realtimeFields);
1269
1268
  }
1270
1269
 
@@ -1373,7 +1372,7 @@ Grid.prototype._updateTimeSeriesFields = function (e) {
1373
1372
  /** @private
1374
1373
  * @param {ColumnDefinition} colDef
1375
1374
  */
1376
- Grid.prototype._insertTimeSeriesChildren = function (colDef) {
1375
+ Grid.prototype._populateTimeSeriesChildren = function (colDef) {
1377
1376
  if(this._timeSeriesChildConflator.conflate(colDef) ) {
1378
1377
  return;
1379
1378
  }
@@ -1423,7 +1422,7 @@ Grid.prototype._cloneTimeSeriesColumn = function (parentColDef, childField, idx)
1423
1422
  }
1424
1423
  }
1425
1424
  columnOption = cloneObject(obj);
1426
- columnOption["field"] = childField.replace("TR.", "");
1425
+ columnOption["field"] = childField.replace("TR.", ""); // We need to remove the 'TR' prefix from the field to avoid confusion with time series fields.
1427
1426
  columnOption["name"] = childField.split("_")[1].split("T")[0]; // Currently, response server format utc date ex "2022-11-23T00:00:00"
1428
1427
  columnOption["parent"] = parentColDef;
1429
1428
  this.insertColumn(columnOption, idx++);
@@ -1530,6 +1529,11 @@ Grid.prototype._onFieldLoadedError = function (err) {
1530
1529
  * @param {string} referrer
1531
1530
  */
1532
1531
  Grid.prototype._onFieldLoaded = function (field, referrer) {
1532
+ // For time series, we need to wait until the field is loadedm, then we can insert a child from the field data.
1533
+ if(FieldDefinition.isTimeSeries(field)) {
1534
+ var colDef = this.getColumnDefinitionById(referrer); // The 'referrer' is a column ID that was just added
1535
+ this._populateTimeSeriesChildren(colDef);
1536
+ }
1533
1537
  this._connector.addFields(field, referrer);
1534
1538
  };
1535
1539
 
@@ -1559,7 +1563,7 @@ Grid.prototype._shouldLoadFieldInfo = function (field, isRealTime) {
1559
1563
  var fieldDef = FieldDefinition.get(field);
1560
1564
  if (!fieldDef &&
1561
1565
  field !== 'X_RIC_NAME' && // ignore X_RIC_NAME
1562
- (isRealTime || ColumnDefinition.isAdcField(field)) && // realtime field or adc field (Without static field)
1566
+ (isRealTime || FieldDefinition.isAdc(field)) && // realtime field or adc field (Without static field)
1563
1567
  (this._RTK || window["JET"]) // have rtk instance or window jet sub
1564
1568
  ) {
1565
1569
  return true;
@@ -1663,14 +1667,13 @@ Grid.prototype._onColumnAdded = function(e) {
1663
1667
  }
1664
1668
  }
1665
1669
  this._grid.setDataColumnName(idx, ROW_DEF); // This make ColumnDefinition renderer work
1666
-
1667
1670
  var fields = colDef.getAllFields();
1668
1671
  var referrer = colDef.getId();
1669
1672
  var len = fields.length;
1670
1673
  var field, dataType, prom, isRealTimeField, onLoaded;
1671
1674
  for(i = 0; i < len; i++) {
1672
1675
  field = fields[i];
1673
- isRealTimeField = ColumnDefinition.isRealTimeField(field);
1676
+ isRealTimeField = FieldDefinition.isRealTimeField(field);
1674
1677
  if(this._shouldLoadFieldInfo(field, isRealTimeField)) {
1675
1678
  if(field === colField) {
1676
1679
  dataType = colDef.getDataType(); // Data-type from user's column options
@@ -1686,14 +1689,14 @@ Grid.prototype._onColumnAdded = function(e) {
1686
1689
  onLoaded = this._onFieldLoaded.bind(this, field, referrer);
1687
1690
  prom = prom.then(onLoaded).catch(onLoaded);
1688
1691
  } else {
1689
- if(colDef.isTimeSeriesField()) {
1690
- this._insertTimeSeriesChildren(colDef);
1692
+ if(colDef.isTimeSeries()) {
1693
+ this._populateTimeSeriesChildren(colDef);
1691
1694
  }
1692
1695
  this._connector.addFields(field, referrer);
1693
1696
  }
1694
1697
  } else {
1695
- if(colDef.isTimeSeriesField()) {
1696
- this._insertTimeSeriesChildren(colDef);
1698
+ if(colDef.isTimeSeries()) {
1699
+ this._populateTimeSeriesChildren(colDef);
1697
1700
  }
1698
1701
  this._connector.addFields(field, referrer);
1699
1702
  }
@@ -1975,7 +1978,7 @@ Grid.prototype.addDataFields = function(fieldRef, referrer) {
1975
1978
  var i, field, dataType, prom, isRealTimeField, onLoaded;
1976
1979
  for(i = 0; i < len; i++) {
1977
1980
  field = fields[i];
1978
- isRealTimeField = ColumnDefinition.isRealTimeField(field);
1981
+ isRealTimeField = FieldDefinition.isRealTimeField(field);
1979
1982
  if(this._shouldLoadFieldInfo(field, isRealTimeField)) {
1980
1983
  dataType = ColumnDefinition.getDataType(field);
1981
1984
  prom = FieldDefinition.loadFieldInfo(field)
@@ -193,7 +193,7 @@ SnapshotFiller.prototype._onRequest = function () {
193
193
  var fields = [];
194
194
  var timeSeriesFields = [];
195
195
  for (var field in this._fields) {
196
- if(!FieldDefinition.isTimeSeriesField(field)) {
196
+ if(!FieldDefinition.isTimeSeries(field)) {
197
197
  fields.push(field);
198
198
  } else {
199
199
  timeSeriesFields.push(field);
package/package.json CHANGED
@@ -62,5 +62,5 @@
62
62
  "publishConfig": {
63
63
  "access": "public"
64
64
  },
65
- "version": "6.0.22"
65
+ "version": "6.0.23"
66
66
  }