@refinitiv-ui/efx-grid 6.0.49 → 6.0.50

Sign up to get free protection for your applications and to get access to all the features.
@@ -11243,6 +11243,14 @@ DataTable.prototype._removedRows = null;
11243
11243
  */
11244
11244
  DataTable.prototype._userSegmentComparer = null;
11245
11245
  /** @private
11246
+ * @type {number}
11247
+ */
11248
+ DataTable.prototype._segmentSortOrder = 0;
11249
+ /** @private
11250
+ * @type {*}
11251
+ */
11252
+ DataTable.prototype._segmentSortContext = null;
11253
+ /** @private
11246
11254
  * @type {Object.<string, Object>}
11247
11255
  */
11248
11256
  DataTable.prototype._clsSource = null;
@@ -12415,6 +12423,51 @@ DataTable.prototype.getSegmentChildIds = function(segmentId) {
12415
12423
  }
12416
12424
  return null;
12417
12425
  };
12426
+ /** Sort all of existing segments by multiple sort logics
12427
+ * @public
12428
+ * @param {Function|Array.<Function>} sortLogics
12429
+ * @param {Array.<number>} sortOrders
12430
+ * @param {Array.<string>} cids
12431
+ * @return {boolean}
12432
+ */
12433
+ DataTable.prototype.sortSeparators = function (sortLogics, sortOrders, cids) {
12434
+ var dirty = false;
12435
+ if(!this._segments){
12436
+ return false;
12437
+ }
12438
+ if(typeof sortLogics === "function"){
12439
+ return this.sortSegments(sortLogics);
12440
+ }
12441
+ var sortingDefs = DataTable._buildSortContext(
12442
+ [],
12443
+ cids,
12444
+ sortOrders,
12445
+ sortLogics
12446
+ );
12447
+ var defCount = sortingDefs ? sortingDefs.length : 0;
12448
+ if(!defCount){
12449
+ return dirty;
12450
+ }
12451
+
12452
+ var sortOrder = 0;
12453
+ var sortLogic, sortContext;
12454
+ if(defCount > 1) {
12455
+ sortLogic = DataTable._multiColumnSeparatorCompareLogic;
12456
+ sortContext = sortingDefs;
12457
+ sortOrder = 1; // sortOrder is not used by _multiColumnSeparatorCompareLogic
12458
+ } else { // Single level sorting
12459
+ sortLogic = DataTable._singleColumnSeparatorCompareLogic;
12460
+ sortContext = sortingDefs[0];
12461
+ sortOrder = /** @type{number} */(sortContext[3]);
12462
+ }
12463
+ this._segmentSortOrder = sortOrder;
12464
+ this._segmentSortContext = sortContext;
12465
+ dirty = this.sortSegments(sortLogic);
12466
+ this._segmentSortOrder = 0;
12467
+ this._segmentSortContext = null;
12468
+
12469
+ return dirty;
12470
+ };
12418
12471
  /** Sort all of existing segments by given compare function
12419
12472
  * @public
12420
12473
  * @param {Function} compare
@@ -12483,7 +12536,9 @@ DataTable.prototype.sortSegments = function (compare) {
12483
12536
  DataTable.prototype._bySegmentSeparator = function (segmentA, segmentB) {
12484
12537
  return /** @type{number} */(this._userSegmentComparer(
12485
12538
  this.getRowData(segmentA.getId()),
12486
- this.getRowData(segmentB.getId())
12539
+ this.getRowData(segmentB.getId()),
12540
+ this._segmentSortOrder,
12541
+ this._segmentSortContext
12487
12542
  ));
12488
12543
  };
12489
12544
 
@@ -12824,6 +12879,47 @@ DataTable._singleColumnCompareLogic = function(a, b, order, sortingDef) {
12824
12879
  sortingDef[4] // Context object
12825
12880
  ));
12826
12881
  };
