@refinitiv-ui/efx-grid 6.0.33 → 6.0.35

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. package/lib/column-dragging/es6/ColumnDragging.js +50 -40
  2. package/lib/core/dist/core.js +210 -38
  3. package/lib/core/dist/core.min.js +1 -1
  4. package/lib/core/es6/data/DataTable.d.ts +3 -1
  5. package/lib/core/es6/data/DataTable.js +27 -9
  6. package/lib/core/es6/data/DataView.d.ts +2 -0
  7. package/lib/core/es6/data/DataView.js +12 -1
  8. package/lib/core/es6/data/Segment.d.ts +2 -0
  9. package/lib/core/es6/data/Segment.js +16 -0
  10. package/lib/core/es6/data/SegmentCollection.d.ts +1 -3
  11. package/lib/core/es6/data/SegmentCollection.js +25 -18
  12. package/lib/core/es6/grid/Core.d.ts +12 -0
  13. package/lib/core/es6/grid/Core.js +64 -2
  14. package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +13 -7
  15. package/lib/grid/index.js +1 -1
  16. package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
  17. package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
  18. package/lib/grid/themes/halo/efx-grid.less +3 -1
  19. package/lib/grid/themes/halo/light/efx-grid.js +1 -1
  20. package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
  21. package/lib/rt-grid/dist/rt-grid.js +766 -293
  22. package/lib/rt-grid/dist/rt-grid.min.js +1 -1
  23. package/lib/rt-grid/es6/ColumnDefinition.js +13 -8
  24. package/lib/rt-grid/es6/DataConnector.js +3 -2
  25. package/lib/rt-grid/es6/Grid.d.ts +3 -1
  26. package/lib/rt-grid/es6/Grid.js +148 -40
  27. package/lib/rt-grid/es6/RowDefSorter.d.ts +5 -5
  28. package/lib/rt-grid/es6/RowDefSorter.js +165 -71
  29. package/lib/rt-grid/es6/RowDefinition.d.ts +7 -2
  30. package/lib/rt-grid/es6/RowDefinition.js +48 -10
  31. package/lib/rt-grid/es6/SnapshotFiller.d.ts +1 -0
  32. package/lib/rt-grid/es6/SnapshotFiller.js +1 -11
  33. package/lib/tr-grid-column-selection/es6/ColumnSelection.js +66 -0
  34. package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +2 -0
  35. package/lib/tr-grid-column-stack/es6/ColumnStack.js +38 -13
  36. package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.d.ts +12 -5
  37. package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +128 -42
  38. package/lib/tr-grid-heat-map/es6/HeatMap.d.ts +3 -3
  39. package/lib/tr-grid-heat-map/es6/HeatMap.js +13 -2
  40. package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +2 -1
  41. package/lib/tr-grid-row-dragging/es6/RowDragging.js +153 -17
  42. package/lib/tr-grid-rowcoloring/es6/RowColoring.js +3 -2
  43. package/lib/tr-grid-textformatting/es6/TextFormatting.d.ts +20 -20
  44. package/lib/tr-grid-textformatting/es6/TextFormatting.js +37 -138
  45. package/lib/tr-grid-util/es6/CellPainter.d.ts +1 -1
  46. package/lib/tr-grid-util/es6/CellPainter.js +56 -55
  47. package/lib/tr-grid-util/es6/DragUI.js +7 -3
  48. package/lib/tr-grid-util/es6/FieldFormatter.js +6 -2
  49. package/lib/tr-grid-util/es6/NumberFormatter.js +23 -11
  50. package/lib/tr-grid-util/es6/Util.d.ts +3 -0
  51. package/lib/tr-grid-util/es6/Util.js +53 -0
  52. package/lib/tr-grid-util/es6/jet/DataGenerator.js +36 -33
  53. package/lib/types/es6/ColumnStack.d.ts +2 -0
  54. package/lib/types/es6/ConditionalColoring.d.ts +12 -5
  55. package/lib/types/es6/Core/data/DataTable.d.ts +3 -1
  56. package/lib/types/es6/Core/data/DataView.d.ts +2 -0
  57. package/lib/types/es6/Core/data/Segment.d.ts +2 -0
  58. package/lib/types/es6/Core/data/SegmentCollection.d.ts +1 -3
  59. package/lib/types/es6/Core/grid/Core.d.ts +4 -0
  60. package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +1 -0
  61. package/lib/types/es6/HeatMap.d.ts +3 -3
  62. package/lib/types/es6/RealtimeGrid/Grid.d.ts +3 -1
  63. package/lib/types/es6/RealtimeGrid/RowDefSorter.d.ts +5 -5
  64. package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +7 -2
  65. package/lib/types/es6/RealtimeGrid/SnapshotFiller.d.ts +1 -0
  66. package/lib/types/es6/RowDragging.d.ts +2 -1
  67. package/lib/types/es6/TextFormatting.d.ts +20 -20
  68. package/lib/versions.json +9 -9
  69. package/package.json +1 -1
