@refinitiv-ui/efx-grid 6.0.21 → 6.0.22
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/column-dragging/es6/ColumnDragging.js +46 -24
- package/lib/core/dist/core.js +61 -14
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.js +11 -1
- package/lib/core/es6/grid/LayoutGrid.js +1 -0
- package/lib/core/es6/grid/components/CellSpans.d.ts +2 -0
- package/lib/core/es6/grid/components/CellSpans.js +35 -10
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.d.ts +2 -0
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +14 -3
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +239 -37
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.d.ts +4 -1
- package/lib/rt-grid/es6/Grid.js +73 -13
- package/lib/rt-grid/es6/ReferenceCounter.js +13 -2
- package/lib/rt-grid/es6/RowDefinition.d.ts +2 -0
- package/lib/rt-grid/es6/RowDefinition.js +74 -8
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +5 -1
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +228 -55
- package/lib/types/es6/ColumnGrouping.d.ts +5 -1
- package/lib/types/es6/Core/grid/components/CellSpans.d.ts +2 -0
- package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +2 -0
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +4 -1
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +2 -0
- package/lib/versions.json +2 -2
- package/package.json +3 -2
@@ -80,7 +80,8 @@ declare namespace Grid {
|
|
80
80
|
scrollbarParent?: Element|null,
|
81
81
|
formulaEngine?: boolean|null,
|
82
82
|
adcPollingInterval?: number|null,
|
83
|
-
fieldCaching?: boolean|null
|
83
|
+
fieldCaching?: boolean|null,
|
84
|
+
childDataField?: string|null
|
84
85
|
};
|
85
86
|
|
86
87
|
type RowReference = number|string|RowDefinition|null;
|
@@ -143,6 +144,8 @@ declare class Grid extends EventDispatcher {
|
|
143
144
|
|
144
145
|
public moveColumnById(srcCol: number|string|null, destCol?: (number|string)|null): boolean;
|
145
146
|
|
147
|
+
public reorderColumns(colRefs: number|string|(number|string)[]|null, destCol: number|string|null): boolean;
|
148
|
+
|
146
149
|
public hideColumn(colRef: Grid.ColumnReference|null, hidden?: boolean|null): void;
|
147
150
|
|
148
151
|
public hideColumns(colRefs: (Grid.ColumnReference)[]|null, hidden?: boolean|null): void;
|
package/lib/rt-grid/es6/Grid.js
CHANGED
@@ -84,6 +84,7 @@ import { ElementWrapper } from "../../core/es6/grid/components/ElementWrapper.js
|
|
84
84
|
* @property {boolean=} formulaEngine=false If enabled, field with leading equal sign will be treated as a formula and rows will be filled with the calculated values.
|
85
85
|
* @property {number=} adcPollingInterval=0 Length of polling interval for refreshing ADC data in milliseconds. The default value (0) means no polling.
|
86
86
|
* @property {boolean=} fieldCaching=false If enabled, field definition will be caching internal mechanism
|
87
|
+
* @property {string=} childDataField=CHILD_VALUES The given field will be used to store children's static data, such as row color assignment.
|
87
88
|
*/
|
88
89
|
|
89
90
|
/** @typedef {number|string|RowDefinition} Grid~RowReference
|
@@ -546,6 +547,10 @@ Grid.prototype._pollingEnabled = true;
|
|
546
547
|
* @private
|
547
548
|
*/
|
548
549
|
Grid.prototype._fieldCaching = false;
|
550
|
+
/** @type {string}
|
551
|
+
* @private
|
552
|
+
*/
|
553
|
+
Grid.prototype._childDataField = "";
|
549
554
|
|
550
555
|
|
551
556
|
/** @public
|
@@ -960,6 +965,9 @@ Grid.prototype.initialize = function(gridOption) {
|
|
960
965
|
}
|
961
966
|
|
962
967
|
// Row operations
|
968
|
+
if(gridOption["childDataField"] != null) {
|
969
|
+
this._childDataField = RowDefinition._childDataField = gridOption["childDataField"];
|
970
|
+
}
|
963
971
|
var rows = gridOption["rows"];
|
964
972
|
if(!rows) {
|
965
973
|
rows = gridOption["rics"] || null; // Make "rics" an alias to "rows"
|
@@ -1115,6 +1123,10 @@ Grid.prototype.getConfigObject = function (gridOptions) {
|
|
1115
1123
|
obj["fieldCaching"] = this._fieldCaching;
|
1116
1124
|
}
|
1117
1125
|
|
1126
|
+
if(this._childDataField) {
|
1127
|
+
obj["childDataField"] = this._childDataField;
|
1128
|
+
}
|
1129
|
+
|
1118
1130
|
// get all rows config
|
1119
1131
|
var rowDefs = this.getAllRowDefinitions();
|
1120
1132
|
var rows = obj["rows"] = [];
|
@@ -1252,9 +1264,8 @@ Grid.prototype._onFieldAdded = function(e) {
|
|
1252
1264
|
|
1253
1265
|
// JET
|
1254
1266
|
if (this._subs) {
|
1255
|
-
var
|
1256
|
-
|
1257
|
-
this._subs["addFields"](fields);
|
1267
|
+
var realtimeFields = addedFields.filter(ColumnDefinition.isRealTimeField);
|
1268
|
+
this._subs["addFields"](realtimeFields);
|
1258
1269
|
}
|
1259
1270
|
|
1260
1271
|
this._dispatch(e.type, e);
|
@@ -1265,6 +1276,7 @@ Grid.prototype._onFieldAdded = function(e) {
|
|
1265
1276
|
Grid.prototype._onFieldRemoved = function(e) {
|
1266
1277
|
var removedFields = e.removedFields;
|
1267
1278
|
|
1279
|
+
// TODO: ADC fields have an interval load. Currently, we only keep the field but do not delete it.
|
1268
1280
|
// JET
|
1269
1281
|
if(this._subs) {
|
1270
1282
|
this._subs["removeFields"](removedFields);
|
@@ -1518,15 +1530,7 @@ Grid.prototype._onFieldLoadedError = function (err) {
|
|
1518
1530
|
* @param {string} referrer
|
1519
1531
|
*/
|
1520
1532
|
Grid.prototype._onFieldLoaded = function (field, referrer) {
|
1521
|
-
|
1522
|
-
var colIndex = this.getColumnIndex(field);
|
1523
|
-
if(colIndex > -1) {
|
1524
|
-
var colDef = this._getColumnDefinition(field);
|
1525
|
-
if(colDef.isTimeSeriesField()) {
|
1526
|
-
this._insertTimeSeriesChildren(colDef);
|
1527
|
-
}
|
1528
|
-
this._connector.addFields(field, referrer);
|
1529
|
-
}
|
1533
|
+
this._connector.addFields(field, referrer);
|
1530
1534
|
};
|
1531
1535
|
|
1532
1536
|
/**
|
@@ -1845,6 +1849,62 @@ Grid.prototype.moveColumnById = function (srcCol, destCol) {
|
|
1845
1849
|
return this.moveColumn(srcIndex, destIndex);
|
1846
1850
|
};
|
1847
1851
|
|
1852
|
+
/** @public
|
1853
|
+
* @param {number|string|Array.<number|string>} colRefs List of column index or column id to be moved
|
1854
|
+
* @param {number|string} destCol Destination position where the moved columns will be placed BEFORE the specified position. This can be column id or index
|
1855
|
+
* @return {boolean} Return true if there is any change, and false otherwise
|
1856
|
+
*/
|
1857
|
+
Grid.prototype.reorderColumns = function (colRefs, destCol) {
|
1858
|
+
var destId = (typeof destCol === "number") ? this.getColumnId(destCol) : destCol;
|
1859
|
+
|
1860
|
+
if(Array.isArray(colRefs)) {
|
1861
|
+
var srcLen = colRefs.length;
|
1862
|
+
if(srcLen > 1) {
|
1863
|
+
var colIds = this.getColumnIds();
|
1864
|
+
var srcIds = [];
|
1865
|
+
var invalidDest = false;
|
1866
|
+
var i;
|
1867
|
+
for(i = 0; i < srcLen; ++i) {
|
1868
|
+
var colRef = colRefs[i];
|
1869
|
+
var srcId = (typeof colRef === "number") ? colIds[colRef] : colRef;
|
1870
|
+
if(srcId) {
|
1871
|
+
srcIds.push(srcId);
|
1872
|
+
if(destId === srcId) {
|
1873
|
+
invalidDest = true; // Destination must not exist in source columns
|
1874
|
+
}
|
1875
|
+
}
|
1876
|
+
}
|
1877
|
+
srcLen = srcIds.length;
|
1878
|
+
if(invalidDest) { // Find the next valid destination where it is not contained in the source columns
|
1879
|
+
var colCount = colIds.length;
|
1880
|
+
var destIdx = this.getColumnIndex(destId);
|
1881
|
+
if(destIdx >= 0) {
|
1882
|
+
while(++destIdx < colCount) {
|
1883
|
+
destId = colIds[destIdx];
|
1884
|
+
if(srcIds.indexOf(destId) < 0) {
|
1885
|
+
break;
|
1886
|
+
}
|
1887
|
+
}
|
1888
|
+
}
|
1889
|
+
if(destIdx < 0 || destIdx >= colCount) {
|
1890
|
+
destId = "";
|
1891
|
+
}
|
1892
|
+
}
|
1893
|
+
|
1894
|
+
var dirty = 0;
|
1895
|
+
for(i = 0; i < srcLen; ++i) {
|
1896
|
+
dirty |= this.moveColumnById(srcIds[i], destId);
|
1897
|
+
}
|
1898
|
+
// TODO: Handle the case where all columns stay in the same place
|
1899
|
+
return dirty ? true : false;
|
1900
|
+
} else {
|
1901
|
+
return this.moveColumnById(colRefs[0], destId);
|
1902
|
+
}
|
1903
|
+
}
|
1904
|
+
|
1905
|
+
// colRefs will be a number or string
|
1906
|
+
return this.moveColumnById(colRefs, destId);
|
1907
|
+
};
|
1848
1908
|
|
1849
1909
|
/** The hidden column still occupies the same index.
|
1850
1910
|
* @public
|
@@ -3035,7 +3095,7 @@ Grid.prototype.unpinColumn = function(colRef, dest) {
|
|
3035
3095
|
var len = ary.length;
|
3036
3096
|
|
3037
3097
|
var dirty = 0;
|
3038
|
-
for(var i =
|
3098
|
+
for(var i = len; --i >= 0;) { // WARNING: unpinning is done in reversed order
|
3039
3099
|
dirty |= this._unpinColumn(ary[i], dest);
|
3040
3100
|
}
|
3041
3101
|
return dirty ? true : false;
|
@@ -66,6 +66,7 @@ ReferenceCounter.prototype.getSession = function() {
|
|
66
66
|
} else if(val < 0) {
|
67
67
|
removedEntries.push(key);
|
68
68
|
}
|
69
|
+
// else {} // when val 0 do nothing, doesn't change anything
|
69
70
|
}
|
70
71
|
return {
|
71
72
|
newEntries: newEntries.filter(Boolean),
|
@@ -94,9 +95,15 @@ ReferenceCounter.prototype.addReference = function(key, referer) {
|
|
94
95
|
|
95
96
|
if(this._counter[key]) {
|
96
97
|
++this._counter[key];
|
98
|
+
// The session will not change when a field already exists and a counter is attempted to be added
|
97
99
|
} else {
|
98
100
|
this._counter[key] = 1;
|
99
|
-
this._session[key]
|
101
|
+
if(this._session[key] === -1) {
|
102
|
+
this._session[key] = 0;
|
103
|
+
} else {
|
104
|
+
this._session[key] = 1;
|
105
|
+
}
|
106
|
+
|
100
107
|
return true;
|
101
108
|
}
|
102
109
|
}
|
@@ -146,7 +153,11 @@ ReferenceCounter.prototype.removeReference = function(key, referer, count) {
|
|
146
153
|
val -= count;
|
147
154
|
if(!val || val < 0) {
|
148
155
|
delete this._counter[key];
|
149
|
-
this._session[key]
|
156
|
+
if(this._session[key] === 1) {
|
157
|
+
this._session[key] = 0;
|
158
|
+
} else {
|
159
|
+
this._session[key] = -1;
|
160
|
+
}
|
150
161
|
return true;
|
151
162
|
}
|
152
163
|
|
@@ -45,6 +45,8 @@ declare class RowDefinition {
|
|
45
45
|
|
46
46
|
public setStaticRowData(data: { [key: string]: any }|any[], opt_fields?: (string)[]|null): void;
|
47
47
|
|
48
|
+
public _getStaticRowData(): { [key: string]: any };
|
49
|
+
|
48
50
|
public updateRowData(data: { [key: string]: any }|any[], opt_fields?: (string)[]|null): void;
|
49
51
|
|
50
52
|
public setStaticData(field: string, value: any): void;
|
@@ -50,6 +50,10 @@ var RowDefinition = function(rowOptions) {
|
|
50
50
|
* @private
|
51
51
|
*/
|
52
52
|
RowDefinition._runningId = 0;
|
53
|
+
/** @type {string}
|
54
|
+
* @private
|
55
|
+
*/
|
56
|
+
RowDefinition._childDataField = "CHILD_VALUES";
|
53
57
|
//#region Private Members
|
54
58
|
/** @type {string}
|
55
59
|
* @private
|
@@ -240,7 +244,11 @@ RowDefinition.prototype._initializeAsConstituent = function(rowOptions) {
|
|
240
244
|
}
|
241
245
|
}
|
242
246
|
}
|
243
|
-
|
247
|
+
var val = rowOptions["values"];
|
248
|
+
// eslint-disable-next-line no-undefined
|
249
|
+
if(val !== undefined) {
|
250
|
+
this.setStaticRowData(val, rowOptions["fields"]);
|
251
|
+
}
|
244
252
|
};
|
245
253
|
/** @public
|
246
254
|
* @param {string} userInput
|
@@ -312,11 +320,6 @@ RowDefinition.prototype.getConfigObject = function(rowOptions) {
|
|
312
320
|
obj["ric"] = val;
|
313
321
|
}
|
314
322
|
|
315
|
-
val = this._staticValues;
|
316
|
-
if(val) {
|
317
|
-
obj["values"] = cloneObject(val);
|
318
|
-
}
|
319
|
-
|
320
323
|
val = this._chainRic;
|
321
324
|
if(val) {
|
322
325
|
obj["chainRic"] = val;
|
@@ -348,6 +351,40 @@ RowDefinition.prototype.getConfigObject = function(rowOptions) {
|
|
348
351
|
obj["hidden"] = val;
|
349
352
|
}
|
350
353
|
|
354
|
+
val = this._getStaticRowData();
|
355
|
+
if(val) {
|
356
|
+
obj["values"] = val;
|
357
|
+
}
|
358
|
+
|
359
|
+
// obtain the static values of constituent rows
|
360
|
+
if(this.isChain()) {
|
361
|
+
var children = this.getChildren();
|
362
|
+
if(children) {
|
363
|
+
var childValues = val ? val[RowDefinition._childDataField] : {};
|
364
|
+
if(!childValues) {
|
365
|
+
childValues = {};
|
366
|
+
}
|
367
|
+
var dirty = false;
|
368
|
+
var len = children.length;
|
369
|
+
var i, rowDef, staticValues;
|
370
|
+
for(i = 0; i < len; i++) {
|
371
|
+
rowDef = children[i];
|
372
|
+
staticValues = rowDef._getStaticRowData();
|
373
|
+
if(staticValues) {
|
374
|
+
dirty = true;
|
375
|
+
childValues[rowDef.getRic()] = staticValues;
|
376
|
+
}
|
377
|
+
}
|
378
|
+
|
379
|
+
if(dirty) {
|
380
|
+
if(!obj["values"]) {
|
381
|
+
obj["values"] = {};
|
382
|
+
}
|
383
|
+
obj["values"][RowDefinition._childDataField] = childValues;
|
384
|
+
}
|
385
|
+
}
|
386
|
+
}
|
387
|
+
|
351
388
|
return obj;
|
352
389
|
};
|
353
390
|
/** Since an index chain (e.g. .FTSE) can automatically produce rows for its constituent, we need to separate rowId and dataId, so that the constituents still use the same data Id as that of its parent.
|
@@ -422,6 +459,12 @@ RowDefinition.prototype.setStaticRowData = function(data, opt_fields) {
|
|
422
459
|
}
|
423
460
|
};
|
424
461
|
/** @public
|
462
|
+
* @return {Object.<string, *>}
|
463
|
+
*/
|
464
|
+
RowDefinition.prototype._getStaticRowData = function() {
|
465
|
+
return this._staticValues ? cloneObject(this._staticValues) : null;
|
466
|
+
};
|
467
|
+
/** @public
|
425
468
|
* @param {Object.<string, *>|Array} data
|
426
469
|
* @param {Array.<string>=} opt_fields In case of the given data is an array, this param will be used for mapping index to field
|
427
470
|
*/
|
@@ -722,6 +765,22 @@ RowDefinition.deregisterFromView = function(rowIds, rowDef) {
|
|
722
765
|
rowDef._deregisterFromView(rowIds);
|
723
766
|
return rowIds;
|
724
767
|
};
|
768
|
+
/** @private
|
769
|
+
* @param {string} ric
|
770
|
+
* @return {Object}
|
771
|
+
*/
|
772
|
+
RowDefinition.prototype._getChildStaticRowData = function(ric) {
|
773
|
+
if(!this._staticValues) {
|
774
|
+
return null;
|
775
|
+
}
|
776
|
+
|
777
|
+
var childValues = this._staticValues[RowDefinition._childDataField];
|
778
|
+
if(!childValues) {
|
779
|
+
return null;
|
780
|
+
}
|
781
|
+
|
782
|
+
return childValues[ric] || null;
|
783
|
+
};
|
725
784
|
/** @public
|
726
785
|
* @ignore
|
727
786
|
* @param {string} ric
|
@@ -749,12 +808,19 @@ RowDefinition.prototype.addConstituent = function(ric) {
|
|
749
808
|
|
750
809
|
var newChild = !childDef;
|
751
810
|
if(newChild) {
|
752
|
-
|
811
|
+
var rowOptions = {
|
753
812
|
"asConstituent": true,
|
754
813
|
"dataId": this._subId + ric,
|
755
814
|
"ric": ric,
|
756
815
|
"parent": this
|
757
|
-
}
|
816
|
+
};
|
817
|
+
|
818
|
+
var staticData = this._getChildStaticRowData(ric);
|
819
|
+
if(staticData) {
|
820
|
+
rowOptions["values"] = staticData;
|
821
|
+
}
|
822
|
+
|
823
|
+
childDef = new RowDefinition(rowOptions);
|
758
824
|
}
|
759
825
|
|
760
826
|
if(this._view) {
|
@@ -48,7 +48,7 @@ declare class ColumnGroupingPlugin extends GridPlugin {
|
|
48
48
|
|
49
49
|
public getGroupDefinitions(): ColumnGroupingPlugin.GroupDefinitions;
|
50
50
|
|
51
|
-
public setGroupDefinition(groupId: string,
|
51
|
+
public setGroupDefinition(groupId: string, groupDef?: ColumnGroupingPlugin.GroupDefinition|null): string;
|
52
52
|
|
53
53
|
public setGroupDefinitions(groupDefs: ColumnGroupingPlugin.GroupDefinitions|null): void;
|
54
54
|
|
@@ -70,6 +70,10 @@ declare class ColumnGroupingPlugin extends GridPlugin {
|
|
70
70
|
|
71
71
|
public setColumnParent(colRef: number|string|null, groupId: string): void;
|
72
72
|
|
73
|
+
public getValidDestinationIndex(id: string, destCol: number|string|null): number;
|
74
|
+
|
75
|
+
public moveGroup(id: string, destCol: number|string|null): void;
|
76
|
+
|
73
77
|
}
|
74
78
|
|
75
79
|
export default ColumnGroupingPlugin;
|