12882
+ /** Performance is extremely vital in this method
12883
+ * @public
12884
+ * @ignore
12885
+ * @function
12886
+ * @param {*} a
12887
+ * @param {*} b
12888
+ * @param {number} order Not used by in this method
12889
+ * @param {Array.<Array>} sortingDefs
12890
+ * @return {number}
12891
+ */
12892
+ DataTable._multiColumnSeparatorCompareLogic = function(a, b, order, sortingDefs) {
12893
+ var count = sortingDefs.length;
12894
+ var result = 0;
12895
+ for(var c = 0; c < count; ++c) {
12896
+ var sortingDef = sortingDefs[c];
12897
+ result = DataTable._singleColumnSeparatorCompareLogic(a, b, sortingDef[3], sortingDef);
12898
+ if(result) {
12899
+ return result;
12900
+ }
12901
+ }
12902
+ return result;
12903
+ };
12904
+ /** Performance is extremely vital in this method
12905
+ * @public
12906
+ * @ignore
12907
+ * @function
12908
+ * @param {*} a
12909
+ * @param {*} b
12910
+ * @param {number} order
12911
+ * @param {Array} sortingDef
12912
+ * @return {number}
12913
+ */
12914
+ DataTable._singleColumnSeparatorCompareLogic = function(a, b, order, sortingDef) {
12915
+ var key = /** @type{string} */(sortingDef[0]);
12916
+ return /** @type{number} */(sortingDef[2](
12917
+ a[key], // Value1
12918
+ b[key], // Value2
12919
+ order, // Sort order (3)
12920
+ sortingDef[4] // Context object
12921
+ ));
12922
+ };
12827
12923
  /** @public
12828
12924
  * @function
12829
12925
  * @ignore
@@ -31351,6 +31447,15 @@ DataView.prototype.getSegmentIds = function() {
31351
31447
  DataView.prototype.getSegmentChildIds = function(segmentRef) {
31352
31448
  return this._dt.getSegmentChildIds(this._toRowId(segmentRef));
31353
31449
  };
31450
+ /** Sort all of existing segments by multiple sort logics
31451
+ * @public
31452
+ * @param {Array.<Function>} sortLogics
31453
+ * @param {Array.<number>} sortOrders
31454
+ * @param {Array.<string>} cids
31455
+ */
31456
+ DataView.prototype.sortSeparators = function (sortLogics, sortOrders, cids) {
31457
+ this._dt.sortSeparators(sortLogics, sortOrders, cids);
31458
+ };
31354
31459
  /** Sort all of existing segments by given compare function
31355
31460
  * @public
31356
31461
  * @param {Function} compare
@@ -35906,7 +36011,7 @@ Core.prototype._batches = null;
35906
36011
  * @return {string}
35907
36012
  */
35908
36013
  Core.getVersion = function () {
35909
- return "5.1.63";
36014
+ return "5.1.67";
35910
36015
  };
35911
36016
  /** {@link ElementWrapper#dispose}
35912
36017
  * @override
@@ -43415,6 +43520,28 @@ SortableTitlePlugin.prototype.setSortingSequence = function (sequence, colRef) {
43415
43520
  SortableTitlePlugin.prototype.clearAllColumnSortingSequences = function () {
43416
43521
  this._sortingSequenceMap = null;
43417
43522
  };
43523
+ /** @public
43524
+ * @description Sorting all separators according to compare function. If compare function is not specified, separators will will be sort by current sorting states.
43525
+ * @param {Function} comparer Compare function
43526
+ */
43527
+ SortableTitlePlugin.prototype.sortSeparators = function (comparer) {
43528
+ var host = this._hosts[0];
43529
+ var dv = host.getDataSource();
43530
+ if(comparer){
43531
+ dv.sortSeparators(comparer);
43532
+ } else {
43533
+ var sortLogics = dv.getSortingLogics();
43534
+ var sortOrders = [];
43535
+ var sortFields = [];
43536
+ var sortStateCount = this._sortStates.length;
43537
+ for(var i = 0; i < sortStateCount; i++){
43538
+ var sortState = this._sortStates[i];
43539
+ sortOrders.push(sortState["sortOrder"]);
43540
+ sortFields.push(sortState["field"]);
43541
+ }
43542
+ dv.sortSeparators(sortLogics, sortOrders, sortFields);
43543
+ }
43544
+ };
43418
43545
 
43419
43546
 
