@refinitiv-ui/efx-grid 6.0.13 → 6.0.14
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 +1209 -160
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataCache.js +1 -1
- package/lib/core/es6/data/DataTable.d.ts +18 -3
- package/lib/core/es6/data/DataTable.js +203 -17
- package/lib/core/es6/data/DataView.d.ts +8 -1
- package/lib/core/es6/data/DataView.js +30 -2
- package/lib/core/es6/data/Segment.d.ts +36 -11
- package/lib/core/es6/data/Segment.js +575 -59
- package/lib/core/es6/data/SegmentCollection.d.ts +15 -1
- package/lib/core/es6/data/SegmentCollection.js +236 -80
- package/lib/core/es6/grid/Core.js +1 -1
- package/lib/grid/index.js +1 -1
- package/lib/row-segmenting/es6/RowSegmenting.d.ts +2 -0
- package/lib/row-segmenting/es6/RowSegmenting.js +26 -3
- package/lib/rt-grid/dist/rt-grid.js +1115 -158
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.d.ts +2 -0
- package/lib/rt-grid/es6/Grid.js +53 -0
- package/lib/rt-grid/es6/RowDefinition.js +22 -2
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +1 -0
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +194 -366
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +10 -3
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +93 -36
- package/lib/tr-grid-util/es6/RowPainter.d.ts +2 -1
- package/lib/tr-grid-util/es6/RowPainter.js +7 -1
- package/lib/tr-grid-util/es6/jet/mockDataAPI.d.ts +1 -0
- package/lib/tr-grid-util/es6/jet/mockDataAPI.js +191 -52
- package/lib/types/es6/ColumnGrouping.d.ts +1 -0
- package/lib/types/es6/ColumnStack.d.ts +10 -3
- package/lib/types/es6/Core/data/DataTable.d.ts +18 -3
- package/lib/types/es6/Core/data/DataView.d.ts +8 -1
- package/lib/types/es6/Core/data/Segment.d.ts +36 -11
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +15 -1
- package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +6 -1
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +2 -0
- package/lib/types/es6/RowSegmenting.d.ts +2 -0
- package/lib/versions.json +4 -4
- package/package.json +1 -1
@@ -30,7 +30,14 @@ declare namespace ColumnStackPlugin {
|
|
30
30
|
spreading?: boolean|null,
|
31
31
|
collapsed?: boolean|null,
|
32
32
|
children: (string)[]|null,
|
33
|
-
name?: string|null
|
33
|
+
name?: string|null,
|
34
|
+
activeColumn?: string|null
|
35
|
+
};
|
36
|
+
|
37
|
+
type StackConfiguration = {
|
38
|
+
spreading?: boolean|null,
|
39
|
+
collapsed?: boolean|null,
|
40
|
+
activeColumn?: string|null
|
34
41
|
};
|
35
42
|
|
36
43
|
}
|
@@ -75,9 +82,9 @@ declare class ColumnStackPlugin extends GridPlugin {
|
|
75
82
|
|
76
83
|
public getStackId(colIndex: number): string;
|
77
84
|
|
78
|
-
public stackColumns(colRefs?: (number|string)[]|null, stackId?: string|null, options?:
|
85
|
+
public stackColumns(colRefs?: (number|string)[]|null, stackId?: string|null, options?: ColumnStackPlugin.StackConfiguration|null): boolean;
|
79
86
|
|
80
|
-
public setStack(colRefs?: (number|string)[]|null): boolean;
|
87
|
+
public setStack(colRefs?: (number|string)[]|null, activeColRef?: number|string|null): boolean;
|
81
88
|
|
82
89
|
public unstackColumns(colIndices?: (number)[]|null): boolean;
|
83
90
|
|
@@ -33,6 +33,14 @@ import { preventDefault } from "../../tr-grid-util/es6/EventDispatcher.js";
|
|
33
33
|
* @property {boolean=} collapsed=true If disabled, this group will be expanded at the first time
|
34
34
|
* @property {Array.<string>} children Children column ID
|
35
35
|
* @property {string=} name="" Name defined for specific stack
|
36
|
+
* @property {string=} activeColumn="" Column Id of active column in stack
|
37
|
+
*/
|
38
|
+
|
39
|
+
/** @typedef {Object} ColumnStackPlugin~StackConfiguration
|
40
|
+
* @description Available options describing grouped column displaying
|
41
|
+
* @property {boolean=} spreading=false If specified true, this group will be running in collapsing mode
|
42
|
+
* @property {boolean=} collapsed=true If disabled, this group will be expanded at the first time
|
43
|
+
* @property {string=} activeColumn="" Column index or field for set as active column
|
36
44
|
*/
|
37
45
|
|
38
46
|
/** @constructor
|
@@ -256,9 +264,17 @@ ColumnStackPlugin.prototype.config = function (options) {
|
|
256
264
|
}
|
257
265
|
|
258
266
|
if(this._initializedGrid) {
|
259
|
-
|
267
|
+
if(Object.keys(stacks).length){
|
268
|
+
this.removeAllStacks(false);
|
269
|
+
} else {
|
270
|
+
this.removeAllStacks();
|
271
|
+
}
|
260
272
|
for(sid in stacks) {
|
261
|
-
|
273
|
+
var config = stacks[sid];
|
274
|
+
if(!config.colRefs){
|
275
|
+
this._transformStackConfig(config);
|
276
|
+
}
|
277
|
+
this.stackColumns(config.colRefs, sid, config);
|
262
278
|
}
|
263
279
|
} else {
|
264
280
|
this._pendingStacks = this._pendingStacks || stacks;
|
@@ -281,9 +297,11 @@ ColumnStackPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
281
297
|
|
282
298
|
for (var stackKey in stacks) {
|
283
299
|
var stackOption = stacks[stackKey];
|
300
|
+
var activeColIndex = this._getColumnIndex(stackOption.activeColumn);
|
284
301
|
var stackConfigObj = {
|
285
302
|
id: stackOption.stackId,
|
286
|
-
children: this.getStackMemberIds(stackOption.stackId)
|
303
|
+
children: this.getStackMemberIds(stackOption.stackId),
|
304
|
+
activeColumn: this.getColumnId(activeColIndex)
|
287
305
|
};
|
288
306
|
var name = stackOption.name;
|
289
307
|
var collapsed = stackOption.collapsed;
|
@@ -314,6 +332,9 @@ ColumnStackPlugin.prototype._afterInit = function () {
|
|
314
332
|
this.removeAllStacks(false);
|
315
333
|
for(var sid in this._pendingStacks) {
|
316
334
|
var stackOpt = this._pendingStacks[sid];
|
335
|
+
if(!stackOpt.colRefs){
|
336
|
+
this._transformStackConfig(stackOpt);
|
337
|
+
}
|
317
338
|
this.stackColumns(stackOpt.colRefs, sid, stackOpt);
|
318
339
|
}
|
319
340
|
this._pendingStacks = null;
|
@@ -363,6 +384,37 @@ ColumnStackPlugin.prototype._setColumnStackOptions = function(colIndex, stackOpt
|
|
363
384
|
}
|
364
385
|
};
|
365
386
|
/** @private
|
387
|
+
* @param {object} stackConfig
|
388
|
+
* @return {object} stack config object
|
389
|
+
*/
|
390
|
+
ColumnStackPlugin.prototype._transformStackConfig = function(stackConfig) {
|
391
|
+
stackConfig.colRefs = [];
|
392
|
+
var children = stackConfig.children;
|
393
|
+
var activeColumn = stackConfig.activeColumn;
|
394
|
+
var field;
|
395
|
+
if(children){
|
396
|
+
var childLen = stackConfig.children.length;
|
397
|
+
for(var j = 0; j < childLen; j++){
|
398
|
+
var colIndex = this.getColumnIndex(children[j]);
|
399
|
+
if(colIndex !== -1){
|
400
|
+
field = this._getField(colIndex);
|
401
|
+
stackConfig.colRefs.push(field);
|
402
|
+
}
|
403
|
+
}
|
404
|
+
}
|
405
|
+
if(activeColumn){
|
406
|
+
var activeColIndex = this.getColumnIndex(activeColumn);
|
407
|
+
if(activeColIndex !== -1){
|
408
|
+
field = this._getField(colIndex);
|
409
|
+
if(field){
|
410
|
+
stackConfig.activeColumn;
|
411
|
+
}
|
412
|
+
|
413
|
+
}
|
414
|
+
}
|
415
|
+
return stackConfig;
|
416
|
+
};
|
417
|
+
/** @private
|
366
418
|
* @param {number} colIndex
|
367
419
|
* @return {*}
|
368
420
|
*/
|
@@ -803,20 +855,16 @@ ColumnStackPlugin.prototype.getStackId = function(colIndex) {
|
|
803
855
|
/** @public
|
804
856
|
* @param {Array.<number|string>=} colRefs Names of fields or column indices. If not specified, selected columns will be used.
|
805
857
|
* @param {string=} stackId Must be unique
|
806
|
-
* @param {
|
807
|
-
* @param {boolean=} sort Default to true. If enable and colRefs are column indices, column in stack will be sorted
|
858
|
+
* @param {ColumnStackPlugin~StackConfiguration=} options
|
808
859
|
* @return {boolean} Return true if all of the given columns is stacked together
|
809
860
|
*/
|
810
|
-
ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options
|
811
|
-
|
812
|
-
colRefs = this.getColumnIndicesByColumnIds(options.children);
|
813
|
-
}
|
861
|
+
ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options) {
|
862
|
+
var needSorting = true;
|
814
863
|
|
815
864
|
if(!colRefs) {
|
816
865
|
colRefs = this._getSelectedColumns();
|
817
866
|
}
|
818
867
|
|
819
|
-
var needSorting = sort !== null ? sort : true;
|
820
868
|
if(colRefs.length) {
|
821
869
|
if(typeof colRefs[0] === "string") {// Do not sort in the case of field stack
|
822
870
|
needSorting = false;
|
@@ -847,7 +895,13 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options, s
|
|
847
895
|
|
848
896
|
options = options || {};
|
849
897
|
|
850
|
-
var activeIndex = colRefs[0];
|
898
|
+
var activeIndex = options.activeColumn ? this.getColumnIndices(options.activeColumn) : colRefs[0];
|
899
|
+
if (activeIndex.length){
|
900
|
+
activeIndex = activeIndex[0];
|
901
|
+
}
|
902
|
+
if(activeIndex == null || colRefs.indexOf(activeIndex) == -1){
|
903
|
+
activeIndex = colRefs[0];
|
904
|
+
}
|
851
905
|
// Collecting data
|
852
906
|
var stack = {};
|
853
907
|
stack.stackId = sid;
|
@@ -864,6 +918,10 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options, s
|
|
864
918
|
this._setColumnStackOptions(colIndex, stack);
|
865
919
|
stack.stackRefs[i] = this._getColumnStacking(colIndex);
|
866
920
|
|
921
|
+
if(colIndex == activeIndex){
|
922
|
+
stack.activeColumn = stack.stackRefs[i];
|
923
|
+
}
|
924
|
+
|
867
925
|
// Prevent from flashing in stack mode
|
868
926
|
if(colIndex !== activeIndex && stack.collapsed !== false) {
|
869
927
|
this._setColumnVisibility(colIndex, false);
|
@@ -876,7 +934,6 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options, s
|
|
876
934
|
if(stack.spreading) {
|
877
935
|
stack.activeColumn = stack.stackRefs[stack.stackRefs.length - 1]; // Right most column is the active column
|
878
936
|
} else {
|
879
|
-
stack.activeColumn = stack.stackRefs[0]; // Left most column is the active column
|
880
937
|
var csp = this._getPlugin("ColumnSelectionPlugin");
|
881
938
|
if(csp && csp.isEnabled()) {
|
882
939
|
csp.selectSingleColumn(activeIndex);
|
@@ -899,9 +956,10 @@ ColumnStackPlugin.prototype.stackColumns = function(colRefs, stackId, options, s
|
|
899
956
|
* When adding columns, Grid will attempt to restore stacking
|
900
957
|
* if there are at least two visible columns that match to the retained fields.
|
901
958
|
* @param {Array.<number|string>=} colRefs Field names or column indices
|
959
|
+
* @param {number|string=} activeColRef Field names or column index of active column
|
902
960
|
* @return {boolean} If the stack has been updated, return true.
|
903
961
|
*/
|
904
|
-
ColumnStackPlugin.prototype.setStack = function(colRefs) {
|
962
|
+
ColumnStackPlugin.prototype.setStack = function(colRefs, activeColRef) {
|
905
963
|
// Keep state
|
906
964
|
var i, colRef, type;
|
907
965
|
var fields = [];
|
@@ -916,6 +974,9 @@ ColumnStackPlugin.prototype.setStack = function(colRefs) {
|
|
916
974
|
}
|
917
975
|
}
|
918
976
|
}
|
977
|
+
if(activeColRef && typeof activeColRef === "number") {
|
978
|
+
activeColRef = this._getField(activeColRef);
|
979
|
+
}
|
919
980
|
|
920
981
|
if(fields.length > 1) {
|
921
982
|
if(!this._columnStack) {
|
@@ -949,29 +1010,19 @@ ColumnStackPlugin.prototype.setStack = function(colRefs) {
|
|
949
1010
|
return this.removeAllStacks();
|
950
1011
|
}
|
951
1012
|
|
952
|
-
//
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
var stacking = this._getColumnStacking(colRefs[i]);
|
960
|
-
var oldStacking = stackRefs[i];
|
961
|
-
if(stacking === oldStacking) {
|
962
|
-
count++;
|
963
|
-
}
|
964
|
-
}
|
965
|
-
if(count === colRefs.length) {
|
966
|
-
return false;
|
1013
|
+
var activeIndex = colRefs[0]; // For the active index, choose the first element.
|
1014
|
+
if(activeColRef){
|
1015
|
+
var indices = this.getColumnIndices(activeColRef);
|
1016
|
+
if(indices.length){
|
1017
|
+
var index = indices[0];
|
1018
|
+
if(colRefs.indexOf(index) !== -1){
|
1019
|
+
activeIndex = indices[0];
|
967
1020
|
}
|
968
1021
|
}
|
969
1022
|
}
|
970
1023
|
|
971
1024
|
this.removeAllStacks(false); // Remove the stack without updating the UI (UI will only update when column is stacked)
|
972
1025
|
|
973
|
-
var activeIndex = colRefs[0]; // For the active index, choose the first element.
|
974
|
-
|
975
1026
|
// Collecting data
|
976
1027
|
var stack = {};
|
977
1028
|
stack.stackId = sid;
|
@@ -982,6 +1033,10 @@ ColumnStackPlugin.prototype.setStack = function(colRefs) {
|
|
982
1033
|
stack.stackRefs[i] = this._getColumnStacking(colIndex);
|
983
1034
|
this._setColumnStackOptions(colIndex, stack);
|
984
1035
|
|
1036
|
+
if(colIndex == activeIndex){
|
1037
|
+
stack.activeColumn = stack.stackRefs[i];
|
1038
|
+
}
|
1039
|
+
|
985
1040
|
// Prevent from flashing in stack mode
|
986
1041
|
if(colIndex !== activeIndex && stack.collapsed !== false) {
|
987
1042
|
this._setColumnVisibility(colIndex, false);
|
@@ -991,7 +1046,7 @@ ColumnStackPlugin.prototype.setStack = function(colRefs) {
|
|
991
1046
|
// Make sure that all columns stay packed together
|
992
1047
|
this._moveStackedColumns(stack.stackRefs);
|
993
1048
|
|
994
|
-
stack.activeColumn = stack.stackRefs[0]; // The first stacking (the first given columns) is the active column
|
1049
|
+
// stack.activeColumn = stack.stackRefs[0]; // The first stacking (the first given columns) is the active column
|
995
1050
|
this._stacks[sid] = stack;
|
996
1051
|
var cfp = this._getPlugin("ColumnFilterPlugin");
|
997
1052
|
if(cfp) {
|
@@ -1136,8 +1191,6 @@ ColumnStackPlugin.prototype.swapColumn = function(colRef, swappingIndex) {
|
|
1136
1191
|
return false; // The given index is already active stacked column
|
1137
1192
|
}
|
1138
1193
|
|
1139
|
-
colData.stackRefs.splice(swappingIndex, 1);
|
1140
|
-
colData.stackRefs.unshift(newActiveColumn); // Move data to front
|
1141
1194
|
var prevActiveColumnIndex = this._getColumnIndex(colData.activeColumn);
|
1142
1195
|
var newActiveColumnIndex = this._getColumnIndex(newActiveColumn);
|
1143
1196
|
colData.activeColumn = newActiveColumn; // Change active column
|
@@ -1145,8 +1198,6 @@ ColumnStackPlugin.prototype.swapColumn = function(colRef, swappingIndex) {
|
|
1145
1198
|
this._setColumnVisibility(newActiveColumnIndex, true);
|
1146
1199
|
this._setColumnVisibility(prevActiveColumnIndex, false); // Hide current active column
|
1147
1200
|
|
1148
|
-
this._moveColumn(newActiveColumnIndex, prevActiveColumnIndex); // Move UI to front
|
1149
|
-
|
1150
1201
|
var csp = this._getPlugin("ColumnSelectionPlugin");
|
1151
1202
|
if(csp && csp.isEnabled()) {
|
1152
1203
|
csp.selectSingleColumn(newActiveColumnIndex);
|
@@ -1158,6 +1209,7 @@ ColumnStackPlugin.prototype.swapColumn = function(colRef, swappingIndex) {
|
|
1158
1209
|
|
1159
1210
|
colData = this._getColumnStackOptions(prevActiveColumnIndex);
|
1160
1211
|
this._updateIcon(prevActiveColumnIndex, colData);
|
1212
|
+
this._updateIcon(newActiveColumnIndex, colData);
|
1161
1213
|
|
1162
1214
|
return true;
|
1163
1215
|
};
|
@@ -1380,6 +1432,7 @@ ColumnStackPlugin.prototype._onStackButtonClicked = function(e) {
|
|
1380
1432
|
|
1381
1433
|
var stackRefs = colData.stackRefs;
|
1382
1434
|
var activeIndex = stackRefs.indexOf(colData.activeColumn);
|
1435
|
+
|
1383
1436
|
var len = stackRefs.length;
|
1384
1437
|
var colIndices = new Array(len);
|
1385
1438
|
var menuData = new Array(len);
|
@@ -1639,8 +1692,12 @@ ColumnStackPlugin.prototype.reorderStackColumns = function(colRefs, stackId) {
|
|
1639
1692
|
collapsed: stack.collapsed
|
1640
1693
|
};
|
1641
1694
|
|
1695
|
+
for(i = 0; i < newStackMembers.length; i++){
|
1696
|
+
newStackMembers[i] = this._getField(newStackMembers[i]);
|
1697
|
+
}
|
1698
|
+
|
1642
1699
|
this.unstackColumns(stackMemberIndices);
|
1643
|
-
this.stackColumns(newStackMembers, stackId, options
|
1700
|
+
this.stackColumns(newStackMembers, stackId, options);
|
1644
1701
|
|
1645
1702
|
};
|
1646
1703
|
|
@@ -25,6 +25,7 @@ import { Icon } from "./Icon.js";
|
|
25
25
|
* @property {boolean=} nonGroupRow
|
26
26
|
* @property {string=} colorTagClass CSS class for custom coloring
|
27
27
|
* @property {number=} indentSize
|
28
|
+
* @property {*} content Content to be rendered on the first cell. If null or undefined value is given, no content will be changed.
|
28
29
|
*/
|
29
30
|
|
30
31
|
/**
|
@@ -335,7 +336,12 @@ RowPainter.prototype.applyHeaderStyle = function(e) {
|
|
335
336
|
if (this._clickableCell) {
|
336
337
|
cell.listen("click", this._onCellClicked); // WARNING: content row share this same listener with this header cell
|
337
338
|
}
|
338
|
-
if (
|
339
|
+
if (this._segmentMode) {
|
340
|
+
var content = e.content;
|
341
|
+
if(content != null) {
|
342
|
+
cell.setContent(content);
|
343
|
+
}
|
344
|
+
} else {
|
339
345
|
cell.setContent(e.groupId || "");
|
340
346
|
}
|
341
347
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { DataGenerator } from "./DataGenerator.js";
|
2
|
+
import { DateTime } from "../DateTime.js";
|
2
3
|
|
3
4
|
/**
|
4
5
|
* @private
|
@@ -24,6 +25,7 @@ function setInvalidFields(fields) {
|
|
24
25
|
}
|
25
26
|
}
|
26
27
|
|
28
|
+
|
27
29
|
var dataGen = new DataGenerator();
|
28
30
|
|
29
31
|
/** @private
|
@@ -125,70 +127,207 @@ Adc.request = function (payload, mockResponse) {
|
|
125
127
|
return Promise.resolve(JSON.stringify(mockResponse));
|
126
128
|
}
|
127
129
|
|
128
|
-
|
129
|
-
var
|
130
|
-
var
|
131
|
-
var fields
|
130
|
+
// build row header
|
131
|
+
var rows = [];
|
132
|
+
var i, f, len, row, j;
|
133
|
+
var identifiers, formula, fields, invalidDict;
|
134
|
+
if(payload.output === "Col,date|,Row,In|,va,T,NoEmptyTickers") {
|
132
135
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
136
|
+
identifiers = payload.identifiers;
|
137
|
+
formula = payload.formula.trim().split(/(?=,TR.)/);// TODO: check each field with another way, this doesn't work when user use some comma (,) formula
|
138
|
+
fields = [];
|
139
|
+
|
140
|
+
// _invalidFieldDict is a dictionary of non exist field
|
141
|
+
// so we must remove invalid field to make "mocking api" return result more like a "real api".
|
142
|
+
invalidDict = _invalidFieldDict;
|
143
|
+
for (i = 0; i < formula.length; i++) {
|
144
|
+
f = formula[i];
|
145
|
+
if (!invalidDict[f]) {
|
146
|
+
fields.push(f);
|
147
|
+
}
|
140
148
|
}
|
141
|
-
}
|
142
149
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
150
|
+
var fieldCount = fields.length;
|
151
|
+
// formula = payload.formula.trim().split(",TR"); // TODO: split wit
|
152
|
+
|
153
|
+
rows.push([
|
154
|
+
{
|
155
|
+
"h": true,
|
156
|
+
"i": "instrument",
|
157
|
+
"v": "Instrument"
|
158
|
+
},
|
159
|
+
{
|
160
|
+
"h": true,
|
161
|
+
"i": "date",
|
162
|
+
"v": "Date"
|
163
|
+
}
|
164
|
+
]);
|
165
|
+
|
166
|
+
for (var index = 0; index < fieldCount; index++) {
|
167
|
+
var timeSeriesField = fields[index];
|
168
|
+
|
169
|
+
var regex = /TR.(.*)(?=\()/;
|
170
|
+
var result = timeSeriesField.match(regex);
|
171
|
+
var field = result[0].replace("TR.", "");
|
172
|
+
var phrase = timeSeriesField.toLowerCase();
|
173
|
+
var startDateRegex = /sdate=(.*)[,]/;
|
174
|
+
var endDateRegex = /edate=(.*)[)]/;
|
175
|
+
var startDateMatch = phrase.match(startDateRegex);
|
176
|
+
var endDateMatch = phrase.match(endDateRegex);
|
177
|
+
|
178
|
+
var startDate = startDateMatch ? startDateMatch[1] : DateTime.format(new Date(), "YYYY-MM-DD");
|
179
|
+
var endDate = endDateMatch[1];
|
180
|
+
|
181
|
+
var swapDateTmp;
|
182
|
+
if(startDate > endDate) {
|
183
|
+
swapDateTmp = startDate;
|
184
|
+
startDate = endDate;
|
185
|
+
endDate = swapDateTmp;
|
186
|
+
}
|
187
|
+
|
188
|
+
var msBetweenDate = (+new Date(endDate)) - (+new Date(startDate));
|
189
|
+
|
190
|
+
var msInDay = 1000 * 60 * 60 * 24;
|
191
|
+
var betweenDay = msBetweenDate / msInDay;
|
192
|
+
// var betweenDay = Math.floor(Math.random() * 10); // For random length
|
193
|
+
|
194
|
+
|
195
|
+
for (i = 0; i <= betweenDay; i++) {
|
196
|
+
var date = new Date(new Date(startDate).setDate(new Date(startDate).getDate() + i));
|
197
|
+
var fieldValue = {
|
198
|
+
"h": true,
|
199
|
+
"v": DateTime.format(date, "YYYY-MM-DDT00:00:00")
|
200
|
+
};
|
201
|
+
if(index === 0) { // add header 1 time
|
202
|
+
rows[0].push(fieldValue);
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
var rics = identifiers;
|
207
|
+
for (i = 0; i < rics.length; i++) {
|
208
|
+
|
209
|
+
var ric = rics[i];
|
210
|
+
var rowValue = [
|
211
|
+
ric,
|
212
|
+
field
|
213
|
+
];
|
214
|
+
for (j = 1; j <= betweenDay + 1; j++) {
|
215
|
+
var generatedValue = DataGenerator.generateRecord(field);
|
216
|
+
rowValue.push(generatedValue[field]);
|
217
|
+
|
218
|
+
}
|
219
|
+
rows.push(rowValue);
|
220
|
+
}
|
221
|
+
// The example rows should be look like
|
222
|
+
/*
|
223
|
+
[
|
224
|
+
[
|
225
|
+
{
|
226
|
+
"h": true,
|
227
|
+
"i": "instrument",
|
228
|
+
"v": "Instrument"
|
229
|
+
},
|
230
|
+
{
|
231
|
+
"h": true,
|
232
|
+
"i": "date",
|
233
|
+
"v": "Date"
|
234
|
+
},
|
235
|
+
{
|
236
|
+
"h": true,
|
237
|
+
"v": "2011-08-11T00:00:00"
|
238
|
+
},
|
239
|
+
{
|
240
|
+
"h": true,
|
241
|
+
"v": "2011-08-12T00:00:00"
|
242
|
+
},
|
243
|
+
{
|
244
|
+
"h": true,
|
245
|
+
"v": "2011-08-15T00:00:00"
|
246
|
+
}
|
247
|
+
],
|
248
|
+
[
|
249
|
+
"IBM",
|
250
|
+
"Price Close", // NOTE: this cannot be detech we join it with space Ex. PriceClose
|
251
|
+
159.25449372,
|
252
|
+
160.6585848,
|
253
|
+
165.23382036
|
254
|
+
],
|
255
|
+
[
|
256
|
+
"GOOGL.O",
|
257
|
+
"Price Close",
|
258
|
+
14.066881653,
|
259
|
+
14.107921423,
|
260
|
+
13.944262828
|
261
|
+
]
|
262
|
+
]
|
263
|
+
*/
|
264
|
+
}
|
265
|
+
|
266
|
+
} else {
|
267
|
+
|
268
|
+
identifiers = payload.identifiers;
|
269
|
+
formula = payload.formula.trim().split(","); // TODO: check each field with another way, this doesn't work when user use some comma (,) formula
|
270
|
+
fields = [];
|
271
|
+
|
272
|
+
// _invalidFieldDict is a dictionary of non exist field
|
273
|
+
// so we must remove invalid field to make "mocking api" return result more like a "real api".
|
274
|
+
invalidDict = _invalidFieldDict;
|
275
|
+
for (i = 0; i < formula.length; i++) {
|
276
|
+
f = formula[i];
|
277
|
+
if (!invalidDict[f]) {
|
278
|
+
fields.push(f);
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
rows[0] = [{
|
153
283
|
"h": true,
|
154
|
-
"
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
284
|
+
"i": "instrument",
|
285
|
+
"v": "Instrument"
|
286
|
+
}];
|
287
|
+
for (i = 0; i < fields.length; i++) {
|
288
|
+
f = fields[i];
|
289
|
+
rows[0].push({
|
290
|
+
"h": true,
|
291
|
+
"r": f.toUpperCase().trim()
|
292
|
+
// "v": "Price Close", // Doesn't use
|
293
|
+
// "p": "I_TRP_PH_PriceClose" // Doesn't use this property
|
294
|
+
});
|
295
|
+
}
|
159
296
|
|
160
|
-
|
161
|
-
|
297
|
+
// build data
|
298
|
+
var rowMap = {};
|
162
299
|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
300
|
+
len = identifiers.length;
|
301
|
+
var rowData = dataGen.generate(fields, len);
|
302
|
+
for (i = 0; i < len; ++i) {
|
303
|
+
var inst = identifiers[i];
|
304
|
+
row = rowMap[inst];
|
305
|
+
if (!row) {
|
306
|
+
row = rowMap[inst] = rowData[i];
|
307
|
+
row.unshift(inst); // prepend instrument on each row
|
308
|
+
}
|
309
|
+
rows.push(row);
|
171
310
|
}
|
172
|
-
rows.push(row);
|
173
|
-
}
|
174
311
|
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
312
|
+
// There is a chance that rtk will return multiple row data per instrument
|
313
|
+
// so we must create mock up for this case
|
314
|
+
if (rows.length > 0) {
|
315
|
+
var chance = dataGen.randInt(1, 10);
|
316
|
+
if (chance <= 3) { // chance 30%
|
317
|
+
var pos = dataGen.randInt(0, rows.length - 1); // random row pos
|
318
|
+
row = rows[pos];
|
319
|
+
len = row.length;
|
320
|
+
var mockupRow = new Array(len);
|
321
|
+
mockupRow[0] = row[0]; // 1st index is for instrument
|
322
|
+
for (i = 1; i < len; i++) {
|
323
|
+
mockupRow[i] = ''; // real case will return null or empty string
|
324
|
+
}
|
325
|
+
rows.splice(pos + 1, 0, mockupRow);
|
187
326
|
}
|
188
|
-
rows.splice(pos + 1, 0, mockupRow);
|
189
327
|
}
|
190
328
|
}
|
191
329
|
|
330
|
+
|
192
331
|
/*
|
193
332
|
response type is :
|
194
333
|
{
|
@@ -30,7 +30,14 @@ declare namespace ColumnStackPlugin {
|
|
30
30
|
spreading?: boolean|null,
|
31
31
|
collapsed?: boolean|null,
|
32
32
|
children: (string)[]|null,
|
33
|
-
name?: string|null
|
33
|
+
name?: string|null,
|
34
|
+
activeColumn?: string|null
|
35
|
+
};
|
36
|
+
|
37
|
+
type StackConfiguration = {
|
38
|
+
spreading?: boolean|null,
|
39
|
+
collapsed?: boolean|null,
|
40
|
+
activeColumn?: string|null
|
34
41
|
};
|
35
42
|
|
36
43
|
}
|
@@ -75,9 +82,9 @@ declare class ColumnStackPlugin extends GridPlugin {
|
|
75
82
|
|
76
83
|
public getStackId(colIndex: number): string;
|
77
84
|
|
78
|
-
public stackColumns(colRefs?: (number|string)[]|null, stackId?: string|null, options?:
|
85
|
+
public stackColumns(colRefs?: (number|string)[]|null, stackId?: string|null, options?: ColumnStackPlugin.StackConfiguration|null): boolean;
|
79
86
|
|
80
|
-
public setStack(colRefs?: (number|string)[]|null): boolean;
|
87
|
+
public setStack(colRefs?: (number|string)[]|null, activeColRef?: number|string|null): boolean;
|
81
88
|
|
82
89
|
public unstackColumns(colIndices?: (number)[]|null): boolean;
|
83
90
|
|