@refinitiv-ui/efx-grid 6.0.24 → 6.0.26
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/core/dist/core.css +1 -1
- package/lib/core/dist/core.js +1331 -145
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/grid/Core.d.ts +11 -0
- package/lib/core/es6/grid/Core.js +81 -10
- package/lib/core/es6/grid/util/ElementFrameWork.js +1 -1
- package/lib/core/es6/tr-grid-theme.js +1 -1
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +768 -53
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.js +1 -1
- package/lib/rt-grid/es6/FieldDefinition.d.ts +2 -0
- package/lib/rt-grid/es6/FieldDefinition.js +13 -2
- package/lib/rt-grid/es6/Grid.d.ts +3 -1
- package/lib/rt-grid/es6/Grid.js +83 -39
- package/lib/rt-grid/es6/RowDefinition.d.ts +14 -1
- package/lib/rt-grid/es6/RowDefinition.js +54 -2
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +3 -2
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +314 -566
- package/lib/tr-grid-column-selection/es6/ColumnSelection.d.ts +13 -11
- package/lib/tr-grid-column-selection/es6/ColumnSelection.js +233 -81
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +3 -3
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +50 -56
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +21 -9
- package/lib/tr-grid-range-bar/es6/RangeBar.d.ts +18 -9
- package/lib/tr-grid-range-bar/es6/RangeBar.js +318 -139
- package/lib/tr-grid-util/es6/GridPlugin.d.ts +1 -1
- package/lib/tr-grid-util/es6/GridPlugin.js +13 -15
- package/lib/tr-grid-util/es6/GroupDefinitions.d.ts +58 -0
- package/lib/tr-grid-util/es6/GroupDefinitions.js +538 -0
- package/lib/tr-grid-util/es6/Popup.js +1 -1
- package/lib/tr-grid-util/es6/index.d.ts +2 -0
- package/lib/tr-grid-util/es6/index.js +3 -0
- package/lib/types/es6/ColumnGrouping.d.ts +3 -2
- package/lib/types/es6/ColumnSelection.d.ts +13 -11
- package/lib/types/es6/ColumnStack.d.ts +3 -3
- package/lib/types/es6/Core/grid/Core.d.ts +11 -0
- package/lib/types/es6/RealtimeGrid/FieldDefinition.d.ts +2 -0
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +3 -1
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +14 -1
- package/lib/types/es6/index.d.ts +1 -1
- package/lib/versions.json +6 -6
- package/package.json +1 -1
@@ -0,0 +1,58 @@
|
|
1
|
+
import { cloneObject } from "./Util.js";
|
2
|
+
|
3
|
+
declare class GroupDefinitions {
|
4
|
+
|
5
|
+
constructor();
|
6
|
+
|
7
|
+
public static getGroupId(groupDef: any): string;
|
8
|
+
|
9
|
+
public static calcTreeDepth(groupMap: { [key: string]: any }|null, groupDef: any): number;
|
10
|
+
|
11
|
+
public static getLeafDescendants(groupMap: { [key: string]: any }|null, groupId: string): (string)[]|null;
|
12
|
+
|
13
|
+
public toString(): string;
|
14
|
+
|
15
|
+
public getGroup(groupId: string): any;
|
16
|
+
|
17
|
+
public getDefinition(groupId: string): any;
|
18
|
+
|
19
|
+
public getGroups(): (any)[];
|
20
|
+
|
21
|
+
public getGroupMap(): { [key: string]: any };
|
22
|
+
|
23
|
+
public cloneGroupMap(): { [key: string]: any };
|
24
|
+
|
25
|
+
public getGroupChildren(groupId: string): (string)[]|null;
|
26
|
+
|
27
|
+
public getLeafDescendants(groupId: string): (string)[]|null;
|
28
|
+
|
29
|
+
public getGroupLevel(groupId: string): number;
|
30
|
+
|
31
|
+
public getRootGroup(groupId: string): any;
|
32
|
+
|
33
|
+
public getParentGroup(childId: string): any;
|
34
|
+
|
35
|
+
public getParentIds(childId: string): (string)[]|null;
|
36
|
+
|
37
|
+
public getParentId(childId: string, groupLevel?: number|null): string;
|
38
|
+
|
39
|
+
public setGroups(groupDefs?: (any)[]|null): void;
|
40
|
+
|
41
|
+
public addGroup(groupDef: any): string;
|
42
|
+
|
43
|
+
public removeGroup(groupId: string): boolean;
|
44
|
+
|
45
|
+
public setGroup(groupId: string, groupDef?: (string)[]|any|null): string;
|
46
|
+
|
47
|
+
public addGroupChild(parentId: string, childId: string): boolean;
|
48
|
+
|
49
|
+
public removeGroupChild(childId: string): boolean;
|
50
|
+
|
51
|
+
public removeAllChildren(groupId: string): boolean;
|
52
|
+
|
53
|
+
public setGroupChildren(groupId: string, newChildList: (string)[]|null): boolean;
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
export default GroupDefinitions;
|
58
|
+
export { GroupDefinitions };
|
@@ -0,0 +1,538 @@
|
|
1
|
+
import { cloneObject } from "./Util.js";
|
2
|
+
|
3
|
+
/** @constructor
|
4
|
+
*/
|
5
|
+
var GroupDefinitions = function () {
|
6
|
+
this._groupMap = {};
|
7
|
+
this._childToParent = {};
|
8
|
+
};
|
9
|
+
|
10
|
+
/** @type {!Object.<string, Object>}
|
11
|
+
* @description A map of group id to group defintion
|
12
|
+
* @private
|
13
|
+
*/
|
14
|
+
GroupDefinitions.prototype._groupMap;
|
15
|
+
/** @type {!Object.<string, string>}
|
16
|
+
* @description A map of child id to parent id
|
17
|
+
* @private
|
18
|
+
*/
|
19
|
+
GroupDefinitions.prototype._childToParent;
|
20
|
+
|
21
|
+
|
22
|
+
/** @public
|
23
|
+
* @function
|
24
|
+
* @param {Object} groupDef
|
25
|
+
* @return {string}
|
26
|
+
*/
|
27
|
+
GroupDefinitions.getGroupId = function(groupDef) {
|
28
|
+
if(groupDef) {
|
29
|
+
return groupDef.id || "";
|
30
|
+
}
|
31
|
+
return "";
|
32
|
+
};
|
33
|
+
/** @public
|
34
|
+
* @param {Object.<string, Object>} groupMap
|
35
|
+
* @param {Object} groupDef
|
36
|
+
* @return {number} Return total number of parents. Return 0 if there is no parent.
|
37
|
+
*/
|
38
|
+
GroupDefinitions.calcTreeDepth = function (groupMap, groupDef) {
|
39
|
+
var curDepth = -1;
|
40
|
+
var curNode = groupDef;
|
41
|
+
while(curNode) { // WARNING: infinite loop could occured, if parentId is cycle back to one of the child group
|
42
|
+
if(++curDepth > 15) {
|
43
|
+
console.log("WARNING: Infinite loop detected during column group creation");
|
44
|
+
break;
|
45
|
+
}
|
46
|
+
var parentId = curNode.parentId;
|
47
|
+
curNode = groupMap[parentId];
|
48
|
+
}
|
49
|
+
return curDepth;
|
50
|
+
};
|
51
|
+
/** @public
|
52
|
+
* @param {Object.<string, Object>} groupMap
|
53
|
+
* @param {string} groupId
|
54
|
+
* @return {Array.<string>}
|
55
|
+
*/
|
56
|
+
GroupDefinitions.getLeafDescendants = function (groupMap, groupId) {
|
57
|
+
var groupDef = groupMap[groupId];
|
58
|
+
if(!groupDef) {
|
59
|
+
return null;
|
60
|
+
}
|
61
|
+
|
62
|
+
var leaves = [];
|
63
|
+
var unvisitedGroups = [groupDef];
|
64
|
+
var visitedCount = 0;
|
65
|
+
var visitedMap = {};
|
66
|
+
while(visitedCount < unvisitedGroups.length) {
|
67
|
+
groupDef = unvisitedGroups[visitedCount++];
|
68
|
+
visitedMap[groupDef.id] = true;
|
69
|
+
var chdr = groupDef.children;
|
70
|
+
var len = chdr.length;
|
71
|
+
for(var i = 0; i < len; ++i) {
|
72
|
+
var childId = chdr[i];
|
73
|
+
groupDef = groupMap[childId];
|
74
|
+
if(groupDef) {
|
75
|
+
if(!visitedMap[groupDef.id]) { // Prevent infinite loop
|
76
|
+
unvisitedGroups.push(groupDef);
|
77
|
+
}
|
78
|
+
} else {
|
79
|
+
leaves.push(childId);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
return leaves;
|
84
|
+
};
|
85
|
+
|
86
|
+
|
87
|
+
/** @private
|
88
|
+
* @function
|
89
|
+
* @param {Object} obj
|
90
|
+
* @return {Object}
|
91
|
+
*/
|
92
|
+
GroupDefinitions._cloneObject = function(obj) {
|
93
|
+
var newObj = cloneObject(obj);
|
94
|
+
if(Array.isArray(newObj.children)) {
|
95
|
+
newObj.children = newObj.children;
|
96
|
+
} else {
|
97
|
+
newObj.children = [];
|
98
|
+
}
|
99
|
+
return newObj;
|
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
|
+
|
116
|
+
/** @private
|
117
|
+
* @function
|
118
|
+
* @param {Array.<string>|Object} obj
|
119
|
+
* @param {string=} groupId
|
120
|
+
* @return {Object}
|
121
|
+
*/
|
122
|
+
GroupDefinitions._toGroupDefinition = function(obj, groupId) {
|
123
|
+
var groupDef = null;
|
124
|
+
if(obj) {
|
125
|
+
if(Array.isArray(obj)) {
|
126
|
+
groupDef = {
|
127
|
+
children: obj
|
128
|
+
};
|
129
|
+
} else {
|
130
|
+
groupDef = GroupDefinitions._cloneObject(obj);
|
131
|
+
}
|
132
|
+
if(groupId) {
|
133
|
+
if(!groupDef.id) {
|
134
|
+
groupDef.name = groupId;
|
135
|
+
}
|
136
|
+
groupDef.id = groupId;
|
137
|
+
}
|
138
|
+
}
|
139
|
+
return groupDef;
|
140
|
+
};
|
141
|
+
|
142
|
+
/** @public
|
143
|
+
* @return {string}
|
144
|
+
*/
|
145
|
+
GroupDefinitions.prototype.toString = function() {
|
146
|
+
var groupMap = this._groupMap;
|
147
|
+
var lines = [];
|
148
|
+
lines.push("=== groupDefs ===");
|
149
|
+
for(var key in groupMap) {
|
150
|
+
var group = groupMap[key];
|
151
|
+
lines.push(key + ": " + JSON.stringify(group, ["id", "parentId", "children"]));
|
152
|
+
}
|
153
|
+
|
154
|
+
lines.push("=== childToParent ===");
|
155
|
+
lines.push(JSON.stringify(this._childToParent, null, 2));
|
156
|
+
lines.push("");
|
157
|
+
|
158
|
+
return lines.join("\n");
|
159
|
+
};
|
160
|
+
|
161
|
+
/** Get group definition object. This method can be used to check whether the given id is a group id or not (i.e., isGroupId).
|
162
|
+
* @public
|
163
|
+
* @param {string} groupId
|
164
|
+
* @return {Object}
|
165
|
+
*/
|
166
|
+
GroupDefinitions.prototype.getGroup = function (groupId) {
|
167
|
+
if(groupId) {
|
168
|
+
return this._groupMap[groupId] || null;
|
169
|
+
}
|
170
|
+
return null;
|
171
|
+
};
|
172
|
+
/** @public
|
173
|
+
* @function
|
174
|
+
* @param {string} groupId
|
175
|
+
* @return {Object}
|
176
|
+
*/
|
177
|
+
GroupDefinitions.prototype.getDefinition = GroupDefinitions.prototype.getGroup;
|
178
|
+
/** Get array of all existing group definitions
|
179
|
+
* @public
|
180
|
+
* @return {!Array.<Object>}
|
181
|
+
*/
|
182
|
+
GroupDefinitions.prototype.getGroups = function () {
|
183
|
+
var groupDefs = [];
|
184
|
+
var groupMap = this._groupMap;
|
185
|
+
for(var key in groupMap) {
|
186
|
+
groupDefs.push(groupMap[key]);
|
187
|
+
}
|
188
|
+
return groupDefs;
|
189
|
+
};
|
190
|
+
/** @public
|
191
|
+
* @return {!Object.<string, Object>}
|
192
|
+
*/
|
193
|
+
GroupDefinitions.prototype.getGroupMap = function () {
|
194
|
+
return this._groupMap; // WARNING: Allow access to private member
|
195
|
+
};
|
196
|
+
/** @public
|
197
|
+
* @return {!Object.<string, Object>}
|
198
|
+
*/
|
199
|
+
GroupDefinitions.prototype.cloneGroupMap = function () {
|
200
|
+
return GroupDefinitions._cloneGroupMap(this._groupMap);
|
201
|
+
};
|
202
|
+
|
203
|
+
/** Get immediate child ids of the specified group. The returned array can contain both child ids and group ids
|
204
|
+
* @public
|
205
|
+
* @param {string} groupId
|
206
|
+
* @return {Array.<string>}
|
207
|
+
*/
|
208
|
+
GroupDefinitions.prototype.getGroupChildren = function (groupId) {
|
209
|
+
var groupDef = this._groupMap[groupId];
|
210
|
+
return groupDef ? groupDef.children : null;
|
211
|
+
};
|
212
|
+
/** Get all non-group descendants of the given group id.
|
213
|
+
* @public
|
214
|
+
* @param {string} groupId
|
215
|
+
* @return {Array.<string>}
|
216
|
+
*/
|
217
|
+
GroupDefinitions.prototype.getLeafDescendants = function (groupId) {
|
218
|
+
return GroupDefinitions.getLeafDescendants(this._groupMap, groupId);
|
219
|
+
};
|
220
|
+
/** @public
|
221
|
+
* @param {string} groupId
|
222
|
+
* @return {number} Return -1 if the given groupDef is null. Return 0 if there is no parent. Return 1 or more if it has a parent
|
223
|
+
*/
|
224
|
+
GroupDefinitions.prototype.getGroupLevel = function (groupId) {
|
225
|
+
return GroupDefinitions.calcTreeDepth(this._groupMap, this._groupMap[groupId]);
|
226
|
+
};
|
227
|
+
/** @public
|
228
|
+
* @param {string} groupId
|
229
|
+
* @return {Object}
|
230
|
+
*/
|
231
|
+
GroupDefinitions.prototype.getRootGroup = function (groupId) {
|
232
|
+
if (!groupId) {
|
233
|
+
return null;
|
234
|
+
}
|
235
|
+
var groupMap = this._groupMap;
|
236
|
+
var groupDef = groupMap[groupId] || null;
|
237
|
+
// TODO: Support column id
|
238
|
+
if(groupDef) {
|
239
|
+
while (groupDef.parentId) {
|
240
|
+
var parentDef = groupMap[groupDef.parentId];
|
241
|
+
if(parentDef) {
|
242
|
+
groupDef = parentDef;
|
243
|
+
} else {
|
244
|
+
break;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
248
|
+
return groupDef;
|
249
|
+
};
|
250
|
+
/** @public
|
251
|
+
* @param {string} childId
|
252
|
+
* @return {Object}
|
253
|
+
*/
|
254
|
+
GroupDefinitions.prototype.getParentGroup = function (childId) {
|
255
|
+
return this.getGroup(this._childToParent[childId]);
|
256
|
+
};
|
257
|
+
/** @public
|
258
|
+
* @param {string} childId
|
259
|
+
* @return {Array.<string>}
|
260
|
+
*/
|
261
|
+
GroupDefinitions.prototype.getParentIds = function(childId) {
|
262
|
+
if (childId && typeof childId === "string") {
|
263
|
+
var groupId = this._childToParent[childId];
|
264
|
+
if (groupId) {
|
265
|
+
var groupIds = [groupId];
|
266
|
+
var group = this._groupMap[groupId];
|
267
|
+
while (group && group.parentId) {
|
268
|
+
group = this._groupMap[group.parentId];
|
269
|
+
if (group) {
|
270
|
+
groupIds.push(group.id);
|
271
|
+
}
|
272
|
+
}
|
273
|
+
return groupIds;
|
274
|
+
}
|
275
|
+
}
|
276
|
+
return null;
|
277
|
+
};
|
278
|
+
/** @public
|
279
|
+
* @param {string} childId
|
280
|
+
* @param {number=} groupLevel
|
281
|
+
* @return {string}
|
282
|
+
*/
|
283
|
+
GroupDefinitions.prototype.getParentId = function (childId, groupLevel) {
|
284
|
+
var parentId = this._childToParent[childId];
|
285
|
+
if(groupLevel != null) {
|
286
|
+
var currentLevel = this.getGroupLevel(parentId);
|
287
|
+
while(currentLevel > groupLevel && parentId){
|
288
|
+
parentId = this._childToParent[parentId];
|
289
|
+
currentLevel--;
|
290
|
+
}
|
291
|
+
}
|
292
|
+
|
293
|
+
return parentId || "";
|
294
|
+
};
|
295
|
+
|
296
|
+
|
297
|
+
/** Remove all existing group definitions and replace them with the given definitions.
|
298
|
+
* @public
|
299
|
+
* @param {Array.<Object>=} groupDefs Use null or empty array to remove all existing groups
|
300
|
+
*/
|
301
|
+
GroupDefinitions.prototype.setGroups = function (groupDefs) {
|
302
|
+
// Clear existing group structure
|
303
|
+
var groupMap = this._groupMap = {};
|
304
|
+
var childToParent = this._childToParent = {};
|
305
|
+
|
306
|
+
// Create group map
|
307
|
+
var i;
|
308
|
+
var grpCount = groupDefs ? groupDefs.length : 0;
|
309
|
+
var groupId = "";
|
310
|
+
for (i = 0; i < grpCount; i++) {
|
311
|
+
var groupDef = groupDefs[i];
|
312
|
+
groupId = groupDef.id;
|
313
|
+
if(groupId) {
|
314
|
+
groupMap[groupId] = groupDef;
|
315
|
+
}
|
316
|
+
}
|
317
|
+
|
318
|
+
// Create child to parent map
|
319
|
+
var groupIds = Object.keys(groupMap);
|
320
|
+
grpCount = groupIds.length;
|
321
|
+
for(i = 0; i < grpCount; ++i) {
|
322
|
+
groupId = groupIds[i];
|
323
|
+
var children = groupMap[groupId].children;
|
324
|
+
var childCount = children.length;
|
325
|
+
for (var j = 0; j < childCount; j++) {
|
326
|
+
childToParent[children[j]] = groupId;
|
327
|
+
}
|
328
|
+
}
|
329
|
+
|
330
|
+
// Apply a parent id to group definition to make it easier to find depth
|
331
|
+
for(i = 0; i < grpCount; ++i) {
|
332
|
+
groupId = groupIds[i];
|
333
|
+
var parentId = childToParent[groupId];
|
334
|
+
if(parentId) {
|
335
|
+
groupMap[groupId].parentId = parentId;
|
336
|
+
}
|
337
|
+
}
|
338
|
+
};
|
339
|
+
/** Add new group definition to existing group structure. Existing group with the same id will be replaced.
|
340
|
+
* @public
|
341
|
+
* @param {Object} groupDef Group definition object
|
342
|
+
* @return {string} Return group ID
|
343
|
+
*/
|
344
|
+
GroupDefinitions.prototype.addGroup = function (groupDef) {
|
345
|
+
var groupId = GroupDefinitions.getGroupId(groupDef);
|
346
|
+
if(groupId) {
|
347
|
+
return this.setGroup(groupId, groupDef);
|
348
|
+
}
|
349
|
+
return groupId;
|
350
|
+
};
|
351
|
+
/** @public
|
352
|
+
* @param {string} groupId
|
353
|
+
* @return {boolean}
|
354
|
+
*/
|
355
|
+
GroupDefinitions.prototype.removeGroup = function (groupId) {
|
356
|
+
var curDef = this._groupMap[groupId];
|
357
|
+
if(curDef) {
|
358
|
+
this.removeAllChildren(groupId);
|
359
|
+
this.removeGroupChild(groupId);
|
360
|
+
delete this._groupMap[groupId];
|
361
|
+
|
362
|
+
return true;
|
363
|
+
}
|
364
|
+
return false;
|
365
|
+
};
|
366
|
+
/** 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.
|
367
|
+
* @public
|
368
|
+
* @param {string} groupId
|
369
|
+
* @param {Array.<string>|Object=} groupDef
|
370
|
+
* @return {string} Return group Id. Return empty string if nothing has been changed.
|
371
|
+
*/
|
372
|
+
GroupDefinitions.prototype.setGroup = function (groupId, groupDef) {
|
373
|
+
if(!groupId) {
|
374
|
+
return "";
|
375
|
+
}
|
376
|
+
|
377
|
+
if(groupDef) {
|
378
|
+
var newDef = GroupDefinitions._toGroupDefinition(groupDef, groupId);
|
379
|
+
this._ungroupChildren(newDef.children);
|
380
|
+
|
381
|
+
var curDef = this._groupMap[groupId];
|
382
|
+
if(curDef) { // Replace
|
383
|
+
this.removeAllChildren(groupId);
|
384
|
+
}
|
385
|
+
var parentDef = this._childToParent[groupId];
|
386
|
+
if(parentDef) {
|
387
|
+
newDef.parentId = parentDef.id;
|
388
|
+
}
|
389
|
+
this._groupMap[groupId] = newDef;
|
390
|
+
|
391
|
+
var chdr = newDef.children;
|
392
|
+
var len = chdr.length;
|
393
|
+
for(var i = 0; i < len; ++i) {
|
394
|
+
var childId = chdr[i];
|
395
|
+
this._childToParent[childId] = groupId;
|
396
|
+
var childDef = this._groupMap[childId];
|
397
|
+
if(childDef) {
|
398
|
+
childDef.parentId = groupId;
|
399
|
+
}
|
400
|
+
}
|
401
|
+
} else { // Remove
|
402
|
+
if(!this.removeGroup(groupId)) {
|
403
|
+
return "";
|
404
|
+
}
|
405
|
+
}
|
406
|
+
|
407
|
+
return groupId;
|
408
|
+
};
|
409
|
+
|
410
|
+
/** Remove each child from any group
|
411
|
+
* @private
|
412
|
+
* @param {Array.<string>} children
|
413
|
+
*/
|
414
|
+
GroupDefinitions.prototype._ungroupChildren = function(children) {
|
415
|
+
if (Array.isArray(children)) {
|
416
|
+
var len = children.length;
|
417
|
+
for(var i = 0; i < len; ++i) {
|
418
|
+
this.removeGroupChild(children[i]);
|
419
|
+
}
|
420
|
+
}
|
421
|
+
};
|
422
|
+
|
423
|
+
|
424
|
+
/** @public
|
425
|
+
* @param {string} parentId Group id
|
426
|
+
* @param {string} childId
|
427
|
+
* @return {boolean}
|
428
|
+
*/
|
429
|
+
GroupDefinitions.prototype.addGroupChild = function (parentId, childId) {
|
430
|
+
var groupDef = this._groupMap[parentId];
|
431
|
+
|
432
|
+
if(childId && groupDef) {
|
433
|
+
var chdr = groupDef.children;
|
434
|
+
if(chdr && chdr.indexOf(childId) < 0) {
|
435
|
+
this.removeGroupChild(childId); // Remove previous parent
|
436
|
+
// Add new child to group structures
|
437
|
+
this._childToParent[childId] = parentId;
|
438
|
+
var childDef = this._groupMap[childId];
|
439
|
+
if(childDef) {
|
440
|
+
childDef.parentId = parentId;
|
441
|
+
}
|
442
|
+
chdr.push(childId);
|
443
|
+
return true;
|
444
|
+
}
|
445
|
+
}
|
446
|
+
return false;
|
447
|
+
};
|
448
|
+
/** Remove the given child from its own parent (i.e., unset Parent of the given child).
|
449
|
+
* @public
|
450
|
+
* @param {string} childId
|
451
|
+
* @return {boolean}
|
452
|
+
*/
|
453
|
+
GroupDefinitions.prototype.removeGroupChild = function (childId) {
|
454
|
+
var parentId = this._childToParent[childId];
|
455
|
+
if(!parentId) {
|
456
|
+
return false;
|
457
|
+
}
|
458
|
+
this._childToParent[childId] = "";
|
459
|
+
var childDef = this._groupMap[childId];
|
460
|
+
if(childDef) {
|
461
|
+
childDef.parentId = "";
|
462
|
+
}
|
463
|
+
var parentDef = this._groupMap[parentId];
|
464
|
+
if(parentDef) {
|
465
|
+
var chdr = parentDef.children;
|
466
|
+
if(chdr.length) {
|
467
|
+
var at = chdr.indexOf(childId);
|
468
|
+
if (at >= 0) {
|
469
|
+
chdr.splice(at, 1); // splice is slow
|
470
|
+
}
|
471
|
+
}
|
472
|
+
}
|
473
|
+
return true;
|
474
|
+
};
|
475
|
+
/** Remove all children from the specified group
|
476
|
+
* @public
|
477
|
+
* @param {string} groupId
|
478
|
+
* @return {boolean}
|
479
|
+
*/
|
480
|
+
GroupDefinitions.prototype.removeAllChildren = function(groupId) {
|
481
|
+
var grpDef = this._groupMap[groupId];
|
482
|
+
if(grpDef) {
|
483
|
+
var chdr = grpDef.children;
|
484
|
+
var len = chdr.length;
|
485
|
+
if(len) {
|
486
|
+
grpDef.children = [];
|
487
|
+
for(var i = 0; i < len; ++i) {
|
488
|
+
var childId = chdr[i];
|
489
|
+
if(this._childToParent[childId]) {
|
490
|
+
this._childToParent[childId] = "";
|
491
|
+
}
|
492
|
+
var childDef = this._groupMap[childId];
|
493
|
+
if(childDef) {
|
494
|
+
childDef.parentId = "";
|
495
|
+
}
|
496
|
+
}
|
497
|
+
return true;
|
498
|
+
}
|
499
|
+
}
|
500
|
+
return false;
|
501
|
+
};
|
502
|
+
/** Replace and update existing group definition.
|
503
|
+
* @public
|
504
|
+
* @param {string} groupId
|
505
|
+
* @param {Array.<string>} newChildList If null is given, all existing children in the group will be removed
|
506
|
+
* @return {boolean}
|
507
|
+
*/
|
508
|
+
GroupDefinitions.prototype.setGroupChildren = function (groupId, newChildList) {
|
509
|
+
var groupDef = this._groupMap[groupId];
|
510
|
+
if(groupDef) {
|
511
|
+
if(Array.isArray(newChildList)) {
|
512
|
+
var chdr = newChildList.slice();
|
513
|
+
this._ungroupChildren(chdr);
|
514
|
+
this.removeAllChildren(groupId);
|
515
|
+
groupDef.children = chdr;
|
516
|
+
|
517
|
+
var parentId = groupDef.id;
|
518
|
+
var len = chdr.length;
|
519
|
+
for(var i = 0; i < len; ++i) {
|
520
|
+
var childId = chdr[i];
|
521
|
+
this._childToParent[childId] = parentId;
|
522
|
+
var childDef = this._groupMap[childId];
|
523
|
+
if(childDef) {
|
524
|
+
childDef.parentId = parentId;
|
525
|
+
}
|
526
|
+
}
|
527
|
+
|
528
|
+
return true;
|
529
|
+
} else if(!newChildList && groupDef.children.length) {
|
530
|
+
this.removeAllChildren(groupId);
|
531
|
+
return true;
|
532
|
+
}
|
533
|
+
}
|
534
|
+
return false;
|
535
|
+
};
|
536
|
+
|
537
|
+
export default GroupDefinitions;
|
538
|
+
export { GroupDefinitions };
|
@@ -647,7 +647,7 @@ Popup.prototype.updatePosition = function () {
|
|
647
647
|
if ((y + eh > bb) && (py + aw - eh > sy)) {
|
648
648
|
y = py + aw - eh;
|
649
649
|
}
|
650
|
-
} else { // bottom
|
650
|
+
} else { // under, bottom, or etc.
|
651
651
|
x = px;
|
652
652
|
y = py + ah;
|
653
653
|
// Re-position, if the popup exceeds the bounds
|
@@ -30,6 +30,7 @@ import {Table} from "./Table.js";
|
|
30
30
|
import {ExpanderIcon} from "./ExpanderIcon.js";
|
31
31
|
import ElementObserver from "./ElementObserver.js";
|
32
32
|
import MultiTableManager from "./MultiTableManager.js";
|
33
|
+
import GroupDefinitions from "./GroupDefinitions.js";
|
33
34
|
|
34
35
|
export {
|
35
36
|
GridPlugin
|
@@ -60,4 +61,5 @@ GridPlugin
|
|
60
61
|
, ExpanderIcon
|
61
62
|
, ElementObserver
|
62
63
|
, MultiTableManager
|
64
|
+
, GroupDefinitions
|
63
65
|
};
|
@@ -31,6 +31,7 @@ import {Table} from "./Table.js";
|
|
31
31
|
import {ExpanderIcon} from "./ExpanderIcon.js";
|
32
32
|
import ElementObserver from "./ElementObserver.js";
|
33
33
|
import MultiTableManager from "./MultiTableManager.js";
|
34
|
+
import GroupDefinitions from "./GroupDefinitions.js";
|
34
35
|
|
35
36
|
var tr = window["tr"];
|
36
37
|
if(!tr) {
|
@@ -65,6 +66,7 @@ tr.Table = Table;
|
|
65
66
|
tr.ExpanderIcon = ExpanderIcon;
|
66
67
|
tr.ElementObserver = ElementObserver;
|
67
68
|
tr.MultiTableManager = MultiTableManager;
|
69
|
+
tr.GroupDefinitions = GroupDefinitions;
|
68
70
|
|
69
71
|
export {
|
70
72
|
GridPlugin
|
@@ -95,5 +97,6 @@ GridPlugin
|
|
95
97
|
, ExpanderIcon
|
96
98
|
, ElementObserver
|
97
99
|
, MultiTableManager
|
100
|
+
, GroupDefinitions
|
98
101
|
};
|
99
102
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Ext } from "../../tr-grid-util/es6/Ext.js";
|
2
2
|
import { cloneObject } from "../../tr-grid-util/es6/Util.js";
|
3
3
|
import { GridPlugin } from "../../tr-grid-util/es6/GridPlugin.js";
|
4
|
+
import { GroupDefinitions } from "../../tr-grid-util/es6/GroupDefinitions.js";
|
4
5
|
import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
|
5
6
|
|
6
7
|
declare namespace ColumnGroupingPlugin {
|
@@ -42,7 +43,7 @@ declare class ColumnGroupingPlugin extends GridPlugin {
|
|
42
43
|
|
43
44
|
public addColumnGrouping(groupDef: ColumnGroupingPlugin.GroupDefinition|null): void;
|
44
45
|
|
45
|
-
public removeGroup(groupId: string):
|
46
|
+
public removeGroup(groupId: string): boolean;
|
46
47
|
|
47
48
|
public getGroupDefinition(groupId: string): ColumnGroupingPlugin.GroupDefinition|null;
|
48
49
|
|
@@ -52,7 +53,7 @@ declare class ColumnGroupingPlugin extends GridPlugin {
|
|
52
53
|
|
53
54
|
public setGroupDefinitions(groupDefs: ColumnGroupingPlugin.GroupDefinitions|null): void;
|
54
55
|
|
55
|
-
public setGroupChildren(groupId: string, newChildList: (string)[]|null):
|
56
|
+
public setGroupChildren(groupId: string, newChildList: (string)[]|null): boolean;
|
56
57
|
|
57
58
|
public getGroupChildren(groupId: string): (string)[]|null;
|
58
59
|
|