@refinitiv-ui/efx-grid 6.0.13 → 6.0.14
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.js +1209 -160
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataCache.js +1 -1
- package/lib/core/es6/data/DataTable.d.ts +18 -3
- package/lib/core/es6/data/DataTable.js +203 -17
- package/lib/core/es6/data/DataView.d.ts +8 -1
- package/lib/core/es6/data/DataView.js +30 -2
- package/lib/core/es6/data/Segment.d.ts +36 -11
- package/lib/core/es6/data/Segment.js +575 -59
- package/lib/core/es6/data/SegmentCollection.d.ts +15 -1
- package/lib/core/es6/data/SegmentCollection.js +236 -80
- package/lib/core/es6/grid/Core.js +1 -1
- package/lib/grid/index.js +1 -1
- package/lib/row-segmenting/es6/RowSegmenting.d.ts +2 -0
- package/lib/row-segmenting/es6/RowSegmenting.js +26 -3
- package/lib/rt-grid/dist/rt-grid.js +1115 -158
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/Grid.d.ts +2 -0
- package/lib/rt-grid/es6/Grid.js +53 -0
- package/lib/rt-grid/es6/RowDefinition.js +22 -2
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +1 -0
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +194 -366
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +10 -3
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +93 -36
- package/lib/tr-grid-util/es6/RowPainter.d.ts +2 -1
- package/lib/tr-grid-util/es6/RowPainter.js +7 -1
- package/lib/tr-grid-util/es6/jet/mockDataAPI.d.ts +1 -0
- package/lib/tr-grid-util/es6/jet/mockDataAPI.js +191 -52
- package/lib/types/es6/ColumnGrouping.d.ts +1 -0
- package/lib/types/es6/ColumnStack.d.ts +10 -3
- package/lib/types/es6/Core/data/DataTable.d.ts +18 -3
- package/lib/types/es6/Core/data/DataView.d.ts +8 -1
- package/lib/types/es6/Core/data/Segment.d.ts +36 -11
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +15 -1
- package/lib/types/es6/RealtimeGrid/ColumnDefinition.d.ts +6 -1
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +2 -0
- package/lib/types/es6/RowSegmenting.d.ts +2 -0
- package/lib/versions.json +4 -4
- package/package.json +1 -1
@@ -1,9 +1,13 @@
|
|
1
|
+
import Ext from "../../../tr-grid-util/es6/Ext.js";
|
2
|
+
import EventDispatcher from "../../../tr-grid-util/es6/EventDispatcher.js";
|
1
3
|
import Segment from "./Segment.js";
|
2
4
|
|
3
5
|
declare class SegmentCollection {
|
4
6
|
|
5
7
|
constructor();
|
6
8
|
|
9
|
+
public dispose(): void;
|
10
|
+
|
7
11
|
public addSegment(rid: string): boolean;
|
8
12
|
|
9
13
|
public addSegments(rids: (string)[]|null): boolean;
|
@@ -34,7 +38,7 @@ declare class SegmentCollection {
|
|
34
38
|
|
35
39
|
public getCollapsedRows(): any;
|
36
40
|
|
37
|
-
public addSegmentChild(segmentId: string, rid: string): boolean;
|
41
|
+
public addSegmentChild(segmentId: string, rid: string, dataId?: string|null): boolean;
|
38
42
|
|
39
43
|
public addSegmentChildren(segmentId: string, rids: (string)[]|null): boolean;
|
40
44
|
|
@@ -54,6 +58,16 @@ declare class SegmentCollection {
|
|
54
58
|
|
55
59
|
public getSegmentValues(rids: (string)[]): (number)[]|null;
|
56
60
|
|
61
|
+
public logStructure(): string;
|
62
|
+
|
63
|
+
public logRowIdMap(): string;
|
64
|
+
|
65
|
+
public setSegmentClassification(segmentId: string, fields: string|(string)[]|null): boolean;
|
66
|
+
|
67
|
+
public hasClassification(): boolean;
|
68
|
+
|
69
|
+
public classify(rows: { [key: string]: any }|null): boolean;
|
70
|
+
|
57
71
|
}
|
58
72
|
|
59
73
|
export default SegmentCollection;
|
@@ -1,17 +1,29 @@
|
|
1
|
+
import Ext from "../../../tr-grid-util/es6/Ext.js";
|
2
|
+
import EventDispatcher from "../../../tr-grid-util/es6/EventDispatcher.js";
|
1
3
|
import Segment from "./Segment.js";
|
2
4
|
|
3
5
|
/** @constructor
|
4
6
|
*/
|
5
7
|
var SegmentCollection = function() {
|
8
|
+
this._onSubSegmentAdded = this._onSubSegmentAdded.bind(this);
|
9
|
+
this._onSubSegmentRemoved = this._onSubSegmentRemoved.bind(this);
|
10
|
+
|
6
11
|
this._segments = {};
|
7
|
-
this.
|
12
|
+
this._insertionList = [];
|
13
|
+
this._removalList = [];
|
14
|
+
|
15
|
+
this._shared = {
|
16
|
+
childToSegment: {}, // child Id to segment Id
|
17
|
+
dirtyCollapsingState: false
|
18
|
+
};
|
8
19
|
};
|
20
|
+
Ext.inherits(SegmentCollection, EventDispatcher);
|
9
21
|
|
10
22
|
|
11
23
|
/** @type {!Object.<string, Segment>}
|
12
24
|
* @private
|
13
25
|
*/
|
14
|
-
SegmentCollection.prototype._segments;
|
26
|
+
SegmentCollection.prototype._segments; // Contains both segment and their sub segments
|
15
27
|
/** @type {number}
|
16
28
|
* @private
|
17
29
|
*/
|
@@ -20,28 +32,53 @@ SegmentCollection.prototype._segmentCount = 0;
|
|
20
32
|
* @private
|
21
33
|
*/
|
22
34
|
SegmentCollection.prototype._collapsedRids = null;
|
35
|
+
/** @type {!Object}
|
36
|
+
* @private
|
37
|
+
*/
|
38
|
+
SegmentCollection.prototype._shared;
|
39
|
+
/** @type {Array.<Segment>}
|
40
|
+
* @private
|
41
|
+
*/
|
42
|
+
SegmentCollection.prototype._segmentList = null; // Array of main segments
|
43
|
+
/** @type {Array.<Segment>}
|
44
|
+
* @private
|
45
|
+
*/
|
46
|
+
SegmentCollection.prototype._insertionList = null; // Array of sub segments
|
47
|
+
/** @type {Array.<string>}
|
48
|
+
* @private
|
49
|
+
*/
|
50
|
+
SegmentCollection.prototype._removalList = null; // Array of sub segment ids
|
23
51
|
/** @type {boolean}
|
24
52
|
* @private
|
25
53
|
*/
|
26
|
-
SegmentCollection.prototype.
|
27
|
-
/** @type {
|
54
|
+
SegmentCollection.prototype._classification = false;
|
55
|
+
/** @type {boolean}
|
28
56
|
* @private
|
29
57
|
*/
|
30
|
-
SegmentCollection.prototype.
|
31
|
-
|
58
|
+
SegmentCollection.prototype._classifierChanged = false;
|
32
59
|
|
60
|
+
/** @public
|
61
|
+
*/
|
62
|
+
SegmentCollection.prototype.dispose = function() {
|
63
|
+
this.removeAllSegments();
|
64
|
+
this._collapsedRids = null;
|
65
|
+
this._segmentList = this._insertionList = this._removalList = null;
|
66
|
+
};
|
33
67
|
/** @public
|
34
68
|
* @param {string} rid
|
35
69
|
* @return {boolean} Returns true if there is any change. Otherwise, returns false
|
36
70
|
*/
|
37
71
|
SegmentCollection.prototype.addSegment = function(rid) {
|
38
72
|
if(rid && !this._segments[rid]) {
|
39
|
-
if(this.
|
73
|
+
if(this.getParentRowId(rid)) {
|
40
74
|
console.log("child of a segment cannot be set as a segment separator");
|
41
75
|
return false;
|
42
76
|
}
|
43
|
-
this._segments[rid] = new Segment(rid);
|
77
|
+
var segment = this._segments[rid] = new Segment(rid, this._shared);
|
78
|
+
segment.addEventListener("subSegmentAdded", this._onSubSegmentAdded);
|
79
|
+
segment.addEventListener("subSegmentRemoved", this._onSubSegmentRemoved);
|
44
80
|
++this._segmentCount;
|
81
|
+
this._segmentList = null; // order could be changed
|
45
82
|
return true;
|
46
83
|
}
|
47
84
|
return false;
|
@@ -71,7 +108,7 @@ SegmentCollection.prototype.containsSegment = function(rid) {
|
|
71
108
|
* @return {string} parent row id of this segmentation. If the parent row id for this segmentation cannot be found, return ""
|
72
109
|
*/
|
73
110
|
SegmentCollection.prototype.getParentRowId = function(rid) {
|
74
|
-
return this.
|
111
|
+
return this._shared.childToSegment[rid] || "";
|
75
112
|
};
|
76
113
|
/** @public
|
77
114
|
* @param {string} rid
|
@@ -80,10 +117,27 @@ SegmentCollection.prototype.getParentRowId = function(rid) {
|
|
80
117
|
SegmentCollection.prototype.removeSegment = function(rid) {
|
81
118
|
var segment = this._segments[rid];
|
82
119
|
if(segment) {
|
83
|
-
if(
|
84
|
-
this.
|
120
|
+
if(this._segmentCount <= 1) {
|
121
|
+
return this.removeAllSegments();
|
122
|
+
}
|
123
|
+
if(segment.isSubSegment()) {
|
124
|
+
this._removalList.push(segment.getId());
|
85
125
|
}
|
86
|
-
segment.
|
126
|
+
var subSegIds = segment.getSubSegmentIds();
|
127
|
+
if(subSegIds) {
|
128
|
+
var len = subSegIds.length;
|
129
|
+
for(var i = 0; i < len; ++i) {
|
130
|
+
var subSegId = subSegIds[i];
|
131
|
+
if(this._segments[subSegId]) {
|
132
|
+
this._removalList.push(subSegId);
|
133
|
+
delete this._segments[subSegId]; // Slow
|
134
|
+
--this._segmentCount;
|
135
|
+
}
|
136
|
+
}
|
137
|
+
}
|
138
|
+
segment.removeAllChildren(); // This is important for updating childToSegment
|
139
|
+
segment.dispose();
|
140
|
+
|
87
141
|
delete this._segments[rid]; // Slow
|
88
142
|
--this._segmentCount;
|
89
143
|
return true;
|
@@ -95,10 +149,15 @@ SegmentCollection.prototype.removeSegment = function(rid) {
|
|
95
149
|
*/
|
96
150
|
SegmentCollection.prototype.removeAllSegments = function() {
|
97
151
|
if(this._segmentCount) {
|
152
|
+
for(var key in this._segments) {
|
153
|
+
this._segments[key].dispose();
|
154
|
+
}
|
98
155
|
this._segments = {};
|
99
|
-
this._childToSegmentId = {};
|
100
156
|
this._segmentCount = 0;
|
101
|
-
this.
|
157
|
+
this._segmentList = null;
|
158
|
+
this._shared.childToSegment = {};
|
159
|
+
|
160
|
+
this._classification = this._classifierChanged = false;
|
102
161
|
return true;
|
103
162
|
}
|
104
163
|
return false;
|
@@ -139,11 +198,7 @@ SegmentCollection.prototype.getSegmentIds = function() {
|
|
139
198
|
SegmentCollection.prototype.collapseSegment = function(segmentId, bool) {
|
140
199
|
var segment = this._segments[segmentId];
|
141
200
|
if(segment) {
|
142
|
-
|
143
|
-
if(dirty) {
|
144
|
-
this._dirtyCollapsingState = true;
|
145
|
-
return true;
|
146
|
-
}
|
201
|
+
return segment.collapse(bool);
|
147
202
|
}
|
148
203
|
return false;
|
149
204
|
};
|
@@ -166,7 +221,6 @@ SegmentCollection.prototype.expandAllSegments = function() {
|
|
166
221
|
dirty |= segmentSeparators[rid].expand();
|
167
222
|
}
|
168
223
|
if(dirty) {
|
169
|
-
this._dirtyCollapsingState = true;
|
170
224
|
return true;
|
171
225
|
}
|
172
226
|
}
|
@@ -187,17 +241,19 @@ SegmentCollection.prototype.isCollapsedSegment = function(segmentId) {
|
|
187
241
|
* @return {Object}
|
188
242
|
*/
|
189
243
|
SegmentCollection.prototype.getCollapsedRows = function() {
|
190
|
-
if(this.
|
191
|
-
this.
|
244
|
+
if(this._shared.dirtyCollapsingState) {
|
245
|
+
this._shared.dirtyCollapsingState = false;
|
192
246
|
var collapsedRids = null;
|
193
247
|
var count = 0;
|
194
248
|
if(this._segmentCount) {
|
195
249
|
var segmentSeparators = this._segments;
|
196
250
|
collapsedRids = {};
|
197
251
|
for(var rid in segmentSeparators) {
|
198
|
-
|
199
|
-
|
200
|
-
|
252
|
+
var segment = segmentSeparators[rid];
|
253
|
+
if(!segment.isSubSegment()) {
|
254
|
+
if(segment.getCollapsingStates(collapsedRids)) {
|
255
|
+
++count;
|
256
|
+
}
|
201
257
|
}
|
202
258
|
}
|
203
259
|
}
|
@@ -209,18 +265,13 @@ SegmentCollection.prototype.getCollapsedRows = function() {
|
|
209
265
|
/** @public
|
210
266
|
* @param {string} segmentId
|
211
267
|
* @param {string} rid
|
268
|
+
* @param {string=} dataId Row id for retrieving data
|
212
269
|
* @return {boolean} Returns true if there is any change. Otherwise, returns false
|
213
270
|
*/
|
214
|
-
SegmentCollection.prototype.addSegmentChild = function(segmentId, rid) {
|
271
|
+
SegmentCollection.prototype.addSegmentChild = function(segmentId, rid, dataId) {
|
215
272
|
var segment = this._segments[segmentId];
|
216
|
-
if(segment) {
|
217
|
-
|
218
|
-
if(dirty) {
|
219
|
-
if(segment.isCollapsed()) {
|
220
|
-
this._dirtyCollapsingState = true;
|
221
|
-
}
|
222
|
-
return true;
|
223
|
-
}
|
273
|
+
if(segment && !segment.isSubSegment()) {
|
274
|
+
return segment.addChild(rid, dataId);
|
224
275
|
}
|
225
276
|
return false;
|
226
277
|
};
|
@@ -231,14 +282,8 @@ SegmentCollection.prototype.addSegmentChild = function(segmentId, rid) {
|
|
231
282
|
*/
|
232
283
|
SegmentCollection.prototype.addSegmentChildren = function(segmentId, rids) {
|
233
284
|
var segment = this._segments[segmentId];
|
234
|
-
if(segment) {
|
235
|
-
|
236
|
-
if(dirty) {
|
237
|
-
if(segment.isCollapsed()) {
|
238
|
-
this._dirtyCollapsingState = true;
|
239
|
-
}
|
240
|
-
return true;
|
241
|
-
}
|
285
|
+
if(segment && !segment.isSubSegment()) {
|
286
|
+
return segment.addChildren(rids);
|
242
287
|
}
|
243
288
|
return false;
|
244
289
|
};
|
@@ -262,13 +307,7 @@ SegmentCollection.prototype.containsSegmentChild = function(segmentId, rid) {
|
|
262
307
|
SegmentCollection.prototype.removeSegmentChild = function(segmentId, rid) {
|
263
308
|
var segment = this._segments[segmentId];
|
264
309
|
if(segment) {
|
265
|
-
|
266
|
-
if(dirty) {
|
267
|
-
if(segment.isCollapsed()) {
|
268
|
-
this._dirtyCollapsingState = true;
|
269
|
-
}
|
270
|
-
return true;
|
271
|
-
}
|
310
|
+
return segment.removeChild(rid);
|
272
311
|
}
|
273
312
|
return false;
|
274
313
|
};
|
@@ -280,13 +319,7 @@ SegmentCollection.prototype.removeSegmentChild = function(segmentId, rid) {
|
|
280
319
|
SegmentCollection.prototype.removeSegmentChildren = function(segmentId, rids) {
|
281
320
|
var segment = this._segments[segmentId];
|
282
321
|
if(segment) {
|
283
|
-
|
284
|
-
if(dirty) {
|
285
|
-
if(segment.isCollapsed()) {
|
286
|
-
this._dirtyCollapsingState = true;
|
287
|
-
}
|
288
|
-
return true;
|
289
|
-
}
|
322
|
+
return segment.removeChildren(rids);
|
290
323
|
}
|
291
324
|
return false;
|
292
325
|
};
|
@@ -294,20 +327,20 @@ SegmentCollection.prototype.removeSegmentChildren = function(segmentId, rids) {
|
|
294
327
|
* @return {boolean} Returns true if there is any change. Otherwise, returns false
|
295
328
|
*/
|
296
329
|
SegmentCollection.prototype.removeAllSegmentChildren = function() {
|
297
|
-
this.
|
330
|
+
this._shared.childToSegment = {};
|
298
331
|
var segmentSeparators = this._segments;
|
299
|
-
var dirtyCollapsingState = this._dirtyCollapsingState;
|
300
332
|
var dirty = false;
|
301
333
|
for(var rid in segmentSeparators) {
|
302
|
-
var segment =
|
334
|
+
var segment = segmentSeparators[rid];
|
303
335
|
if(segment.removeAllChildren()) {
|
304
336
|
dirty = true;
|
305
|
-
if(!dirtyCollapsingState && segment.isCollapsed()) {
|
306
|
-
dirtyCollapsingState = this._dirtyCollapsingState = true;
|
307
|
-
}
|
308
337
|
}
|
309
338
|
}
|
310
339
|
|
340
|
+
if(dirty) {
|
341
|
+
this.classify();
|
342
|
+
}
|
343
|
+
|
311
344
|
return dirty;
|
312
345
|
};
|
313
346
|
|
@@ -321,22 +354,18 @@ SegmentCollection.prototype.fillSegment = function(segmentId, rids) {
|
|
321
354
|
return;
|
322
355
|
}
|
323
356
|
var segmentSeparators = this._segments;
|
324
|
-
var childToSegmentId = this._childToSegmentId;
|
325
357
|
var curSegment = segmentSeparators[segmentId];
|
326
|
-
if(curSegment) {
|
358
|
+
if(curSegment && !curSegment.isSubSegment()) {
|
327
359
|
var segmentAt = rids.indexOf(segmentId);
|
328
360
|
if(segmentAt >= 0) {
|
329
|
-
|
330
|
-
this._dirtyCollapsingState = true;
|
331
|
-
}
|
332
|
-
curSegment.removeAllChildren(childToSegmentId);
|
361
|
+
curSegment.removeAllChildren();
|
333
362
|
for(var r = segmentAt + 1; r < rowCount; ++r) {
|
334
363
|
var rid = rids[r];
|
335
364
|
var segmentSeparator = segmentSeparators[rid];
|
336
365
|
if(segmentSeparator) {
|
337
366
|
break;
|
338
367
|
}
|
339
|
-
curSegment.addChild(rid
|
368
|
+
curSegment.addChild(rid);
|
340
369
|
}
|
341
370
|
}
|
342
371
|
}
|
@@ -346,23 +375,20 @@ SegmentCollection.prototype.fillSegment = function(segmentId, rids) {
|
|
346
375
|
* @return {boolean} Return true if the fill segments have changed, otherwise return false
|
347
376
|
*/
|
348
377
|
SegmentCollection.prototype.fillSegments = function(rids) {
|
378
|
+
this._shared.childToSegment = {};
|
379
|
+
|
349
380
|
var rowCount = Array.isArray(rids) ? rids.length : 0;
|
350
|
-
this._childToSegmentId = {};
|
351
381
|
var segmentSeparators = this._segments;
|
352
|
-
var childToSegmentId = this._childToSegmentId;
|
353
382
|
var curSegment = null;
|
354
383
|
var change = false;
|
355
384
|
for(var r = 0; r < rowCount; ++r) {
|
356
385
|
var rid = rids[r];
|
357
386
|
var segmentSeparator = segmentSeparators[rid];
|
358
|
-
if(segmentSeparator) {
|
387
|
+
if(segmentSeparator && !segmentSeparator.isSubSegment()) {
|
359
388
|
curSegment = segmentSeparator;
|
360
|
-
if(curSegment.isCollapsed()) {
|
361
|
-
this._dirtyCollapsingState = true;
|
362
|
-
}
|
363
389
|
curSegment.removeAllChildren();
|
364
|
-
} else if(curSegment) {
|
365
|
-
curSegment.addChild(rid
|
390
|
+
} else if(curSegment && !curSegment.isSubSegment()) {
|
391
|
+
curSegment.addChild(rid);
|
366
392
|
change = true;
|
367
393
|
}
|
368
394
|
}
|
@@ -372,6 +398,13 @@ SegmentCollection.prototype.fillSegments = function(rids) {
|
|
372
398
|
* @param {Array.<string>} rids
|
373
399
|
*/
|
374
400
|
SegmentCollection.prototype.calcSegmentOrder = function(rids) {
|
401
|
+
var segmentList = this._segmentList;
|
402
|
+
if(segmentList) {
|
403
|
+
segmentList.length = 0;
|
404
|
+
} else {
|
405
|
+
segmentList = this._segmentList = [];
|
406
|
+
}
|
407
|
+
|
375
408
|
var ridCount = rids ? rids.length : 0;
|
376
409
|
var segmentSeparators = this._segments;
|
377
410
|
var segmentCount = this._segmentCount;
|
@@ -380,8 +413,11 @@ SegmentCollection.prototype.calcSegmentOrder = function(rids) {
|
|
380
413
|
var rid = rids[i];
|
381
414
|
var segment = segmentSeparators[rid];
|
382
415
|
if(segment) {
|
383
|
-
segment.
|
384
|
-
|
416
|
+
if(!segment.isSubSegment()) {
|
417
|
+
this._segmentList.push(segment);
|
418
|
+
segment.setOrder(++order); // WARNING: Segments and sub segments start with 1
|
419
|
+
}
|
420
|
+
if(--segmentCount <= 0) {
|
385
421
|
break;
|
386
422
|
}
|
387
423
|
}
|
@@ -397,7 +433,7 @@ SegmentCollection.prototype.getSegmentValues = function(rids) {
|
|
397
433
|
return null;
|
398
434
|
}
|
399
435
|
var segmentSeparators = this._segments;
|
400
|
-
var childToSegmentId = this.
|
436
|
+
var childToSegmentId = this._shared.childToSegment;
|
401
437
|
var curSegment = null;
|
402
438
|
var prevSegment = null;
|
403
439
|
var segmentValues = new Array(rowCount);
|
@@ -427,6 +463,126 @@ SegmentCollection.prototype.getSegmentValues = function(rids) {
|
|
427
463
|
|
428
464
|
return prevSegment ? segmentValues : null;
|
429
465
|
};
|
466
|
+
/** @public
|
467
|
+
* @return {string}
|
468
|
+
*/
|
469
|
+
SegmentCollection.prototype.logStructure = function() {
|
470
|
+
var segmentList = this._segmentList;
|
471
|
+
if(!segmentList) {
|
472
|
+
return "";
|
473
|
+
}
|
474
|
+
var segmentCount = segmentList.length;
|
475
|
+
var lines = [];
|
476
|
+
for(var i = 0; i < segmentCount; ++i) {
|
477
|
+
segmentList[i].log(lines);
|
478
|
+
}
|
479
|
+
|
480
|
+
return lines.join("\n");
|
481
|
+
};
|
482
|
+
/** @public
|
483
|
+
* @return {string}
|
484
|
+
*/
|
485
|
+
SegmentCollection.prototype.logRowIdMap = function() {
|
486
|
+
var lines = [];
|
487
|
+
var childToSegmentId = this._shared.childToSegment;
|
488
|
+
for(var rid in childToSegmentId) {
|
489
|
+
var segmentId = childToSegmentId[rid];
|
490
|
+
lines.push(rid + " > " + segmentId);
|
491
|
+
}
|
492
|
+
|
493
|
+
return lines.join("\n");
|
494
|
+
};
|
495
|
+
|
496
|
+
|
497
|
+
/** @public
|
498
|
+
* @param {string} segmentId
|
499
|
+
* @param {string|Array.<string>} fields
|
500
|
+
* @return {boolean}
|
501
|
+
*/
|
502
|
+
SegmentCollection.prototype.setSegmentClassification = function(segmentId, fields) {
|
503
|
+
var segment = this._segments[segmentId];
|
504
|
+
if(segment) {
|
505
|
+
if(segment.setClassification(fields)) {
|
506
|
+
if(segment.getClassification()) {
|
507
|
+
this._classification = true;
|
508
|
+
}
|
509
|
+
this._classifierChanged = true;
|
510
|
+
|
511
|
+
return true;
|
512
|
+
}
|
513
|
+
}
|
514
|
+
return false;
|
515
|
+
};
|
516
|
+
/** @public
|
517
|
+
* @return {boolean}
|
518
|
+
*/
|
519
|
+
SegmentCollection.prototype.hasClassification = function() {
|
520
|
+
// WARNING: This include the time when classification is removed
|
521
|
+
return this._classification || this._classifierChanged;
|
522
|
+
};
|
523
|
+
/** @public
|
524
|
+
* @param {Object.<string, Object>} rows Object maps between row id and its record
|
525
|
+
* @return {boolean}
|
526
|
+
*/
|
527
|
+
SegmentCollection.prototype.classify = function(rows) {
|
528
|
+
if(!this._segmentCount) {
|
529
|
+
return false;
|
530
|
+
}
|
531
|
+
if(!this.hasClassification()) {
|
532
|
+
return false;
|
533
|
+
}
|
534
|
+
this._classification = this._classifierChanged = false;
|
535
|
+
|
536
|
+
var segmentSeparators = this._segments;
|
537
|
+
for(var rid in segmentSeparators) {
|
538
|
+
var segment = this._segments[rid];
|
539
|
+
if(!segment.isSubSegment()) {
|
540
|
+
if(segment.getClassification()) {
|
541
|
+
this._classification = true;
|
542
|
+
}
|
543
|
+
segment.classify(rows);
|
544
|
+
}
|
545
|
+
}
|
546
|
+
if(this._insertionList.length || this._removalList.length) {
|
547
|
+
this._dispatch("subSegmentChanged", {
|
548
|
+
"insertionList": this._insertionList,
|
549
|
+
"removalList": this._removalList
|
550
|
+
});
|
551
|
+
this._insertionList.length = 0;
|
552
|
+
this._removalList.length = 0;
|
553
|
+
|
554
|
+
this._dispatch("classified", {});
|
555
|
+
return true;
|
556
|
+
}
|
557
|
+
|
558
|
+
this._dispatch("classified", {});
|
559
|
+
return false;
|
560
|
+
};
|
561
|
+
|
562
|
+
/** @private
|
563
|
+
* @param {!Object} e
|
564
|
+
*/
|
565
|
+
SegmentCollection.prototype._onSubSegmentAdded = function(e) {
|
566
|
+
var rid = e["rid"];
|
567
|
+
if(!this._segments[rid]) {
|
568
|
+
var segment = /** @type{Segment} */(e["segment"]);
|
569
|
+
this._insertionList.push(segment);
|
570
|
+
this._segments[rid] = segment;
|
571
|
+
this._segmentCount++;
|
572
|
+
|
573
|
+
segment.addEventListener("subSegmentAdded", this._onSubSegmentAdded);
|
574
|
+
segment.addEventListener("subSegmentRemoved", this._onSubSegmentRemoved);
|
575
|
+
} else {
|
576
|
+
console.log("Incorrect logic detected.");
|
577
|
+
}
|
578
|
+
};
|
579
|
+
/** @private
|
580
|
+
* @param {!Object} e
|
581
|
+
*/
|
582
|
+
SegmentCollection.prototype._onSubSegmentRemoved = function(e) {
|
583
|
+
var rid = e["rid"];
|
584
|
+
this.removeSegment(rid);
|
585
|
+
};
|
430
586
|
|
431
587
|
|
432
588
|
export default SegmentCollection;
|
package/lib/grid/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
import "./lib/efx-grid.js";
|
2
|
-
window.EFX_GRID = { version: "6.0.
|
2
|
+
window.EFX_GRID = { version: "6.0.14" };
|
@@ -47,6 +47,8 @@ declare class RowSegmentingPlugin extends GridPlugin {
|
|
47
47
|
|
48
48
|
public setSegmentSeparator(rowRef: string|number|null, enabled?: boolean|null): boolean;
|
49
49
|
|
50
|
+
public setSegmentClassification(rowRef: string|number|null, fields: string|(string)[]|null): boolean;
|
51
|
+
|
50
52
|
public unsetAllSegmentSeparators(): boolean;
|
51
53
|
|
52
54
|
public hasSegmentation(): boolean;
|
@@ -424,7 +424,6 @@ RowSegmentingPlugin.prototype._updateHeader = function (settings, firstRowIndex,
|
|
424
424
|
var arg = {};
|
425
425
|
arg.section = section;
|
426
426
|
arg.colIndex = headerColumn;
|
427
|
-
arg.groupLevel = 1;
|
428
427
|
|
429
428
|
var colCount = section.getColumnCount();
|
430
429
|
for (var c = 0; c < colCount; c++) {
|
@@ -446,12 +445,22 @@ RowSegmentingPlugin.prototype._updateHeader = function (settings, firstRowIndex,
|
|
446
445
|
arg.rowIndex = r;
|
447
446
|
arg.rowData = this._getRow(dv, r); // Support composite and rt-grid
|
448
447
|
arg.spanning = null;
|
448
|
+
arg.content = null;
|
449
449
|
var rowId = arg.rowId = dv.getRowId(r); // Slow
|
450
|
+
// TODO: Getting segment once for better performance
|
450
451
|
var segmentSeparator = arg.segmentSeparator = dv.isSegmentSeparator(rowId);
|
451
452
|
arg.collapsedSegment = arg.collapsed = segmentSeparator ? dv.isSegmentCollapsed(rowId) : false;
|
452
|
-
var indentLevel = 0;
|
453
453
|
|
454
454
|
if (segmentSeparator) {
|
455
|
+
arg.groupLevel = dv.getSegmentLevel ? dv.getSegmentLevel(rowId) : 1;
|
456
|
+
arg.indentSize = this._getIndentSize(arg.groupLevel - 1, true); // Group level starts from 1
|
457
|
+
if(dv.getSegment) {
|
458
|
+
var segment = dv.getSegment(rowId);
|
459
|
+
if(segment && arg.groupLevel > 1) { // Sub segment always has name
|
460
|
+
arg.content = segment.getSubSegmentName();
|
461
|
+
}
|
462
|
+
}
|
463
|
+
|
455
464
|
var spanning = arg.rowData[this._rowSpanningField];
|
456
465
|
if(spanning != null) {
|
457
466
|
arg.spanning = !!spanning;
|
@@ -460,10 +469,11 @@ RowSegmentingPlugin.prototype._updateHeader = function (settings, firstRowIndex,
|
|
460
469
|
if (this._predefinedColors) {
|
461
470
|
arg.colorTagClass = arg.rowData[cssField];
|
462
471
|
}
|
463
|
-
arg.indentSize = this._getIndentSize(indentLevel, true);
|
464
472
|
rowPainter.applyHeaderStyle(arg);
|
465
473
|
this._dispatch("segmentSeparatorBinding", arg);
|
466
474
|
} else {
|
475
|
+
arg.groupLevel = 0;
|
476
|
+
var indentLevel = 0;
|
467
477
|
var parentId = this.getSegmentParentRowId(rowId);
|
468
478
|
if(parentId) {
|
469
479
|
indentLevel = 1; // TODO: Provide a way for segmenting multiple levels. Currently, just one level is supported.
|
@@ -553,6 +563,19 @@ RowSegmentingPlugin.prototype.setSegmentSeparator = function(rowRef, enabled) {
|
|
553
563
|
}
|
554
564
|
return false;
|
555
565
|
};
|
566
|
+
/** Set classification for the specified segment
|
567
|
+
* @public
|
568
|
+
* @param {string|number} rowRef Row id or row index
|
569
|
+
* @param {string|Array.<string>} fields
|
570
|
+
* @return {boolean}
|
571
|
+
*/
|
572
|
+
RowSegmentingPlugin.prototype.setSegmentClassification = function(rowRef, fields) {
|
573
|
+
var dv = this._getDataView();
|
574
|
+
if(dv) {
|
575
|
+
return dv.setSegmentClassification(rowRef, fields);
|
576
|
+
}
|
577
|
+
return false;
|
578
|
+
};
|
556
579
|
/** Clear all segment separator rows
|
557
580
|
* @public
|
558
581
|
* @return {boolean} Return true if there is any change
|