@refinitiv-ui/efx-grid 6.0.91 → 6.0.93
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/column-dragging/es6/ColumnDragging.d.ts +1 -1
- package/lib/column-dragging/es6/ColumnDragging.js +144 -34
- package/lib/core/dist/core.js +2410 -2621
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/ColumnStats.js +14 -14
- package/lib/core/es6/data/DataCache.js +118 -118
- package/lib/core/es6/data/DataTable.d.ts +3 -1
- package/lib/core/es6/data/DataTable.js +208 -190
- package/lib/core/es6/data/DataView.d.ts +1 -1
- package/lib/core/es6/data/DataView.js +291 -291
- package/lib/core/es6/data/Segment.js +79 -79
- package/lib/core/es6/data/SegmentCollection.js +81 -81
- package/lib/core/es6/data/WrappedView.js +41 -41
- package/lib/core/es6/grid/Core.js +635 -635
- package/lib/core/es6/grid/ILayoutGrid.js +1 -1
- package/lib/core/es6/grid/LayoutGrid.js +183 -183
- package/lib/core/es6/grid/VirtualizedLayoutGrid.js +91 -91
- package/lib/core/es6/grid/components/Cell.js +29 -29
- package/lib/core/es6/grid/components/CellFloatingPanel.js +11 -11
- package/lib/core/es6/grid/components/CellSpan.js +7 -7
- package/lib/core/es6/grid/components/CellSpans.js +36 -34
- package/lib/core/es6/grid/components/Column.js +40 -40
- package/lib/core/es6/grid/components/ElementWrapper.js +17 -17
- package/lib/core/es6/grid/components/HScrollbar.js +31 -31
- package/lib/core/es6/grid/components/Scrollbar.js +77 -77
- package/lib/core/es6/grid/components/StretchedCells.js +49 -49
- package/lib/core/es6/grid/components/VScrollbar.js +11 -11
- package/lib/core/es6/grid/components/VirtualItems.js +3 -3
- package/lib/core/es6/grid/event/EventDispatcher.js +9 -9
- package/lib/core/es6/grid/event/EventListeners.js +4 -4
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +186 -186
- package/lib/core/es6/grid/util/Conflator.js +4 -4
- package/lib/core/es6/grid/util/Reverter.js +1 -1
- package/lib/core/es6/grid/util/SectionSettings.js +20 -20
- package/lib/core/es6/grid/util/SelectionList.js +23 -23
- package/lib/core/es6/grid/util/TrackLayout.js +74 -74
- package/lib/core/es6/grid/util/Virtualizer.js +15 -15
- package/lib/core/es6/grid/util/util.js +20 -20
- package/lib/core/es6/index.d.ts +0 -2
- package/lib/core/es6/index.js +0 -3
- package/lib/filter-dialog/lib/filter-dialog.js +1 -0
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +193 -70
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.js +46 -30
- package/lib/rt-grid/es6/RowDefinition.d.ts +2 -1
- package/lib/rt-grid/es6/RowDefinition.js +74 -16
- package/lib/tr-grid-cell-selection/es6/CellSelection.js +56 -1
- package/lib/tr-grid-checkbox/es6/Checkbox.js +268 -268
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +3 -2
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +60 -32
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +279 -279
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +227 -207
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +11 -11
- package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +1 -2
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +120 -121
- package/lib/tr-grid-util/es6/CellPainter.js +94 -104
- package/lib/tr-grid-util/es6/Conflator.js +4 -4
- package/lib/tr-grid-util/es6/CoralItems.js +6 -6
- package/lib/tr-grid-util/es6/DateTime.js +41 -41
- package/lib/tr-grid-util/es6/Deferred.js +5 -5
- package/lib/tr-grid-util/es6/Delay.d.ts +3 -3
- package/lib/tr-grid-util/es6/Delay.js +14 -3
- package/lib/tr-grid-util/es6/Dom.js +26 -26
- package/lib/tr-grid-util/es6/DragUI.js +17 -17
- package/lib/tr-grid-util/es6/ElementObserver.js +12 -12
- package/lib/tr-grid-util/es6/ElementWrapper.js +2 -2
- package/lib/tr-grid-util/es6/ElfDate.js +4 -4
- package/lib/tr-grid-util/es6/ElfUtil.js +37 -37
- package/lib/tr-grid-util/es6/EventDispatcher.js +12 -12
- package/lib/tr-grid-util/es6/ExpanderIcon.js +6 -6
- package/lib/tr-grid-util/es6/ExpressionParser.js +43 -43
- package/lib/tr-grid-util/es6/Ext.js +6 -6
- package/lib/tr-grid-util/es6/FieldFormatter.js +17 -17
- package/lib/tr-grid-util/es6/FilterBuilder.js +57 -58
- package/lib/tr-grid-util/es6/FilterOperators.d.ts +12 -1
- package/lib/tr-grid-util/es6/FilterOperators.js +13 -2
- package/lib/tr-grid-util/es6/GridPlugin.js +86 -87
- package/lib/tr-grid-util/es6/GroupDefinitions.js +90 -90
- package/lib/tr-grid-util/es6/Icon.js +4 -4
- package/lib/tr-grid-util/es6/MouseDownTrait.js +6 -6
- package/lib/tr-grid-util/es6/MultiTableManager.js +71 -80
- package/lib/tr-grid-util/es6/NumberFormatter.js +23 -23
- package/lib/tr-grid-util/es6/PercentBar.js +17 -17
- package/lib/tr-grid-util/es6/Perf.js +5 -5
- package/lib/tr-grid-util/es6/Popup.js +42 -42
- package/lib/tr-grid-util/es6/RangeBar.js +5 -5
- package/lib/tr-grid-util/es6/RequestQueue.js +5 -5
- package/lib/tr-grid-util/es6/RowPainter.js +23 -23
- package/lib/tr-grid-util/es6/SubTable.js +94 -94
- package/lib/tr-grid-util/es6/Table.js +51 -51
- package/lib/tr-grid-util/es6/TextHighlighter.js +52 -52
- package/lib/tr-grid-util/es6/TickCodes.js +2 -2
- package/lib/tr-grid-util/es6/Timer.js +2 -2
- package/lib/tr-grid-util/es6/TouchProxy.js +7 -7
- package/lib/tr-grid-util/es6/Util.js +50 -50
- package/lib/tr-grid-util/es6/formula/ADCService.js +2 -2
- package/lib/tr-grid-util/es6/formula/ADCSubscription.js +19 -19
- package/lib/tr-grid-util/es6/formula/AdFinService.js +2 -2
- package/lib/tr-grid-util/es6/formula/AdFinSubscription.js +19 -19
- package/lib/tr-grid-util/es6/formula/Engine.js +56 -56
- package/lib/tr-grid-util/es6/formula/Formula.js +62 -62
- package/lib/tr-grid-util/es6/formula/IntervalSubscription.js +3 -3
- package/lib/tr-grid-util/es6/formula/Realtime.js +15 -15
- package/lib/tr-grid-util/es6/formula/RealtimeService.js +15 -15
- package/lib/tr-grid-util/es6/formula/TSIService.js +2 -2
- package/lib/tr-grid-util/es6/formula/TSISubscription.js +104 -104
- package/lib/tr-grid-util/es6/formula/VariableToken.js +20 -20
- package/lib/tr-grid-util/es6/formula/functions/AdFin.js +10 -10
- package/lib/tr-grid-util/es6/formula/functions/Excel.js +1 -1
- package/lib/tr-grid-util/es6/formula/functions/Info.js +2 -2
- package/lib/tr-grid-util/es6/formula/functions/Internal.js +5 -5
- package/lib/tr-grid-util/es6/formula/functions/Logic.js +5 -5
- package/lib/tr-grid-util/es6/formula/functions/Math.js +46 -46
- package/lib/tr-grid-util/es6/formula/functions/Statistics.js +27 -27
- package/lib/tr-grid-util/es6/formula/functions/Text.js +19 -19
- package/lib/tr-grid-util/es6/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/Adc.js +36 -36
- package/lib/tr-grid-util/es6/jet/CollectionDict.js +11 -11
- package/lib/tr-grid-util/es6/jet/DataGenerator.js +95 -95
- package/lib/tr-grid-util/es6/jet/DataSet.js +1 -1
- package/lib/tr-grid-util/es6/jet/MockArchive.js +5 -5
- package/lib/tr-grid-util/es6/jet/MockJET.js +1 -1
- package/lib/tr-grid-util/es6/jet/MockQuotes.js +13 -13
- package/lib/tr-grid-util/es6/jet/MockQuotes2.js +100 -100
- package/lib/tr-grid-util/es6/jet/MockRTK.js +4 -4
- package/lib/tr-grid-util/es6/jet/MockUtil.js +2 -2
- package/lib/tr-grid-util/es6/jet/index.js +1 -1
- package/lib/tr-grid-util/es6/jet/mockDataAPI.js +15 -15
- package/lib/tr-grid-util/es6/locale/translation-de.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-en.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-ja.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-zh-hant.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation-zh.js +1 -1
- package/lib/tr-grid-util/es6/locale/translation.js +1 -1
- package/lib/types/es6/ColumnDragging.d.ts +1 -1
- package/lib/types/es6/ColumnGrouping.d.ts +3 -1
- package/lib/types/es6/Core/data/DataTable.d.ts +4 -0
- package/lib/types/es6/Core/data/DataView.d.ts +2 -0
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +2 -0
- package/lib/types/es6/Core/index.d.ts +0 -2
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +2 -1
- package/lib/types/es6/RowDragging.d.ts +1 -2
- package/lib/versions.json +12 -12
- package/package.json +1 -1
- package/lib/core/es6/grid/util/ElementFrameWork.d.ts +0 -18
- package/lib/core/es6/grid/util/ElementFrameWork.js +0 -227
- package/lib/core/es6/grid/util/HttpRequest.d.ts +0 -53
- package/lib/core/es6/grid/util/HttpRequest.js +0 -371
- package/lib/core/es6/grid/util/PercentBar.d.ts +0 -43
- package/lib/core/es6/grid/util/PercentBar.js +0 -390
- package/lib/core/es6/grid/util/PercentBarRenderer.d.ts +0 -41
- package/lib/core/es6/grid/util/PercentBarRenderer.js +0 -316
- package/lib/core/es6/grid/util/RangeBar.d.ts +0 -25
- package/lib/core/es6/grid/util/RangeBar.js +0 -255
- package/lib/types/es6/Core/grid/util/ElementFrameWork.d.ts +0 -18
- package/lib/types/es6/Core/grid/util/HttpRequest.d.ts +0 -53
- package/lib/types/es6/Core/grid/util/PercentBar.d.ts +0 -43
- package/lib/types/es6/Core/grid/util/PercentBarRenderer.d.ts +0 -41
- package/lib/types/es6/Core/grid/util/RangeBar.d.ts +0 -25
@@ -6,7 +6,7 @@ import {CollectionDict} from "./CollectionDict.js";
|
|
6
6
|
* @param {Object} subB
|
7
7
|
* @return {string}
|
8
8
|
*/
|
9
|
-
|
9
|
+
let _joinSubKeys = function(subA, subB) {
|
10
10
|
return subA.ric + "_" + subB.ric;
|
11
11
|
};
|
12
12
|
|
@@ -14,9 +14,9 @@ var _joinSubKeys = function(subA, subB) {
|
|
14
14
|
* @param {string} ric
|
15
15
|
* @return {boolean}
|
16
16
|
*/
|
17
|
-
|
17
|
+
let _isDynamicChain = function(ric) {
|
18
18
|
// Dynamic chain will be 2 . (dot) for example .PG.PA
|
19
|
-
|
19
|
+
let matching = ric.match(/\./g); // Can be null when doesn't found dot(.)
|
20
20
|
if(matching) {
|
21
21
|
return matching.length > 1;
|
22
22
|
}
|
@@ -27,9 +27,9 @@ var _isDynamicChain = function(ric) {
|
|
27
27
|
* @param {Array<Object>} arr sub children
|
28
28
|
* @return {Array<Object>}
|
29
29
|
*/
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
let _shuffleArray = function(arr) {
|
31
|
+
let arrayShuffled = arr; // Modify original array
|
32
|
+
let i, randNumber, tmp;
|
33
33
|
// Shuffle the array randomly using the Fisher-Yates algorithm
|
34
34
|
for (i = arrayShuffled.length - 1; i > 0; i--) {
|
35
35
|
randNumber = Math.floor(Math.random() * (i + 1)); // TODO: it can be use this._dataGen.randInt(min, max) range
|
@@ -46,16 +46,16 @@ var _shuffleArray = function(arr) {
|
|
46
46
|
return arrayShuffled;
|
47
47
|
};
|
48
48
|
|
49
|
-
|
49
|
+
let _assignChildOrder = function(obj, index) {
|
50
50
|
obj["CHILD_ORDER"] = index;
|
51
51
|
};
|
52
52
|
|
53
|
-
|
53
|
+
let _childOrderSort = function(a, b) {
|
54
54
|
return a["CHILD_ORDER"] - b["CHILD_ORDER"];
|
55
55
|
};
|
56
56
|
|
57
57
|
/** @constructor */
|
58
|
-
|
58
|
+
let MockQuotes2 = function() {
|
59
59
|
|
60
60
|
};
|
61
61
|
/** @private
|
@@ -127,7 +127,7 @@ MockQuotes2.prototype.setPercentageDataUpdate = function(percent) {
|
|
127
127
|
/** @constructor
|
128
128
|
* @param {Object=} options
|
129
129
|
*/
|
130
|
-
|
130
|
+
let MockSubscriptions = function(options) {
|
131
131
|
this._onSubscriptionResponse = this._onSubscriptionResponse.bind(this);
|
132
132
|
|
133
133
|
this._subMap = {};
|
@@ -159,7 +159,7 @@ MockSubscriptions.prototype.config = function(options) {
|
|
159
159
|
if(!options) {
|
160
160
|
return;
|
161
161
|
}
|
162
|
-
|
162
|
+
let num = options.minInterval;
|
163
163
|
if(typeof num === "number") {
|
164
164
|
this._minInterval = num;
|
165
165
|
if(this._minInterval > this._maxInterval) {
|
@@ -235,8 +235,8 @@ MockSubscriptions.prototype.addFields = function(fields) {
|
|
235
235
|
if(typeof fields === "string") {
|
236
236
|
fields = [fields];
|
237
237
|
}
|
238
|
-
|
239
|
-
for(
|
238
|
+
let len = fields.length;
|
239
|
+
for(let i = 0; i < len; ++i) {
|
240
240
|
this._fields[fields[i]] = true;
|
241
241
|
}
|
242
242
|
};
|
@@ -245,7 +245,7 @@ MockSubscriptions.prototype.addFields = function(fields) {
|
|
245
245
|
* @param {string} subId
|
246
246
|
*/
|
247
247
|
MockSubscriptions.prototype.removeSubscription = function(subId) {
|
248
|
-
|
248
|
+
let sub = this._subMap[subId];
|
249
249
|
if(!sub) {
|
250
250
|
return;
|
251
251
|
}
|
@@ -253,10 +253,10 @@ MockSubscriptions.prototype.removeSubscription = function(subId) {
|
|
253
253
|
delete this._subMap[subId];
|
254
254
|
this._dataMap.removeItem(sub["ric"], sub);
|
255
255
|
if(sub["chain"]) {
|
256
|
-
|
257
|
-
|
258
|
-
for(
|
259
|
-
|
256
|
+
let children = sub["children"];
|
257
|
+
let len = children.length;
|
258
|
+
for(let i = 0; i < len; ++i) {
|
259
|
+
let child = children[i];
|
260
260
|
this._dataMap.removeItem(_joinSubKeys(sub, child), child);
|
261
261
|
child["parent"] = null;
|
262
262
|
}
|
@@ -274,12 +274,12 @@ MockSubscriptions.prototype.removeRic = MockSubscriptions.prototype.removeSubscr
|
|
274
274
|
MockSubscriptions.prototype.removeChain = MockSubscriptions.prototype.removeSubscription;
|
275
275
|
/** @public */
|
276
276
|
MockSubscriptions.prototype.removeAllSubscriptions = function() { // All channels will also be closed
|
277
|
-
|
277
|
+
let working = this._working;
|
278
278
|
this.stop();
|
279
279
|
|
280
280
|
if(this._hasListener("subscriptionRemoved")) {
|
281
|
-
|
282
|
-
for(
|
281
|
+
let subs = [];
|
282
|
+
for(let subId in this._subMap) {
|
283
283
|
subs.push(this._subMap[subId]);
|
284
284
|
}
|
285
285
|
if(subs.length > 0) {
|
@@ -301,9 +301,9 @@ MockSubscriptions.prototype.removeFields = function(fields) {
|
|
301
301
|
if(typeof fields === "string") {
|
302
302
|
fields = [fields];
|
303
303
|
}
|
304
|
-
|
305
|
-
for(
|
306
|
-
|
304
|
+
let len = fields.length;
|
305
|
+
for(let i = 0; i < len; ++i) {
|
306
|
+
let field = fields[i];
|
307
307
|
if(this._fields[field]) {
|
308
308
|
delete this._fields[field];
|
309
309
|
}
|
@@ -311,8 +311,8 @@ MockSubscriptions.prototype.removeFields = function(fields) {
|
|
311
311
|
};
|
312
312
|
/** @public */
|
313
313
|
MockSubscriptions.prototype.removeAllFields = function() {
|
314
|
-
|
315
|
-
for(
|
314
|
+
let dirty = false;
|
315
|
+
for(let field in this._fields) { // eslint-disable-line no-unused-vars
|
316
316
|
dirty = true;
|
317
317
|
break;
|
318
318
|
}
|
@@ -355,7 +355,7 @@ MockSubscriptions.prototype.dispose = function() {
|
|
355
355
|
MockSubscriptions.prototype.addEventListener = function(type, handler) {
|
356
356
|
if(!handler) { return; }
|
357
357
|
|
358
|
-
|
358
|
+
let listeners = this._events[type];
|
359
359
|
if(listeners) {
|
360
360
|
if(listeners.indexOf(handler) < 0) {
|
361
361
|
listeners.push(handler);
|
@@ -369,10 +369,10 @@ MockSubscriptions.prototype.addEventListener = function(type, handler) {
|
|
369
369
|
* @param {Function} handler
|
370
370
|
*/
|
371
371
|
MockSubscriptions.prototype.removeEventListener = function(type, handler) {
|
372
|
-
|
372
|
+
let listeners = (this._events) ? this._events[type] : null;
|
373
373
|
if(!listeners) { return; }
|
374
374
|
|
375
|
-
|
375
|
+
let at = listeners.indexOf(handler);
|
376
376
|
if(at >= 0) {
|
377
377
|
listeners.splice(at, 1);
|
378
378
|
}
|
@@ -394,7 +394,7 @@ MockSubscriptions.prototype.getSubscription = function(subId) {
|
|
394
394
|
* @return {string} string
|
395
395
|
*/
|
396
396
|
MockSubscriptions.prototype.getRic = function(subId) {
|
397
|
-
|
397
|
+
let sub = this._subMap[subId];
|
398
398
|
if(sub) {
|
399
399
|
return sub["ric"];
|
400
400
|
}
|
@@ -429,8 +429,8 @@ MockSubscriptions.prototype.filter = function (start, count) {
|
|
429
429
|
* @param {!Object} toObj
|
430
430
|
* @return {!Object} Return toObj
|
431
431
|
*/
|
432
|
-
|
433
|
-
for(
|
432
|
+
let copyValues = function(fromObj, toObj) {
|
433
|
+
for(let key in fromObj) {
|
434
434
|
toObj[key] = fromObj[key];
|
435
435
|
}
|
436
436
|
return toObj;
|
@@ -459,21 +459,21 @@ MockSubscriptions.prototype._addSymbol = function(ric, asChain, subId) {
|
|
459
459
|
if(asChain) {
|
460
460
|
ric = ric.replace("0#", ""); // The receiver is not expecting 0# symbol
|
461
461
|
}
|
462
|
-
|
462
|
+
let sub = {};
|
463
463
|
sub["ric"] = ric;
|
464
464
|
sub["chain"] = asChain;
|
465
465
|
sub["id"] = subId;
|
466
466
|
sub["dataId"] = subId + ric;
|
467
467
|
this._subMap[subId] = sub; // Collect all user subscriptions
|
468
468
|
this._dataMap.addItem(ric, sub);
|
469
|
-
|
470
|
-
|
469
|
+
let subs = this._dataMap.getItems(ric);
|
470
|
+
let subCount = subs.length;
|
471
471
|
|
472
472
|
this._dispatch("subscriptionAdded", {"subs": [sub]});
|
473
473
|
|
474
|
-
|
475
|
-
|
476
|
-
|
474
|
+
let childSub = null;
|
475
|
+
let childCount = 0;
|
476
|
+
let i;
|
477
477
|
if(asChain) {
|
478
478
|
// Note that constituents should have no subscription object. They should share the same subscription as their parent. Hence we does not register it to the _subMap
|
479
479
|
if(subCount === 1) { // The first chain detected
|
@@ -490,8 +490,8 @@ MockSubscriptions.prototype._addSymbol = function(ric, asChain, subId) {
|
|
490
490
|
this._dataMap.addItem(_joinSubKeys(sub, childSub), childSub);
|
491
491
|
}
|
492
492
|
} else {
|
493
|
-
|
494
|
-
|
493
|
+
let firstSub = subs[0];
|
494
|
+
let constituents = firstSub["children"];
|
495
495
|
childCount = constituents.length;
|
496
496
|
sub["children"] = new Array(childCount);
|
497
497
|
|
@@ -521,9 +521,9 @@ MockSubscriptions.prototype._addSymbol = function(ric, asChain, subId) {
|
|
521
521
|
* @return {number}
|
522
522
|
*/
|
523
523
|
MockSubscriptions.simpleDigest = function(str) {
|
524
|
-
|
525
|
-
|
526
|
-
for(
|
524
|
+
let len = str.length;
|
525
|
+
let sum = 0;
|
526
|
+
for(let i = 0; i < len; ++i) {
|
527
527
|
sum += str.charCodeAt(i);
|
528
528
|
}
|
529
529
|
return sum;
|
@@ -532,7 +532,7 @@ MockSubscriptions.simpleDigest = function(str) {
|
|
532
532
|
/** @private */
|
533
533
|
MockSubscriptions.prototype._connect = function() {
|
534
534
|
if(this._working && !this._timerId) {
|
535
|
-
|
535
|
+
let delay = this._dataGen.randInt(this._minInterval, this._maxInterval);
|
536
536
|
this._timerId = window.setTimeout(this._onSubscriptionResponse, delay); // This will be async for fire event to user
|
537
537
|
}
|
538
538
|
};
|
@@ -541,49 +541,49 @@ MockSubscriptions.prototype._connect = function() {
|
|
541
541
|
MockSubscriptions.prototype._onSubscriptionResponse = function() {
|
542
542
|
this._timerId = 0;
|
543
543
|
|
544
|
-
|
545
|
-
|
544
|
+
let keys = this._dataMap.getAllKeys(); // list of all rics
|
545
|
+
let len = keys ? keys.length : 0; // len include all row index (Constituent and normal ric)
|
546
546
|
if(!len) { // No symbol has been added
|
547
547
|
this._connect();
|
548
548
|
return;
|
549
549
|
}
|
550
550
|
|
551
|
-
|
551
|
+
let minRow = (this._percentageDataUpdate - 0.02) * len;
|
552
552
|
minRow = minRow > 0 ? minRow : 1; // update at least 1 row
|
553
|
-
|
553
|
+
let maxRow = (this._percentageDataUpdate + 0.02) * len;
|
554
554
|
maxRow = maxRow < len ? maxRow : len; // not more than all rows
|
555
|
-
|
556
|
-
|
555
|
+
let numRows = this._dataGen.randInt(minRow, maxRow);
|
556
|
+
let fields = this._fields;
|
557
557
|
|
558
|
-
for(
|
559
|
-
|
560
|
-
|
558
|
+
for(let i = 0; i < numRows; i++) {
|
559
|
+
let key = keys[this._dataGen.randIndex(len)]; // WARNING: Same sub could be picked more than once
|
560
|
+
let subs = this._dataMap.getItems(key); // Get all subs with the same RIC
|
561
561
|
|
562
|
-
|
563
|
-
|
564
|
-
|
562
|
+
let sub = subs[0]; // Only the first sub is need to generate data
|
563
|
+
let subParent = sub.parent;
|
564
|
+
let updatePosition = this._dataGen.randBoolean(); // Flag for change CHILD_ORDER position
|
565
565
|
|
566
|
-
|
566
|
+
let values, j, jLen;
|
567
567
|
if(_isDynamicChain(key) && subParent && updatePosition) { // subParent in header of dynamic chain is behavior like a normal ric
|
568
568
|
// TODO: support rate of ordering is changed
|
569
|
-
|
569
|
+
let children = subParent.children;
|
570
570
|
|
571
571
|
children = _shuffleArray(children);
|
572
|
-
|
573
|
-
|
572
|
+
let childrenLen = children.length;
|
573
|
+
let subIndex = children.indexOf(sub);
|
574
574
|
sub["CHILD_ORDER"] = subIndex;
|
575
575
|
|
576
576
|
values = this._generateQuoteData(sub, fields);
|
577
577
|
|
578
578
|
jLen = subs.length;
|
579
579
|
for(j = 0; j < jLen; ++j) { // It could be same ric and it need to dispatch with same ric number
|
580
|
-
for (
|
581
|
-
|
580
|
+
for (let k = 0; k < childrenLen; k++) {
|
581
|
+
let child = children[k];
|
582
582
|
if(subs[j] === child) {
|
583
583
|
values["CHILD_ORDER"] = child["CHILD_ORDER"];
|
584
584
|
this._dispatchDataChanged(subs[j], values);
|
585
585
|
} else {
|
586
|
-
|
586
|
+
let currentChild = child["CHILD_ORDER"];
|
587
587
|
this._dispatchDataChanged(child, {
|
588
588
|
X_RIC_NAME: child.ric,
|
589
589
|
CHILD_ORDER: currentChild
|
@@ -597,7 +597,7 @@ MockSubscriptions.prototype._onSubscriptionResponse = function() {
|
|
597
597
|
values = this._generateQuoteData(sub, fields);
|
598
598
|
jLen = subs.length;
|
599
599
|
for(j = 0; j < jLen; ++j) { // It could be same ric and it need to dispatch with same ric number
|
600
|
-
|
600
|
+
let childOrder = subs[j]["CHILD_ORDER"];
|
601
601
|
if(childOrder != null) { // Children of chain will have a CHILD_ORDER
|
602
602
|
values["CHILD_ORDER"] = childOrder;
|
603
603
|
}
|
@@ -623,17 +623,17 @@ MockSubscriptions.prototype._dispatchPostUpdate = function (obj) {
|
|
623
623
|
* @return {!Object}
|
624
624
|
*/
|
625
625
|
MockSubscriptions.prototype._generateQuoteData = function(sub, fields) {
|
626
|
-
|
627
|
-
|
626
|
+
let ric = sub.ric;
|
627
|
+
let prevData = sub.prevData;
|
628
628
|
|
629
|
-
|
630
|
-
|
629
|
+
let values = {};
|
630
|
+
let options = {
|
631
631
|
text: ric,
|
632
632
|
prefix: sub["parent"] ? sub["parent"]["ric"] : "" // prefix for constituents
|
633
633
|
};
|
634
|
-
for(
|
635
|
-
|
636
|
-
|
634
|
+
for(let field in fields){
|
635
|
+
let data = this._dataGen.generateQuoteData(field, options);
|
636
|
+
let formattedField = field + "_FORMATTED";
|
637
637
|
if(prevData) {
|
638
638
|
if(data.changeOnly) {
|
639
639
|
if(prevData[field] === data.value) {
|
@@ -664,11 +664,11 @@ MockSubscriptions.prototype._generateQuoteData = function(sub, fields) {
|
|
664
664
|
* @return {Object}
|
665
665
|
*/
|
666
666
|
MockSubscriptions.prototype._getChildSubByRic = function(parentSub, ric) {
|
667
|
-
|
667
|
+
let children = parentSub["children"];
|
668
668
|
if(children) {
|
669
|
-
|
670
|
-
for(
|
671
|
-
|
669
|
+
let childCount = children.length;
|
670
|
+
for(let i = 0; i < childCount; ++i) {
|
671
|
+
let child = children[i];
|
672
672
|
if(child["ric"] === ric) {
|
673
673
|
return child;
|
674
674
|
}
|
@@ -680,21 +680,21 @@ MockSubscriptions.prototype._getChildSubByRic = function(parentSub, ric) {
|
|
680
680
|
* @param {string} ric
|
681
681
|
*/
|
682
682
|
MockSubscriptions.prototype._updateDuplicateSymbol = function(ric) {
|
683
|
-
|
683
|
+
let subs = this._dataMap.getItems(ric);
|
684
684
|
if(!subs) {
|
685
685
|
return;
|
686
686
|
}
|
687
|
-
|
687
|
+
let subCount = subs.length;
|
688
688
|
if(subCount < 2) {
|
689
689
|
return;
|
690
690
|
}
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
691
|
+
let firstSub = subs[0];
|
692
|
+
let prevData = firstSub["prevData"];
|
693
|
+
let isChain = firstSub["chain"] ? true : false;
|
694
|
+
let i;
|
695
695
|
if(prevData) {
|
696
696
|
for(i = 1; i < subCount; ++i) {
|
697
|
-
|
697
|
+
let sub = subs[i];
|
698
698
|
if(!sub["prevData"]) {
|
699
699
|
// TODO: check in duplicate dynamic chain
|
700
700
|
this._dispatchDataChanged(sub, prevData);
|
@@ -706,20 +706,20 @@ MockSubscriptions.prototype._updateDuplicateSymbol = function(ric) {
|
|
706
706
|
if(!isChain) {
|
707
707
|
return;
|
708
708
|
}
|
709
|
-
|
709
|
+
let ricList = firstSub["ricList"];
|
710
710
|
if(!ricList) {
|
711
711
|
return;
|
712
712
|
}
|
713
|
-
|
713
|
+
let childCount = ricList.length;
|
714
714
|
|
715
715
|
for(i = 1; i < subCount; ++i) {
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
for(
|
720
|
-
|
721
|
-
|
722
|
-
|
716
|
+
let sub2 = subs[i];
|
717
|
+
let ricList2 = sub2["ricList"];
|
718
|
+
let childCount2 = ricList2 ? ricList2.length : 0;
|
719
|
+
for(let j = childCount2; j < childCount; ++j) {
|
720
|
+
let childRic = ricList[j];
|
721
|
+
let childSub = this._getChildSubByRic(firstSub, childRic);
|
722
|
+
let childSub2 = this._getChildSubByRic(sub2, childRic);
|
723
723
|
if(childSub && childSub2) {
|
724
724
|
if(childSub["prevData"]) {
|
725
725
|
// TODO: check in duplicate dynamic chain
|
@@ -734,13 +734,13 @@ MockSubscriptions.prototype._updateDuplicateSymbol = function(ric) {
|
|
734
734
|
* @param {Object} dataUpdates
|
735
735
|
*/
|
736
736
|
MockSubscriptions.prototype._dispatchDataChanged = function(sub, dataUpdates) {
|
737
|
-
|
738
|
-
|
737
|
+
let values = copyValues(dataUpdates, {});
|
738
|
+
let evtArg = {};
|
739
739
|
evtArg["ric"] = sub["ric"];
|
740
740
|
evtArg["values"] = values;
|
741
741
|
evtArg["subId"] = sub["id"];
|
742
742
|
|
743
|
-
|
743
|
+
let prevData = sub.prevData; // For data generation on the next update
|
744
744
|
if(!prevData) {
|
745
745
|
prevData = {};
|
746
746
|
sub.prevData = prevData;
|
@@ -751,9 +751,9 @@ MockSubscriptions.prototype._dispatchDataChanged = function(sub, dataUpdates) {
|
|
751
751
|
values["SUB_ID"] = sub["id"];
|
752
752
|
copyValues(values, prevData);
|
753
753
|
|
754
|
-
|
754
|
+
let parentSub = sub.parent;
|
755
755
|
if(parentSub) { // This is the first time constituent have the data
|
756
|
-
|
756
|
+
let ricList = parentSub["ricList"];
|
757
757
|
if(!ricList) {
|
758
758
|
ricList = parentSub["ricList"] = [];
|
759
759
|
}
|
@@ -780,7 +780,7 @@ MockSubscriptions.prototype.onFeedStatusChanged = function(feedNames, handler) {
|
|
780
780
|
* @return {boolean}
|
781
781
|
*/
|
782
782
|
MockSubscriptions.prototype._hasListener = function(type) {
|
783
|
-
|
783
|
+
let listeners = this._events[type];
|
784
784
|
return listeners ? (listeners.length > 0) : false;
|
785
785
|
};
|
786
786
|
/** @private
|
@@ -788,10 +788,10 @@ MockSubscriptions.prototype._hasListener = function(type) {
|
|
788
788
|
* @param {Object} eventArg
|
789
789
|
*/
|
790
790
|
MockSubscriptions.prototype._dispatch = function(type, eventArg) {
|
791
|
-
|
791
|
+
let listeners = this._events[type];
|
792
792
|
if(!listeners) { return; }
|
793
|
-
|
794
|
-
for(
|
793
|
+
let len = listeners.length;
|
794
|
+
for(let i = 0; i < len; ++i) {
|
795
795
|
listeners[i](eventArg);
|
796
796
|
}
|
797
797
|
};
|
@@ -3,7 +3,7 @@ import { MockQuotes2 } from "./MockQuotes2.js";
|
|
3
3
|
import { cloneObject } from "../Util.js";
|
4
4
|
|
5
5
|
/** @constructor */
|
6
|
-
|
6
|
+
let MockRTKData = {};
|
7
7
|
|
8
8
|
/** @type {Object}
|
9
9
|
* @public
|
@@ -14,7 +14,7 @@ MockRTKData.DataGrid = cloneObject(DataGrid);
|
|
14
14
|
* @return {*}
|
15
15
|
*/
|
16
16
|
MockRTKData.DataGrid.request = function (payload) {
|
17
|
-
|
17
|
+
let p = DataGrid.request(payload);
|
18
18
|
return p.then(function (res) {
|
19
19
|
return JSON.parse(res);
|
20
20
|
});
|
@@ -29,7 +29,7 @@ MockRTKData.Adc = cloneObject(Adc);
|
|
29
29
|
* @return {*}
|
30
30
|
*/
|
31
31
|
MockRTKData.Adc.request = function (payload) {
|
32
|
-
|
32
|
+
let p = Adc.request(payload);
|
33
33
|
return p.then(function (res) {
|
34
34
|
return JSON.parse(res);
|
35
35
|
});
|
@@ -44,7 +44,7 @@ MockRTKData.setInvalidFields = setInvalidFields;
|
|
44
44
|
|
45
45
|
|
46
46
|
/** @constructor */
|
47
|
-
|
47
|
+
let MockRTK = {};
|
48
48
|
|
49
49
|
/** @type {MockQuotes2}
|
50
50
|
* @public
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* @public
|
3
3
|
* @type {Object}
|
4
4
|
*/
|
5
|
-
|
5
|
+
let invalidFieldDict = {
|
6
6
|
'TR.NonExistField': true,
|
7
7
|
'TR.NotExistField': true,
|
8
8
|
'CF_IGNORE_FIELD': true
|
@@ -16,7 +16,7 @@ function setInvalidFields(fields) {
|
|
16
16
|
if (fields && typeof fields === 'string') {
|
17
17
|
invalidFieldDict[fields] = true;
|
18
18
|
} else if (Array.isArray(fields)) {
|
19
|
-
for (
|
19
|
+
for (let i = 0; i < fields.length; i++) {
|
20
20
|
invalidFieldDict[fields[i]] = true;
|
21
21
|
}
|
22
22
|
}
|
@@ -2,12 +2,12 @@ import { Adc } from "./Adc.js";
|
|
2
2
|
import { DataGenerator } from "./DataGenerator.js";
|
3
3
|
import { invalidFieldDict, setInvalidFields } from "./MockUtil.js";
|
4
4
|
|
5
|
-
|
5
|
+
let dataGen = new DataGenerator();
|
6
6
|
|
7
7
|
/** @private
|
8
8
|
* @namespace
|
9
9
|
*/
|
10
|
-
|
10
|
+
let DataGrid = {};
|
11
11
|
|
12
12
|
/** @private
|
13
13
|
* @function
|
@@ -20,13 +20,13 @@ DataGrid.request = function (payload, mockResponse) {
|
|
20
20
|
return Promise.resolve(JSON.stringify(mockResponse));
|
21
21
|
}
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
let i, f, len, row;
|
24
|
+
let instruments = payload.instruments;
|
25
|
+
let fields = payload.fields;
|
26
26
|
|
27
27
|
// _invalidFieldDict is a dictionary of non exist field
|
28
28
|
// so we must remove invalid field to make "mocking api" return result more like a "real api".
|
29
|
-
|
29
|
+
let invalidDict = invalidFieldDict;
|
30
30
|
fields = [];
|
31
31
|
for (i = 0; i < payload.fields.length; i++) {
|
32
32
|
f = payload.fields[i];
|
@@ -36,14 +36,14 @@ DataGrid.request = function (payload, mockResponse) {
|
|
36
36
|
}
|
37
37
|
|
38
38
|
// for filter duplicate instrument
|
39
|
-
|
39
|
+
let rowMap = {};
|
40
40
|
|
41
41
|
// build data
|
42
42
|
len = instruments.length;
|
43
|
-
|
44
|
-
|
43
|
+
let data2D = [];
|
44
|
+
let rowData = dataGen.generate(fields, len);
|
45
45
|
for (i = 0; i < len; ++i) {
|
46
|
-
|
46
|
+
let inst = instruments[i];
|
47
47
|
row = rowMap[inst];
|
48
48
|
if (!row) {
|
49
49
|
row = rowMap[inst] = rowData[i];
|
@@ -55,12 +55,12 @@ DataGrid.request = function (payload, mockResponse) {
|
|
55
55
|
// There is a chance that rtk will return multiple row data per instrument
|
56
56
|
// so we must create mock up for this case
|
57
57
|
if (data2D.length > 0) {
|
58
|
-
|
58
|
+
let chance = dataGen.randInt(1, 10);
|
59
59
|
if (chance <= 3) { // chance 30%
|
60
|
-
|
60
|
+
let pos = dataGen.randInt(0, data2D.length - 1); // random row pos
|
61
61
|
row = data2D[pos];
|
62
62
|
len = row.length;
|
63
|
-
|
63
|
+
let mockupRow = new Array(len);
|
64
64
|
mockupRow[0] = row[0]; // 1st index is for instrument
|
65
65
|
for (i = 1; i < len; i++) {
|
66
66
|
mockupRow[i] = ''; // real case will return null or empty string
|
@@ -70,7 +70,7 @@ DataGrid.request = function (payload, mockResponse) {
|
|
70
70
|
}
|
71
71
|
|
72
72
|
// build header
|
73
|
-
|
73
|
+
let headers = [{
|
74
74
|
"displayName": "Instrument"
|
75
75
|
}];
|
76
76
|
for (i = 0; i < fields.length; i++) {
|
@@ -92,7 +92,7 @@ DataGrid.request = function (payload, mockResponse) {
|
|
92
92
|
* @param {string} dataType
|
93
93
|
* @return {Promise}
|
94
94
|
*/
|
95
|
-
|
95
|
+
let mockDataAPI = function (dataType) {
|
96
96
|
if (dataType === "datagrid") {
|
97
97
|
return Promise.resolve(DataGrid);
|
98
98
|
} else if(dataType === "adc") {
|