@refinitiv-ui/efx-grid 6.0.52 → 6.0.54

Sign up to get free protection for your applications and to get access to all the features.
@@ -67,7 +67,7 @@ GroupDefinitions.getLeafDescendants = function (groupMap, groupId) {
67
67
  groupDef = unvisitedGroups[visitedCount++];
68
68
  visitedMap[groupDef.id] = true;
69
69
  var chdr = groupDef.children;
70
- var len = chdr.length;
70
+ var len = chdr ? chdr.length : 0;
71
71
  for(var i = 0; i < len; ++i) {
72
72
  var childId = chdr[i];
73
73
  groupDef = groupMap[childId];
@@ -87,44 +87,30 @@ GroupDefinitions.getLeafDescendants = function (groupMap, groupId) {
87
87
  /** @private
88
88
  * @function
89
89
  * @param {Object} obj
90
- * @return {Object}
90
+ * @return {Object} Return a new object with guaranteed children property
91
91
  */
92
92
  GroupDefinitions._cloneObject = function(obj) {
93
93
  var newObj = cloneObject(obj);
94
- if(Array.isArray(newObj.children)) {
95
- newObj.children = newObj.children;
94
+ if(Array.isArray(newObj.children)) { // This is to prevent modification from the outside source
95
+ newObj.children = newObj.children.slice();
96
96
  } else {
97
97
  newObj.children = [];
98
98
  }
99
99
  return newObj;
100
100
  };
101
- /** @private
102
- * @param {Object} groupMap
103
- * @return {!Object}
104
- */
105
- GroupDefinitions._cloneGroupMap = function (groupMap) {
106
- var outMap = {};
107
- for(var groupId in groupMap) {
108
- var groupDef = groupMap[groupId];
109
- var obj = GroupDefinitions._cloneObject(groupDef);
110
- obj.children = groupDef.children.slice();
111
- outMap[groupId] = obj;
112
- }
113
- return outMap;
114
- };
115
101
 
116
102
  /** @private
117
103
  * @function
118
104
  * @param {Array.<string>|Object} obj
119
105
  * @param {string=} groupId
120
- * @return {Object}
106
+ * @return {Object} Return a new object with guaranteed children property
121
107
  */
122
108
  GroupDefinitions._toGroupDefinition = function(obj, groupId) {
123
109
  var groupDef = null;
124
110
  if(obj) {
125
111
  if(Array.isArray(obj)) {
126
112
  groupDef = {
127
- children: obj
113
+ children: obj.slice()
128
114
  };
129
115
  } else {
130
116
  groupDef = GroupDefinitions._cloneObject(obj);
@@ -204,7 +190,43 @@ GroupDefinitions.prototype.getGroupMap = function () {
204
190
  * @return {!Object.<string, Object>}
205
191
  */
206
192
  GroupDefinitions.prototype.cloneGroupMap = function () {
207
- return GroupDefinitions._cloneGroupMap(this._groupMap);
193
+ var groupMap = this._groupMap;
194
+ var outMap = {};
195
+ for(var groupId in groupMap) {
196
+ var groupDef = groupMap[groupId];
197
+ var obj = GroupDefinitions._cloneObject(groupDef);
198
+ outMap[groupId] = obj;
199
+ }
200
+ return outMap;
201
+ };
202
+ /** In case of a children array has been modified outside of GroupDefinitions, this method is needed to re-create internal maps to reflect existing structure
203
+ * @public
204
+ */
205
+ GroupDefinitions.prototype.rebuildMap = function () {
206
+ var groupMap = this._groupMap;
207
+ var childToParent = this._childToParent = {};
208
+
209
+ // Create child to parent map
210
+ var groupIds = Object.keys(groupMap);
211
+ var grpCount = groupIds.length;
212
+ var i, groupId;
213
+ for(i = 0; i < grpCount; ++i) {
214
+ groupId = groupIds[i];
215
+ var chdr = groupMap[groupId].children;
216
+ var childCount = chdr ? chdr.length : 0;
217
+ for (var j = 0; j < childCount; j++) {
218
+ childToParent[chdr[j]] = groupId;
219
+ }
220
+ }
221
+
222
+ // Apply a parent id to group definition to make it easier to find depth
223
+ for(i = 0; i < grpCount; ++i) {
224
+ groupId = groupIds[i];
225
+ var parentId = childToParent[groupId];
226
+ if(parentId) {
227
+ groupMap[groupId].parentId = parentId;
228
+ }
229
+ }
208
230
  };
209
231
 
210
232
  /** Get immediate child ids of the specified group. The returned array can contain both child ids and group ids
@@ -284,7 +306,7 @@ GroupDefinitions.prototype.getParentIds = function(childId) {
284
306
  };
285
307
  /** @public
286
308
  * @param {string} childId
287
- * @param {number=} groupLevel
309
+ * @param {number=} groupLevel Default is to retrieve immediate parent id. Use 0 to get root (topmost) group id
288
310
  * @return {string}
289
311
  */
290
312
  GroupDefinitions.prototype.getParentId = function (childId, groupLevel) {
@@ -312,47 +334,25 @@ GroupDefinitions.prototype.removeAllGroups = function () {
312
334
  }
313
335
  return false;
314
336
  };
315
- /** Remove all existing group definitions and replace them with the given definitions.
337
+ /** Remove all existing group definitions and replace them with the given definitions. Note that this method does not check for circular referencing nor duplication of ids
316
338
  * @public
317
339
  * @param {Array.<Object>=} groupDefs Use null or empty array to remove all existing groups
318
340
  */
319
341
  GroupDefinitions.prototype.setGroups = function (groupDefs) {
320
342
  // Clear existing group structure
321
343
  var groupMap = this._groupMap = {};
322
- var childToParent = this._childToParent = {};
323
344
 
324
345
  // Create group map
325
- var i;
326
346
  var grpCount = groupDefs ? groupDefs.length : 0;
327
- var groupId = "";
328
- for (i = 0; i < grpCount; i++) {
347
+ for (var i = 0; i < grpCount; i++) {
329
348
  var groupDef = groupDefs[i];
330
- groupId = groupDef.id;
349
+ var groupId = groupDef.id;
331
350
  if(groupId) {
332
- groupMap[groupId] = groupDef;
351
+ groupMap[groupId] = GroupDefinitions._cloneObject(groupDef);
333
352
  }
334
353
  }
335
354
 
336
- // Create child to parent map
337
- var groupIds = Object.keys(groupMap);
338
- grpCount = groupIds.length;
339
- for(i = 0; i < grpCount; ++i) {
340
- groupId = groupIds[i];
341
- var children = groupMap[groupId].children;
342
- var childCount = children.length;
343
- for (var j = 0; j < childCount; j++) {
344
- childToParent[children[j]] = groupId;
345
- }
346
- }
347
-
348
- // Apply a parent id to group definition to make it easier to find depth
349
- for(i = 0; i < grpCount; ++i) {
350
- groupId = groupIds[i];
351
- var parentId = childToParent[groupId];
352
- if(parentId) {
353
- groupMap[groupId].parentId = parentId;
354
- }
355
- }
355
+ this.rebuildMap();
356
356
  };
357
357
  /** Add new group definition to existing group structure. Existing group with the same id will be replaced.
358
358
  * @public
@@ -381,11 +381,11 @@ GroupDefinitions.prototype.removeGroup = function (groupId) {
381
381
  }
382
382
  return false;
383
383
  };
384
- /** Replace and update existing group definition. New group is added if the given id has no match. Existing group will be removed of no new definition is given.
384
+ /** Replace and update existing group definition. A new group will be added, only if the given id has no match. Existing group will be removed of no new definition is given.
385
385
  * @public
386
386
  * @param {string} groupId
387
- * @param {Array.<string>|Object=} groupDef
388
- * @return {string} Return group Id. Return empty string if nothing has been changed.
387
+ * @param {(Array.<string>|Object)=} groupDef
388
+ * @return {string} Return group Id. Return empty string, if nothing has been changed
389
389
  */
390
390
  GroupDefinitions.prototype.setGroup = function (groupId, groupDef) {
391
391
  if(!groupId) {
@@ -406,7 +406,7 @@ GroupDefinitions.prototype.setGroup = function (groupId, groupDef) {
406
406
  }
407
407
  this._groupMap[groupId] = newDef;
408
408
 
409
- var chdr = newDef.children;
409
+ var chdr = newDef.children; // newDef is guaranteed to have children property
410
410
  var len = chdr.length;
411
411
  for(var i = 0; i < len; ++i) {
412
412
  var childId = chdr[i];
@@ -438,7 +438,8 @@ GroupDefinitions.prototype._ungroupChildren = function(children) {
438
438
  }
439
439
  };
440
440
 
441
- /** @public
441
+ /** Check if the given child id is an immediate child of the given group
442
+ * @public
442
443
  * @param {string} parentId Group id
443
444
  * @param {string} childId
444
445
  * @return {boolean}
@@ -448,7 +449,30 @@ GroupDefinitions.prototype.hasGroupChild = function (parentId, childId) {
448
449
  if(childId && groupDef) {
449
450
  var chdr = groupDef.children;
450
451
  if(chdr) {
451
- return chdr.indexOf(childId) >= 0;
452
+ return chdr.indexOf(childId) >= 0; // TODO: Use childToParent map to improve performance
453
+ }
454
+ }
455
+ return false;
456
+ };
457
+ /** Check if the specified id is contained within the given group regardless of any group level that the id is in
458
+ * @public
459
+ * @param {string} groupId
460
+ * @param {string} childId
461
+ * @return {boolean}
462
+ */
463
+ GroupDefinitions.prototype.contains = function (groupId, childId) {
464
+ if(groupId && childId) {
465
+ if(groupId === childId) {
466
+ return true;
467
+ }
468
+ var levelLimit = 20;
469
+ var parentId = this._childToParent[childId];
470
+ while(parentId && levelLimit) { // WARNING: Circular dependency could happen
471
+ if(groupId === parentId) {
472
+ return true;
473
+ }
474
+ --levelLimit;
475
+ parentId = this._childToParent[parentId];
452
476
  }
453
477
  }
454
478
  return false;
@@ -515,7 +539,7 @@ GroupDefinitions.prototype.unsetParent = function (childId) {
515
539
  var parentDef = this._groupMap[parentId];
516
540
  if(parentDef) {
517
541
  var chdr = parentDef.children;
518
- if(chdr.length) {
542
+ if(chdr && chdr.length) {
519
543
  var at = chdr.indexOf(childId);
520
544
  if (at >= 0) {
521
545
  chdr.splice(at, 1); // splice is slow
@@ -533,7 +557,7 @@ GroupDefinitions.prototype.removeAllChildren = function(groupId) {
533
557
  var grpDef = this._groupMap[groupId];
534
558
  if(grpDef) {
535
559
  var chdr = grpDef.children;
536
- var len = chdr.length;
560
+ var len = chdr ? chdr.length : 0;
537
561
  if(len) {
538
562
  grpDef.children = [];
539
563
  for(var i = 0; i < len; ++i) {
@@ -4,22 +4,22 @@ import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
4
4
  declare namespace AutoTooltipPlugin {
5
5
 
6
6
  type Options = {
7
- header?: boolean,
8
- title?: boolean,
9
- footer?: boolean,
10
- content?: boolean,
11
- quickMode?: boolean
7
+ header?: boolean|null,
8
+ title?: boolean|null,
9
+ footer?: boolean|null,
10
+ content?: boolean|null,
11
+ quickMode?: boolean|null
12
12
  };
13
13
 
14
14
  type ColumnOptions = {
15
- autoTooltip?: boolean
15
+ autoTooltip?: boolean|null
16
16
  };
17
17
 
18
18
  }
19
19
 
20
20
  declare class AutoTooltipPlugin extends GridPlugin {
21
21
 
22
- constructor(options?: AutoTooltipPlugin.Options);
22
+ constructor(options?: AutoTooltipPlugin.Options|null);
23
23
 
24
24
  public getName(): string;
25
25
 
@@ -31,9 +31,9 @@ declare class AutoTooltipPlugin extends GridPlugin {
31
31
 
32
32
  public getConfigObject(gridOptions?: any): any;
33
33
 
34
- public applyTooltip(colIndex: number, fromR?: number, toR?: number): void;
34
+ public applyTooltip(colIndex: number, fromR?: number|null, toR?: number|null): void;
35
35
 
36
- public applyTooltipToColumns(colIndices?: (number)[]): void;
36
+ public applyTooltipToColumns(colIndices?: (number)[]|null): void;
37
37
 
38
38
  public applyTooltipToAllColumns(): void;
39
39
 
@@ -93,6 +93,8 @@ declare class ColumnGroupingPlugin extends GridPlugin {
93
93
 
94
94
  public unpinGroup(groupId: string, dest?: (number|string)|null): void;
95
95
 
96
+ public selectGroupHeaders(colIndices: (number)[]|null): void;
97
+
96
98
  public static getObjectIndex(column: any): number;
97
99
 
98
100
  public static getObjectId(column: any): string;
@@ -8,6 +8,8 @@ declare namespace FieldDefinition {
8
8
 
9
9
  function get(field: string): any;
10
10
 
11
+ function getFieldInfo(field: string): any;
12
+
11
13
  function hasFieldInfo(field: string): boolean;
12
14
 
13
15
  function getTimeSeriesChildren(field: string): any;
@@ -18,8 +20,6 @@ declare namespace FieldDefinition {
18
20
 
19
21
  function setSynapseConfig(config: Grid.SynapseConfig|null): void;
20
22
 
21
- function setFieldCaching(caching: boolean): void;
22
-
23
23
  function disableTimeSeriesExpansion(disabled: boolean): void;
24
24
 
25
25
  function isFormula(field: string): boolean;
@@ -135,9 +135,13 @@ declare class Grid extends EventDispatcher {
135
135
 
136
136
  public replaceColumn(columnOption: ColumnDefinition.Options|string|null, colRef: Grid.ColumnReference|null): void;
137
137
 
138
+ public getFieldInfo(field: string): any;
139
+
140
+ public loadFieldInfo(field: string): Promise<any>|null;
141
+
138
142
  public setColumns(columns: (any)[]|null): void;
139
143
 
140
- public restoreColumns(columns: (any)[]|null): void;
144
+ public restoreColumns(columns: (any)[]|null, byId?: boolean|null): void;
141
145
 
142
146
  public setFields(ary: (string)[]|null): void;
143
147
 
package/lib/versions.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
- "tr-grid-util": "1.3.116",
2
+ "tr-grid-util": "1.3.117",
3
3
  "tr-grid-printer": "1.0.16",
4
4
  "@grid/column-dragging": "1.0.14",
5
5
  "@grid/row-segmenting": "1.0.24",
6
6
  "@grid/statistics-row": "1.0.14",
7
7
  "@grid/zoom": "1.0.11",
8
- "tr-grid-auto-tooltip": "1.1.5",
8
+ "tr-grid-auto-tooltip": "1.1.6",
9
9
  "tr-grid-cell-selection": "1.0.33",
10
10
  "tr-grid-checkbox": "1.0.60",
11
11
  "tr-grid-column-fitter": "1.0.39",
12
12
  "tr-grid-column-formatting": "0.9.34",
13
- "tr-grid-column-grouping": "1.0.52",
13
+ "tr-grid-column-grouping": "1.0.53",
14
14
  "tr-grid-column-resizing": "1.0.28",
15
- "tr-grid-column-selection": "1.0.28",
16
- "tr-grid-column-stack": "1.0.67",
15
+ "tr-grid-column-selection": "1.0.29",
16
+ "tr-grid-column-stack": "1.0.68",
17
17
  "tr-grid-conditional-coloring": "1.0.61",
18
18
  "tr-grid-content-wrap": "1.0.20",
19
19
  "tr-grid-contextmenu": "1.0.39",
package/package.json CHANGED
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "version": "6.0.52"
69
+ "version": "6.0.54"
70
70
  }