@@ -1,70 +1,147 @@
1
+ import { cloneObject } from "../../tr-grid-util/es6/Util.js";
2
+
3
+ /** @private
4
+ * @param {*} a
5
+ * @param {*} b
6
+ * @param {number} order
7
+ * @return {number}
8
+ */
9
+ var _defaultCompare = function(a, b, order) {
10
+ if(a == null || a !== a) {
11
+ if(b == null || b !== b) {
12
+ return 0;
13
+ }
14
+ return 1;
15
+ }
16
+ if(b == null || b !== b) {
17
+ return -1;
18
+ }
19
+
20
+ if(a < b) {
21
+ return -order;
22
+ }
23
+ if(b < a) {
24
+ return order;
25
+ }
26
+ return 0;
27
+ };
28
+
1
29
  /** @constructor
2
30
  */
3
31
  var RowDefSorter = function() {
4
32
  this._defaultSorter = this._defaultSorter.bind(this);
5
33
  this._dataSorter = this._dataSorter.bind(this);
6
34
  this._rowDefSorter = this._rowDefSorter.bind(this);
35
+ this._multiColumnsSorter = this._multiColumnsSorter.bind(this);
7
36
 
8
- this._sortContext = {};
37
+ this._globalContext = {};
38
+ this._sortParams = [];
39
+ this._ctxCaches = [];
9
40
  };
10
41
 
11
-
12
- /** @type {string}
42
+ /** @type {!Object}
13
43
  * @private
14
44
  */
15
- RowDefSorter.prototype._field = "";
16
- /** @type {!Object}
45
+ RowDefSorter.prototype._globalContext;
46
+ /** @type {!Array.<Array>}
47
+ * @private
48
+ */
49
+ RowDefSorter.prototype._sortParams;
50
+ /** @type {!Array.<Object>}
17
51
  * @private
18
52
  */
19
- RowDefSorter.prototype._sortContext;
20
- /** @type {Function}
53
+ RowDefSorter.prototype._ctxCaches;
54
+ /** @type {Array}
21
55
  * @private
22
56
  */
23
- RowDefSorter.prototype._sortLogic = null;
57
+ RowDefSorter.prototype._primaryParams;
24
58
 
25
59
 
26
60
  /** @public
27
61
  */
28
62
  RowDefSorter.prototype.dispose = function() {
29
- this._sortLogic = null;
30
- this._sortContext = {}; // Clear any existing reference
63
+ this._globalContext = {}; // Clear any existing reference
64
+ this._sortParams.length = 0;
65
+ this._ctxCaches.length = 0;
66
+ this._primaryParams = null;
31
67
  };
32
68
 
33
69
  /** @public
34
- * @param {boolean=} rowSorting=false
35
70
  * @return {Function}
36
71
  */
