@refinitiv-ui/efx-grid 6.0.49 → 6.0.51
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.
- package/lib/core/dist/core.js +192 -95
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataTable.d.ts +1 -1
- package/lib/core/es6/data/DataTable.js +3 -3
- package/lib/core/es6/data/DataView.d.ts +3 -1
- package/lib/core/es6/data/DataView.js +177 -85
- package/lib/core/es6/data/Segment.d.ts +2 -0
- package/lib/core/es6/data/Segment.js +6 -0
- package/lib/core/es6/grid/Core.js +2 -5
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +4 -2
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +355 -107
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.js +1 -2
- package/lib/rt-grid/es6/Grid.js +15 -0
- package/lib/tr-grid-printer/es6/GridPrinter.js +5 -5
- package/lib/tr-grid-util/es6/CoralItems.js +2 -2
- package/lib/tr-grid-util/es6/ElfDate.js +1 -1
- package/lib/tr-grid-util/es6/ElfUtil.js +2 -2
- package/lib/tr-grid-util/es6/ExpanderIcon.js +1 -1
- package/lib/tr-grid-util/es6/GridPlugin.js +1 -1
- package/lib/tr-grid-util/es6/Icon.js +3 -3
- package/lib/tr-grid-util/es6/MultiTableManager.js +3 -3
- package/lib/tr-grid-util/es6/jet/MockQuotes2.js +5 -1
- package/lib/types/es6/Core/data/DataTable.d.ts +1 -1
- package/lib/types/es6/Core/data/DataView.d.ts +3 -1
- package/lib/types/es6/Core/data/Segment.d.ts +2 -0
- package/lib/versions.json +2 -0
- package/package.json +1 -1
@@ -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
|
@@ -16020,8 +16116,7 @@ ColumnDefinition.prototype._retrieveNestedFields = function(fields) {
|
|
16020
16116
|
*/
|
16021
16117
|
ColumnDefinition.prototype._defaultRenderer = function(e) {
|
16022
16118
|
var rowDef = /** @type{RowDefinition} */(e["dataValue"]);
|
16023
|
-
|
16024
|
-
e["cell"].setContent(data);
|
16119
|
+
e["cell"].setContent(rowDef ? rowDef.getData(this._field) : null);
|
16025
16120
|
};
|
16026
16121
|
/** @private
|
16027
16122
|
* @param {Object} e
|
@@ -31351,6 +31446,15 @@ DataView.prototype.getSegmentIds = function() {
|
|
31351
31446
|
DataView.prototype.getSegmentChildIds = function(segmentRef) {
|
31352
31447
|
return this._dt.getSegmentChildIds(this._toRowId(segmentRef));
|
31353
31448
|
};
|
31449
|
+
/** Sort all of existing segments by multiple sort logics
|
31450
|
+
* @public
|
31451
|
+
* @param {Array.<Function>} sortLogics
|
31452
|
+
* @param {Array.<number>} sortOrders
|
31453
|
+
* @param {Array.<string>} cids
|
31454
|
+
*/
|
31455
|
+
DataView.prototype.sortSeparators = function (sortLogics, sortOrders, cids) {
|
31456
|
+
this._dt.sortSeparators(sortLogics, sortOrders, cids);
|
31457
|
+
};
|
31354
31458
|
/** Sort all of existing segments by given compare function
|
31355
31459
|
* @public
|
31356
31460
|
* @param {Function} compare
|
@@ -35906,7 +36010,7 @@ Core.prototype._batches = null;
|
|
35906
36010
|
* @return {string}
|
35907
36011
|
*/
|
35908
36012
|
Core.getVersion = function () {
|
35909
|
-
return "5.1.
|
36013
|
+
return "5.1.67";
|
35910
36014
|
};
|
35911
36015
|
/** {@link ElementWrapper#dispose}
|
35912
36016
|
* @override
|
@@ -43415,6 +43519,28 @@ SortableTitlePlugin.prototype.setSortingSequence = function (sequence, colRef) {
|
|
43415
43519
|
SortableTitlePlugin.prototype.clearAllColumnSortingSequences = function () {
|
43416
43520
|
this._sortingSequenceMap = null;
|
43417
43521
|
};
|
43522
|
+
/** @public
|
43523
|
+
* @description Sorting all separators according to compare function. If compare function is not specified, separators will will be sort by current sorting states.
|
43524
|
+
* @param {Function} comparer Compare function
|
43525
|
+
*/
|
43526
|
+
SortableTitlePlugin.prototype.sortSeparators = function (comparer) {
|
43527
|
+
var host = this._hosts[0];
|
43528
|
+
var dv = host.getDataSource();
|
43529
|
+
if(comparer){
|
43530
|
+
dv.sortSeparators(comparer);
|
43531
|
+
} else {
|
43532
|
+
var sortLogics = dv.getSortingLogics();
|
43533
|
+
var sortOrders = [];
|
43534
|
+
var sortFields = [];
|
43535
|
+
var sortStateCount = this._sortStates.length;
|
43536
|
+
for(var i = 0; i < sortStateCount; i++){
|
43537
|
+
var sortState = this._sortStates[i];
|
43538
|
+
sortOrders.push(sortState["sortOrder"]);
|
43539
|
+
sortFields.push(sortState["field"]);
|
43540
|
+
}
|
43541
|
+
dv.sortSeparators(sortLogics, sortOrders, sortFields);
|
43542
|
+
}
|
43543
|
+
};
|
43418
43544
|
|
43419
43545
|
|
43420
43546
|
/** @private
|
@@ -43895,6 +44021,12 @@ SortableTitlePlugin.prototype._isCellSortable = function (section, colIndex, row
|
|
43895
44021
|
if (targetCell !== bottomCell) {
|
43896
44022
|
return false;
|
43897
44023
|
}
|
44024
|
+
var parentCell = targetCell.getParent();
|
44025
|
+
var classList = parentCell["classList"];
|
44026
|
+
// "collapsed" class in column element only enable by column stack in spreading mode
|
44027
|
+
if (classList.contains("collapsed")) { // HACK: unsortable for collapsed stack in spreading mode
|
44028
|
+
return false;
|
44029
|
+
}
|
43898
44030
|
|
43899
44031
|
return true; // By default all cells are sortable
|
43900
44032
|
};
|
@@ -44059,6 +44191,12 @@ SortableTitlePlugin._proto = SortableTitlePlugin.prototype;
|
|
44059
44191
|
* @property {Grid} grid
|
44060
44192
|
* @property {RowDefinition} rowDef
|
44061
44193
|
*/
|
44194
|
+
|
44195
|
+
/** @event Grid#beforeContentBinding
|
44196
|
+
* @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.
|
44197
|
+
* @description Trigger before content binding.
|
44198
|
+
*/
|
44199
|
+
|
44062
44200
|
/** @event Grid#beforeRowRemoved
|
44063
44201
|
* @description Fired only when a row will be removed through Grid's API and before occurring of the actual removal
|
44064
44202
|
*/
|
@@ -44209,6 +44347,7 @@ var Grid = function(placeholder, config) {
|
|
44209
44347
|
t.updateColumnTitle = t.updateColumnTitle.bind(t);
|
44210
44348
|
t._populateTimeSeriesChildren = t._populateTimeSeriesChildren.bind(t);
|
44211
44349
|
|
44350
|
+
t._onBeforeContentBinding = t._onBeforeContentBinding.bind(t);
|
44212
44351
|
t._onPostSectionDataBinding = t._onPostSectionDataBinding.bind(t);
|
44213
44352
|
t._asyncClearDataUpdates = t._asyncClearDataUpdates.bind(t);
|
44214
44353
|
t._clearDataUpdates = t._clearDataUpdates.bind(t);
|
@@ -44301,6 +44440,7 @@ var Grid = function(placeholder, config) {
|
|
44301
44440
|
t._grid.loadPlugin(t._stp, config);
|
44302
44441
|
}
|
44303
44442
|
|
44443
|
+
t._grid.listen("beforeContentBinding", t._onBeforeContentBinding);
|
44304
44444
|
t._grid.listen("preSectionRender", t._onColumnHeaderBinding);
|
44305
44445
|
t._grid.listen("postSectionDataBinding", t._onPostSectionDataBinding);
|
44306
44446
|
|
@@ -47420,6 +47560,13 @@ Grid.prototype._mainSorter = function (rowDefA, rowDefB, order) {
|
|
47420
47560
|
return this._columnSorter(rowDefA, rowDefB, order);
|
47421
47561
|
};
|
47422
47562
|
|
47563
|
+
/** @private
|
47564
|
+
* @param {Object} e
|
47565
|
+
*/
|
47566
|
+
Grid.prototype._onBeforeContentBinding = function(e) {
|
47567
|
+
this._dispatch("beforeContentBinding", e);
|
47568
|
+
};
|
47569
|
+
|
47423
47570
|
/** @private
|
47424
47571
|
* @param {Object} e
|
47425
47572
|
*/
|
@@ -49517,6 +49664,46 @@ var _joinSubKeys = function(subA, subB) {
|
|
49517
49664
|
return subA.ric + "_" + subB.ric;
|
49518
49665
|
};
|
49519
49666
|
|
49667
|
+
/** @private
|
49668
|
+
* @param {string} ric
|
49669
|
+
* @return {boolean}
|
49670
|
+
*/
|
49671
|
+
var _isDynamicChain = function(ric) {
|
49672
|
+
// Dynamic chain will be 2 . (dot) for example .PG.PA
|
49673
|
+
return ric.match(/\./g).length > 1;
|
49674
|
+
};
|
49675
|
+
|
49676
|
+
/** @private
|
49677
|
+
* @param {Array<Object>} arr sub children
|
49678
|
+
* @return {Array<Object>}
|
49679
|
+
*/
|
49680
|
+
var _shuffleArray = function(arr) {
|
49681
|
+
var arrayShuffled = arr; // Modify original array
|
49682
|
+
var i, randNumber, tmp;
|
49683
|
+
// Shuffle the array randomly using the Fisher-Yates algorithm
|
49684
|
+
for (i = arrayShuffled.length - 1; i > 0; i--) {
|
49685
|
+
randNumber = Math.floor(Math.random() * (i + 1)); // TODO: it can be use this._dataGen.randInt(min, max) range
|
49686
|
+
tmp = arrayShuffled[i];
|
49687
|
+
arrayShuffled[i] = arrayShuffled[randNumber];
|
49688
|
+
arrayShuffled[randNumber] = tmp;
|
49689
|
+
}
|
49690
|
+
|
49691
|
+
// TODO: merge into 1 loop
|
49692
|
+
// Update the CHILD_ORDER property based on the new index
|
49693
|
+
arrayShuffled.forEach(_assignChildOrder);
|
49694
|
+
arrayShuffled = arrayShuffled.sort(_childOrderSort);
|
49695
|
+
|
49696
|
+
return arrayShuffled;
|
49697
|
+
};
|
49698
|
+
|
49699
|
+
var _assignChildOrder = function(obj, index) {
|
49700
|
+
obj["CHILD_ORDER"] = index;
|
49701
|
+
};
|
49702
|
+
|
49703
|
+
var _childOrderSort = function(a, b) {
|
49704
|
+
return a["CHILD_ORDER"] - b["CHILD_ORDER"];
|
49705
|
+
};
|
49706
|
+
|
49520
49707
|
/** @constructor */
|
49521
49708
|
var MockQuotes2 = function() {
|
49522
49709
|
|
@@ -49949,7 +50136,7 @@ MockSubscriptions.prototype._addSymbol = function(ric, asChain, subId) {
|
|
49949
50136
|
childSub["dataId"] = subId + childSub["ric"];
|
49950
50137
|
childSub["parent"] = sub; // This does not exist in real subscription
|
49951
50138
|
sub["children"].push(childSub);
|
49952
|
-
|
50139
|
+
childSub["CHILD_ORDER"] = i;
|
49953
50140
|
this._dataMap.addItem(_joinSubKeys(sub, childSub), childSub);
|
49954
50141
|
}
|
49955
50142
|
} else {
|
@@ -49996,7 +50183,7 @@ MockSubscriptions.simpleDigest = function(str) {
|
|
49996
50183
|
MockSubscriptions.prototype._connect = function() {
|
49997
50184
|
if(this._working && !this._timerId) {
|
49998
50185
|
var delay = this._dataGen.randInt(this._minInterval, this._maxInterval);
|
49999
|
-
this._timerId = window.setTimeout(this._onSubscriptionResponse, delay);
|
50186
|
+
this._timerId = window.setTimeout(this._onSubscriptionResponse, delay); // This will be async for fire event to user
|
50000
50187
|
}
|
50001
50188
|
};
|
50002
50189
|
|
@@ -50005,7 +50192,7 @@ MockSubscriptions.prototype._onSubscriptionResponse = function() {
|
|
50005
50192
|
this._timerId = 0;
|
50006
50193
|
|
50007
50194
|
var keys = this._dataMap.getAllKeys(); // list of all rics
|
50008
|
-
var len = keys ? keys.length : 0;
|
50195
|
+
var len = keys ? keys.length : 0; // len include all row index (Constituent and normal ric)
|
50009
50196
|
if(!len) { // No symbol has been added
|
50010
50197
|
this._connect();
|
50011
50198
|
return;
|
@@ -50023,16 +50210,63 @@ MockSubscriptions.prototype._onSubscriptionResponse = function() {
|
|
50023
50210
|
var subs = this._dataMap.getItems(key); // Get all subs with the same RIC
|
50024
50211
|
|
50025
50212
|
var sub = subs[0]; // Only the first sub is need to generate data
|
50026
|
-
var
|
50213
|
+
var subParent = sub.parent;
|
50214
|
+
var updatePosition = this._dataGen.randBoolean(); // Flag for change CHILD_ORDER position
|
50215
|
+
|
50216
|
+
var values, j, jLen;
|
50217
|
+
if(_isDynamicChain(key) && subParent && updatePosition) { // subParent in header of dynamic chain is behavior like a normal ric
|
50218
|
+
// TODO: support rate of ordering is changed
|
50219
|
+
var children = subParent.children;
|
50220
|
+
|
50221
|
+
children = _shuffleArray(children);
|
50222
|
+
var childrenLen = children.length;
|
50223
|
+
var subIndex = children.indexOf(sub);
|
50224
|
+
sub["CHILD_ORDER"] = subIndex;
|
50225
|
+
|
50226
|
+
values = this._generateQuoteData(sub, fields);
|
50227
|
+
|
50228
|
+
jLen = subs.length;
|
50229
|
+
for(j = 0; j < jLen; ++j) { // It could be same ric and it need to dispatch with same ric number
|
50230
|
+
for (var k = 0; k < childrenLen; k++) {
|
50231
|
+
var child = children[k];
|
50232
|
+
if(subs[j] === child) {
|
50233
|
+
values["CHILD_ORDER"] = child["CHILD_ORDER"];
|
50234
|
+
this._dispatchDataChanged(subs[j], values);
|
50235
|
+
} else {
|
50236
|
+
var currentChild = child["CHILD_ORDER"];
|
50237
|
+
this._dispatchDataChanged(child, {
|
50238
|
+
X_RIC_NAME: child.ric,
|
50239
|
+
CHILD_ORDER: currentChild
|
50240
|
+
});
|
50241
|
+
}
|
50242
|
+
}
|
50243
|
+
this._dispatchPostUpdate({ childOrderChange: true });
|
50244
|
+
}
|
50027
50245
|
|
50028
|
-
|
50029
|
-
|
50030
|
-
|
50246
|
+
} else {
|
50247
|
+
values = this._generateQuoteData(sub, fields);
|
50248
|
+
jLen = subs.length;
|
50249
|
+
for(j = 0; j < jLen; ++j) { // It could be same ric and it need to dispatch with same ric number
|
50250
|
+
var childOrder = subs[j]["CHILD_ORDER"];
|
50251
|
+
if(childOrder != null) { // Children of chain will have a CHILD_ORDER
|
50252
|
+
values["CHILD_ORDER"] = childOrder;
|
50253
|
+
}
|
50254
|
+
this._dispatchDataChanged(subs[j], values);
|
50255
|
+
}
|
50031
50256
|
}
|
50032
50257
|
}
|
50033
50258
|
|
50034
50259
|
this._connect();
|
50035
50260
|
};
|
50261
|
+
|
50262
|
+
/** @private
|
50263
|
+
* @param {Object} obj
|
50264
|
+
*/
|
50265
|
+
MockSubscriptions.prototype._dispatchPostUpdate = function (obj) {
|
50266
|
+
// TODO: handlded another property of "postUpdate" event
|
50267
|
+
this._dispatch("postUpdate", obj);
|
50268
|
+
};
|
50269
|
+
|
50036
50270
|
/** @private
|
50037
50271
|
* @param {Object} sub
|
50038
50272
|
* @param {Object} fields
|
@@ -50112,6 +50346,7 @@ MockSubscriptions.prototype._updateDuplicateSymbol = function(ric) {
|
|
50112
50346
|
for(i = 1; i < subCount; ++i) {
|
50113
50347
|
var sub = subs[i];
|
50114
50348
|
if(!sub["prevData"]) {
|
50349
|
+
// TODO: check in duplicate dynamic chain
|
50115
50350
|
this._dispatchDataChanged(sub, prevData);
|
50116
50351
|
}
|
50117
50352
|
}
|
@@ -50137,6 +50372,7 @@ MockSubscriptions.prototype._updateDuplicateSymbol = function(ric) {
|
|
50137
50372
|
var childSub2 = this._getChildSubByRic(sub2, childRic);
|
50138
50373
|
if(childSub && childSub2) {
|
50139
50374
|
if(childSub["prevData"]) {
|
50375
|
+
// TODO: check in duplicate dynamic chain
|
50140
50376
|
this._dispatchDataChanged(childSub2, childSub["prevData"]);
|
50141
50377
|
}
|
50142
50378
|
}
|
@@ -50318,15 +50554,12 @@ MockArchive.prototype.filter = function(func) {
|
|
50318
50554
|
|
50319
50555
|
|
50320
50556
|
|
50321
|
-
// CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/jet/
|
50322
|
-
|
50323
|
-
|
50324
|
-
|
50557
|
+
// CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/jet/MockUtil.js
|
50325
50558
|
/**
|
50326
|
-
* @
|
50327
|
-
* @type {
|
50559
|
+
* @public
|
50560
|
+
* @type {Object}
|
50328
50561
|
*/
|
50329
|
-
var
|
50562
|
+
var invalidFieldDict = {
|
50330
50563
|
'TR.NonExistField': true,
|
50331
50564
|
'TR.NotExistField': true,
|
50332
50565
|
'CF_IGNORE_FIELD': true
|
@@ -50338,104 +50571,27 @@ var _invalidFieldDict = {
|
|
50338
50571
|
*/
|
50339
50572
|
function setInvalidFields(fields) {
|
50340
50573
|
if (fields && typeof fields === 'string') {
|
50341
|
-
|
50574
|
+
invalidFieldDict[fields] = true;
|
50342
50575
|
} else if (Array.isArray(fields)) {
|
50343
50576
|
for (var i = 0; i < fields.length; i++) {
|
50344
|
-
|
50577
|
+
invalidFieldDict[fields[i]] = true;
|
50345
50578
|
}
|
50346
50579
|
}
|
50347
50580
|
}
|
50348
50581
|
|
50349
50582
|
|
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
50583
|
|
50377
|
-
|
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
|
-
}
|
50584
|
+
// CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/jet/Adc.js
|
50387
50585
|
|
50388
|
-
// for filter duplicate instrument
|
50389
|
-
var rowMap = {};
|
50390
50586
|
|
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
50587
|
|
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
50588
|
|
50422
|
-
|
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
|
-
}
|
50589
|
+
var dataGen = new DataGenerator();
|
50433
50590
|
|
50434
|
-
|
50435
|
-
|
50436
|
-
|
50437
|
-
|
50438
|
-
};
|
50591
|
+
/** @private
|
50592
|
+
* @namespace
|
50593
|
+
*/
|
50594
|
+
var Adc = {};
|
50439
50595
|
|
50440
50596
|
/** @private
|
50441
50597
|
* @function
|
@@ -50458,9 +50614,9 @@ Adc.request = function (payload, mockResponse) {
|
|
50458
50614
|
formula = payload.formula.trim().split(/(?=,TR.)/);// TODO: check each field with another way, this doesn't work when user use some comma (,) formula
|
50459
50615
|
fields = [];
|
50460
50616
|
|
50461
|
-
//
|
50617
|
+
// invalidFieldDict is a dictionary of non exist field
|
50462
50618
|
// so we must remove invalid field to make "mocking api" return result more like a "real api".
|
50463
|
-
invalidDict =
|
50619
|
+
invalidDict = invalidFieldDict;
|
50464
50620
|
for (i = 0; i < formula.length; i++) {
|
50465
50621
|
f = formula[i];
|
50466
50622
|
if (!invalidDict[f]) {
|
@@ -50590,9 +50746,9 @@ Adc.request = function (payload, mockResponse) {
|
|
50590
50746
|
formula = Adc.splitFields(payload.formula);
|
50591
50747
|
fields = [];
|
50592
50748
|
|
50593
|
-
//
|
50749
|
+
// invalidFieldDict is a dictionary of non exist field
|
50594
50750
|
// so we must remove invalid field to make "mocking api" return result more like a "real api".
|
50595
|
-
invalidDict =
|
50751
|
+
invalidDict = invalidFieldDict;
|
50596
50752
|
for (i = 0; i < formula.length; i++) {
|
50597
50753
|
f = formula[i];
|
50598
50754
|
if (!invalidDict[f]) {
|
@@ -50693,6 +50849,98 @@ Adc.splitFields = function(strFields) {
|
|
50693
50849
|
return fields;
|
50694
50850
|
};
|
50695
50851
|
|
50852
|
+
|
50853
|
+
|
50854
|
+
// CONCATENATED MODULE: ./node_modules/tr-grid-util/es6/jet/mockDataAPI.js
|
50855
|
+
|
50856
|
+
|
50857
|
+
|
50858
|
+
|
50859
|
+
var mockDataAPI_dataGen = new DataGenerator();
|
50860
|
+
|
50861
|
+
/** @private
|
50862
|
+
* @namespace
|
50863
|
+
*/
|
50864
|
+
var DataGrid = {};
|
50865
|
+
|
50866
|
+
/** @private
|
50867
|
+
* @function
|
50868
|
+
* @param {Object} payload
|
50869
|
+
* @param {Object=} mockResponse
|
50870
|
+
* @return {Promise}
|
50871
|
+
*/
|
50872
|
+
DataGrid.request = function (payload, mockResponse) {
|
50873
|
+
if (mockResponse) {
|
50874
|
+
return Promise.resolve(JSON.stringify(mockResponse));
|
50875
|
+
}
|
50876
|
+
|
50877
|
+
var i, f, len, row;
|
50878
|
+
var instruments = payload.instruments;
|
50879
|
+
var fields = payload.fields;
|
50880
|
+
|
50881
|
+
// _invalidFieldDict is a dictionary of non exist field
|
50882
|
+
// so we must remove invalid field to make "mocking api" return result more like a "real api".
|
50883
|
+
var invalidDict = invalidFieldDict;
|
50884
|
+
fields = [];
|
50885
|
+
for (i = 0; i < payload.fields.length; i++) {
|
50886
|
+
f = payload.fields[i];
|
50887
|
+
if (!invalidDict[f.name]) {
|
50888
|
+
fields.push(f);
|
50889
|
+
}
|
50890
|
+
}
|
50891
|
+
|
50892
|
+
// for filter duplicate instrument
|
50893
|
+
var rowMap = {};
|
50894
|
+
|
50895
|
+
// build data
|
50896
|
+
len = instruments.length;
|
50897
|
+
var data2D = [];
|
50898
|
+
var rowData = mockDataAPI_dataGen.generate(fields, len);
|
50899
|
+
for (i = 0; i < len; ++i) {
|
50900
|
+
var inst = instruments[i];
|
50901
|
+
row = rowMap[inst];
|
50902
|
+
if (!row) {
|
50903
|
+
row = rowMap[inst] = rowData[i];
|
50904
|
+
row.unshift(inst); // prepend instrument on each row
|
50905
|
+
}
|
50906
|
+
data2D.push(row);
|
50907
|
+
}
|
50908
|
+
|
50909
|
+
// There is a chance that rtk will return multiple row data per instrument
|
50910
|
+
// so we must create mock up for this case
|
50911
|
+
if (data2D.length > 0) {
|
50912
|
+
var chance = mockDataAPI_dataGen.randInt(1, 10);
|
50913
|
+
if (chance <= 3) { // chance 30%
|
50914
|
+
var pos = mockDataAPI_dataGen.randInt(0, data2D.length - 1); // random row pos
|
50915
|
+
row = data2D[pos];
|
50916
|
+
len = row.length;
|
50917
|
+
var mockupRow = new Array(len);
|
50918
|
+
mockupRow[0] = row[0]; // 1st index is for instrument
|
50919
|
+
for (i = 1; i < len; i++) {
|
50920
|
+
mockupRow[i] = ''; // real case will return null or empty string
|
50921
|
+
}
|
50922
|
+
data2D.splice(pos + 1, 0, mockupRow);
|
50923
|
+
}
|
50924
|
+
}
|
50925
|
+
|
50926
|
+
// build header
|
50927
|
+
var headers = [{
|
50928
|
+
"displayName": "Instrument"
|
50929
|
+
}];
|
50930
|
+
for (i = 0; i < fields.length; i++) {
|
50931
|
+
f = fields[i];
|
50932
|
+
headers.push({
|
50933
|
+
"displayName": f.name,
|
50934
|
+
"field": f.name.toUpperCase() // server only return in uppercase
|
50935
|
+
});
|
50936
|
+
}
|
50937
|
+
|
50938
|
+
return Promise.resolve(JSON.stringify({
|
50939
|
+
data: data2D,
|
50940
|
+
headers: [headers]
|
50941
|
+
}));
|
50942
|
+
};
|
50943
|
+
|
50696
50944
|
/** @public
|
50697
50945
|
* @function
|
50698
50946
|
* @param {string} dataType
|