@refinitiv-ui/efx-grid 6.0.44 → 6.0.46

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/lib/column-selection-dialog/lib/column-selection-dialog.d.ts +3 -1
  2. package/lib/column-selection-dialog/lib/column-selection-dialog.js +24 -3
  3. package/lib/column-selection-dialog/themes/base.less +23 -12
  4. package/lib/column-selection-dialog/themes/elemental/dark/column-selection-dialog.js +1 -1
  5. package/lib/column-selection-dialog/themes/elemental/dark/es5/all-elements.js +1 -1
  6. package/lib/column-selection-dialog/themes/elemental/light/column-selection-dialog.js +1 -1
  7. package/lib/column-selection-dialog/themes/elemental/light/es5/all-elements.js +1 -1
  8. package/lib/column-selection-dialog/themes/halo/dark/column-selection-dialog.js +1 -1
  9. package/lib/column-selection-dialog/themes/halo/dark/es5/all-elements.js +1 -1
  10. package/lib/column-selection-dialog/themes/halo/light/column-selection-dialog.js +1 -1
  11. package/lib/column-selection-dialog/themes/halo/light/es5/all-elements.js +1 -1
  12. package/lib/column-selection-dialog/themes/solar/charcoal/column-selection-dialog.js +1 -1
  13. package/lib/column-selection-dialog/themes/solar/charcoal/es5/all-elements.js +1 -1
  14. package/lib/column-selection-dialog/themes/solar/pearl/column-selection-dialog.js +1 -1
  15. package/lib/column-selection-dialog/themes/solar/pearl/es5/all-elements.js +1 -1
  16. package/lib/core/dist/core.js +204 -186
  17. package/lib/core/dist/core.min.js +1 -1
  18. package/lib/core/es6/data/DataView.d.ts +2 -0
  19. package/lib/core/es6/data/DataView.js +170 -81
  20. package/lib/core/es6/data/Segment.d.ts +2 -0
  21. package/lib/core/es6/data/Segment.js +6 -0
  22. package/lib/core/es6/grid/Core.d.ts +0 -4
  23. package/lib/core/es6/grid/Core.js +28 -105
  24. package/lib/grid/index.js +1 -1
  25. package/lib/index.d.ts +0 -4
  26. package/lib/index.js +0 -4
  27. package/lib/tr-grid-printer/es6/GridPrinter.js +5 -5
  28. package/lib/tr-grid-printer/es6/index.js +1 -1
  29. package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +5 -0
  30. package/lib/tr-grid-row-filtering/es6/RowFiltering.js +30 -1
  31. package/lib/tr-grid-util/es6/CoralItems.js +2 -2
  32. package/lib/tr-grid-util/es6/ElfDate.js +1 -1
  33. package/lib/tr-grid-util/es6/ElfUtil.js +2 -2
  34. package/lib/tr-grid-util/es6/ExpanderIcon.js +1 -1
  35. package/lib/tr-grid-util/es6/GridPlugin.js +1 -1
  36. package/lib/tr-grid-util/es6/Icon.js +3 -3
  37. package/lib/tr-grid-util/es6/MultiTableManager.js +3 -3
  38. package/lib/tr-grid-util/es6/RowPainter.js +6 -2
  39. package/lib/tr-grid-util/es6/jet/Adc.d.ts +9 -0
  40. package/lib/tr-grid-util/es6/jet/Adc.js +268 -0
  41. package/lib/tr-grid-util/es6/jet/MockQuotes2.js +96 -7
  42. package/lib/tr-grid-util/es6/jet/MockUtil.d.ts +7 -0
  43. package/lib/tr-grid-util/es6/jet/MockUtil.js +25 -0
  44. package/lib/tr-grid-util/es6/jet/mockDataAPI.d.ts +2 -3
  45. package/lib/tr-grid-util/es6/jet/mockDataAPI.js +3 -288
  46. package/lib/types/es6/Core/data/DataView.d.ts +2 -0
  47. package/lib/types/es6/Core/data/Segment.d.ts +2 -0
  48. package/lib/types/es6/Core/grid/Core.d.ts +0 -4
  49. package/lib/types/es6/RowFiltering.d.ts +5 -0
  50. package/lib/utils/index.d.ts +5 -3
  51. package/lib/utils/index.js +5 -3
  52. package/lib/versions.json +3 -5
  53. package/lib/window-exporter.js +5 -0
  54. package/package.json +1 -1
