@refinitiv-ui/efx-grid 6.0.91 → 6.0.93
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/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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @private
|
|
3
3
|
* @const
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
let OperatorPrecedences = {
|
|
6
6
|
"||": 1,
|
|
7
7
|
"&&": 2,
|
|
8
8
|
"<": 3,
|
|
@@ -25,7 +25,7 @@ var OperatorPrecedences = {
|
|
|
25
25
|
* @private
|
|
26
26
|
* @const
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
let OperatorFunctions = {
|
|
29
29
|
"+": function(lhs, rhs){ return lhs + rhs; },
|
|
30
30
|
"-": function(lhs, rhs){ return lhs - rhs; },
|
|
31
31
|
"*": function(lhs, rhs){ return lhs * rhs; },
|
|
@@ -46,7 +46,7 @@ var OperatorFunctions = {
|
|
|
46
46
|
* @private
|
|
47
47
|
* @const
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
let OperandRequirements = {
|
|
50
50
|
"+": 2,
|
|
51
51
|
"-": 2,
|
|
52
52
|
"*": 2,
|
|
@@ -71,8 +71,8 @@ var OperandRequirements = {
|
|
|
71
71
|
* @param {string=} dataType
|
|
72
72
|
* @return {number}
|
|
73
73
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
let _addToken = function(ary, value, type, dataType) {
|
|
75
|
+
let tok = {
|
|
76
76
|
value: value,
|
|
77
77
|
type: type
|
|
78
78
|
};
|
|
@@ -92,14 +92,14 @@ var _addToken = function(ary, value, type, dataType) {
|
|
|
92
92
|
* @param {Object} obj
|
|
93
93
|
* @returns {*}
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
let _toValue = function(obj) { // eslint-disable-line
|
|
96
96
|
return obj.value;
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
/** @public
|
|
100
100
|
* @namespace
|
|
101
101
|
*/
|
|
102
|
-
|
|
102
|
+
let ExpressionParser = {};
|
|
103
103
|
/** @type {Array.<Object>}
|
|
104
104
|
* @private
|
|
105
105
|
* @const
|
|
@@ -113,7 +113,7 @@ ExpressionParser._tokens = [];
|
|
|
113
113
|
* @return {string}
|
|
114
114
|
*/
|
|
115
115
|
ExpressionParser._withString = function(str) {
|
|
116
|
-
|
|
116
|
+
let tokId = _addToken(ExpressionParser._tokens,
|
|
117
117
|
str.substring(1, str.length - 1),
|
|
118
118
|
"literal",
|
|
119
119
|
"string"
|
|
@@ -126,7 +126,7 @@ ExpressionParser._withString = function(str) {
|
|
|
126
126
|
* @return {string}
|
|
127
127
|
*/
|
|
128
128
|
ExpressionParser._withField = function(field) {
|
|
129
|
-
|
|
129
|
+
let tokId = _addToken(ExpressionParser._tokens,
|
|
130
130
|
field,
|
|
131
131
|
"literal",
|
|
132
132
|
"variable"
|
|
@@ -147,9 +147,9 @@ ExpressionParser._withFieldInBrackets = function(field) {
|
|
|
147
147
|
* @return {string}
|
|
148
148
|
*/
|
|
149
149
|
ExpressionParser._withNegativeNumber = function(numStr) {
|
|
150
|
-
|
|
150
|
+
let num = +numStr;
|
|
151
151
|
if(num === num) {
|
|
152
|
-
|
|
152
|
+
let tokId = _addToken(ExpressionParser._tokens,
|
|
153
153
|
num,
|
|
154
154
|
"literal",
|
|
155
155
|
"number"
|
|
@@ -179,7 +179,7 @@ ExpressionParser._withOperator = function(opStr) {
|
|
|
179
179
|
if(opStr == "=" || opStr == "===") {
|
|
180
180
|
opStr = "==";
|
|
181
181
|
}
|
|
182
|
-
|
|
182
|
+
let tokId = _addToken(ExpressionParser._tokens, opStr, "operator");
|
|
183
183
|
return "#" + tokId + "#";
|
|
184
184
|
}
|
|
185
185
|
return "";
|
|
@@ -190,7 +190,7 @@ ExpressionParser._withOperator = function(opStr) {
|
|
|
190
190
|
* @return {string}
|
|
191
191
|
*/
|
|
192
192
|
ExpressionParser._withParenthesis = function(paStr) {
|
|
193
|
-
|
|
193
|
+
let tokId = _addToken(ExpressionParser._tokens, paStr, "parenthesis");
|
|
194
194
|
return "#" + tokId + "#";
|
|
195
195
|
};
|
|
196
196
|
|
|
@@ -201,14 +201,14 @@ ExpressionParser._withParenthesis = function(paStr) {
|
|
|
201
201
|
* @return {boolean} Returns true if there is any error, otherwise returns false (everything is OK)
|
|
202
202
|
*/
|
|
203
203
|
ExpressionParser._tester = function(ctx) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
for(
|
|
209
|
-
|
|
204
|
+
let rpn = ctx._rpn;
|
|
205
|
+
let inputCount = rpn.length;
|
|
206
|
+
let operandCount = 0;
|
|
207
|
+
let maxStack = 0;
|
|
208
|
+
for(let i = 0; i < inputCount; ++i) {
|
|
209
|
+
let tok = rpn[i];
|
|
210
210
|
if(tok.type !== "literal") {
|
|
211
|
-
|
|
211
|
+
let requiredCount = OperandRequirements[tok.value];
|
|
212
212
|
if(operandCount >= requiredCount) {
|
|
213
213
|
operandCount -= requiredCount;
|
|
214
214
|
} else {
|
|
@@ -236,14 +236,14 @@ ExpressionParser._tester = function(ctx) {
|
|
|
236
236
|
* @return {boolean}
|
|
237
237
|
*/
|
|
238
238
|
ExpressionParser._filter = function(ctx, rowData) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
for(
|
|
245
|
-
|
|
246
|
-
|
|
239
|
+
let rpn = ctx._rpn;
|
|
240
|
+
let results = new Array(ctx._stackSize);
|
|
241
|
+
let inputCount = rpn.length;
|
|
242
|
+
let operandCount = 0;
|
|
243
|
+
let curRes;
|
|
244
|
+
for(let i = 0; i < inputCount; ++i) {
|
|
245
|
+
let tok = rpn[i];
|
|
246
|
+
let tokValue = tok.value;
|
|
247
247
|
if(tok.type === "literal") {
|
|
248
248
|
if(tok.dataType !== "variable") {
|
|
249
249
|
curRes = tokValue;
|
|
@@ -287,7 +287,7 @@ ExpressionParser.parse = function(expression) {
|
|
|
287
287
|
return null;
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
-
|
|
290
|
+
let tokExp = expression.trim();
|
|
291
291
|
if(!tokExp) {
|
|
292
292
|
return null;
|
|
293
293
|
}
|
|
@@ -302,23 +302,23 @@ ExpressionParser.parse = function(expression) {
|
|
|
302
302
|
tokExp = tokExp.replace(/[\-\/+*%!=<>&|]+/g, ExpressionParser._withOperator);
|
|
303
303
|
tokExp = tokExp.replace(/[()]/g, ExpressionParser._withParenthesis); // round brackets
|
|
304
304
|
|
|
305
|
-
|
|
306
|
-
|
|
305
|
+
let tokens = ExpressionParser._tokens;
|
|
306
|
+
let tokCount = tokens.length;
|
|
307
307
|
if(!tokCount) {
|
|
308
308
|
return null; // There is no recognizable character
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
// Generate infix token list
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
312
|
+
let infixTokens = [];
|
|
313
|
+
let matches = tokExp.match(/#[0-9]+#/g);
|
|
314
|
+
let i, tok, tokType;
|
|
315
315
|
for(i = 0; i < tokCount; ++i) {
|
|
316
|
-
|
|
317
|
-
|
|
316
|
+
let tokId = matches[i];
|
|
317
|
+
let tokIdx = +(tokId.substring(1, tokId.length - 1));
|
|
318
318
|
tok = tokens[tokIdx];
|
|
319
319
|
tokType = tok.type;
|
|
320
320
|
if(tokType === "literal") {
|
|
321
|
-
|
|
321
|
+
let prevTok = infixTokens[infixTokens.length - 1];
|
|
322
322
|
if(prevTok && prevTok.type === "literal") { // Incorrect infix notation detected
|
|
323
323
|
if(tok.value < 0 && tok.dataType === "number") {
|
|
324
324
|
_addToken(infixTokens, "-", "operator");
|
|
@@ -336,10 +336,10 @@ ExpressionParser.parse = function(expression) {
|
|
|
336
336
|
// Convert Infix notation to Reverse Polish Notation (Postfix)
|
|
337
337
|
// See https://en.wikipedia.org/wiki/Shunting_yard_algorithm#The_algorithm_in_detail
|
|
338
338
|
tokCount = infixTokens.length;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
339
|
+
let rpn = [];
|
|
340
|
+
let operators = [];
|
|
341
|
+
let lastOp = null;
|
|
342
|
+
let foundLeftPa = false;
|
|
343
343
|
for(i = 0; i < tokCount; ++i) {
|
|
344
344
|
tok = infixTokens[i];
|
|
345
345
|
tokType = tok.type;
|
|
@@ -388,12 +388,12 @@ ExpressionParser.parse = function(expression) {
|
|
|
388
388
|
console.warn("No right parenthesis paired with the left one");
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
|
|
391
|
+
let inputCount = rpn.length;
|
|
392
392
|
if(!inputCount) {
|
|
393
393
|
return null; // The expression contains nothing but parentheses
|
|
394
394
|
}
|
|
395
395
|
|
|
396
|
-
|
|
396
|
+
let ctx = {
|
|
397
397
|
_rpn: rpn
|
|
398
398
|
};
|
|
399
399
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/** Provide ability for prototype based Class to inherits another class
|
|
2
2
|
* @namespace
|
|
3
3
|
* @example
|
|
4
|
-
*
|
|
4
|
+
* let BaseClass = function() {};
|
|
5
5
|
* BaseClass.prototype.method = function() {};
|
|
6
6
|
* BaseClass.prototype._member = 1;
|
|
7
|
-
*
|
|
7
|
+
* let DerivedClass = function() {};
|
|
8
8
|
* Ext.inherits(DerivedClass, BaseClass); // Derived class will have methods and members of the base class
|
|
9
9
|
* // To call base class method
|
|
10
10
|
* DeriveClass["base"](this, "methodName", ...params);
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
let Ext = {};
|
|
13
13
|
|
|
14
14
|
/** @public
|
|
15
15
|
* @function
|
|
@@ -39,9 +39,9 @@ Ext.inherits = function (childCtor, parentCtor) {
|
|
|
39
39
|
childCtor["base"] = function(me, methodName, var_args) {
|
|
40
40
|
if(!methodName) { methodName = 'constructor'; }
|
|
41
41
|
// Copying using loop to avoid deop due to passing arguments object to function. This is faster in many JS engines as of late 2014.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
for (
|
|
42
|
+
let len = arguments.length;
|
|
43
|
+
let args = new Array(len); // http://jsperf.com/creating-an-array
|
|
44
|
+
for (let i = 2; i < len; i++) {
|
|
45
45
|
args[i - 2] = arguments[i];
|
|
46
46
|
}
|
|
47
47
|
return parentCtor.prototype[methodName].apply(me, args);
|
|
@@ -35,7 +35,7 @@ const DEFAULT_DATE_TIME_FORMAT = "MM/DD/YYYY";
|
|
|
35
35
|
* @param {string} formatType
|
|
36
36
|
* @return {string}
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
let toDateTimeType = function(formatType) {
|
|
39
39
|
if (formatType != null && DATE_TIME_TYPE[formatType.toUpperCase()]) {
|
|
40
40
|
return DATE_TIME;
|
|
41
41
|
}
|
|
@@ -45,11 +45,11 @@ var toDateTimeType = function(formatType) {
|
|
|
45
45
|
/** @constructor
|
|
46
46
|
* @param {FieldFormatter~Options=} options
|
|
47
47
|
* @example
|
|
48
|
-
*
|
|
48
|
+
* let ff = new FieldFormatter();
|
|
49
49
|
* ff.format(anyValue);
|
|
50
50
|
* ff.getOptions(); // For serialization
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
let FieldFormatter = function(options) {
|
|
53
53
|
this["format"] = this.format = this.format.bind(this); // Always export bound format method
|
|
54
54
|
|
|
55
55
|
FieldFormatter._startMidnightInterval();
|
|
@@ -126,8 +126,8 @@ FieldFormatter._updateMidnight = function() {
|
|
|
126
126
|
FieldFormatter._startMidnightInterval = function() {
|
|
127
127
|
if(!FieldFormatter._lastMidnight) {
|
|
128
128
|
FieldFormatter._updateMidnight();
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
let currentMidnight = FieldFormatter._lastMidnight.valueOf();
|
|
130
|
+
let timeUntilNextUpdate = currentMidnight + 86405000 - (new Date().valueOf()); // delay to the next midnight + 5sec
|
|
131
131
|
setTimeout(FieldFormatter._setMidnightInterval, timeUntilNextUpdate);
|
|
132
132
|
}
|
|
133
133
|
};
|
|
@@ -148,15 +148,15 @@ FieldFormatter.prototype.init = function(options) { // deserialize
|
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
|
|
151
|
+
let val = options["field"];
|
|
152
152
|
if(val) {
|
|
153
153
|
// DateTime pairs come from the JET's user settings
|
|
154
154
|
// Datetime paired will have special column that suffix with "_COMBINED"
|
|
155
155
|
this.setField(val); // , (this._dateTimePairs[field]) ? field + "_COMBINED" : "");
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
let formatType = /** @type{string} */(options["formatType"] || options["type"]);
|
|
159
|
+
let fieldDataType = options["fieldDataType"]; // Keep backward compatibility
|
|
160
160
|
this._userFormatType = formatType || fieldDataType;
|
|
161
161
|
|
|
162
162
|
formatType = toDateTimeType(this._userFormatType);
|
|
@@ -165,8 +165,8 @@ FieldFormatter.prototype.init = function(options) { // deserialize
|
|
|
165
165
|
if(val) {
|
|
166
166
|
this.setFormatType(val);
|
|
167
167
|
}
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
let dtf = options["dateTimeFormat"];
|
|
169
|
+
let utc = options["useUTCTime"];
|
|
170
170
|
if(utc != null || dtf != null) {
|
|
171
171
|
this.setDateTimeMeta(
|
|
172
172
|
dtf,
|
|
@@ -211,7 +211,7 @@ FieldFormatter.prototype.getField = function() {
|
|
|
211
211
|
* @return {FieldFormatter}
|
|
212
212
|
*/
|
|
213
213
|
FieldFormatter.prototype.clone = function() {
|
|
214
|
-
|
|
214
|
+
let newFF = new FieldFormatter();
|
|
215
215
|
newFF._field = this._field;
|
|
216
216
|
newFF._formattedField = this._formattedField;
|
|
217
217
|
newFF._combinedField = this._combinedField;
|
|
@@ -279,7 +279,7 @@ FieldFormatter.prototype.setNumberFormatter = function(formatter) {
|
|
|
279
279
|
};
|
|
280
280
|
|
|
281
281
|
FieldFormatter.prototype.getProperties = function() {
|
|
282
|
-
|
|
282
|
+
let obj = {
|
|
283
283
|
"field": this._field,
|
|
284
284
|
"formattedField": this._formattedField,
|
|
285
285
|
"combinedField": this._combinedField,
|
|
@@ -350,7 +350,7 @@ FieldFormatter.prototype._format = function(val, rowData) {
|
|
|
350
350
|
|
|
351
351
|
if(this._nf) { // Number formatter will override any default field format
|
|
352
352
|
if(typeof val != "number") { // string
|
|
353
|
-
|
|
353
|
+
let num = (+val); // Only convertible value will be formatted by the number formatter
|
|
354
354
|
return (num === num) ? this._nf(num) : val + "";
|
|
355
355
|
}
|
|
356
356
|
|
|
@@ -375,19 +375,19 @@ FieldFormatter.prototype._format = function(val, rowData) {
|
|
|
375
375
|
FieldFormatter.prototype._formatDateTime = function(val, rowData) {
|
|
376
376
|
if(!this._df) { return ""; }
|
|
377
377
|
if(this._idnSource) { // IDN Source will send time in second instead of millisecond.
|
|
378
|
-
|
|
378
|
+
let sec = +val; // Date object can be converted to number
|
|
379
379
|
if(sec !== sec) { // NaN checking
|
|
380
380
|
return val; // WARNING: val could be number
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
-
|
|
383
|
+
let cmbValue = (rowData && this._combinedField) ? +rowData[this._combinedField] : NaN;
|
|
384
384
|
if(cmbValue === cmbValue) { // Combined value is not NaN
|
|
385
385
|
sec = cmbValue;
|
|
386
386
|
} else if(sec < 86400) { // No paired date and sec < 24 hours -> this is a time within this day
|
|
387
387
|
sec += FieldFormatter._lastMidnight.valueOf() / 1000;
|
|
388
388
|
} else { // No paired sec. Date need to add for timezone
|
|
389
389
|
if((this._field !== "NEWS_TIME") && (this._timeZone === "LOCAL")) {
|
|
390
|
-
|
|
390
|
+
let d = new Date(sec * 1000); // Need to know the timezone of given date
|
|
391
391
|
sec += d.getTimezoneOffset() * 60;
|
|
392
392
|
}
|
|
393
393
|
}
|
|
@@ -401,7 +401,7 @@ FieldFormatter.prototype._formatDateTime = function(val, rowData) {
|
|
|
401
401
|
* @return {string}
|
|
402
402
|
*/
|
|
403
403
|
FieldFormatter.prototype._formatNumber = function(val, rowData) {
|
|
404
|
-
|
|
404
|
+
let ff;
|
|
405
405
|
if(rowData) {
|
|
406
406
|
ff = rowData[this._formattedField];
|
|
407
407
|
if(!ff) { // null, undefined, empty string, zero, or NaN
|
|
@@ -25,7 +25,7 @@ import { ExpressionParser } from "./ExpressionParser.js";
|
|
|
25
25
|
* @type {Object.<string, number>}
|
|
26
26
|
* @const
|
|
27
27
|
*/
|
|
28
|
-
|
|
28
|
+
let connectorMap = {
|
|
29
29
|
"or": 1,
|
|
30
30
|
"OR": 1,
|
|
31
31
|
"Or": 1,
|
|
@@ -38,7 +38,7 @@ var connectorMap = {
|
|
|
38
38
|
* @param {*} val
|
|
39
39
|
* @return {number}
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
let convertToNumber = function(val) {
|
|
42
42
|
if(typeof val === "number") {
|
|
43
43
|
return val;
|
|
44
44
|
}
|
|
@@ -56,17 +56,17 @@ var convertToNumber = function(val) {
|
|
|
56
56
|
/** @private
|
|
57
57
|
* @type {RegExp}
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
let _dateStringRule = /^\w{3} \w{3}/;
|
|
60
60
|
/** Convert default string natively generated from a Date object to a Date object. For instance, string "Sun Sep 09 2001 08:46:40 GMT+0700 (Indochina Time)" can be converted, while string "2001-09-09" cannot be converted.
|
|
61
61
|
* @public
|
|
62
62
|
* @function
|
|
63
63
|
* @param {*} str
|
|
64
64
|
* @return {*} Return Date object for successful conversion, otherwise the same input string
|
|
65
65
|
*/
|
|
66
|
-
|
|
66
|
+
let stringToDateObject = function(str) {
|
|
67
67
|
if(typeof str === "string") {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
let dateObj = new Date(str);
|
|
69
|
+
let t = dateObj.getTime();
|
|
70
70
|
if(t === t) {
|
|
71
71
|
if(_dateStringRule.test(str)) {
|
|
72
72
|
return dateObj;
|
|
@@ -80,7 +80,7 @@ var stringToDateObject = function(str) {
|
|
|
80
80
|
* @param {*} val
|
|
81
81
|
* @return {string}
|
|
82
82
|
*/
|
|
83
|
-
|
|
83
|
+
let convertToString = function(val) {
|
|
84
84
|
if(typeof val === "string") {
|
|
85
85
|
return val;
|
|
86
86
|
}
|
|
@@ -102,7 +102,7 @@ var convertToString = function(val) {
|
|
|
102
102
|
* @param {boolean=} useUTCTime
|
|
103
103
|
* @return {number}
|
|
104
104
|
*/
|
|
105
|
-
|
|
105
|
+
let convertToDateValue = function(dateObj, useUTCTime) {
|
|
106
106
|
if(dateObj && dateObj.getTime) {
|
|
107
107
|
if(useUTCTime) {
|
|
108
108
|
return dateObj.getUTCFullYear() * 10000 + dateObj.getUTCMonth() * 100 + dateObj.getUTCDate();
|
|
@@ -118,26 +118,25 @@ var convertToDateValue = function(dateObj, useUTCTime) {
|
|
|
118
118
|
* @param {Object} rowData
|
|
119
119
|
* @return {boolean}
|
|
120
120
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
let _filterByConditions = function(ctx, rowData) {
|
|
122
|
+
let conds = ctx._conds;
|
|
123
|
+
let condCount = conds ? conds.length : 0;
|
|
124
124
|
|
|
125
125
|
if(!condCount) {
|
|
126
126
|
return true; // There is no filter condition
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
let fieldName = ctx._fieldName;
|
|
130
|
+
let fmtFieldName = ctx._formattedFieldName;
|
|
131
131
|
|
|
132
|
-
|
|
132
|
+
let val = rowData[fieldName];
|
|
133
133
|
if(ctx._rawDataAccessor) {
|
|
134
134
|
val = ctx._rawDataAccessor(val);
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
var orConnector = 0;
|
|
136
|
+
let str, lowercasedStr, num, dateVal; // intentionally left undefined
|
|
137
|
+
let finalResult = false;
|
|
138
|
+
for(let i = 0; i < condCount; ++i) {
|
|
139
|
+
let orConnector = 0;
|
|
141
140
|
if(i > 0) {
|
|
142
141
|
orConnector = connectorMap[conds[i - 1].connector];
|
|
143
142
|
// TODO: AND operator has higher precedence than OR operator
|
|
@@ -150,13 +149,13 @@ var _filterByConditions = function(ctx, rowData) {
|
|
|
150
149
|
}
|
|
151
150
|
}
|
|
152
151
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
result = false;
|
|
152
|
+
let cond = conds[i];
|
|
153
|
+
let opDef = FilterOperators[cond.operatorId];
|
|
154
|
+
let result = false;
|
|
156
155
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
let opType = opDef.type;
|
|
157
|
+
let opId = opDef.id;
|
|
158
|
+
let opFunc = OperatorFunctions[opId];
|
|
160
159
|
if(opType === "blank") {
|
|
161
160
|
result = opFunc(val);
|
|
162
161
|
} else if(opType === "number") {
|
|
@@ -215,8 +214,8 @@ var _filterByConditions = function(ctx, rowData) {
|
|
|
215
214
|
* @param {Object} rowData
|
|
216
215
|
* @return {boolean}
|
|
217
216
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
let _filterByObjectMap = function(ctx, rowData) {
|
|
218
|
+
let val = rowData[ctx._fieldName];
|
|
220
219
|
if(ctx._rawDataAccessor) {
|
|
221
220
|
val = ctx._rawDataAccessor(val);
|
|
222
221
|
}
|
|
@@ -229,7 +228,7 @@ var _filterByObjectMap = function(ctx, rowData) {
|
|
|
229
228
|
* @param {Object} cond Internal condition object
|
|
230
229
|
* @return {FilterBuilder~Condition}
|
|
231
230
|
*/
|
|
232
|
-
|
|
231
|
+
let conditionToArray = function(cond) {
|
|
233
232
|
return [
|
|
234
233
|
cond.operatorId,
|
|
235
234
|
cond.origValue,
|
|
@@ -241,7 +240,7 @@ var conditionToArray = function(cond) {
|
|
|
241
240
|
* @constructor
|
|
242
241
|
* @param {FilterBuilder~Options=} options
|
|
243
242
|
*/
|
|
244
|
-
|
|
243
|
+
let FilterBuilder = function (options) {
|
|
245
244
|
this._initStaticVariables();
|
|
246
245
|
|
|
247
246
|
this._conditions = [];
|
|
@@ -255,7 +254,7 @@ FilterBuilder.prototype._initStaticVariables = function() {
|
|
|
255
254
|
FilterBuilder._initStatic = true;
|
|
256
255
|
|
|
257
256
|
FilterBuilder._updateTimezoneOffset();
|
|
258
|
-
|
|
257
|
+
let timeUntilNextDay = 86400000 - (new Date() % 86400000);
|
|
259
258
|
setTimeout(FilterBuilder._setUpdateInterval, timeUntilNextDay);
|
|
260
259
|
}
|
|
261
260
|
};
|
|
@@ -328,20 +327,20 @@ FilterBuilder.prototype.init = function(options) {
|
|
|
328
327
|
if(!options) {
|
|
329
328
|
return;
|
|
330
329
|
}
|
|
331
|
-
|
|
330
|
+
let field = options["field"];
|
|
332
331
|
if(field) {
|
|
333
332
|
this.setFieldDefinition(field, options["formatter"], options["formattedField"]);
|
|
334
333
|
} else if(field != null) {
|
|
335
334
|
this.setFieldDefinition("");
|
|
336
335
|
}
|
|
337
336
|
|
|
338
|
-
|
|
337
|
+
let useUTCTime = options["useUTCTime"];
|
|
339
338
|
if(useUTCTime != null) {
|
|
340
339
|
this._useUTCTime = useUTCTime ? true : false;
|
|
341
340
|
}
|
|
342
341
|
|
|
343
|
-
|
|
344
|
-
|
|
342
|
+
let rawDataAccessor = options["rawDataAccessor"];
|
|
343
|
+
let formattedDataAccessor = options["formattedDataAccessor"];
|
|
345
344
|
if(rawDataAccessor != null || formattedDataAccessor != null) {
|
|
346
345
|
this.setDataAccessors(rawDataAccessor, formattedDataAccessor);
|
|
347
346
|
}
|
|
@@ -381,8 +380,8 @@ FilterBuilder.prototype.setDataAccessors = function(rawDataAccessor, formattedDa
|
|
|
381
380
|
* @return {boolean} Return true, if the new condition is added
|
|
382
381
|
*/
|
|
383
382
|
FilterBuilder.prototype.addCondition = function (oper, value, connector, useUTCTime) {
|
|
384
|
-
|
|
385
|
-
|
|
383
|
+
let opId = oper ? oper.toUpperCase() : "";
|
|
384
|
+
let opDef = FilterOperators[opId];
|
|
386
385
|
if (!opDef) {
|
|
387
386
|
return false; // Unknown operation
|
|
388
387
|
}
|
|
@@ -395,7 +394,7 @@ FilterBuilder.prototype.addCondition = function (oper, value, connector, useUTCT
|
|
|
395
394
|
return false; // Invalid comparer value ("", null, undefined, NaN)
|
|
396
395
|
}
|
|
397
396
|
}
|
|
398
|
-
|
|
397
|
+
let cond = {
|
|
399
398
|
operatorId: opId,
|
|
400
399
|
origValue: value,
|
|
401
400
|
connector: connector || ""
|
|
@@ -412,11 +411,11 @@ FilterBuilder.prototype.addCondition = function (oper, value, connector, useUTCT
|
|
|
412
411
|
* @return {number} Return number of conditions being added.
|
|
413
412
|
*/
|
|
414
413
|
FilterBuilder.prototype.addConditions = function (conditions) {
|
|
415
|
-
|
|
414
|
+
let count = 0;
|
|
416
415
|
if(Array.isArray(conditions)) {
|
|
417
|
-
|
|
418
|
-
for(
|
|
419
|
-
|
|
416
|
+
let len = conditions.length;
|
|
417
|
+
for(let i = 0; i < len; ++i) {
|
|
418
|
+
let condition = conditions[i];
|
|
420
419
|
if(Array.isArray(condition)) {
|
|
421
420
|
if(this.addCondition(condition[0], condition[1], condition[2], condition[3])) {
|
|
422
421
|
++count;
|
|
@@ -449,25 +448,25 @@ FilterBuilder.prototype.buildFilter = function() {
|
|
|
449
448
|
if (!this._fieldName) {
|
|
450
449
|
return null;
|
|
451
450
|
}
|
|
452
|
-
|
|
451
|
+
let condCount = this._conditions.length;
|
|
453
452
|
if(!condCount) {
|
|
454
453
|
return null;
|
|
455
454
|
}
|
|
456
455
|
|
|
457
456
|
// Prepare user value to be in ready to use form to boost performance
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
for(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
457
|
+
let formatter = this._formatter;
|
|
458
|
+
let conds = this._conditions.slice();
|
|
459
|
+
for(let i = 0; i < condCount; ++i) {
|
|
460
|
+
let cond = conds[i];
|
|
461
|
+
let opDef = FilterOperators[cond.operatorId];
|
|
462
|
+
let opType = opDef.type;
|
|
463
|
+
let value = cond.origValue;
|
|
465
464
|
|
|
466
465
|
if(opType === "number") {
|
|
467
466
|
value = stringToDateObject(value);
|
|
468
467
|
value = convertToNumber(value);
|
|
469
468
|
} else if(opType === "date") {
|
|
470
|
-
|
|
469
|
+
let dateObj = null;
|
|
471
470
|
if(value instanceof Date) {
|
|
472
471
|
dateObj = value;
|
|
473
472
|
} else if(typeof value === "number" || typeof value === "string") {
|
|
@@ -487,7 +486,7 @@ FilterBuilder.prototype.buildFilter = function() {
|
|
|
487
486
|
cond.value = value;
|
|
488
487
|
}
|
|
489
488
|
|
|
490
|
-
|
|
489
|
+
let ctx = {
|
|
491
490
|
_conds: conds,
|
|
492
491
|
_fieldName: this._fieldName || "",
|
|
493
492
|
_formatter: formatter || null,
|
|
@@ -510,11 +509,11 @@ FilterBuilder.prototype.buildFilter = function() {
|
|
|
510
509
|
*/
|
|
511
510
|
FilterBuilder.prototype.buildMonitorFilter = function(filterStr, field, formatter, formattedField) {
|
|
512
511
|
this.setFieldDefinition(field, formatter, formattedField);
|
|
513
|
-
|
|
512
|
+
let needConvertValue = (field.lastIndexOf("_LOCAL") === field.length - 6); // _LOCAL field is special monitor field which convert time value to local timezone (idn)
|
|
514
513
|
|
|
515
|
-
|
|
516
|
-
for (
|
|
517
|
-
|
|
514
|
+
let conds = filterStr.split("♣");
|
|
515
|
+
for (let i = 0; i < conds.length; i++) {
|
|
516
|
+
let tokens = conds[i].split("♦");
|
|
518
517
|
if(needConvertValue) {
|
|
519
518
|
tokens[1] = ((tokens[1] - FilterBuilder._timezoneOffset) % 86400) + ""; // Convert to local timezone value for range filtering
|
|
520
519
|
}
|
|
@@ -530,11 +529,11 @@ FilterBuilder.prototype.buildMonitorFilter = function(filterStr, field, formatte
|
|
|
530
529
|
* @param {Function=} rawDataAccessor Raw data getter for custom data type
|
|
531
530
|
* @return {Function}
|
|
532
531
|
*/
|
|
533
|
-
|
|
532
|
+
let buildFilterFromObjectMap = function(obj, field, rawDataAccessor) {
|
|
534
533
|
if(!obj || !field) {
|
|
535
534
|
return null;
|
|
536
535
|
}
|
|
537
|
-
|
|
536
|
+
let ctx = {
|
|
538
537
|
_fieldName: field,
|
|
539
538
|
_itemMap: obj
|
|
540
539
|
};
|
|
@@ -555,7 +554,7 @@ var buildFilterFromObjectMap = function(obj, field, rawDataAccessor) {
|
|
|
555
554
|
* @return {Function} Filter function that takes rowData object
|
|
556
555
|
*/
|
|
557
556
|
FilterBuilder.prototype.parse = function(condition, field, formatter, formattedField, rawDataAccessor, formattedDataAccessor) {
|
|
558
|
-
|
|
557
|
+
let type = typeof(condition);
|
|
559
558
|
if(type === "string") {
|
|
560
559
|
if(condition.indexOf("♦") >= 0) {
|
|
561
560
|
return this.buildMonitorFilter(condition, field, formatter, formattedField);
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
declare namespace FilterOperators {
|
|
4
4
|
|
|
5
5
|
type Operator = {
|
|
6
|
+
id: string,
|
|
6
7
|
name: string,
|
|
7
8
|
type: string,
|
|
8
9
|
positive: number,
|
|
@@ -32,7 +33,17 @@ declare namespace FilterOperators {
|
|
|
32
33
|
DTB: FilterOperators.Operator,
|
|
33
34
|
TXTEQ: FilterOperators.Operator,
|
|
34
35
|
BLANK: FilterOperators.Operator,
|
|
35
|
-
NBLANK: FilterOperators.Operator
|
|
36
|
+
NBLANK: FilterOperators.Operator,
|
|
37
|
+
NEQ_BLANK: FilterOperators.Operator,
|
|
38
|
+
GREATER_THAN: FilterOperators.Operator,
|
|
39
|
+
GREATER_THAN_OR_EQUAL_TO: FilterOperators.Operator,
|
|
40
|
+
EQUAL_TO: FilterOperators.Operator,
|
|
41
|
+
LESS_THAN: FilterOperators.Operator,
|
|
42
|
+
LESS_THAN_OR_EQUAL_TO: FilterOperators.Operator,
|
|
43
|
+
TEXT_THAT_CONTAINS: FilterOperators.Operator,
|
|
44
|
+
TEXT_THAT_NOT_CONTAINS: FilterOperators.Operator,
|
|
45
|
+
TEXT_IS: FilterOperators.Operator,
|
|
46
|
+
NOT_BLANK: FilterOperators.Operator
|
|
36
47
|
};
|
|
37
48
|
|
|
38
49
|
}
|