@refinitiv-ui/efx-grid 6.0.86 → 6.0.88
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/column-dragging/es6/ColumnDragging.js +55 -0
- package/lib/column-format-dialog/lib/column-format-dialog.js +5 -8
- package/lib/column-format-dialog/lib/preview-table.d.ts +1 -1
- package/lib/column-format-dialog/lib/preview-table.js +15 -15
- package/lib/column-selection-dialog/themes/base.less +0 -1
- package/lib/column-selection-dialog/themes/elemental/dark/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/dark/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/light/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/elemental/light/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/halo/dark/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/halo/light/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/solar/charcoal/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/solar/charcoal/es5/all-elements.js +1 -1
- package/lib/column-selection-dialog/themes/solar/pearl/column-selection-dialog.js +1 -1
- package/lib/column-selection-dialog/themes/solar/pearl/es5/all-elements.js +1 -1
- package/lib/core/dist/core.js +8 -2
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataView.js +1 -1
- package/lib/core/es6/grid/Core.d.ts +2 -0
- package/lib/core/es6/grid/Core.js +7 -1
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +789 -712
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.js +70 -70
- package/lib/rt-grid/es6/DataConnector.js +26 -26
- package/lib/rt-grid/es6/FieldDefinition.js +27 -27
- package/lib/rt-grid/es6/Grid.js +385 -376
- package/lib/rt-grid/es6/PredefinedFormula.js +1 -1
- package/lib/rt-grid/es6/ReferenceCounter.js +15 -15
- package/lib/rt-grid/es6/RowDefSorter.js +26 -26
- package/lib/rt-grid/es6/RowDefinition.d.ts +5 -2
- package/lib/rt-grid/es6/RowDefinition.js +106 -77
- package/lib/rt-grid/es6/SnapshotFiller.js +77 -77
- package/lib/rt-grid/es6/StyleLoader.js +1 -1
- package/lib/tr-grid-percent-bar/es6/PercentBar.d.ts +18 -18
- package/lib/tr-grid-percent-bar/es6/PercentBar.js +4 -0
- package/lib/tr-grid-range-bar/es6/RangeBar.js +4 -1
- package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +2 -0
- package/lib/tr-grid-row-filtering/es6/RowFiltering.js +31 -19
- package/lib/tr-grid-util/es6/DragUI.js +2 -1
- package/lib/types/es6/Checkbox.d.ts +2 -0
- package/lib/types/es6/Core/grid/Core.d.ts +2 -0
- package/lib/types/es6/PercentBar.d.ts +18 -18
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +5 -2
- package/lib/types/es6/RowFiltering.d.ts +2 -0
- package/lib/versions.json +7 -7
- package/package.json +1 -1
@@ -49,14 +49,14 @@ import Engine from "../../tr-grid-util/es6/formula/Engine.js";
|
|
49
49
|
* @property {boolean=} stationary=false If enabled, the column order cannot be changed (i.e., this column and any column to its left cannot be moved)
|
50
50
|
* @property {boolean=} leftPinned=false If enabled, the column will not be part of the scrollable area and is pinned to the left side
|
51
51
|
* @property {boolean=} rightPinned=false If enabled, the column will not be part of the scrollable area and is pinned to the right side
|
52
|
-
* @property {Object=} info=null
|
52
|
+
* @property {Object=} info=null For storing any additional information to the column
|
53
53
|
*/
|
54
54
|
|
55
55
|
/** mapping of field type to javascript type
|
56
56
|
* @type {Object.<string, string>}
|
57
57
|
* @private
|
58
58
|
*/
|
59
|
-
|
59
|
+
const TYPE_MAPPING = {
|
60
60
|
STRING: "string",
|
61
61
|
BOOLEAN: "boolean",
|
62
62
|
NUMBER: "number",
|
@@ -82,15 +82,15 @@ var TYPE_MAPPING = {
|
|
82
82
|
* @public
|
83
83
|
* @const
|
84
84
|
*/
|
85
|
-
|
85
|
+
const COL_DEF = "COL_DEF";
|
86
86
|
|
87
87
|
/** @private
|
88
88
|
* @param {string} str
|
89
89
|
* @return {string}
|
90
90
|
*/
|
91
|
-
|
91
|
+
let _toAlignment = function(str) {
|
92
92
|
if(str) {
|
93
|
-
|
93
|
+
let ch = str.charAt(0).toLowerCase();
|
94
94
|
if(ch === "l") {
|
95
95
|
return "left";
|
96
96
|
}
|
@@ -108,7 +108,7 @@ var _toAlignment = function(str) {
|
|
108
108
|
* @param {ColumnDefinition~Options=} columnOption
|
109
109
|
* @param {*=} hostGrid
|
110
110
|
*/
|
111
|
-
|
111
|
+
let ColumnDefinition = function(columnOption, hostGrid) {
|
112
112
|
this._defaultRenderer = this._defaultRenderer.bind(this);
|
113
113
|
this._customRenderer = this._customRenderer.bind(this);
|
114
114
|
|
@@ -280,7 +280,7 @@ ColumnDefinition.prototype.dispose = function() {
|
|
280
280
|
*/
|
281
281
|
ColumnDefinition.prototype._initializeTimeSeriesChild = function(columnOption) {
|
282
282
|
this._autoGenerated = true;
|
283
|
-
|
283
|
+
let parentDef = /** @type{ColumnDefinition} */(columnOption["parent"]);
|
284
284
|
this._setParent(parentDef);
|
285
285
|
this.initialize(columnOption);
|
286
286
|
};
|
@@ -292,13 +292,13 @@ ColumnDefinition.prototype.initialize = function(columnOption) {
|
|
292
292
|
return;
|
293
293
|
}
|
294
294
|
|
295
|
-
|
295
|
+
let i, len, key, val;
|
296
296
|
//#region Apply pre-defined option
|
297
|
-
|
298
|
-
|
297
|
+
let field = columnOption["field"]; // Field could be null or undefined here
|
298
|
+
let defaultOption = FieldDefinition.get(field);
|
299
299
|
if(defaultOption && defaultOption !== columnOption) { // The column match the default field list
|
300
300
|
// WARNING: This changes reference of the user object. Any new property added won't affect anything outside of this method
|
301
|
-
|
301
|
+
let userOption = columnOption;
|
302
302
|
columnOption = {}; // Create a new object for cloning process
|
303
303
|
|
304
304
|
for(key in defaultOption) {
|
@@ -489,7 +489,7 @@ ColumnDefinition.prototype.getFieldDefinition = function () {
|
|
489
489
|
* @return {string}
|
490
490
|
*/
|
491
491
|
ColumnDefinition.prototype.getFieldDataType = function () {
|
492
|
-
|
492
|
+
let fieldDef = this.getFieldDefinition();
|
493
493
|
if(fieldDef && fieldDef.fieldDataType) {
|
494
494
|
return fieldDef.fieldDataType;
|
495
495
|
}
|
@@ -502,7 +502,7 @@ ColumnDefinition.prototype.getFieldDataType = function () {
|
|
502
502
|
ColumnDefinition.prototype.getDataType = function () {
|
503
503
|
if(this._dataType) return this._dataType;
|
504
504
|
|
505
|
-
|
505
|
+
let fieldDataType = this.getFieldDataType();
|
506
506
|
if(fieldDataType) {
|
507
507
|
return TYPE_MAPPING[fieldDataType.toUpperCase()];
|
508
508
|
}
|
@@ -513,7 +513,7 @@ ColumnDefinition.prototype.getDataType = function () {
|
|
513
513
|
* @param {string} dataType
|
514
514
|
*/
|
515
515
|
ColumnDefinition.prototype.setDataType = function (dataType) {
|
516
|
-
|
516
|
+
let val = TYPE_MAPPING[dataType.toUpperCase()];
|
517
517
|
if(val) {
|
518
518
|
dataType = val;
|
519
519
|
}
|
@@ -525,9 +525,9 @@ ColumnDefinition.prototype.setDataType = function (dataType) {
|
|
525
525
|
* @return {string}
|
526
526
|
*/
|
527
527
|
ColumnDefinition.getDataType = function(field) {
|
528
|
-
|
528
|
+
let fieldDef = FieldDefinition.get(field);
|
529
529
|
if(fieldDef) {
|
530
|
-
|
530
|
+
let fieldDataType = fieldDef.fieldDataType ? fieldDef.fieldDataType.toUpperCase() : null;
|
531
531
|
return TYPE_MAPPING[fieldDataType] ? TYPE_MAPPING[fieldDataType] : "";
|
532
532
|
}
|
533
533
|
return "";
|
@@ -544,12 +544,12 @@ ColumnDefinition.prototype.getTooltip = function() {
|
|
544
544
|
}
|
545
545
|
}
|
546
546
|
|
547
|
-
|
547
|
+
let name = this.getName();
|
548
548
|
if(name) {
|
549
549
|
return name;
|
550
550
|
}
|
551
551
|
|
552
|
-
|
552
|
+
let field = this.getField();
|
553
553
|
if(field) {
|
554
554
|
return field;
|
555
555
|
}
|
@@ -569,7 +569,7 @@ ColumnDefinition.prototype.getField = function() {
|
|
569
569
|
* @return {!Array.<string>}
|
570
570
|
*/
|
571
571
|
ColumnDefinition.prototype.getAllFields = function() {
|
572
|
-
|
572
|
+
let field = this.getField();
|
573
573
|
if(field) {
|
574
574
|
return this._requiredFields.concat(field);
|
575
575
|
}
|
@@ -632,10 +632,10 @@ ColumnDefinition.getRealTimeFields = function(fields, colDef) {
|
|
632
632
|
}
|
633
633
|
|
634
634
|
// TODO: Exclude any formula references from requesting real-time field
|
635
|
-
|
636
|
-
|
637
|
-
for(
|
638
|
-
|
635
|
+
let reqFields = colDef.getRequiredFields();
|
636
|
+
let len = reqFields.length;
|
637
|
+
for(let i = 0; i < len; ++i) {
|
638
|
+
let field = reqFields[i];
|
639
639
|
if(ColumnDefinition.isRealTimeField(field)) {
|
640
640
|
fields.push(field);
|
641
641
|
}
|
@@ -653,9 +653,9 @@ ColumnDefinition.prototype.isSortable = function() {
|
|
653
653
|
* @return {boolean}
|
654
654
|
*/
|
655
655
|
ColumnDefinition.prototype.isScalable = function() {
|
656
|
-
|
657
|
-
|
658
|
-
|
656
|
+
let core = this._eventArg["core"];
|
657
|
+
let grid = this._eventArg["grid"];
|
658
|
+
let colIndex = grid.getColumnIndex(this);
|
659
659
|
return core.getColumnScalability(colIndex);
|
660
660
|
};
|
661
661
|
/** Deprecated, this function will be return initial sort order of this column, The current sort state may be different from initial sort state.
|
@@ -671,27 +671,27 @@ ColumnDefinition.prototype.getInitialSortOrder = function() {
|
|
671
671
|
* @return {number}
|
672
672
|
*/
|
673
673
|
ColumnDefinition.prototype.getWidth = function() {
|
674
|
-
|
675
|
-
|
676
|
-
|
674
|
+
let core = this._eventArg["core"];
|
675
|
+
let grid = this._eventArg["grid"];
|
676
|
+
let colIndex = grid.getColumnIndex(this);
|
677
677
|
return core.getColumnWidth(colIndex);
|
678
678
|
};
|
679
679
|
/** @public
|
680
680
|
* @return {number}
|
681
681
|
*/
|
682
682
|
ColumnDefinition.prototype.getMinWidth = function() {
|
683
|
-
|
684
|
-
|
685
|
-
|
683
|
+
let core = this._eventArg["core"];
|
684
|
+
let grid = this._eventArg["grid"];
|
685
|
+
let colIndex = grid.getColumnIndex(this);
|
686
686
|
return core.getMinimumColumnWidth(colIndex);
|
687
687
|
};
|
688
688
|
/** @public
|
689
689
|
* @return {string}
|
690
690
|
*/
|
691
691
|
ColumnDefinition.prototype.getTextAlign = function() {
|
692
|
-
|
693
|
-
|
694
|
-
|
692
|
+
let core = this._eventArg["core"];
|
693
|
+
let grid = this._eventArg["grid"];
|
694
|
+
let colIndex = grid.getColumnIndex(this);
|
695
695
|
return core.getColumnAlignment(colIndex);
|
696
696
|
};
|
697
697
|
/** @public
|
@@ -718,7 +718,7 @@ ColumnDefinition.prototype.getClasses = function() {
|
|
718
718
|
* @return {!Object}
|
719
719
|
*/
|
720
720
|
ColumnDefinition.prototype.getConfigObject = function(colOptions) {
|
721
|
-
|
721
|
+
let obj = colOptions || {};
|
722
722
|
|
723
723
|
if(this._info){
|
724
724
|
obj["info"] = this._info;
|
@@ -726,14 +726,14 @@ ColumnDefinition.prototype.getConfigObject = function(colOptions) {
|
|
726
726
|
|
727
727
|
if(obj["field"] == null) {
|
728
728
|
if(!this._defaultField) {
|
729
|
-
|
729
|
+
let field = this.getField();
|
730
730
|
if(field) {
|
731
731
|
obj["field"] = field;
|
732
732
|
}
|
733
733
|
}
|
734
734
|
}
|
735
735
|
|
736
|
-
|
736
|
+
let value = this.getDataType();
|
737
737
|
if(value) {
|
738
738
|
obj["dataType"] = value;
|
739
739
|
}
|
@@ -768,7 +768,7 @@ ColumnDefinition.prototype.getConfigObject = function(colOptions) {
|
|
768
768
|
obj["sortable"] = false;
|
769
769
|
}
|
770
770
|
|
771
|
-
|
771
|
+
let classes = this._classes;
|
772
772
|
if(classes && classes.length > 0) {
|
773
773
|
obj["className"] = classes.join(" ");
|
774
774
|
}
|
@@ -785,13 +785,13 @@ ColumnDefinition.prototype.getConfigObject = function(colOptions) {
|
|
785
785
|
obj["autoGenerated"] = this._autoGenerated;
|
786
786
|
}
|
787
787
|
|
788
|
-
|
789
|
-
|
790
|
-
|
788
|
+
let core = this._eventArg["core"];
|
789
|
+
let grid = this._eventArg["grid"];
|
790
|
+
let colIndex = grid.getColumnIndex(this);
|
791
791
|
|
792
792
|
// The scalable, width and minWidth cannot be shifted into core as getConfigObject is accessible from colDef.
|
793
|
-
|
794
|
-
|
793
|
+
let scalable = core.getColumnScalability(colIndex);
|
794
|
+
let width = core.getColumnCustomLaneSize(colIndex);
|
795
795
|
|
796
796
|
if (scalable !== true || width !== 1) {
|
797
797
|
obj["scalable"] = scalable;
|
@@ -799,7 +799,7 @@ ColumnDefinition.prototype.getConfigObject = function(colOptions) {
|
|
799
799
|
}
|
800
800
|
|
801
801
|
value = core.getMinimumColumnWidth(colIndex);
|
802
|
-
if(value
|
802
|
+
if(value > 0) {
|
803
803
|
obj["minWidth"] = value;
|
804
804
|
}
|
805
805
|
|
@@ -821,9 +821,9 @@ ColumnDefinition.prototype.getConfigObject = function(colOptions) {
|
|
821
821
|
* @return {boolean}
|
822
822
|
*/
|
823
823
|
ColumnDefinition.prototype.isHidden = function() {
|
824
|
-
|
825
|
-
|
826
|
-
|
824
|
+
let core = this._eventArg["core"];
|
825
|
+
let grid = this._eventArg["grid"];
|
826
|
+
let colIndex = grid.getColumnIndex(this);
|
827
827
|
return !core.isColumnVisible(colIndex);
|
828
828
|
};
|
829
829
|
/** @public
|
@@ -836,9 +836,9 @@ ColumnDefinition.prototype.isTextSelect = function () {
|
|
836
836
|
* @param {boolean=} bool
|
837
837
|
*/
|
838
838
|
ColumnDefinition.prototype.hide = function(bool) {
|
839
|
-
|
840
|
-
|
841
|
-
|
839
|
+
let core = this._eventArg["core"];
|
840
|
+
let grid = this._eventArg["grid"];
|
841
|
+
let colIndex = grid.getColumnIndex(this);
|
842
842
|
core.hideColumn(colIndex, bool !== false);
|
843
843
|
};
|
844
844
|
/** This will clear all previously stored renderers and set a new one.
|
@@ -901,7 +901,7 @@ ColumnDefinition.prototype.getChildren = function() {
|
|
901
901
|
};
|
902
902
|
/**
|
903
903
|
* @private
|
904
|
-
* @param {
|
904
|
+
* @param {ColumnDefinition} colDef Child column definition
|
905
905
|
*/
|
906
906
|
ColumnDefinition.prototype._addChild = function(colDef) {
|
907
907
|
if(this === colDef || this._children.indexOf(colDef) > -1) {
|
@@ -930,9 +930,9 @@ ColumnDefinition.prototype.addRenderer = function(func) {
|
|
930
930
|
* @return {boolean} Current activation state after the call
|
931
931
|
*/
|
932
932
|
ColumnDefinition.prototype.activateRenderer = function(id, func) {
|
933
|
-
|
933
|
+
let renderer = null;
|
934
934
|
if (id != null) {
|
935
|
-
|
935
|
+
let rendererMap = this._rendererMap;
|
936
936
|
if (!rendererMap) {
|
937
937
|
rendererMap = this._rendererMap = {};
|
938
938
|
}
|
@@ -1003,10 +1003,10 @@ ColumnDefinition.prototype._setField = function(field, columnOption) {
|
|
1003
1003
|
}
|
1004
1004
|
field = field.trim();
|
1005
1005
|
|
1006
|
-
|
1006
|
+
let formulaStr = columnOption ? columnOption["formula"] : "";
|
1007
1007
|
if(this._fnEngine) {
|
1008
|
-
|
1009
|
-
|
1008
|
+
let uppercasedF = field.toUpperCase(); // For comparison only
|
1009
|
+
let predefinedF = formulaStr || PredefinedFormula.get(uppercasedF);
|
1010
1010
|
if(predefinedF || ColumnDefinition.isFormulaField(field)) {
|
1011
1011
|
field = Formula.toUpperCase(field);
|
1012
1012
|
this._formula = this._fnEngine.addFormula(predefinedF || field); // Always a success
|
@@ -1028,7 +1028,7 @@ ColumnDefinition.prototype._setField = function(field, columnOption) {
|
|
1028
1028
|
// We need to cache time series in field definition for improve performance of checking methond
|
1029
1029
|
FieldDefinition.setFieldProperty(field, "timeSeries", FieldDefinition.isTimeSeries(field) ? true : false);
|
1030
1030
|
|
1031
|
-
|
1031
|
+
let parentColDef = columnOption["parent"];
|
1032
1032
|
if(columnOption && parentColDef) {
|
1033
1033
|
FieldDefinition.setFieldProperty(field, "timeSeriesParent", parentColDef.getField());
|
1034
1034
|
}
|
@@ -1045,12 +1045,12 @@ ColumnDefinition.prototype._retrieveNestedFields = function(fields) {
|
|
1045
1045
|
if(!fields) {
|
1046
1046
|
return;
|
1047
1047
|
}
|
1048
|
-
for(
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1048
|
+
for(let i = fields.length; --i >= 0;) {
|
1049
|
+
let field = fields[i];
|
1050
|
+
let uppercasedF = field.toUpperCase();
|
1051
|
+
let predefinedF = PredefinedFormula.get(uppercasedF);
|
1052
1052
|
if(predefinedF) { // Predefined formula
|
1053
|
-
|
1053
|
+
let f = this._fnEngine.getFormula(field); // Get formula by reference name
|
1054
1054
|
if(f) {
|
1055
1055
|
f.addFormulaCount(); // Add reference count
|
1056
1056
|
} else {
|
@@ -1068,18 +1068,18 @@ ColumnDefinition.prototype._retrieveNestedFields = function(fields) {
|
|
1068
1068
|
* @param {Object} e
|
1069
1069
|
*/
|
1070
1070
|
ColumnDefinition.prototype._defaultRenderer = function(e) {
|
1071
|
-
|
1071
|
+
let rowDef = /** @type{RowDefinition} */(e["dataValue"]);
|
1072
1072
|
e["cell"].setContent(rowDef ? rowDef.getData(this._field) : null);
|
1073
1073
|
};
|
1074
1074
|
/** @private
|
1075
1075
|
* @param {Object} e
|
1076
1076
|
*/
|
1077
1077
|
ColumnDefinition.prototype._customRenderer = function(e) {
|
1078
|
-
|
1078
|
+
let rowDef = /** @type{RowDefinition} */(e["dataValue"]);
|
1079
1079
|
|
1080
|
-
|
1080
|
+
let arg = this._eventArg; // Reuse the same object
|
1081
1081
|
if(rowDef) {
|
1082
|
-
|
1082
|
+
let rowData = rowDef.getRowData();
|
1083
1083
|
arg["rowDef"] = rowDef;
|
1084
1084
|
arg["rowData"] = rowData;
|
1085
1085
|
arg["rowIndex"] = e["rowIndex"];
|
@@ -1098,9 +1098,9 @@ ColumnDefinition.prototype._customRenderer = function(e) {
|
|
1098
1098
|
if(this._activatedRenderer) {
|
1099
1099
|
this._activatedRenderer(arg);
|
1100
1100
|
} else {
|
1101
|
-
|
1102
|
-
|
1103
|
-
for(
|
1101
|
+
let urs = this._userRenderers;
|
1102
|
+
let len = urs.length;
|
1103
|
+
for(let i = 0; i < len; ++i) {
|
1104
1104
|
urs[i](arg);
|
1105
1105
|
}
|
1106
1106
|
}
|
@@ -9,8 +9,8 @@ import RowDefinition from "./RowDefinition.js"; // eslint-disable-line
|
|
9
9
|
* @constructor
|
10
10
|
* @extends {EventDispatcher}
|
11
11
|
*/
|
12
|
-
|
13
|
-
|
12
|
+
let DataConnector = function () {
|
13
|
+
let t = this;
|
14
14
|
t._commitRicsChanges = t._commitRicsChanges.bind(this);
|
15
15
|
t._commitFieldsChanges = t._commitFieldsChanges.bind(this);
|
16
16
|
t._fieldChangedConflator = new Conflator(0, t._commitFieldsChanges);
|
@@ -57,8 +57,8 @@ DataConnector.prototype.getAllRics = function () {
|
|
57
57
|
* @returns {Array.<RowDefinition>}
|
58
58
|
*/
|
59
59
|
DataConnector.prototype.getAllRowDefs = function () {
|
60
|
-
|
61
|
-
for (
|
60
|
+
let results = [];
|
61
|
+
for (let i in this._rowDefMap) { // TODO: Check if push is better than concat
|
62
62
|
results = results.concat(this._rowDefMap[i]);
|
63
63
|
}
|
64
64
|
return results;
|
@@ -85,13 +85,13 @@ DataConnector.prototype.getRowDefByRic = function (ric) {
|
|
85
85
|
* @return {boolean} True if new reference is added.
|
86
86
|
*/
|
87
87
|
DataConnector.prototype.addRic = function (rowDef) {
|
88
|
-
|
88
|
+
let ric = rowDef ? rowDef.getSymbol() : "";
|
89
89
|
if(!ric) {
|
90
90
|
return false;
|
91
91
|
}
|
92
92
|
|
93
|
-
|
94
|
-
|
93
|
+
let rowDefMap = this._rowDefMap;
|
94
|
+
let rowDefs = rowDefMap[ric];
|
95
95
|
if (!rowDefs) {
|
96
96
|
rowDefs = rowDefMap[ric] = [rowDef];
|
97
97
|
} else {
|
@@ -101,7 +101,7 @@ DataConnector.prototype.addRic = function (rowDef) {
|
|
101
101
|
}
|
102
102
|
|
103
103
|
// Referer could be added, even if no new reference is added.
|
104
|
-
|
104
|
+
let newReference = this._rics.addReference(ric, rowDef.getRowId());
|
105
105
|
|
106
106
|
this._commitRicsChanges();
|
107
107
|
return newReference;
|
@@ -120,10 +120,10 @@ DataConnector.prototype.removeRic = function (rowDef, ric) {
|
|
120
120
|
return;
|
121
121
|
}
|
122
122
|
|
123
|
-
|
124
|
-
|
123
|
+
let rowDefMap = this._rowDefMap;
|
124
|
+
let rowDefs = rowDefMap[ric];
|
125
125
|
if (rowDefs) {
|
126
|
-
|
126
|
+
let index = rowDefs.indexOf(rowDef);
|
127
127
|
if (index >= 0) {
|
128
128
|
rowDefs.splice(index, 1);
|
129
129
|
}
|
@@ -136,8 +136,8 @@ DataConnector.prototype.removeRic = function (rowDef, ric) {
|
|
136
136
|
/** @public
|
137
137
|
*/
|
138
138
|
DataConnector.prototype.removeAllRics = function () {
|
139
|
-
|
140
|
-
for (
|
139
|
+
let referers = this._rics.getAllReferers(); // TODO: Add method to removeAllReferers at once
|
140
|
+
for (let i in referers) {
|
141
141
|
this._rics.removeReferer(referers[i]);
|
142
142
|
}
|
143
143
|
this._rowDefMap = {};
|
@@ -151,10 +151,10 @@ DataConnector.prototype._commitRicsChanges = function () {
|
|
151
151
|
return;
|
152
152
|
}
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
154
|
+
let rics = this._rics;
|
155
|
+
let session = rics.getSession();
|
156
|
+
let removedEntries = session.removedEntries;
|
157
|
+
let newEntries = session.newEntries;
|
158
158
|
|
159
159
|
if (removedEntries.length) {
|
160
160
|
this._doDispatch({
|
@@ -179,7 +179,7 @@ DataConnector.prototype._commitRicsChanges = function () {
|
|
179
179
|
DataConnector.prototype.addFields = function (fieldRef, referer) {
|
180
180
|
if (!fieldRef) { return; }
|
181
181
|
|
182
|
-
|
182
|
+
let fields = this._fields;
|
183
183
|
|
184
184
|
if (fieldRef instanceof ColumnDefinition) {
|
185
185
|
fields.addReferences(fieldRef.getAllFields(), fieldRef.getId());
|
@@ -215,8 +215,8 @@ DataConnector.prototype.removeFieldReferrer = function (referrer) {
|
|
215
215
|
/** @public
|
216
216
|
*/
|
217
217
|
DataConnector.prototype.removeAllFields = function () {
|
218
|
-
|
219
|
-
for (
|
218
|
+
let referers = this._fields.getAllReferers();
|
219
|
+
for (let i in referers) { // TODO: Add method to removeAllReferers at once
|
220
220
|
this._fields.removeReferer(referers[i]);
|
221
221
|
}
|
222
222
|
this._commitFieldsChanges();
|
@@ -229,10 +229,10 @@ DataConnector.prototype._commitFieldsChanges = function () {
|
|
229
229
|
return;
|
230
230
|
}
|
231
231
|
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
232
|
+
let fields = this._fields;
|
233
|
+
let session = fields.getSession();
|
234
|
+
let removedEntries = session.removedEntries;
|
235
|
+
let newEntries = session.newEntries;
|
236
236
|
|
237
237
|
if (removedEntries.length) {
|
238
238
|
this._doDispatch({
|
@@ -253,7 +253,7 @@ DataConnector.prototype._commitFieldsChanges = function () {
|
|
253
253
|
* @param {Object} payload
|
254
254
|
*/
|
255
255
|
DataConnector.prototype._doDispatch = function (payload) {
|
256
|
-
|
256
|
+
let t = this;
|
257
257
|
payload.fields = t.getAllFields();
|
258
258
|
payload.rics = t.getAllRics();
|
259
259
|
payload.rowDefs = t.getAllRowDefs();
|
@@ -263,7 +263,7 @@ DataConnector.prototype._doDispatch = function (payload) {
|
|
263
263
|
/** @public
|
264
264
|
*/
|
265
265
|
DataConnector.prototype.reset = function () {
|
266
|
-
|
266
|
+
let t = this;
|
267
267
|
t._rowDefMap = {};
|
268
268
|
t._fields.reset();
|
269
269
|
t._rics.reset();
|
@@ -9,13 +9,13 @@ import { Deferred } from "../../tr-grid-util/es6/Deferred.js";
|
|
9
9
|
* @private
|
10
10
|
* @const
|
11
11
|
*/
|
12
|
-
|
12
|
+
const SYNAPSE_URL =
|
13
13
|
"/synapse/service/suggestions/suggest/?"
|
14
14
|
+ "hits=1" // search only 1 result
|
15
15
|
+ "&profile=" + encodeURIComponent("Field Selector");
|
16
16
|
|
17
17
|
/* @namespace */
|
18
|
-
|
18
|
+
let FieldDefinition = {};
|
19
19
|
|
20
20
|
/** @type {Object.<string, Object>}
|
21
21
|
* @private
|
@@ -157,7 +157,7 @@ FieldDefinition.set = function(field, def) {
|
|
157
157
|
if (!FieldDefinition._defs[field]) {
|
158
158
|
FieldDefinition._defs[field] = def;
|
159
159
|
} else {
|
160
|
-
for (
|
160
|
+
for (let key in def) {
|
161
161
|
FieldDefinition._defs[field][key] = def[key];
|
162
162
|
}
|
163
163
|
}
|
@@ -185,7 +185,7 @@ FieldDefinition.getFieldInfo = FieldDefinition.get;
|
|
185
185
|
* @return {boolean}
|
186
186
|
*/
|
187
187
|
FieldDefinition.hasFieldInfo = function(field) {
|
188
|
-
|
188
|
+
let val = FieldDefinition.get(field);
|
189
189
|
return (val && val.field) ? true : false; // Already preventing an error caused by accessing a property on a null value
|
190
190
|
};
|
191
191
|
|
@@ -298,7 +298,7 @@ FieldDefinition.isTimeSeries = function (field) {
|
|
298
298
|
}
|
299
299
|
|
300
300
|
// We can check time series using a cache to avoid duplicating checks in regular expressions.
|
301
|
-
|
301
|
+
let timeSeriesField = FieldDefinition.getFieldProperty(field, "timeSeries");
|
302
302
|
if (timeSeriesField != null) {
|
303
303
|
return timeSeriesField;
|
304
304
|
}
|
@@ -313,7 +313,7 @@ FieldDefinition.isTimeSeries = function (field) {
|
|
313
313
|
[\)]$ => end with only )
|
314
314
|
i => for match both upper and lower cases
|
315
315
|
*/
|
316
|
-
|
316
|
+
let timeSeriesRegex = /^TR\.[\w]+\([\w\-\=\,]*(?:EDATE|SDATE)\=+[\w\-\=\,]*[ \w]*\)$/i;
|
317
317
|
return timeSeriesRegex.test(field);
|
318
318
|
};
|
319
319
|
|
@@ -339,7 +339,7 @@ FieldDefinition.setFieldProperty = function(field, propertyName, value) {
|
|
339
339
|
* @return {*}
|
340
340
|
*/
|
341
341
|
FieldDefinition.getFieldProperty = function(field, propertyName) {
|
342
|
-
|
342
|
+
let fieldDef = FieldDefinition._defs[field];
|
343
343
|
if(fieldDef) {
|
344
344
|
return fieldDef[propertyName];
|
345
345
|
}
|
@@ -356,8 +356,8 @@ FieldDefinition.loadFieldInfo = function (field) {
|
|
356
356
|
return FieldDefinition._loadingField[field].promise;
|
357
357
|
}
|
358
358
|
|
359
|
-
|
360
|
-
|
359
|
+
let defer = new Deferred();
|
360
|
+
let synapse = FieldDefinition._synapse;
|
361
361
|
// cannot call request without synapse config
|
362
362
|
if (!synapse) {
|
363
363
|
defer.resolve(null);
|
@@ -368,7 +368,7 @@ FieldDefinition.loadFieldInfo = function (field) {
|
|
368
368
|
}
|
369
369
|
// in debug using mock data instead
|
370
370
|
else if (synapse.debug) {
|
371
|
-
|
371
|
+
let mockData = this._mockOnLoadEndData(field, defer);
|
372
372
|
setTimeout(onLoadEnd.bind(null, mockData), 1000);
|
373
373
|
}
|
374
374
|
// cannot call request without apiKey and contextApp
|
@@ -377,7 +377,7 @@ FieldDefinition.loadFieldInfo = function (field) {
|
|
377
377
|
}
|
378
378
|
// everything fine, call synapse service
|
379
379
|
else {
|
380
|
-
|
380
|
+
let queryUrl = SYNAPSE_URL
|
381
381
|
+ "&api-key=" + encodeURIComponent(synapse.apiKey)
|
382
382
|
+ "&contextApp=" + encodeURIComponent(synapse.contextApp)
|
383
383
|
+ "&language=" + encodeURIComponent(FieldDefinition._lang)
|
@@ -386,7 +386,7 @@ FieldDefinition.loadFieldInfo = function (field) {
|
|
386
386
|
queryUrl += "&auth=" + encodeURIComponent(synapse.auth);
|
387
387
|
}
|
388
388
|
// TODO: handle client timeout
|
389
|
-
|
389
|
+
let xmr = new XMLHttpRequest();
|
390
390
|
xmr._defer = defer;
|
391
391
|
xmr._field = field;
|
392
392
|
FieldDefinition._loadingField[field] = defer;
|
@@ -419,16 +419,16 @@ function onError(e) {
|
|
419
419
|
* @returns {Object}
|
420
420
|
*/
|
421
421
|
FieldDefinition._mockOnLoadEndData = function (field, defer) {
|
422
|
-
|
423
|
-
|
424
|
-
|
422
|
+
let fieldUpperCase = field.toUpperCase();
|
423
|
+
let fieldLowerCase = fieldUpperCase.toLowerCase();
|
424
|
+
let label;
|
425
425
|
if (fieldLowerCase.indexOf("_") === 2) { // transform XX_ABCD -> Abcd
|
426
426
|
label = fieldUpperCase[3] + fieldLowerCase.substring(4);
|
427
427
|
} else {
|
428
428
|
label = fieldUpperCase[0] + fieldLowerCase.substring(1);
|
429
429
|
}
|
430
|
-
|
431
|
-
|
430
|
+
let dataType = (fieldUpperCase.indexOf("DATE") >= 0) ? "DATE" : "PRICE";
|
431
|
+
let item = {
|
432
432
|
cmd: label,
|
433
433
|
explanation: null,
|
434
434
|
fr: false,
|
@@ -457,7 +457,7 @@ FieldDefinition._mockOnLoadEndData = function (field, defer) {
|
|
457
457
|
vc: "FLD"
|
458
458
|
};
|
459
459
|
|
460
|
-
|
460
|
+
let response = {
|
461
461
|
action: '\"' + fieldUpperCase + '\" SRCH',
|
462
462
|
assetClassifierExplanation: "AssetClassifier is disabled.",
|
463
463
|
assetClassifierStatus: "NOT_INVOKED",
|
@@ -482,21 +482,21 @@ FieldDefinition._mockOnLoadEndData = function (field, defer) {
|
|
482
482
|
* @param {Event} e
|
483
483
|
*/
|
484
484
|
function onLoadEnd(e) {
|
485
|
-
|
486
|
-
|
487
|
-
|
485
|
+
let xmr = e.currentTarget;
|
486
|
+
let defer = xmr._defer;
|
487
|
+
let field = xmr._field;
|
488
488
|
|
489
489
|
delete FieldDefinition._loadingField[field];
|
490
490
|
|
491
491
|
if (xmr.status === 200) { // case success
|
492
|
-
|
493
|
-
|
492
|
+
let res = JSON.parse(xmr.responseText);
|
493
|
+
let fieldDef = null;
|
494
494
|
|
495
|
-
|
495
|
+
let result = res.result && res.result[0];
|
496
496
|
if (result) {
|
497
|
-
|
497
|
+
let item = result.hits && result.hits[0];
|
498
498
|
if (item && item.p) {
|
499
|
-
|
499
|
+
let profile = item.p;
|
500
500
|
if (profile.fn.toUpperCase() === field.toUpperCase()) {
|
501
501
|
fieldDef = FieldDefinition.get(field) || {};
|
502
502
|
|
@@ -535,7 +535,7 @@ function onLoadEnd(e) {
|
|
535
535
|
}
|
536
536
|
|
537
537
|
(function() { // Add "field" property to all default field definitions. This reduces file size and redundancy
|
538
|
-
for(
|
538
|
+
for(let key in FieldDefinition._defs) {
|
539
539
|
FieldDefinition._defs[key]["field"] = key;
|
540
540
|
}
|
541
541
|
})();
|