37
- RowDefSorter.prototype.getSorter = function(rowSorting) {
38
- if(this._sortLogic) {
39
- return rowSorting ? this._rowDefSorter : this._dataSorter;
40
- } else {
41
- return this._defaultSorter;
72
+ RowDefSorter.prototype.getSorter = function() {
73
+ this._primaryParams = null;
74
+ var sortCount = this._sortParams.length;
75
+ if(sortCount === 1) {
76
+ var params = this._primaryParams = this._sortParams[0];
77
+ var sortLogic = params[1];
78
+ if(sortLogic) {
79
+ var rowSorting = params[3];
80
+ return rowSorting ? this._rowDefSorter : this._dataSorter;
81
+ } else {
82
+ return this._defaultSorter;
83
+ }
84
+ } else if(sortCount > 1) {
85
+ return this._multiColumnsSorter;
42
86
  }
43
- };
44
- /** @public
45
- * @param {Function=} func
46
- */
47
- RowDefSorter.prototype.setSortLogic = function(func) {
48
- this._sortLogic = (typeof func === "function") ? func : null;
49
- };
50
87
 
88
+ return RowDefSorter._noSorting;
89
+ };
51
90
 
52
91
  /** @public
53
- * @param {string} field
92
+ * @param {string} key
93
+ * @param {*} value
54
94
  */
55
- RowDefSorter.prototype.setField = function(field) {
56
- if(!field) {
57
- field = "";
95
+ RowDefSorter.prototype.reset = function() {
96
+ if(this._sortParams.length) {
97
+ this._sortParams.length = 0;
58
98
  }
59
- this._sortContext["field"] = this._field = field;
60
- this._sortContext["formattedField"] = field + "_FORMATTED";
61
99
  };
62
100
  /** @public
63
101
  * @param {string} key
64
102
  * @param {*} value
65
103
  */
66
104
  RowDefSorter.prototype.setContext = function(key, value) {
67
- this._sortContext[key] = value;
105
+ this._globalContext[key] = value;
106
+ };
107
+ /** @public
108
+ * @param {string} field
109
+ * @param {Function} logic
110
+ * @param {boolean} rowSorting
111
+ * @param {string} order
112
+ * @param {number} colIndex
113
+ * @param {*} colDef
114
+ */
115
+ RowDefSorter.prototype.addColumnContext = function(field, logic, rowSorting, order, colIndex, colDef) {
116
+ if(!field) {
117
+ field = "";
118
+ }
119
+ var sortPriority = this._sortParams.length;
120
+ var ctx = this._ctxCaches[sortPriority];
121
+ if(!ctx) {
122
+ ctx = this._ctxCaches[sortPriority] = cloneObject(this._globalContext);
123
+ }
124
+ var orderNum = 0;
125
+ if(order === "a") {
126
+ orderNum = 1;
127
+ } else if(order === "d") {
128
+ orderNum = -1;
129
+ }
130
+
131
+ var params = [
132
+ field, // 0
133
+ (typeof logic === "function") ? logic : null, // 1
134
+ ctx, // 2
135
+ rowSorting, // 3
136
+ orderNum // 4
137
+ ];
138
+
139
+ ctx["colIndex"] = colIndex;
140
+ ctx["field"] = field;
141
+ ctx["formattedField"] = field + "_FORMATTED";
142
+ ctx["colDef"] = colDef;
143
+
144
+ this._sortParams.push(params);
68
145
  };
69
146
 
70
147
  /** @private
@@ -73,32 +150,7 @@ RowDefSorter.prototype.setContext = function(key, value) {
73
150
  * @param {number} order
74
151
  * @return {number}
75
152
  */
76
- RowDefSorter.prototype._defaultSorter = function(rowDefA, rowDefB, order) {
77
- var orderA = rowDefA.getGroupOrder();
78
- var orderB = rowDefB.getGroupOrder();
79
- if(orderA !== orderB) {
80
- return orderA - orderB; // Regardless of sort order
81
- }
82
-
83
- var a = rowDefA.getData(this._field);
84
- var b = rowDefB.getData(this._field);
85
-
86
- if(a == null || a !== a) {
87
- if(b == null || b !== b) {
88
- return 0;
89
- }
90
- return 1;
91
- }
92
- if(b == null || b !== b) {
93
- return -1;
94
- }
95
-
96
- if(a < b) {
97
- return -order;
98
- }
99
- if(b < a) {
100
- return order;
101
- }
153
+ RowDefSorter._noSorting = function(rowDefA, rowDefB, order) {
102
154
  return 0;
103
155
  };
104
156
  /** @private
@@ -107,16 +159,30 @@ RowDefSorter.prototype._defaultSorter = function(rowDefA, rowDefB, order) {
107
159
  * @param {number} order
108
160
  * @return {number}
109
161
  */
162
+ RowDefSorter.prototype._defaultSorter = function(rowDefA, rowDefB, order) {
163
+ var field = this._primaryParams[0];
164
+ return _defaultCompare(
165
+ rowDefA.getData(field),
166
+ rowDefB.getData(field),
167
+ order
168
+ );
169
+ };
170
+ /** @private
171
+ * @param {RowDefinition} rowDefA
172
+ * @param {RowDefinition} rowDefB
173
+ * @param {number} order
174
+ * @return {number}
175
+ */
110
176
  RowDefSorter.prototype._dataSorter = function(rowDefA, rowDefB, order) {
111
- var orderA = rowDefA.getGroupOrder();
112
- var orderB = rowDefB.getGroupOrder();
113
- if(orderA !== orderB) {
114
- return orderA - orderB; // Regardless of sort order
115
- }
116
-
117
- var a = rowDefA.getData(this._field);
118
- var b = rowDefB.getData(this._field);
119
- return this._sortLogic(a, b, order, this._sortContext);
177
+ var params = this._primaryParams;
178
+ var field = params[0];
179
+ var sortLogic = params[1];
180
+ return sortLogic(
181
+ rowDefA.getData(field),
182
+ rowDefB.getData(field),
183
+ order,
184
+ params[2]
185
+ );
120
186
  };
121
187
  /** @private
122
188
  * @param {RowDefinition} rowDefA
@@ -125,13 +191,41 @@ RowDefSorter.prototype._dataSorter = function(rowDefA, rowDefB, order) {
125
191
  * @return {number}
126
192
  */
127
193
  RowDefSorter.prototype._rowDefSorter = function(rowDefA, rowDefB, order) {
128
- var orderA = rowDefA.getGroupOrder();
129
- var orderB = rowDefB.getGroupOrder();
130
- if(orderA !== orderB) {
131
- return orderA - orderB; // Regardless of sort order
194
+ var params = this._primaryParams;
195
+ var sortLogic = params[1];
196
+ return sortLogic(rowDefA, rowDefB, order, params[2]);
197
+ };
198
+ /** @private
199
+ * @param {RowDefinition} rowDefA
200
+ * @param {RowDefinition} rowDefB
201
+ * @param {number} primaryOrder
202
+ * @return {number}
203
+ */
204
+ RowDefSorter.prototype._multiColumnsSorter = function(rowDefA, rowDefB, primaryOrder) {
205
+ var sortParams = this._sortParams;
206
+ var sortCount = sortParams.length;
207
+ for(var i = 0; i < sortCount; ++i) {
208
+ var params = sortParams[i];
209
+ var field = params[0];
210
+ var sortLogic = params[1];
211
+ var ctx = params[2];
212
+ var rowSorting = params[3];
213
+ var orderNum = params[4];
214
+ var ret = 0;
215
+ if(sortLogic) {
216
+ if(rowSorting) {
217
+ ret = sortLogic(rowDefA, rowDefB, orderNum, ctx);
218
+ } else {
219
+ ret = sortLogic(rowDefA.getData(field), rowDefB.getData(field), orderNum, ctx);
220
+ }
221
+ } else {
222
+ ret = _defaultCompare(rowDefA.getData(field), rowDefB.getData(field), orderNum);
223
+ }
224
+ if(ret) {
225
+ return ret;
226
+ }
132
227
  }
133
-
134
- return this._sortLogic(rowDefA, rowDefB, order, this._sortContext);
228
+ return 0;
135
229
  };
136
230
 
137
231
  export default RowDefSorter;
@@ -6,6 +6,7 @@ declare namespace RowDefinition {
6
6
 
7
7
  type Options = {
8
8
  ric?: string|null,
9
+ permId?: string|null,
9
10
  values?: (any[]|any)|null,
10
11
  fields?: (string)[]|null,
11
12
  asChain?: boolean|null,
@@ -36,7 +37,7 @@ declare class RowDefinition {
36
37
 
37
38
  public initialize(rowOptions?: RowDefinition.Options|null): void;
38
39
 
39
- public setContent(userInput: string): boolean;
40
+ public setContent(userInput: string, permId?: string|null): boolean;
40
41
 
41
42
  public getRowId(): string;
42
43
 
@@ -70,6 +71,10 @@ declare class RowDefinition {
70
71
 
71
72
  public getRic(): string;
72
73
 
74
+ public getPermId(): string;
75
+
76
+ public getSymbol(): string;
77
+
73
78
  public getDisplayText(): string;
74
79
 
75
80
  public getLabel(): string|null|null;
@@ -138,7 +143,7 @@ declare const ROW_DEF: string;
138
143
 
139
144
  declare const ROW_TYPES: RowDefinition.RowTypes;
140
145
 
141
- declare function rowData(userInput: string): boolean;
146
+ declare function rowData(userInput: string, permId?: string|null): boolean;
142
147
 
143
148
  export {RowDefinition, ROW_DEF, ROW_TYPES};
144
149
  export default RowDefinition;
@@ -7,6 +7,7 @@ import { DataTable } from "../../core/es6/data/DataTable.js";
7
7
  /** @typedef {Object} RowDefinition~Options
8
8
  * @description RowDefinition options
9
9
  * @property {string=} ric="" RIC for real-time fields. Prefixing 0# to the ric is equivalent to specifying asChain property.
10
+ * @property {string=} permId="" Organization PermId to be used instead of ric for private company.
10
11
  * @property {(Array|Object)=} values=null Values for static data
11
12
  * @property {Array.<string>=} fields=null Field that corresponds to the given static values
12
13
  * @property {boolean=} asChain=false The given ric will be treated as a chain
@@ -88,6 +89,10 @@ RowDefinition.prototype._ric = ""; // Contains no 0#
88
89
  /** @type {string}
89
90
  * @private
90
91
  */
92
+ RowDefinition.prototype._permId = "";
93
+ /** @type {string}
94
+ * @private
95
+ */
91
96
  RowDefinition.prototype._displayText = "";
92
97
  /** @type {string|null}
93
98
  * @private
@@ -213,13 +218,20 @@ RowDefinition.prototype.initialize = function(rowOptions) {
213
218
 
214
219
  var val = rowOptions["ric"];
215
220
  if(val != null) {
216
- this.setContent(/** @type{string} */(val)); // this._dataId is modified
221
+ this._ric = val;
222
+ }
223
+ val = rowOptions["permId"];
224
+ if(val != null) {
225
+ this._permId = val;
226
+ }
227
+ if(this._ric || this._permId){
228
+ this.setContent(this._ric, this._permId); // this._dataId is modified
217
229
  }
230
+
218
231
  val = rowOptions["chainRic"];
219
232
  if(val != null) {
220
233
  this._chainRic = val;
221
234
  }
222
-
223
235
  val = rowOptions["values"];
224
236
  // eslint-disable-next-line no-undefined
225
237
  if(val !== undefined) {
@@ -273,10 +285,11 @@ RowDefinition.prototype._initializeAsConstituent = function(rowOptions) {
273
285
  }
274
286
  };
275
287
  /** @public
276
- * @param {string} userInput
288
+ * @param {string} userInput RIC
289
+ * @param {string=} permId=null Organization PermId, which use for getting ADC data for private company
277
290
  * @return {boolean} True if there is any change otherwise false
278
291
  */
279
- RowDefinition.prototype.setContent = function(userInput) {
292
+ RowDefinition.prototype.setContent = function(userInput, permId) {
280
293
  if(this._autoGenerated) { // AutoGenerated RowDefinition cannot be changed by user input
281
294
  return false;
282
295
  }
@@ -287,7 +300,15 @@ RowDefinition.prototype.setContent = function(userInput) {
287
300
  userInput += "";
288
301
  }
289
302
 
290
- if(this._userInput === userInput) {
303
+ var dirty = (this._userInput !== userInput);
304
+ if(this._permId !== permId){
305
+ this._permId = permId || "";
306
+ if(!userInput){
307
+ this._displayText = this._permId;
308
+ dirty = true;
309
+ }
310
+ }
311
+ if(!dirty) {
291
312
  return false;
292
313
  }
293
314
 
@@ -314,7 +335,7 @@ RowDefinition.prototype.setContent = function(userInput) {
314
335
  this._displayText = this._ric; // No 0#
315
336
  }
316
337
 
317
- this._dataId = this._rowId + this._ric; // JET/RTK will generate data id to be rowId (given from this rowDef) + ric;
338
+ this._dataId = this._rowId + this.getSymbol(); // JET/RTK will generate data id to be rowId (given from this rowDef) + ric;
318
339
 
319
340
  // This will work for runtime ric modification, but not for first initilization.
320
341
  if(!this.subscribeForUpdates()) {
@@ -342,6 +363,11 @@ RowDefinition.prototype.getConfigObject = function(rowOptions) {
342
363
  obj["ric"] = val;
343
364
  }
344
365
 
366
+ val = this._permId;
367
+ if(val) {
368
+ obj["permId"] = val;
369
+ }
370
+
345
371
  val = this._chainRic;
346
372
  if(val) {
347
373
  obj["chainRic"] = val;
@@ -587,6 +613,18 @@ RowDefinition.prototype.getRic = function() {
587
613
  /** @public
588
614
  * @return {string}
589
615
  */
616
+ RowDefinition.prototype.getPermId = function() {
617
+ return this._permId;
618
+ };
619
+ /** @public
620
+ * @return {string}
621
+ */
622
+ RowDefinition.prototype.getSymbol = function() {
623
+ return this._ric || this._permId;
624
+ };
625
+ /** @public
626
+ * @return {string}
627
+ */
590
628
  RowDefinition.prototype.getDisplayText = function() {
591
629
  if(this._label != null) { // Empty string is allowed
592
630
  return this._label;
@@ -652,7 +690,7 @@ RowDefinition.prototype.isAutoGenerated = function() {
652
690
  * @return {boolean}
653
691
  */
654
692
  RowDefinition.prototype.isRealTimeRow = function() {
655
- if(!this._ric) { // Empty row
693
+ if(!this.getRic()) { // Empty row
656
694
  return false;
657
695
  }
658
696
  if(this.isRowHeader()) {
@@ -669,7 +707,7 @@ RowDefinition.prototype.isRealTimeRow = function() {
669
707
  * @return {boolean} If a subscription is made, return true.
670
708
  */
671
709
  RowDefinition.prototype.subscribeForUpdates = function() {
672
- if(!this.isRealTimeRow()) {
710
+ if(!this.isRealTimeRow() && !this.getPermId()) {
673
711
  return false;
674
712
  }
675
713
 
@@ -683,14 +721,14 @@ RowDefinition.prototype.subscribeForUpdates = function() {
683
721
  if(this.isChain()) {
684
722
  this._subId = subs["addChain"](this._chainRic || this._ric, this._rowId); // Some chain require 0# symbol to populate its constituents
685
723
  // TODO: Handle Dynamic chain such as .PG.PA
686
- } else {
724
+ } else if(this._ric) {
687
725
  this._subId = subs["addRic"](this._ric, this._rowId);
688
726
  }
689
727
 
690
728
  if(prevRowData) {
691
729
  this._dc.setRowData(this._dataId, prevRowData); // TODO: We may need to create a new object instead of prevRowData for data correctness
692
730
  } else {
693
- this._dc.setRowData(this._dataId, {"X_RIC_NAME": this._ric, "ROW_DEF": this}); // Trigger data update immediately
731
+ this._dc.setRowData(this._dataId, {"X_RIC_NAME": this.getSymbol(), "ROW_DEF": this}); // Trigger data update immediately
694
732
  }
695
733
  return true;
696
734
  };
@@ -2,6 +2,7 @@ import Grid from "./Grid.js";
2
2
  import {Ext} from "../../tr-grid-util/es6/Ext.js";
3
3
  import {EventDispatcher} from "../../tr-grid-util/es6/EventDispatcher.js";
4
4
  import {FieldDefinition} from "./FieldDefinition.js";
5
+ import { isEmptyObject } from "../../tr-grid-util/es6/Util.js";
5
6
 
6
7
  declare class SnapshotFiller extends EventDispatcher {
7
8
 
@@ -3,17 +3,7 @@ import Grid from "./Grid.js";
3
3
  import {Ext} from "../../tr-grid-util/es6/Ext.js";
4
4
  import {EventDispatcher} from "../../tr-grid-util/es6/EventDispatcher.js";
5
5
  import {FieldDefinition} from "./FieldDefinition.js";
6
-
7
- /** @private
8
- * @param {Object} obj
9
- * @return {boolean}
10
- */
11
- var isEmptyObject = function (obj) {
12
- for (var key in obj) {
13
- return false;
14
- }
15
- return true;
16
- };
6
+ import { isEmptyObject } from "../../tr-grid-util/es6/Util.js";
17
7
 
18
8
  /** This class make requesting ADC field easier by encapsulating JET.Data APIs and mapping data to the row
19
9
  * @constructor
@@ -38,6 +38,8 @@ var ColumnSelectionPlugin = function ColumnSelectionPlugin(options) {
38
38
  t._onReselection = t._onReselection.bind(t);
39
39
  t._onThemeLoaded = t._onThemeLoaded.bind(t);
40
40
  t._onColumnPositionChanged = t._onColumnPositionChanged.bind(t);
41
+ t._onBeforeBatchOperation = t._onBeforeBatchOperation.bind(t);
42
+ t._onAfterBatchOperation = t._onAfterBatchOperation.bind(t);
41
43
  t._updateMenuIcon = t._updateMenuIcon.bind(t);
42
44
  t._hosts = [];
43
45
 
@@ -121,6 +123,12 @@ ColumnSelectionPlugin.prototype._menuPosition = "outside";
121
123
 
122
124
  ColumnSelectionPlugin.prototype._cgp = null; // Column grouping extension
123
125
 
126
+ /** @type {Array.<string>}
127
+ * @private
128
+ */
129
+
130
+ ColumnSelectionPlugin.prototype._prevSelectedCols = {}; // previous selected columns during batch operation
131
+
124
132
  /** @public
125
133
  * @return {string}
126
134
  */
@@ -156,6 +164,8 @@ ColumnSelectionPlugin.prototype.initialize = function (host, options) {
156
164
  host.listen("columnRemoved", this._onColumnRemoved);
157
165
  host.listen("columnAdded", this._onColumnAdded);
158
166
  host.listen("columnPositionChanged", this._onColumnPositionChanged);
167
+ host.listen("beforeBatchOperation", this._onBeforeBatchOperation);
168
+ host.listen("afterBatchOperation", this._onAfterBatchOperation);
159
169
  this.config(options);
160
170
 
161
171
  if (ColumnSelectionPlugin._stylePromise) {
@@ -1098,6 +1108,62 @@ ColumnSelectionPlugin.prototype._onReselection = function (e) {
1098
1108
  this._activeGrid.focus();
1099
1109
  };
1100
1110
  /** @private
1111
+ * @param {Object} e
1112
+ */
1113
+
1114
+
1115
+ ColumnSelectionPlugin.prototype._onBeforeBatchOperation = function (e) {
1116
+ var host = this._activeGrid;
1117
+
1118
+ if (this._hasSelection && e["batchType"] === "reset") {
1119
+ var colCount = this.getColumnCount();
1120
+
1121
+ for (var i = 0; i < colCount; ++i) {
1122
+ if (this.isSelectedColumn(i)) {
1123
+ var colId = host.getColumnId(i);
1124
+ var field = host.getColumnField(i);
1125
+
1126
+ if (colId) {
1127
+ this._prevSelectedCols[colId] = field;
1128
+ } else {
1129
+ this._prevSelectedCols[field] = "";
1130
+ }
1131
+ }
1132
+ }
1133
+
1134
+ this.clearAllSelections(); //clear all to improve performance during add/remove operation
1135
+ }
1136
+ };
1137
+ /** @private
1138
+ * @param {Object} e
1139
+ */
1140
+
1141
+
1142
+ ColumnSelectionPlugin.prototype._onAfterBatchOperation = function (e) {
1143
+ if (e["batchType"] === "reset") {
1144
+ var prevSelectedCols = Object.keys(this._prevSelectedCols);
1145
+ var prevSelectedCount = prevSelectedCols.length;
1146
+
1147
+ if (prevSelectedCount) {
1148
+ this.clearAllSelections();
1149
+
1150
+ for (var i = 0; i < prevSelectedCount; i++) {
1151
+ var colId = prevSelectedCols[i];
1152
+ var field = this._prevSelectedCols[colId];
1153
+ var prevSelectedIndex = this.getColumnIndex(colId);
1154
+
1155
+ if (prevSelectedIndex < 0) {
1156
+ prevSelectedIndex = this.getColumnIndex(field);
1157
+ }
1158
+
1159
+ this.setSelectedColumn(prevSelectedIndex, true);
1160
+ }
1161
+
1162
+ this._prevSelectedCols = {};
1163
+ }
1164
+ }
1165
+ };
1166
+ /** @private
1101
1167
  * @param {KeyboardEvent} e
1102
1168
  * @return {boolean}
1103
1169
  */
@@ -137,6 +137,8 @@ declare class ColumnStackPlugin extends GridPlugin {
137
137
 
138
138
  public isStackHidden(stackId: string): boolean|null|null;
139
139
 
140
+ public moveStack(stackId: string, destCol?: (number|string)|null): boolean;
141
+
140
142
  }
141
143
 
142
144
  export default ColumnStackPlugin;
@@ -1314,16 +1314,7 @@ ColumnStackPlugin.prototype._onColumnRemoved = function (e) {
1314
1314
  delete this._stacks[stackOpt.stackId];
1315
1315
  }
1316
1316
  } else {
1317
- if(stackOpt.spreading) {
1318
- stackOpt.activeColumn = stackOpt.stackRefs[stackOpt.stackRefs.length - 1];
1319
- } else {
1320
- stackOpt.activeColumn = stackOpt.stackRefs[0];
1321
- }
1322
-
1323
- // TODO: Add a proper way to set visibility to activeColumn when activeColumn is changed
1324
- var activeColIndex = this._getColumnIndex(stackOpt.activeColumn);
1325
- this._setColumnVisibility(activeColIndex, true);
1326
- this._updateUI();
1317
+ this._updateActiveColumn(stackOpt);
1327
1318
  }
1328
1319
  }
1329
1320
  }
@@ -1876,11 +1867,11 @@ ColumnStackPlugin.prototype.unsetParent = ColumnStackPlugin.prototype.removeColu
1876
1867
  */
1877
1868
  ColumnStackPlugin.prototype.reorderColumns = function(colList, destCol) {
1878
1869
  var dirty = false;
1879
- this._stacking = false;
1870
+ this._stacking = true;
1880
1871
 
1881
- this._reorderColumns(colList, destCol);
1872
+ dirty = this._reorderColumns(colList, destCol);
1882
1873
 
1883
- this._stacking = true;
1874
+ this._stacking = false;
1884
1875
  return dirty;
1885
1876
  };
1886
1877
  /** Move the specified column to position before the destination
@@ -1922,6 +1913,26 @@ ColumnStackPlugin.prototype._setStackVisibility = function(stackId, visible) {
1922
1913
  }
1923
1914
  };
1924
1915
 
1916
+ /** @private
1917
+ * @description Check for active column in a stack if it needs an update.
1918
+ * @param {Object} stackOpt
1919
+ */
1920
+ ColumnStackPlugin.prototype._updateActiveColumn = function(stackOpt) {
1921
+ if(!stackOpt) { return; }
1922
+
1923
+ var stackRefs = stackOpt["stackRefs"];
1924
+ if(!stackRefs || !stackRefs.length) { return; }
1925
+
1926
+ if(stackRefs.indexOf(stackOpt.activeColumn) === -1) {
1927
+ stackOpt.activeColumn = stackOpt["spreading"] ? stackRefs[stackRefs.length - 1] : stackRefs[0];
1928
+
1929
+ // TODO: Add a proper way to set visibility to activeColumn when activeColumn is changed
1930
+ var activeColIndex = this._getColumnIndex(stackOpt.activeColumn);
1931
+ this._setColumnVisibility(activeColIndex, true);
1932
+ this._updateUI();
1933
+ }
1934
+ };
1935
+
1925
1936
  /** @public
1926
1937
  * @description Hide specific stack from grid
1927
1938
  * @param {string} stackId
@@ -1962,6 +1973,20 @@ ColumnStackPlugin.prototype.isStackHidden = function(stackId) {
1962
1973
 
1963
1974
  return !isVisible;
1964
1975
  };
1976
+ /** Move an entire stack to position before the destination
1977
+ * @public
1978
+ * @param {string} stackId Stack id to be moved
1979
+ * @param {(number|string)=} destCol Destination column id or index
1980
+ * @return {boolean}
1981
+ */
1982
+ ColumnStackPlugin.prototype.moveStack = function(stackId, destCol) {
1983
+ if(!stackId){
1984
+ return false;
1985
+ }
1986
+ var colList = this.getStackMemberIds(stackId);
1987
+ var dirty = this.reorderColumns(colList, destCol);
1988
+ return dirty;
1989
+ };
1965
1990
 
1966
1991
 
1967
1992