43420
43547
  /** @private
@@ -43895,6 +44022,12 @@ SortableTitlePlugin.prototype._isCellSortable = function (section, colIndex, row
43895
44022
  if (targetCell !== bottomCell) {
43896
44023
  return false;
43897
44024
  }
44025
+ var parentCell = targetCell.getParent();
44026
+ var classList = parentCell["classList"];
44027
+ // "collapsed" class in column element only enable by column stack in spreading mode
44028
+ if (classList.contains("collapsed")) { // HACK: unsortable for collapsed stack in spreading mode
44029
+ return false;
44030
+ }
43898
44031
 
43899
44032
  return true; // By default all cells are sortable
43900
44033
  };
@@ -44059,6 +44192,12 @@ SortableTitlePlugin._proto = SortableTitlePlugin.prototype;
44059
44192
  * @property {Grid} grid
44060
44193
  * @property {RowDefinition} rowDef
44061
44194
  */
44195
+
44196
+ /** @event Grid#beforeContentBinding
44197
+ * @property {Object} e Event of beforeContentBinding, We can use e.actualUpdate to check the actual data update, otherwise It will be empty when it is rendered by row virtualization or only the UI changes.
44198
+ * @description Trigger before content binding.
44199
+ */
44200
+
44062
44201
  /** @event Grid#beforeRowRemoved
44063
44202
  * @description Fired only when a row will be removed through Grid's API and before occurring of the actual removal
44064
44203
  */