@@ -274,6 +274,8 @@ declare class DataView extends EventDispatcher {
274
274
 
275
275
  public sortSegments(compare: ((...params: any[]) => any)|null): void;
276
276
 
277
+ public enableEmptySegmentFiltering(enabled?: boolean|null): void;
278
+
277
279
  public setSegmentClassification(segmentRef: string|number|null, fields: string|(string)[]|null): boolean;
278
280
 
279
281
  public getWrapSize(): number;
@@ -68,6 +68,8 @@ var DataView = function(source) {
68
68
  t._onRefreshTimeout = t._onRefreshTimeout.bind(t);
69
69
  t._updateWrapCount = t._updateWrapCount.bind(t);
70
70
 
71
+ t._byRemovalMap = t._byRemovalMap.bind(t);
72
+
71
73
  t._rids = [];
72
74
  t._sortingDefs = [];
73
75
  t._columnStats = {};
@@ -121,6 +123,15 @@ DataView.prototype._hiddenRids = null;
121
123
  * @type {Object.<string, boolean>}
122
124
  */
123
125
  DataView.prototype._collapsedRids = null; // for segmentation
126
+ /** @private
127
+ * @type {Object.<string, number>}
128
+ */
129
+ DataView.prototype._excludedRids = null;
130
+ /** @private
131
+ * @type {boolean}
132
+ */
133
+ DataView.prototype._emptySegmentFiltering = false;
134
+
124
135
  /** @private
125
136
  * @type {Object.<string, number>}
126
137
  */
@@ -817,8 +828,6 @@ DataView.prototype.hideRow = function(rId, hidden) {
817
828
  */
818
829
  DataView.prototype.hideRows = function(rowRefs, hidden) {
819
830
  hidden = hidden !== false;
820
- var dirty = false;
821
- var rids = this._toRowIds(rowRefs);
822
831
  var hiddenRids = this._hiddenRids;
823
832
 
824
833
  if(hidden){
@@ -829,11 +838,19 @@ DataView.prototype.hideRows = function(rowRefs, hidden) {
829
838
  return; // All rows are visible
830
839
  }
831
840
 
841
+ var rids = this._toRowIds(rowRefs);
842
+ var dirty = false;
843
+
832
844
  for(var i = rids.length; --i >= 0;) {
833
845
  var rid = rids[i];
834
846
  if(rid) { // undefined, null, and an empty string value are not a valid row id
835
- if(!!hiddenRids[rid] !== hidden) {
836
- hiddenRids[rid] = hidden;
847
+ if(hidden) {
848
+ if(!hiddenRids[rid]) {
849
+ hiddenRids[rid] = true;
850
+ dirty = true;
851
+ }
852
+ } else if(hiddenRids[rid]) {
853
+ delete hiddenRids[rid];
837
854
  dirty = true;
838
855
  }
839
856
  }
@@ -842,11 +859,9 @@ DataView.prototype.hideRows = function(rowRefs, hidden) {
842
859
  if(dirty) {
843
860
  if(!hidden) {
844
861
  var hasHiddenRow = false;
845
- for(var key in hiddenRids) {
846
- if(hiddenRids[key]) {
847
- hasHiddenRow = true;
848
- break;
849
- }
862
+ for(var key in hiddenRids) { // eslint-disable-line
863
+ hasHiddenRow = true;
864
+ break;
850
865
  }
851
866
  if(!hasHiddenRow) {
852
867
  hiddenRids = this._hiddenRids = null;
@@ -935,23 +950,14 @@ DataView.prototype.filterOut = function(cid, value) {
935
950
  */
936
951
  DataView.prototype.filterInOnce = function(cid, value, opt_filteringOut) {
937
952
  var checker = this._getFilterLogic(cid, value);
938
- if(!checker) { return; }
939
-
940
- var filteringOut = (opt_filteringOut === true);
941
- var rids = this._rids;
942
- var dt = this._dt;
943
953
  var removalMap = {};
944
- var totalRem = 0;
945
- var len = rids.length;
946
- for(var i = len; --i >= 0;) {
947
- var rid = rids[i];
948
- var values = dt.getRowData(rid);
949
- if (!values || checker(rid, values) === filteringOut) {
950
- removalMap[rid] = true;
951
- ++totalRem;
952
- }
954
+ if(!this._getRemovalMap(
955
+ removalMap,
956
+ checker,
957
+ (opt_filteringOut === true)
958
+ )) {
959
+ return;
953
960
  }
954
- if(totalRem <= 0) { return; }
955
961
 
956
962
  var firstChange = this._removeRowIds(removalMap);
957
963
 
@@ -974,13 +980,13 @@ DataView.prototype.filterOutOnce = function(cid, value) {
974
980
  this.filterInOnce(cid, value, true);
975
981
  };
976
982
  /** @private
977
- * @param {!Object.<string, *>} removalMap
983
+ * @param {!Object} removalMap
978
984
  * @return {number}
979
985
  */
980
986
  DataView.prototype._removeRowIds = function(removalMap) {
981
- var firstChange = this._removeArrayItems(this._rids, removalMap);
987
+ var firstChange = DataView._removeArrayItems(this._rids, removalMap);
982
988
  if(this._groupView) {
983
- firstChange = this._removeArrayItems(this._groupView, removalMap);
989
+ firstChange = DataView._removeArrayItems(this._groupView, removalMap);
984
990
  }
985
991
 
986
992
  if(this._groupMembers) {
@@ -2549,6 +2555,19 @@ DataView.prototype.getSegmentChildIds = function(segmentRef) {
2549
2555
  DataView.prototype.sortSegments = function (compare) {
2550
2556
  this._dt.sortSegments(compare);
2551
2557
  };
2558
+ /** Automatically hide empty segment when all of its member are filtered out. An empty segment will not be hidden, if there is no active filter. Collapsed segment does not count as filtering.
2559
+ * @public
2560
+ * @param {boolean=} enabled
2561
+ */
2562
+ DataView.prototype.enableEmptySegmentFiltering = function (enabled) {
2563
+ enabled = enabled !== false;
2564
+ if(this._emptySegmentFiltering !== enabled) {
2565
+ this._emptySegmentFiltering = enabled;
2566
+ if(this._userFilter) {
2567
+ this._refreshAndNotify();
2568
+ }
2569
+ }
2570
+ };
2552
2571
 
2553
2572
  /**
2554
2573
  * @public
@@ -2709,26 +2728,35 @@ DataView.prototype._updateRowIds = function(opt_rowIds) {
2709
2728
  // Perform the following sequences: parent view cloning >> row hiding >> row filtering >> row grouping >> sorting >> paging
2710
2729
  this._rids = opt_rowIds || this._parent.getAllRowIds(); // Get all data ids
2711
2730
 
2712
- if(this._hiddenRids) {
2713
- this._removeArrayItems(this._rids, this._hiddenRids);
2714
- }
2731
+ this._dispatch("beforeFiltering", {});
2732
+
2733
+ this._excludedRids = {};
2734
+ var exclusionCount = 0;
2735
+ exclusionCount += DataView._copyObjectKeys(this._excludedRids, this._hiddenRids);
2736
+
2737
+ // Segment separators should not be filtered out (hidden)
2715
2738
  var segments = this._dt._getSegmentSeparators();
2739
+ var filterExceptions = segments ? segments.getSegments() : null;
2740
+ var userRemoval = this._getRemovalMap(this._excludedRids, this._userFilter, this._filteringOut, filterExceptions);
2741
+ exclusionCount += userRemoval;
2742
+
2716
2743
  this._collapsedRids = null;
2717
- var filterExceptions = null;
2718
2744
  if(segments) {
2719
- filterExceptions = segments.getSegments(); // Segment separators should not be filtered out (hidden)
2720
- var collapsedRows = this._collapsedRids = segments.getCollapsedRows(); // Children of collapsed segments must be filtered out (hidden)
2721
- if(collapsedRows) {
2722
- this._removeArrayItems(this._rids, collapsedRows);
2745
+ if(userRemoval && this._emptySegmentFiltering) {
2746
+ exclusionCount += this._getEmptySegments(this._excludedRids, filterExceptions);
2723
2747
  }
2748
+ this._collapsedRids = segments.getCollapsedRows();
2749
+ // Children of collapsed segments must be filtered out (hidden)
2750
+ exclusionCount += DataView._copyObjectKeys(this._excludedRids, this._collapsedRids);
2724
2751
  }
2725
2752
 
2726
- this._dispatch("beforeFiltering", {});
2727
- this._quickFilter(this._userFilter, this._filteringOut, filterExceptions);
2728
-
2729
- if(this._groupLevel > 0 && !opt_rowIds) {
2730
- this._quickFilter(this._groupFilterLogic, false); // Filter In
2753
+ if(this._groupLevel > 0 && !opt_rowIds) { // WARNING: The line below is quite slow
2754
+ exclusionCount += this._getRemovalMap(this._excludedRids, this._groupFilterLogic, false); // Filter In
2731
2755
  }
2756
+ if(exclusionCount) {
2757
+ this._rids = this._rids.filter(this._byRemovalMap);
2758
+ }
2759
+ this._excludedRids = null;
2732
2760
 
2733
2761
  if(this._groupMembers) { // Has grouping
2734
2762
  this._populateGroups(); // View will be properly re-populate inside _populateGroups()
@@ -3000,9 +3028,9 @@ DataView.prototype._onRowUpdated = function(e) { // onUpdate
3000
3028
 
3001
3029
  if(this._groupLevel > 0) {
3002
3030
  if(processingFlag === 1) { // The row is moved to the other group
3003
- if(this._removeArrayItem(this._rids, rid) >= 0) {
3031
+ if(DataView._removeArrayItem(this._rids, rid) >= 0) {
3004
3032
  if(this._groupView) {
3005
- this._removeArrayItem(this._groupView, rid);
3033
+ DataView._removeArrayItem(this._groupView, rid);
3006
3034
  }
3007
3035
  }
3008
3036
  if(this._shared.multiGroupRow) {
@@ -3202,34 +3230,31 @@ DataView.prototype._getRowIndex = function(rids, opt_nextRid, opt_fallback) {
3202
3230
  * @returns {number}
3203
3231
  */
3204
3232
  DataView.prototype._removeDataRow = function(rid) {
3205
- var at = this._removeArrayItem(this._rids, rid);
3233
+ var at = DataView._removeArrayItem(this._rids, rid);
3206
3234
  if(this._groupView && at >= 0) {
3207
- at = this._removeArrayItem(this._groupView, rid);
3235
+ at = DataView._removeArrayItem(this._groupView, rid);
3208
3236
  }
3209
3237
  return at;
3210
3238
  };
3211
3239
  /** @private
3212
- * @param {Array} ary
3240
+ * @param {!Array} ary
3213
3241
  * @param {*} item
3214
3242
  * @return {number} Index of the removed item
3215
3243
  */
3216
- DataView.prototype._removeArrayItem = function(ary, item) {
3217
- var len = ary.length;
3218
- for(var i = 0; i < len; ++i) {
3219
- if(ary[i] === item) {
3220
- ary.splice(i, 1);
3221
- return i;
3222
- }
3244
+ DataView._removeArrayItem = function(ary, item) {
3245
+ var at = ary.indexOf(item);
3246
+ if(at >= 0) {
3247
+ ary.splice(at, 1);
3223
3248
  }
3224
- return -1;
3249
+ return at;
3225
3250
  };
3226
3251
  /** Remove multiple array items
3227
3252
  * @private
3228
3253
  * @param {Array.<string>} ary
3229
- * @param {Object.<string, *>} items
3254
+ * @param {Object} items
3230
3255
  * @return {number} First item index that is being removed. NaN if no item is removed
3231
3256
  */
3232
- DataView.prototype._removeArrayItems = function(ary, items) {
3257
+ DataView._removeArrayItems = function(ary, items) {
3233
3258
  var f = NaN;
3234
3259
  var c = 0;
3235
3260
  for(var i = ary.length; --i >= 0;) {
@@ -3248,6 +3273,23 @@ DataView.prototype._removeArrayItems = function(ary, items) {
3248
3273
  return f;
3249
3274
  };
3250
3275
  /** @private
3276
+ * @param {Object} baseObj
3277
+ * @param {Object} masterObj
3278
+ * @returns {number}
3279
+ */
3280
+ DataView._copyObjectKeys = function(baseObj, masterObj) {
3281
+ if(masterObj) {
3282
+ var count = 0;
3283
+
3284
+ for(var key in masterObj) {
3285
+ baseObj[key] = 1;
3286
+ ++count; // WARNING: duplicated key can be counted more than once
3287
+ }
3288
+ return count;
3289
+ }
3290
+ return 0;
3291
+ };
3292
+ /** @private
3251
3293
  * @param {string|null} rid
3252
3294
  * @param {Object} rowData
3253
3295
  * @return {boolean}
@@ -3281,9 +3323,6 @@ DataView.prototype.isRowFiltered = function(rid, rowData) {
3281
3323
  return true;
3282
3324
  }
3283
3325
  }
3284
- if(this.isSegmentSeparator(rid)) {
3285
- return false; // Segment separator cannot be filtered
3286
- }
3287
3326
  if(this._collapsedRids) {
3288
3327
  if(this._collapsedRids[rid]) {
3289
3328
  return true;
@@ -3325,40 +3364,90 @@ DataView.prototype._sort = function() {
3325
3364
  };
3326
3365
 
3327
3366
  /** @private
3367
+ * @param {string} rid
3368
+ * @returns {boolean}
3369
+ */
3370
+ DataView.prototype._byRemovalMap = function(rid) {
3371
+ return !this._excludedRids[rid];
3372
+ };
3373
+ /** @private
3374
+ * @param {Object} removalMap
3328
3375
  * @param {Function} checker
3329
3376
  * @param {boolean} filteringOut
3330
3377
  * @param {Object=} exceptions
3378
+ * @returns {number} Number of rids that would be filtered out
3331
3379
  */
3332
- DataView.prototype._quickFilter = function(checker, filteringOut, exceptions) {
3380
+ DataView.prototype._getRemovalMap = function(removalMap, checker, filteringOut, exceptions) {
3333
3381
  if(!checker) {
3334
- return;
3382
+ return 0;
3335
3383
  }
3336
3384
 
3337
3385
  var rids = this._rids; // Make local variable to speed up the process
3338
- var len = rids.length;
3339
3386
  var dt = this._dt;
3340
- var spliceCount = 0;
3341
- for(var i = len; --i >= 0;) {
3342
- var rid = rids[i];
3343
- var removed = false;
3344
- if(!exceptions || !exceptions[rid]) {
3345
- var values = dt.getRowData(rid);
3387
+ var count = 0;
3388
+ var rid, i, values;
3389
+ var len = rids.length;
3390
+
3391
+ if(exceptions) {
3392
+ for(i = len; --i >= 0;) {
3393
+ rid = rids[i];
3394
+ if(!exceptions[rid]) {
3395
+ values = dt.getRowData(rid);
3396
+ if (values) {
3397
+ if(checker(rid, values) === filteringOut) {
3398
+ removalMap[rid] = 1;
3399
+ ++count;
3400
+ }
3401
+ } else {
3402
+ removalMap[rid] = 1;
3403
+ ++count;
3404
+ }
3405
+ }
3406
+ }
3407
+ } else {
3408
+ for(i = len; --i >= 0;) {
3409
+ rid = rids[i];
3410
+ values = dt.getRowData(rid);
3346
3411
  if (values) {
3347
- removed = checker(rid, values) === filteringOut;
3412
+ if(checker(rid, values) === filteringOut) {
3413
+ removalMap[rid] = 1;
3414
+ ++count;
3415
+ }
3348
3416
  } else {
3349
- removed = true;
3417
+ removalMap[rid] = 1;
3418
+ ++count;
3350
3419
  }
3351
3420
  }
3352
- if(removed) {
3353
- ++spliceCount;
3354
- } else if(spliceCount > 0) {
3355
- rids.splice(i + 1, spliceCount);
3356
- spliceCount = 0;
3357
- }
3358
3421
  }
3359
- if(spliceCount > 0) {
3360
- rids.splice(0, spliceCount);
3422
+ return count;
3423
+ };
3424
+ /** @private
3425
+ * @param {Object} removalMap
3426
+ * @param {Object} segmentRids
3427
+ * @returns {number} Number of rids that would be filtered out
3428
+ */
3429
+ DataView.prototype._getEmptySegments = function(removalMap, segmentRids) {
3430
+ var segments = this._dt._getSegmentSeparators();
3431
+ var count = 0;
3432
+ for(var segmentId in segmentRids) {
3433
+ var segment = segments.getSegment(segmentId);
3434
+ if(segment) {
3435
+ var chdr = segment.getChildren();
3436
+ var emptySegment = true;
3437
+ for(var childId in chdr) {
3438
+ if(!removalMap[childId]) {
3439
+ emptySegment = false;
3440
+ break;
3441
+ }
3442
+ }
3443
+ if(emptySegment) {
3444
+ removalMap[segmentId] = 1;
3445
+ ++count;
3446
+ }
3447
+ }
3361
3448
  }
3449
+
3450
+ return count;
3362
3451
  };
3363
3452
  /** @private
3364
3453
  * @param {string|Function|undefined} cid
@@ -3638,13 +3727,13 @@ DataView.prototype._removeGroupMember = function (groupIndex, groupId) {
3638
3727
  };
3639
3728
  /** @private
3640
3729
  * @param {string} cid
3641
- * @param {Object.<string, *>} values
3730
+ * @param {Object} values
3642
3731
  * @return {Array.<string>}
3643
3732
  */
3644
3733
  DataView.prototype._defaultGroupCriteria = function(cid, values) {
3645
3734
  var val = values[cid];
3646
3735
  if(Array.isArray(val)) {
3647
- return val.map(function(data) {
3736
+ return val.map(function(data) { // TODO: this is very slow
3648
3737
  return data + "";
3649
3738
  });
3650
3739
  } else {
@@ -3653,11 +3742,11 @@ DataView.prototype._defaultGroupCriteria = function(cid, values) {
3653
3742
  };
3654
3743
  /** @private
3655
3744
  * @param {string|null} rid
3656
- * @param {Object.<string, *>} values
3745
+ * @param {Object} values
3657
3746
  * @return {boolean}
3658
3747
  */
3659
3748
  DataView.prototype._groupFilterLogic = function(rid, values) {
3660
- var gids = this._groupCriteria[this._groupLevel - 1](values);
3749
+ var gids = this._groupCriteria[this._groupLevel - 1](values); // TODO: this is very slow
3661
3750
  return gids.indexOf(this._groupId) >= 0;
3662
3751
  };
3663
3752
 
@@ -27,6 +27,8 @@ declare class Segment extends EventDispatcher {
27
27
 
28
28
  public getChildIds(): (string)[];
29
29
 
30
+ public getChildren(): any;
31
+
30
32
  public getChildCount(): number;
31
33
 
32
34
  public getClassification(): (string)[]|null;
@@ -292,6 +292,12 @@ Segment.prototype.getChildIds = function() {
292
292
  return this._childCount ? Object.keys(this._children) : [];
293
293
  };
294
294
  /** @public
295
+ * @return {!Object}
296
+ */
297
+ Segment.prototype.getChildren = function() {
298
+ return this._children;
299
+ };
300
+ /** @public
295
301
  * @return {number}
296
302
  */
297
303
  Segment.prototype.getChildCount = function() {
@@ -405,10 +405,6 @@ declare class Core extends ElementWrapper {
405
405
 
406
406
  public getColumnGroupChildIds(groupId: string): (string)[]|null;
407
407
 
408
- public getValidColumnList(colIds: (string)[]|null, columnMap?: any): (string)[];
409
-
410
- public createColumnMap(colIds?: (string)[]|null): any;
411
-
412
408
  public startBatch(batchType: string): boolean;
413
409
 
414
410
  public stopBatch(batchType: string): boolean;