@refinitiv-ui/efx-grid 6.0.157 → 6.0.159
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/column-selection-dialog/lib/column-selection-dialog.d.ts +4 -1
- package/lib/column-selection-dialog/lib/column-selection-dialog.js +36 -25
- package/lib/core/dist/core.js +205 -195
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataTable.js +31 -17
- package/lib/core/es6/data/DataView.js +1 -0
- package/lib/core/es6/data/Segment.d.ts +4 -4
- package/lib/core/es6/data/Segment.js +67 -95
- package/lib/core/es6/data/SegmentCollection.d.ts +5 -1
- package/lib/core/es6/data/SegmentCollection.js +65 -76
- package/lib/core/es6/grid/Core.js +4 -1
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +37 -6
- package/lib/grid/index.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +205 -195
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/types/es6/Core/data/Segment.d.ts +4 -4
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +5 -1
- package/lib/versions.json +2 -2
- package/package.json +1 -1
@@ -96,7 +96,6 @@ DataTable.prototype._classifyingTimer = 0;
|
|
96
96
|
*/
|
97
97
|
DataTable.prototype._segmentDefaultCollapsing = false;
|
98
98
|
|
99
|
-
|
100
99
|
/** @typedef {Function} DataTable~SortLogic
|
101
100
|
* @description SortLogic function is used for comparison between two values during sorting. <br>
|
102
101
|
* The function should return:<br>
|
@@ -206,6 +205,7 @@ DataTable.prototype.getPreviousData = function(rid, cid) {
|
|
206
205
|
return null;
|
207
206
|
};
|
208
207
|
|
208
|
+
|
209
209
|
/** Set data to individual cell
|
210
210
|
* @override
|
211
211
|
* @param {string} rid Row Id
|
@@ -286,7 +286,10 @@ DataTable.prototype.setRowData = function(rid, values, eventArg) { // Data chang
|
|
286
286
|
this._rids.push(rid);
|
287
287
|
} else {
|
288
288
|
this._rids.splice(rowIndex, 0, rid);
|
289
|
-
|
289
|
+
if(this._segments) { // for no sorting case
|
290
|
+
this._segments.invalidateSegmentOrder();
|
291
|
+
}
|
292
|
+
segmentChanged = !this._isLastSegment(rowIndex); // This is slow. Check if this is required
|
290
293
|
}
|
291
294
|
} else {
|
292
295
|
this._rids.push(rid);
|
@@ -731,7 +734,7 @@ DataTable.prototype.moveRow = function(fromIndex, toIndex, suppressEvent) {
|
|
731
734
|
|
732
735
|
if(output) {
|
733
736
|
if(this._segments) {
|
734
|
-
this._segments.
|
737
|
+
this._segments.invalidateSegmentOrder();
|
735
738
|
this._sort(null); // Reorder segment members
|
736
739
|
}
|
737
740
|
this._dispatchPositionChange(suppressEvent);
|
@@ -988,6 +991,9 @@ DataTable.prototype.freeze = function(bool) {
|
|
988
991
|
let prevState = this._frozen;
|
989
992
|
if(prevState !== bool) {
|
990
993
|
this._frozen = bool;
|
994
|
+
if(!bool && this._segments) { // for no sorting case
|
995
|
+
this._segments.invalidateSegmentOrder();
|
996
|
+
}
|
991
997
|
this._autoFillSegments();
|
992
998
|
this.dispatchGlobalChange();
|
993
999
|
}
|
@@ -1054,9 +1060,6 @@ DataTable.prototype.setSegmentSeparators = function(rids, enabled) {
|
|
1054
1060
|
}
|
1055
1061
|
}
|
1056
1062
|
}
|
1057
|
-
if (segmentAdded) {
|
1058
|
-
this._segments.calcSegmentOrder(this._rids);
|
1059
|
-
}
|
1060
1063
|
let changed = segmentAdded || segmentRemoved;
|
1061
1064
|
if(changed && this._needFiring()) {
|
1062
1065
|
this.dispatchGlobalChange();
|
@@ -1084,7 +1087,6 @@ DataTable.prototype.setSegmentSeparator = function(rid, options) {
|
|
1084
1087
|
}
|
1085
1088
|
let children = (options && options["children"]) ? options["children"] : null;
|
1086
1089
|
if(this._segments.addSegment(rid, children)) {
|
1087
|
-
this._segments.calcSegmentOrder(this._rids);
|
1088
1090
|
change = true;
|
1089
1091
|
}
|
1090
1092
|
} else if(this._segments) { // Remove the separator
|
@@ -1209,6 +1211,7 @@ DataTable.prototype.getSegmentParentRowId = function(rid) {
|
|
1209
1211
|
*/
|
1210
1212
|
DataTable.prototype.getSegmentValues = function(rids, partial) {
|
1211
1213
|
if(this._segments) {
|
1214
|
+
this._segments.calcSegmentOrder(this._rids, true); // use cache
|
1212
1215
|
return this._segments.getSegmentValues(rids || this._rids, partial);
|
1213
1216
|
}
|
1214
1217
|
return null;
|
@@ -1286,9 +1289,6 @@ DataTable.prototype.fillSegments = function() {
|
|
1286
1289
|
* @param {boolean=} adding This indicates that segment is changed by adding a new child
|
1287
1290
|
*/
|
1288
1291
|
DataTable.prototype._onSegmentChildChanged = function(adding) {
|
1289
|
-
if(this._segments) {
|
1290
|
-
this._segments.calcSegmentOrder(this._rids, true);
|
1291
|
-
}
|
1292
1292
|
if(adding !== false) {
|
1293
1293
|
this._sort(null);
|
1294
1294
|
}
|
@@ -1477,7 +1477,6 @@ DataTable.prototype.sortSegments = function (compare) {
|
|
1477
1477
|
return false;
|
1478
1478
|
}
|
1479
1479
|
if(typeof compare !== "function") {
|
1480
|
-
this._segments.calcSegmentOrder(this._rids);
|
1481
1480
|
return false;
|
1482
1481
|
}
|
1483
1482
|
|
@@ -1512,7 +1511,6 @@ DataTable.prototype.sortSegments = function (compare) {
|
|
1512
1511
|
}
|
1513
1512
|
|
1514
1513
|
if(dirty) {
|
1515
|
-
this._segments.calcSegmentOrder(rids);
|
1516
1514
|
this._sort(null);
|
1517
1515
|
this._dispatchPositionChange();
|
1518
1516
|
}
|
@@ -1520,18 +1518,34 @@ DataTable.prototype.sortSegments = function (compare) {
|
|
1520
1518
|
};
|
1521
1519
|
/** Sort all of existing segments by given compare function
|
1522
1520
|
* @private
|
1523
|
-
* @param {
|
1524
|
-
* @param {
|
1521
|
+
* @param {*} rowA
|
1522
|
+
* @param {*} rowB
|
1525
1523
|
* @return {number}
|
1526
1524
|
*/
|
1527
|
-
DataTable.prototype._bySegmentSeparator = function (
|
1525
|
+
DataTable.prototype._bySegmentSeparator = function (rowA, rowB) {
|
1528
1526
|
return /** @type{number} */(this._userSegmentComparer(
|
1529
|
-
this.
|
1530
|
-
this.
|
1527
|
+
this._getRowDataFromSegment(rowA),
|
1528
|
+
this._getRowDataFromSegment(rowB),
|
1531
1529
|
this._segmentSortOrder,
|
1532
1530
|
this._segmentSortContext
|
1533
1531
|
));
|
1534
1532
|
};
|
1533
|
+
/** Get row data from either Segment or row id
|
1534
|
+
* @private
|
1535
|
+
* @param {*} obj
|
1536
|
+
* @return {Object}
|
1537
|
+
*/
|
1538
|
+
DataTable.prototype._getRowDataFromSegment = function (obj) {
|
1539
|
+
var rowData = null;
|
1540
|
+
if(obj) {
|
1541
|
+
if(typeof obj == "string") {
|
1542
|
+
rowData = this.getRowData(obj);
|
1543
|
+
} else if(obj.getId) {
|
1544
|
+
rowData = this.getRowData(obj.getId());
|
1545
|
+
}
|
1546
|
+
}
|
1547
|
+
return rowData;
|
1548
|
+
};
|
1535
1549
|
|
1536
1550
|
/** A data source to be used with segment classification
|
1537
1551
|
* @public
|
@@ -53,9 +53,7 @@ declare class Segment extends EventDispatcher {
|
|
53
53
|
|
54
54
|
public getAllSubSegments(out_ary?: (Segment)[]|null): (Segment)[]|null;
|
55
55
|
|
56
|
-
public updateTreeStructure(counter: number): number;
|
57
|
-
|
58
|
-
public calcSubSegmentOrder(counter: number): number;
|
56
|
+
public updateTreeStructure(counter: number, rootOrder: number, ridMap: any): number;
|
59
57
|
|
60
58
|
public getSegmentLevel(): number;
|
61
59
|
|
@@ -87,5 +85,7 @@ declare class Segment extends EventDispatcher {
|
|
87
85
|
|
88
86
|
}
|
89
87
|
|
88
|
+
declare const UNCATEGORY: string;
|
89
|
+
|
90
90
|
export default Segment;
|
91
|
-
export { Segment };
|
91
|
+
export { Segment, UNCATEGORY };
|
@@ -16,6 +16,12 @@ let Segment = function(rid, sharedObj) {
|
|
16
16
|
};
|
17
17
|
Ext.inherits(Segment, EventDispatcher);
|
18
18
|
|
19
|
+
/** @public
|
20
|
+
* @type {string}
|
21
|
+
* @constant
|
22
|
+
*/
|
23
|
+
const UNCATEGORY = "Uncategorized";
|
24
|
+
|
19
25
|
/** @private
|
20
26
|
* @function
|
21
27
|
* @param {string} a
|
@@ -23,10 +29,10 @@ Ext.inherits(Segment, EventDispatcher);
|
|
23
29
|
* @return {number}
|
24
30
|
*/
|
25
31
|
Segment._subSegSortLogic = function(a, b) {
|
26
|
-
if(a ===
|
32
|
+
if(a === UNCATEGORY) {
|
27
33
|
return 1;
|
28
34
|
}
|
29
|
-
if(b ===
|
35
|
+
if(b === UNCATEGORY) {
|
30
36
|
return -1;
|
31
37
|
}
|
32
38
|
|
@@ -503,7 +509,7 @@ Segment.prototype.classify = function(rows) {
|
|
503
509
|
|
504
510
|
sharedObj.childToSegment[rid] = this._rid; // Relocate child in case of it has been moved to a non existence group
|
505
511
|
|
506
|
-
segmentName =
|
512
|
+
segmentName = UNCATEGORY;
|
507
513
|
if(val || val === 0 || val === false) { // Check for null, undefined, "", and NaN value
|
508
514
|
segmentName = val + "";
|
509
515
|
}
|
@@ -579,13 +585,6 @@ Segment.prototype.classify = function(rows) {
|
|
579
585
|
}
|
580
586
|
}
|
581
587
|
|
582
|
-
// Collecting all subsegments including all descendants and reassigning segment order.
|
583
|
-
if(rootSegment && this._subSegDef) {
|
584
|
-
if(segmentCount) {
|
585
|
-
this.calcSubSegmentOrder(0);
|
586
|
-
}
|
587
|
-
// this._subSegDef.classifierChanged = false;
|
588
|
-
}
|
589
588
|
return true;
|
590
589
|
};
|
591
590
|
/** SubSegment implies being classified
|
@@ -653,65 +652,68 @@ Segment.prototype.getAllSubSegments = function(out_ary) {
|
|
653
652
|
/** This method sets order, last order, and depth to entire tree structure in the segment, including the segment itself
|
654
653
|
* @public
|
655
654
|
* @param {number} counter
|
656
|
-
* @
|
655
|
+
* @param {number} rootOrder
|
656
|
+
* @param {Object} ridMap Row id map that stores row order of the entire tree
|
657
|
+
* @return {number} Last order of the segment
|
657
658
|
*/
|
658
|
-
Segment.prototype.updateTreeStructure = function(counter) {
|
659
|
+
Segment.prototype.updateTreeStructure = function(counter, rootOrder, ridMap) {
|
659
660
|
if(!counter) {
|
660
661
|
counter = 0;
|
661
662
|
if(!this._subSegment) { // Subsegment's depth cannot be reset back to 0
|
662
663
|
this._depth = 0; // WARNING: this assumes counter at 0 is the root segment
|
663
664
|
}
|
664
665
|
}
|
665
|
-
if(
|
666
|
-
|
666
|
+
if(!rootOrder) {
|
667
|
+
rootOrder = 0;
|
667
668
|
}
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
669
|
+
if(!ridMap) {
|
670
|
+
ridMap = {};
|
671
|
+
}
|
672
|
+
|
673
|
+
let i;
|
674
|
+
let segmentNames = this._subSegNames;
|
675
|
+
let subSegmentCount = segmentNames ? segmentNames.length : 0;
|
676
|
+
if(subSegmentCount) { // Classified segment
|
677
|
+
let segmentMap = this._subSegMap;
|
678
|
+
for(i = 0; i < subSegmentCount; ++i) {
|
679
|
+
let subSegment = segmentMap[segmentNames[i]];
|
680
|
+
++counter;
|
681
|
+
ridMap[subSegment.getId()] = rootOrder + counter;
|
682
|
+
subSegment.setOrder(counter);
|
683
|
+
counter = subSegment.updateTreeStructure(counter, rootOrder, ridMap);
|
678
684
|
}
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
685
|
+
} else {
|
686
|
+
let childIds = this._childIds;
|
687
|
+
let childCount = childIds.length;
|
688
|
+
let segmentSeparators = this._shared.segments;
|
689
|
+
let prevSeg = "";
|
690
|
+
for(i = 0; i < childCount; ++i) {
|
691
|
+
let childId = childIds[i];
|
692
|
+
let childSegment = segmentSeparators[childId];
|
693
|
+
let segmentId = (childSegment) ? childSegment.getId() : UNCATEGORY;
|
694
|
+
if(prevSeg !== segmentId) {
|
695
|
+
++counter;
|
696
|
+
prevSeg = segmentId;
|
697
|
+
}
|
698
|
+
ridMap[childId] = rootOrder + counter;
|
699
|
+
if(childSegment) {
|
700
|
+
childSegment._depth = this._depth + 1;
|
701
|
+
childSegment.setOrder(counter);
|
702
|
+
counter = childSegment.updateTreeStructure(counter, rootOrder, ridMap);
|
703
|
+
}
|
683
704
|
}
|
684
705
|
}
|
685
706
|
|
686
707
|
return this.setLastOrder(counter);
|
687
708
|
};
|
688
|
-
/**
|
709
|
+
/** Deprecated.
|
710
|
+
* @ignore
|
711
|
+
* @public
|
712
|
+
* @function
|
689
713
|
* @param {number} counter
|
690
714
|
* @return {number}
|
691
715
|
*/
|
692
|
-
Segment.prototype.calcSubSegmentOrder =
|
693
|
-
if(!this.hasSubSegments()) {
|
694
|
-
return this.setLastOrder(counter);
|
695
|
-
}
|
696
|
-
|
697
|
-
let segmentMap = this._subSegMap;
|
698
|
-
let childCount = this._subSegNames.length;
|
699
|
-
let prevSeg = null;
|
700
|
-
for(let i = 0; i < childCount; ++i) {
|
701
|
-
let segmentName = this._subSegNames[i];
|
702
|
-
let segment = segmentMap[segmentName];
|
703
|
-
let segmentId = (segment) ? segment.getId() : "Uncategorized";
|
704
|
-
if(prevSeg !== segmentId) {
|
705
|
-
++counter; // 0 become 1
|
706
|
-
prevSeg = segmentId;
|
707
|
-
}
|
708
|
-
if(segment) {
|
709
|
-
segment.setOrder(counter);
|
710
|
-
counter = segment.calcSubSegmentOrder(counter);
|
711
|
-
}
|
712
|
-
}
|
713
|
-
return this.setLastOrder(counter);
|
714
|
-
};
|
716
|
+
Segment.prototype.calcSubSegmentOrder = Segment.prototype.updateTreeStructure;
|
715
717
|
/** @public
|
716
718
|
* @return {number}
|
717
719
|
*/
|
@@ -761,14 +763,6 @@ Segment.prototype.getSubSegmentName = function(row) {
|
|
761
763
|
return this._subSegName;
|
762
764
|
};
|
763
765
|
/**
|
764
|
-
* @private
|
765
|
-
* @param {!Segment} segment
|
766
|
-
* @returns {string}
|
767
|
-
*/
|
768
|
-
let _toSegmentId = function(segment) {
|
769
|
-
return segment.getId();
|
770
|
-
};
|
771
|
-
/**
|
772
766
|
* @public
|
773
767
|
* @param {!Function} comparer
|
774
768
|
* @returns {boolean} Returns true if there is any change
|
@@ -778,26 +772,17 @@ Segment.prototype.sortSegments = function(comparer) {
|
|
778
772
|
return false;
|
779
773
|
}
|
780
774
|
|
781
|
-
let segmentList = [];
|
782
|
-
let rids = [];
|
783
775
|
let childIds = this._childIds;
|
784
776
|
let childCount = childIds.length;
|
785
777
|
let segments = this._shared.segments;
|
786
778
|
for(let i = 0; i < childCount; ++i) {
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
segmentList.push(childSegment);
|
791
|
-
} else {
|
792
|
-
rids.push(childId);
|
779
|
+
if(segments[childIds[i]]) {
|
780
|
+
this._childIds.sort(comparer); // Perform segment sorting only if children have at least one segment
|
781
|
+
return true;
|
793
782
|
}
|
794
783
|
}
|
795
|
-
|
796
|
-
|
797
|
-
}
|
798
|
-
segmentList.sort(comparer);
|
799
|
-
this._childIds = rids.concat(segmentList.map(_toSegmentId));
|
800
|
-
return true;
|
784
|
+
|
785
|
+
return false;
|
801
786
|
};
|
802
787
|
/** Get segment id and ids of children, including nested segments, but excluding sub segments
|
803
788
|
* @public
|
@@ -911,28 +896,15 @@ Segment.prototype.getCollapsingStates = function(objMap, parentState) {
|
|
911
896
|
return dirty;
|
912
897
|
};
|
913
898
|
|
914
|
-
/** @private
|
915
|
-
* @return {number}
|
916
|
-
*/
|
917
|
-
Segment.prototype._getOrder = function() {
|
918
|
-
return this._order * 10000;
|
919
|
-
};
|
920
|
-
/** @private
|
921
|
-
* @return {number}
|
922
|
-
*/
|
923
|
-
Segment.prototype._getLastOrder = function() {
|
924
|
-
return this._getOrder() + this._offsetOrder;
|
925
|
-
};
|
926
899
|
/** @public
|
927
900
|
* @return {number}
|
928
901
|
*/
|
929
902
|
Segment.prototype.getOrder = function() {
|
930
903
|
let ancestor = this.getFirstAncestor();
|
931
904
|
if(ancestor) {
|
932
|
-
|
933
|
-
return ancestor._getOrder() + this._order;
|
905
|
+
return ancestor._order + this._order;
|
934
906
|
}
|
935
|
-
return this.
|
907
|
+
return this._order; // This is root order
|
936
908
|
};
|
937
909
|
/** Get the last (highest) order from the entire tree regardless of the current position segment in the hierachy
|
938
910
|
* @public
|
@@ -941,10 +913,9 @@ Segment.prototype.getOrder = function() {
|
|
941
913
|
Segment.prototype.getLastOrder = function() {
|
942
914
|
let ancestor = this.getFirstAncestor();
|
943
915
|
if(ancestor) {
|
944
|
-
|
945
|
-
return ancestor._getLastOrder();
|
916
|
+
return ancestor.getLastOrder();
|
946
917
|
}
|
947
|
-
return this.
|
918
|
+
return this._order + this._offsetOrder; // This is root last order
|
948
919
|
};
|
949
920
|
/** @public
|
950
921
|
* @param {number} val
|
@@ -952,12 +923,13 @@ Segment.prototype.getLastOrder = function() {
|
|
952
923
|
Segment.prototype.setOrder = function(val) {
|
953
924
|
this._order = val;
|
954
925
|
};
|
955
|
-
/**
|
926
|
+
/** WARNING: This actually sets offset from the starting order
|
927
|
+
* @public
|
956
928
|
* @param {number} val
|
957
929
|
* @returns {number} Returns the number set
|
958
930
|
*/
|
959
931
|
Segment.prototype.setLastOrder = function(val) {
|
960
|
-
return (this._offsetOrder = val);
|
932
|
+
return (this._offsetOrder = val); // WARNING: this._offsetOrder cannot be greater than 9999
|
961
933
|
};
|
962
934
|
|
963
935
|
/** @private
|
@@ -1026,4 +998,4 @@ Segment.prototype.log = function(lines, tabLevel) {
|
|
1026
998
|
|
1027
999
|
|
1028
1000
|
export default Segment;
|
1029
|
-
export { Segment };
|
1001
|
+
export { Segment, UNCATEGORY };
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import Ext from "../../../tr-grid-util/es6/Ext.js";
|
2
2
|
import EventDispatcher from "../../../tr-grid-util/es6/EventDispatcher.js";
|
3
|
-
import Segment from "./Segment.js";
|
3
|
+
import { Segment, UNCATEGORY } from "./Segment.js";
|
4
4
|
|
5
5
|
declare class SegmentCollection extends EventDispatcher {
|
6
6
|
|
@@ -44,6 +44,8 @@ declare class SegmentCollection extends EventDispatcher {
|
|
44
44
|
|
45
45
|
public getCollapsedRows(): any;
|
46
46
|
|
47
|
+
public invalidateSegmentOrder(): boolean;
|
48
|
+
|
47
49
|
public addSegmentChild(segmentId: string, rid: string, dataId?: string|null): boolean;
|
48
50
|
|
49
51
|
public addSegmentChildren(segmentId: string, rids: (string)[]|null, dataIds?: (string)[]|null): boolean;
|
@@ -62,6 +64,8 @@ declare class SegmentCollection extends EventDispatcher {
|
|
62
64
|
|
63
65
|
public calcSegmentOrder(rids: (string)[]|null, useCache?: boolean|null): void;
|
64
66
|
|
67
|
+
public getSegmentValues(rids: (string)[], partial?: boolean|null): (number)[]|null;
|
68
|
+
|
65
69
|
public logStructure(): string;
|
66
70
|
|
67
71
|
public logRowIdMap(): string;
|