@@ -44209,6 +44348,7 @@ var Grid = function(placeholder, config) {
44209
44348
  t.updateColumnTitle = t.updateColumnTitle.bind(t);
44210
44349
  t._populateTimeSeriesChildren = t._populateTimeSeriesChildren.bind(t);
44211
44350
 
44351
+ t._onBeforeContentBinding = t._onBeforeContentBinding.bind(t);
44212
44352
  t._onPostSectionDataBinding = t._onPostSectionDataBinding.bind(t);
44213
44353
  t._asyncClearDataUpdates = t._asyncClearDataUpdates.bind(t);
44214
44354
  t._clearDataUpdates = t._clearDataUpdates.bind(t);
@@ -44301,6 +44441,7 @@ var Grid = function(placeholder, config) {
44301
44441
  t._grid.loadPlugin(t._stp, config);
44302
44442
  }
44303
44443
 
44444
+ t._grid.listen("beforeContentBinding", t._onBeforeContentBinding);
44304
44445
  t._grid.listen("preSectionRender", t._onColumnHeaderBinding);
44305
44446
  t._grid.listen("postSectionDataBinding", t._onPostSectionDataBinding);
44306
44447
 
@@ -47420,6 +47561,13 @@ Grid.prototype._mainSorter = function (rowDefA, rowDefB, order) {
47420
47561
  return this._columnSorter(rowDefA, rowDefB, order);
47421
47562
  };
47422
47563
 
47564
+ /** @private
47565
+ * @param {Object} e
47566
+ */
47567
+ Grid.prototype._onBeforeContentBinding = function(e) {
47568
+ this._dispatch("beforeContentBinding", e);
47569
+ };
47570
+
47423
47571
  /** @private
47424
47572
  * @param {Object} e
47425
47573
  */
@@ -49517,6 +49665,46 @@ var _joinSubKeys = function(subA, subB) {
49517
49665
  return subA.ric + "_" + subB.ric;
49518
49666
  };
49519
49667
 
49668
+ /** @private
49669
+ * @param {string} ric
49670
+ * @return {boolean}
49671
+ */
49672
+ var _isDynamicChain = function(ric) {
49673
+ // Dynamic chain will be 2 . (dot) for example .PG.PA
49674
+ return ric.match(/\./g).length > 1;
49675
+ };
49676
+
49677
+ /** @private
49678
+ * @param {Array<Object>} arr sub children
49679
+ * @return {Array<Object>}
49680
+ */
49681
+ var _shuffleArray = function(arr) {
49682
+ var arrayShuffled = arr; // Modify original array
49683
+ var i, randNumber, tmp;
49684
+ // Shuffle the array randomly using the Fisher-Yates algorithm
49685
+ for (i = arrayShuffled.length - 1; i > 0; i--) {
49686
+ randNumber = Math.floor(Math.random() * (i + 1)); // TODO: it can be use this._dataGen.randInt(min, max) range
49687
+ tmp = arrayShuffled[i];
49688
+ arrayShuffled[i] = arrayShuffled[randNumber];
49689
+ arrayShuffled[randNumber] = tmp;
49690
+ }
49691
+
49692
+ // TODO: merge into 1 loop
49693
+ // Update the CHILD_ORDER property based on the new index
49694
+ arrayShuffled.forEach(_assignChildOrder);
49695
+ arrayShuffled = arrayShuffled.sort(_childOrderSort);
49696
+
49697
+ return arrayShuffled;
49698
+ };
49699
+
49700
+ var _assignChildOrder = function(obj, index) {
49701
+ obj["CHILD_ORDER"] = index;
49702
+ };
49703
+
49704
+ var _childOrderSort = function(a, b) {
49705
+ return a["CHILD_ORDER"] - b["CHILD_ORDER"];
49706
+ };
49707
+
49520
49708
  /** @constructor */
49521
49709
  var MockQuotes2 = function() {
49522
49710
 
@@ -49949,7 +50137,7 @@ MockSubscriptions.prototype._addSymbol = function(ric, asChain, subId) {
49949
50137
  childSub["dataId"] = subId + childSub["ric"];
49950
50138
  childSub["parent"] = sub; // This does not exist in real subscription
49951
50139
  sub["children"].push(childSub);
49952
-
50140
+ childSub["CHILD_ORDER"] = i;
49953
50141
  this._dataMap.addItem(_joinSubKeys(sub, childSub), childSub);
49954
50142
  }
49955
50143
  } else {
@@ -49996,7 +50184,7 @@ MockSubscriptions.simpleDigest = function(str) {
49996
50184
  MockSubscriptions.prototype._connect = function() {
49997
50185
  if(this._working && !this._timerId) {
49998
50186
  var delay = this._dataGen.randInt(this._minInterval, this._maxInterval);
49999
- this._timerId = window.setTimeout(this._onSubscriptionResponse, delay);
50187
+ this._timerId = window.setTimeout(this._onSubscriptionResponse, delay); // This will be async for fire event to user
50000
50188
  }
50001
50189
  };
50002
50190
 
@@ -50005,7 +50193,7 @@ MockSubscriptions.prototype._onSubscriptionResponse = function() {
50005
50193
  this._timerId = 0;
50006
50194
 
50007
50195
  var keys = this._dataMap.getAllKeys(); // list of all rics
50008
- var len = keys ? keys.length : 0;
50196
+ var len = keys ? keys.length : 0; // len include all row index (Constituent and normal ric)
50009
50197
  if(!len) { // No symbol has been added
50010
50198
  this._connect();
50011
50199
  return;
@@ -50023,16 +50211,63 @@ MockSubscriptions.prototype._onSubscriptionResponse = function() {
50023
50211
  var subs = this._dataMap.getItems(key); // Get all subs with the same RIC
50024
50212
 
50025
50213
  var sub = subs[0]; // Only the first sub is need to generate data
50026
- var values = this._generateQuoteData(sub, fields);
50214
+ var subParent = sub.parent;
50215
+ var updatePosition = this._dataGen.randBoolean(); // Flag for change CHILD_ORDER position
50216
+
50217
+ var values, j, jLen;
50218
+ if(_isDynamicChain(key) && subParent && updatePosition) { // subParent in header of dynamic chain is behavior like a normal ric
50219
+ // TODO: support rate of ordering is changed
50220
+ var children = subParent.children;
50221
+
50222
+ children = _shuffleArray(children);
50223
+ var childrenLen = children.length;
50224
+ var subIndex = children.indexOf(sub);
50225
+ sub["CHILD_ORDER"] = subIndex;
50226
+
50227
+ values = this._generateQuoteData(sub, fields);
50228
+
50229
+ jLen = subs.length;
50230
+ for(j = 0; j < jLen; ++j) { // It could be same ric and it need to dispatch with same ric number
50231
+ for (var k = 0; k < childrenLen; k++) {
50232
+ var child = children[k];
50233
+ if(subs[j] === child) {
50234
+ values["CHILD_ORDER"] = child["CHILD_ORDER"];
50235
+ this._dispatchDataChanged(subs[j], values);
50236
+ } else {
50237
+ var currentChild = child["CHILD_ORDER"];
50238
+ this._dispatchDataChanged(child, {
50239
+ X_RIC_NAME: child.ric,
50240
+ CHILD_ORDER: currentChild
50241
+ });
50242
+ }
50243
+ }
50244
+ this._dispatchPostUpdate({ childOrderChange: true });
50245
+ }
50027
50246
 
50028
- var jLen = subs.length;
50029
- for(var j = 0; j < jLen; ++j) {
50030
- this._dispatchDataChanged(subs[j], values);
50247
+ } else {
50248
+ values = this._generateQuoteData(sub, fields);
50249
+ jLen = subs.length;
50250
+ for(j = 0; j < jLen; ++j) { // It could be same ric and it need to dispatch with same ric number
50251
+ var childOrder = subs[j]["CHILD_ORDER"];
50252
+ if(childOrder != null) { // Children of chain will have a CHILD_ORDER
50253
+ values["CHILD_ORDER"] = childOrder;
50254
+ }
50255
+ this._dispatchDataChanged(subs[j], values);
50256
+ }
50031
50257
  }
50032
50258
  }
50033
50259
 
50034
50260
  this._connect();
50035
50261
  };
50262
+
50263
+ /** @private
50264
+ * @param {Object} obj
50265
+ */
50266
+ MockSubscriptions.prototype._dispatchPostUpdate = function (obj) {
50267
+ // TODO: handlded another property of "postUpdate" event
50268
+ this._dispatch("postUpdate", obj);
50269
+ };
50270
+
50036
50271
  /** @private
50037
50272
  * @param {Object} sub
50038
50273
  * @param {Object} fields
@@ -50112,6 +50347,7 @@ MockSubscriptions.prototype._updateDuplicateSymbol = function(ric) {
50112
50347
  for(i = 1; i < subCount; ++i) {
50113
50348
  var sub = subs[i];
50114
50349
  if(!sub["prevData"]) {
50350
+ // TODO: check in duplicate dynamic chain
50115
50351
  this._dispatchDataChanged(sub, prevData);
50116
50352
  }
50117
50353
  }
@@ -50137,6 +50373,7 @@ MockSubscriptions.prototype._updateDuplicateSymbol = function(ric) {
50137
50373
  var childSub2 = this._getChildSubByRic(sub2, childRic);
50138
50374
  if(childSub && childSub2) {
50139
50375
  if(childSub["prevData"]) {
50376
+ // TODO: check in duplicate dynamic chain
50140
50377
  this._dispatchDataChanged(childSub2, childSub["prevData"]);
50141
50378
  }
50142
50379
  }
@@ -50318,15 +50555,12 @@ MockArchive.prototype.filter = function(func) {
50318
50555
 
50319
50556
 
50320
50557
 
50321
- // CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/jet/mockDataAPI.js
50322
-
50323
-
50324
-
50558
+ // CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/jet/MockUtil.js
50325
50559
  /**
50326
- * @private
50327
- * @type {object}
50560
+ * @public
50561
+ * @type {Object}
50328
50562
  */
50329
- var _invalidFieldDict = {
50563
+ var invalidFieldDict = {
50330
50564
  'TR.NonExistField': true,
50331
50565
  'TR.NotExistField': true,
50332
50566
  'CF_IGNORE_FIELD': true
@@ -50338,104 +50572,27 @@ var _invalidFieldDict = {
50338
50572
  */
50339
50573
  function setInvalidFields(fields) {
50340
50574
  if (fields && typeof fields === 'string') {
50341
- _invalidFieldDict[fields] = true;
50575
+ invalidFieldDict[fields] = true;
50342
50576
  } else if (Array.isArray(fields)) {
50343
50577
  for (var i = 0; i < fields.length; i++) {
50344
- _invalidFieldDict[fields[i]] = true;
50578
+ invalidFieldDict[fields[i]] = true;
50345
50579
  }
50346
50580
  }
50347
50581
  }
50348
50582
 
50349
50583
 
50350
- var dataGen = new DataGenerator();
50351
-
50352
- /** @private
50353
- * @namespace
50354
- */
50355
- var DataGrid = {};
50356
-
50357
- /** @private
50358
- * @namespace
50359
- */
50360
- var Adc = {};
50361
-
50362
- /** @private
50363
- * @function
50364
- * @param {Object} payload
50365
- * @param {Object=} mockResponse
50366
- * @return {Promise}
50367
- */
50368
- DataGrid.request = function (payload, mockResponse) {
50369
- if (mockResponse) {
50370
- return Promise.resolve(JSON.stringify(mockResponse));
50371
- }
50372
-
50373
- var i, f, len, row;
50374
- var instruments = payload.instruments;
50375
- var fields = payload.fields;
50376
50584
 
50377
- // _invalidFieldDict is a dictionary of non exist field
50378
- // so we must remove invalid field to make "mocking api" return result more like a "real api".
50379
- var invalidDict = _invalidFieldDict;
50380
- fields = [];
50381
- for (i = 0; i < payload.fields.length; i++) {
50382
- f = payload.fields[i];
50383
- if (!invalidDict[f.name]) {
50384
- fields.push(f);
50385
- }
50386
- }
50585
+ // CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/jet/Adc.js
50387
50586
 
50388
- // for filter duplicate instrument
50389
- var rowMap = {};
50390
50587
 
50391
- // build data
50392
- len = instruments.length;
50393
- var data2D = [];
50394
- var rowData = dataGen.generate(fields, len);
50395
- for (i = 0; i < len; ++i) {
50396
- var inst = instruments[i];
50397
- row = rowMap[inst];
50398
- if (!row) {
50399
- row = rowMap[inst] = rowData[i];
50400
- row.unshift(inst); // prepend instrument on each row
50401
- }
50402
- data2D.push(row);
50403
- }
50404
50588
 
50405
- // There is a chance that rtk will return multiple row data per instrument
50406
- // so we must create mock up for this case
50407
- if (data2D.length > 0) {
50408
- var chance = dataGen.randInt(1, 10);
50409
- if (chance <= 3) { // chance 30%
50410
- var pos = dataGen.randInt(0, data2D.length - 1); // random row pos
50411
- row = data2D[pos];
50412
- len = row.length;
50413
- var mockupRow = new Array(len);
50414
- mockupRow[0] = row[0]; // 1st index is for instrument
50415
- for (i = 1; i < len; i++) {
50416
- mockupRow[i] = ''; // real case will return null or empty string
50417
- }
50418
- data2D.splice(pos + 1, 0, mockupRow);
50419
- }
50420
- }
50421
50589
 
50422
- // build header
50423
- var headers = [{
50424
- "displayName": "Instrument"
50425
- }];
50426
- for (i = 0; i < fields.length; i++) {
50427
- f = fields[i];
50428
- headers.push({
50429
- "displayName": f.name,
50430
- "field": f.name.toUpperCase() // server only return in uppercase
50431
- });
50432
- }
50590
+ var dataGen = new DataGenerator();
50433
50591
 
50434
- return Promise.resolve(JSON.stringify({
50435
- data: data2D,
50436
- headers: [headers]
50437
- }));
50438
- };
50592
+ /** @private
50593
+ * @namespace
50594
+ */
50595
+ var Adc = {};
50439
50596
 
50440
50597
  /** @private
50441
50598
  * @function
@@ -50458,9 +50615,9 @@ Adc.request = function (payload, mockResponse) {
50458
50615
  formula = payload.formula.trim().split(/(?=,TR.)/);// TODO: check each field with another way, this doesn't work when user use some comma (,) formula
50459
50616
  fields = [];
50460
50617
 
50461
- // _invalidFieldDict is a dictionary of non exist field
50618
+ // invalidFieldDict is a dictionary of non exist field
50462
50619
  // so we must remove invalid field to make "mocking api" return result more like a "real api".
50463
- invalidDict = _invalidFieldDict;
50620
+ invalidDict = invalidFieldDict;
50464
50621
  for (i = 0; i < formula.length; i++) {
50465
50622
  f = formula[i];
50466
50623
  if (!invalidDict[f]) {
@@ -50590,9 +50747,9 @@ Adc.request = function (payload, mockResponse) {
50590
50747
  formula = Adc.splitFields(payload.formula);
50591
50748
  fields = [];
50592
50749
 
50593
- // _invalidFieldDict is a dictionary of non exist field
50750
+ // invalidFieldDict is a dictionary of non exist field
50594
50751
  // so we must remove invalid field to make "mocking api" return result more like a "real api".
50595
- invalidDict = _invalidFieldDict;
50752
+ invalidDict = invalidFieldDict;
50596
50753
  for (i = 0; i < formula.length; i++) {
50597
50754
  f = formula[i];
50598
50755
  if (!invalidDict[f]) {
@@ -50693,6 +50850,98 @@ Adc.splitFields = function(strFields) {
50693
50850
  return fields;
50694
50851
  };
50695
50852
 
50853
+
50854
+
50855
+ // CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/jet/mockDataAPI.js
50856
+
50857
+
50858
+
50859
+
50860
+ var mockDataAPI_dataGen = new DataGenerator();
50861
+
50862
+ /** @private
50863
+ * @namespace
50864
+ */
50865
+ var DataGrid = {};
50866
+
50867
+ /** @private
50868
+ * @function
50869
+ * @param {Object} payload
50870
+ * @param {Object=} mockResponse
50871
+ * @return {Promise}
50872
+ */
50873
+ DataGrid.request = function (payload, mockResponse) {
50874
+ if (mockResponse) {
50875
+ return Promise.resolve(JSON.stringify(mockResponse));
50876
+ }
50877
+
50878
+ var i, f, len, row;
50879
+ var instruments = payload.instruments;
50880
+ var fields = payload.fields;
50881
+
50882
+ // _invalidFieldDict is a dictionary of non exist field
50883
+ // so we must remove invalid field to make "mocking api" return result more like a "real api".
50884
+ var invalidDict = invalidFieldDict;
50885
+ fields = [];
50886
+ for (i = 0; i < payload.fields.length; i++) {
50887
+ f = payload.fields[i];
50888
+ if (!invalidDict[f.name]) {
50889
+ fields.push(f);
50890
+ }
50891
+ }
50892
+
50893
+ // for filter duplicate instrument
50894
+ var rowMap = {};
50895
+
50896
+ // build data
50897
+ len = instruments.length;
50898
+ var data2D = [];
50899
+ var rowData = mockDataAPI_dataGen.generate(fields, len);
50900
+ for (i = 0; i < len; ++i) {
50901
+ var inst = instruments[i];
50902
+ row = rowMap[inst];
50903
+ if (!row) {
50904
+ row = rowMap[inst] = rowData[i];
50905
+ row.unshift(inst); // prepend instrument on each row
50906
+ }
50907
+ data2D.push(row);
50908
+ }
50909
+
50910
+ // There is a chance that rtk will return multiple row data per instrument
50911
+ // so we must create mock up for this case
50912
+ if (data2D.length > 0) {
50913
+ var chance = mockDataAPI_dataGen.randInt(1, 10);
50914
+ if (chance <= 3) { // chance 30%
50915
+ var pos = mockDataAPI_dataGen.randInt(0, data2D.length - 1); // random row pos
50916
+ row = data2D[pos];
50917
+ len = row.length;
50918
+ var mockupRow = new Array(len);
50919
+ mockupRow[0] = row[0]; // 1st index is for instrument
50920
+ for (i = 1; i < len; i++) {
50921
+ mockupRow[i] = ''; // real case will return null or empty string
50922
+ }
50923
+ data2D.splice(pos + 1, 0, mockupRow);
50924
+ }
50925
+ }
50926
+
50927
+ // build header
50928
+ var headers = [{
50929
+ "displayName": "Instrument"
50930
+ }];
50931
+ for (i = 0; i < fields.length; i++) {
50932
+ f = fields[i];
50933
+ headers.push({
50934
+ "displayName": f.name,
50935
+ "field": f.name.toUpperCase() // server only return in uppercase
50936
+ });
50937
+ }
50938
+
50939
+ return Promise.resolve(JSON.stringify({
50940
+ data: data2D,
50941
+ headers: [headers]
50942
+ }));
50943
+ };
50944
+
50696
50945
  /** @public
50697
50946
  * @function
50698
50947
  * @param {string} dataType