@refinitiv-ui/efx-grid 6.0.148 → 6.0.150
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/column-dragging/es6/ColumnDragging.js +74 -77
- package/lib/grid/index.js +1 -1
- package/lib/row-segmenting/es6/RowSegmenting.d.ts +1 -0
- package/lib/row-segmenting/es6/RowSegmenting.js +78 -35
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +11 -23
- package/lib/tr-grid-util/es6/DragUI.d.ts +2 -0
- package/lib/tr-grid-util/es6/DragUI.js +20 -9
- package/lib/versions.json +4 -4
- package/package.json +1 -1
@@ -61,8 +61,8 @@ import { DragUI } from "../../tr-grid-util/es6/DragUI.js";
|
|
61
61
|
* @param {ColumnDraggingPlugin~Options=} options
|
62
62
|
* @extends {GridPlugin}
|
63
63
|
*/
|
64
|
-
|
65
|
-
|
64
|
+
let ColumnDraggingPlugin = function (options) {
|
65
|
+
let t = this;
|
66
66
|
t._onMouseUp = t._onMouseUp.bind(t);
|
67
67
|
t._onMouseDown = t._onMouseDown.bind(t);
|
68
68
|
|
@@ -70,7 +70,6 @@ var ColumnDraggingPlugin = function (options) {
|
|
70
70
|
t._onDragStart = t._onDragStart.bind(t);
|
71
71
|
t._onDragEnd = t._onDragEnd.bind(t);
|
72
72
|
t._onDragPulse = t._onDragPulse.bind(t);
|
73
|
-
t._onThemeLoaded = t._onThemeLoaded.bind(t);
|
74
73
|
|
75
74
|
t._hosts = [];
|
76
75
|
|
@@ -231,19 +230,17 @@ ColumnDraggingPlugin.prototype.initialize = function (host, options) {
|
|
231
230
|
dragBoxIcon: this._dragBoxIcon
|
232
231
|
});
|
233
232
|
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
DragUI.stylePromise.then(this._onThemeLoaded).catch(this._onThemeLoaded);
|
240
|
-
}
|
233
|
+
ElfUtil.getThemeColors().then(
|
234
|
+
ColumnDraggingPlugin._onThemeLoaded.bind(null, host)
|
235
|
+
).catch(
|
236
|
+
ColumnDraggingPlugin._onThemeLoaded.bind(null, host)
|
237
|
+
);
|
241
238
|
};
|
242
239
|
/** @public
|
243
240
|
* @param {Object=} host core grid instance
|
244
241
|
*/
|
245
242
|
ColumnDraggingPlugin.prototype.unload = function (host) {
|
246
|
-
|
243
|
+
let at = this._hosts.indexOf(host);
|
247
244
|
if (at < 0) {
|
248
245
|
return;
|
249
246
|
}
|
@@ -262,8 +259,10 @@ ColumnDraggingPlugin.prototype.unload = function (host) {
|
|
262
259
|
};
|
263
260
|
|
264
261
|
/** @private
|
262
|
+
* @function
|
263
|
+
* @param {Object} grid Core grid instance
|
265
264
|
*/
|
266
|
-
ColumnDraggingPlugin.
|
265
|
+
ColumnDraggingPlugin._onThemeLoaded = function(grid) {
|
267
266
|
if(!ColumnDraggingPlugin._styles) {
|
268
267
|
let styles = [
|
269
268
|
".multi-column-drag-indicator .section.title .cover-layer .column-bound.selection-bound ", [
|
@@ -280,16 +279,13 @@ ColumnDraggingPlugin.prototype._onThemeLoaded = function() {
|
|
280
279
|
ColumnDraggingPlugin._styles = prettifyCss(styles);
|
281
280
|
}
|
282
281
|
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
let host = this._hosts[i];
|
287
|
-
ColumnDraggingPlugin._applyThemeColor(host);
|
288
|
-
DragUI.applyThemeColor(host);
|
289
|
-
}
|
282
|
+
DragUI.initStyles();
|
283
|
+
ColumnDraggingPlugin._applyThemeColor(grid);
|
284
|
+
DragUI.applyThemeColor(grid);
|
290
285
|
};
|
286
|
+
|
291
287
|
/** @private
|
292
|
-
* @param {Object} grid
|
288
|
+
* @param {Object} grid Core grid instance
|
293
289
|
*/
|
294
290
|
ColumnDraggingPlugin._applyThemeColor = function(grid) {
|
295
291
|
if(!grid || grid._columnDraggingStyles) {
|
@@ -307,7 +303,7 @@ ColumnDraggingPlugin._applyThemeColor = function(grid) {
|
|
307
303
|
ColumnDraggingPlugin.prototype.config = function (options) {
|
308
304
|
if (!options) { return; }
|
309
305
|
|
310
|
-
|
306
|
+
let noColumnDragging = options["noColumnDragging"];
|
311
307
|
if (noColumnDragging == null && options["columnReorder"] != null) {
|
312
308
|
noColumnDragging = !options["columnReorder"];
|
313
309
|
}
|
@@ -315,7 +311,7 @@ ColumnDraggingPlugin.prototype.config = function (options) {
|
|
315
311
|
this._disabled = noColumnDragging ? true : false;
|
316
312
|
}
|
317
313
|
|
318
|
-
|
314
|
+
let extOptions = options.columnDragging;
|
319
315
|
if (!extOptions) { return; }
|
320
316
|
|
321
317
|
if (typeof extOptions["dragBoxRenderer"] === "function") {
|
@@ -336,15 +332,15 @@ ColumnDraggingPlugin.prototype.config = function (options) {
|
|
336
332
|
* @return {!Object}
|
337
333
|
*/
|
338
334
|
ColumnDraggingPlugin.prototype.getConfigObject = function (gridOptions) {
|
339
|
-
|
335
|
+
let obj = gridOptions || {};
|
340
336
|
|
341
337
|
if(this._disabled) {
|
342
338
|
obj.noColumnDragging = true;
|
343
339
|
}
|
344
340
|
|
345
|
-
|
341
|
+
let extOptions = obj.columnDragging;
|
346
342
|
if(!extOptions) {
|
347
|
-
extOptions = obj.columnDragging = {};
|
343
|
+
extOptions = obj.columnDragging = {}; // TO_DO: This is unnecessary
|
348
344
|
}
|
349
345
|
|
350
346
|
return obj;
|
@@ -392,9 +388,9 @@ ColumnDraggingPlugin.prototype.disableDragBox = function(disabled) {
|
|
392
388
|
* @return {boolean}
|
393
389
|
*/
|
394
390
|
ColumnDraggingPlugin.prototype._isAllowed = function(colIndex) {
|
395
|
-
|
391
|
+
let host = this._clickedGrid || this._hosts[0];
|
396
392
|
if (host) {
|
397
|
-
|
393
|
+
let stationaryIndex = host.getStationaryColumnIndex();
|
398
394
|
if (stationaryIndex < 0) {
|
399
395
|
return true;
|
400
396
|
}
|
@@ -476,7 +472,7 @@ ColumnDraggingPlugin.prototype._onMouseDown = function (e) {
|
|
476
472
|
return; // Drag timer is already start
|
477
473
|
}
|
478
474
|
|
479
|
-
|
475
|
+
let host = this.getRelativeGrid(e);
|
480
476
|
if(!host) {
|
481
477
|
return; // Given event should be within grid element
|
482
478
|
}
|
@@ -486,14 +482,14 @@ ColumnDraggingPlugin.prototype._onMouseDown = function (e) {
|
|
486
482
|
return; // Only start dragging when mouse is down on the grid
|
487
483
|
}
|
488
484
|
|
489
|
-
|
485
|
+
let section = this._pos["section"];
|
490
486
|
if(!section) {
|
491
487
|
return; // The section that is not in the target section list cannot be dragged
|
492
488
|
} else if(this._pos["sectionType"] !== "title") {
|
493
489
|
return; // Sections other than title section cannot be dragged by default
|
494
490
|
}
|
495
491
|
|
496
|
-
|
492
|
+
let colIndex = this._pos["colIndex"];
|
497
493
|
if(!this._isAllowed(colIndex)) {
|
498
494
|
return; // The column cannot be dragged
|
499
495
|
}
|
@@ -501,9 +497,9 @@ ColumnDraggingPlugin.prototype._onMouseDown = function (e) {
|
|
501
497
|
return; // If the lock frag is on, frozen columns cannot be dragged
|
502
498
|
}
|
503
499
|
|
504
|
-
|
505
|
-
|
506
|
-
|
500
|
+
let rowIndex = this._pos["rowIndex"]; // rowIndex may not exist
|
501
|
+
let movableBorder = this._findMoveableBorder(colIndex, rowIndex - 1, section);
|
502
|
+
let movingColumns = this._getSpan(colIndex, rowIndex, section);
|
507
503
|
|
508
504
|
this._clickedGrid = host;
|
509
505
|
this._clickedSection = section;
|
@@ -597,12 +593,12 @@ ColumnDraggingPlugin.prototype._onDragStart = function (e) {
|
|
597
593
|
window.addEventListener("mousemove", this._onDrag, false); // TODO: support touch operation
|
598
594
|
window.addEventListener("mouseup", this._onDragEnd, true);
|
599
595
|
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
596
|
+
let host = this._clickedGrid;
|
597
|
+
let height = host.getHeight();
|
598
|
+
let sectionBound = this._clickedSection.getBoundingClientRect();
|
599
|
+
let clickedCellBound = this._clickedSection.getCell(this._startColumn, this._clickedRow).getBoundingClientRect();
|
604
600
|
|
605
|
-
|
601
|
+
let gridElem = host.getElement();
|
606
602
|
this._guideline.style.top = (clickedCellBound.top - sectionBound.top) + "px";
|
607
603
|
this._guideline.style.height = (height - 1) + "px";
|
608
604
|
|
@@ -614,10 +610,10 @@ ColumnDraggingPlugin.prototype._onDragStart = function (e) {
|
|
614
610
|
gridElem.appendChild(this._guideline);
|
615
611
|
|
616
612
|
if (this._dragBoxRenderer) { // For custom drag box rendering
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
613
|
+
let arg = cloneObject(e); // TODO: Check if cloning is necessary
|
614
|
+
let id = this.getColumnId(this._startColumn);
|
615
|
+
let index = this.getColumnIndex(id);
|
616
|
+
let field = this._getField(this._startColumn);
|
621
617
|
|
622
618
|
arg.dragBox = this._dragBox;
|
623
619
|
arg.columnData = {
|
@@ -641,7 +637,7 @@ ColumnDraggingPlugin.prototype._onDragStart = function (e) {
|
|
641
637
|
} else if(this._scrollStep > 400) {
|
642
638
|
this._scrollStep = 400;
|
643
639
|
}
|
644
|
-
|
640
|
+
let scrollbar = host.getHScrollbar();
|
645
641
|
this._cacheLeft = scrollbar.getLeft() + 20;
|
646
642
|
this._cacheWidth = scrollbar.getLeft() + scrollbar.getWidth() - 20;
|
647
643
|
|
@@ -659,7 +655,7 @@ ColumnDraggingPlugin.prototype._onDrag = function (e) {
|
|
659
655
|
var host = this.getRelativeGrid(e);
|
660
656
|
if (!host || host !== this._clickedGrid) { return; }
|
661
657
|
|
662
|
-
|
658
|
+
let colIndex = this._pos["colIndex"];
|
663
659
|
if ((colIndex >= this._leftMovableBorder) &&
|
664
660
|
(colIndex <= this._rightMovableBorder) &&
|
665
661
|
this._isAllowed(colIndex) &&
|
@@ -685,7 +681,7 @@ ColumnDraggingPlugin.prototype._onDragEnd = function (e) {
|
|
685
681
|
// document.body.classList.remove("tr-move-cursor");
|
686
682
|
this._dimCol(false);
|
687
683
|
|
688
|
-
|
684
|
+
let pn = this._guideline.parentNode;
|
689
685
|
if(pn) {
|
690
686
|
pn.removeChild(this._guideline);
|
691
687
|
}
|
@@ -704,11 +700,11 @@ ColumnDraggingPlugin.prototype._onDragEnd = function (e) {
|
|
704
700
|
window.clearInterval(this._dragPulseId);
|
705
701
|
this._dragPulseId = 0;
|
706
702
|
}
|
707
|
-
|
703
|
+
let destPos = this._pos;
|
708
704
|
this._pos = null;
|
709
705
|
|
710
706
|
preventDefault(e);
|
711
|
-
|
707
|
+
let operationCancelled = false;
|
712
708
|
if(destPos["cancel"]) {
|
713
709
|
operationCancelled = true;
|
714
710
|
}
|
@@ -728,7 +724,7 @@ ColumnDraggingPlugin.prototype._onDragEnd = function (e) {
|
|
728
724
|
operationCancelled = true;
|
729
725
|
}
|
730
726
|
|
731
|
-
|
727
|
+
let arg = null;
|
732
728
|
|
733
729
|
if(!operationCancelled) {
|
734
730
|
arg = {
|
@@ -786,13 +782,14 @@ ColumnDraggingPlugin.prototype._moveColumns = function (srcColIndices, destColum
|
|
786
782
|
let colList = [];
|
787
783
|
let csp = this._getPlugin("ColumnStackPlugin");
|
788
784
|
let stackId, groupId;
|
785
|
+
let i;
|
789
786
|
if(srcCount === 1) {
|
790
787
|
if(csp) {
|
791
788
|
stackId = csp.getStackId(this._startColumn);
|
792
789
|
}
|
793
790
|
let cgp = this._getPlugin("ColumnGroupingPlugin");
|
794
791
|
if(cgp){
|
795
|
-
|
792
|
+
let cellInfo = cgp.getCellInfo(this._startPos);
|
796
793
|
groupId = cellInfo["groupId"] || cellInfo["columnId"];
|
797
794
|
}
|
798
795
|
|
@@ -801,15 +798,14 @@ ColumnDraggingPlugin.prototype._moveColumns = function (srcColIndices, destColum
|
|
801
798
|
} else if(groupId) {
|
802
799
|
cgp.moveGroup(groupId, destColumnIndex);
|
803
800
|
} else {
|
804
|
-
for(
|
801
|
+
for(i = this._startColumn; i <= this._endColumn; i++){
|
805
802
|
colList.push(i);
|
806
803
|
}
|
807
804
|
}
|
808
805
|
} else {
|
809
806
|
let stacking = {}; // Object to optimize call column stack api repeatly
|
810
|
-
for (
|
807
|
+
for (i = 0; i < srcCount; i++) {
|
811
808
|
let srcIdx = srcColIndices[i];
|
812
|
-
let srcId = this.getColumnId(srcIdx);
|
813
809
|
|
814
810
|
if(csp) {
|
815
811
|
stackId = csp.getStackId(srcIdx);
|
@@ -822,12 +818,13 @@ ColumnDraggingPlugin.prototype._moveColumns = function (srcColIndices, destColum
|
|
822
818
|
colList.push(colId);
|
823
819
|
}
|
824
820
|
} else {
|
821
|
+
let srcId = this.getColumnId(srcIdx);
|
825
822
|
colList.push(srcId); // Normal case
|
826
823
|
}
|
827
824
|
}
|
828
825
|
}
|
829
|
-
for(
|
830
|
-
|
826
|
+
for(i = this._hosts.length; --i >= 0;) {
|
827
|
+
let host = this._hosts[i];
|
831
828
|
host.reorderColumns(colList, destColumnIndex);
|
832
829
|
}
|
833
830
|
};
|
@@ -839,11 +836,11 @@ ColumnDraggingPlugin.prototype._onDragPulse = function() {
|
|
839
836
|
|
840
837
|
this._dispatch("dragInterval", this._pos);
|
841
838
|
|
842
|
-
|
839
|
+
let host = this._clickedGrid;
|
843
840
|
if(!host || !host.getHScrollbar().isActive()) { return; }
|
844
841
|
|
845
|
-
|
846
|
-
|
842
|
+
let x = this._pos["x"];
|
843
|
+
let scrollVal = 0;
|
847
844
|
if(x < this._cacheLeft) {
|
848
845
|
scrollVal = -Math.floor(this._scrollStep * (0.8 + Math.random()));
|
849
846
|
|
@@ -851,8 +848,8 @@ ColumnDraggingPlugin.prototype._onDragPulse = function() {
|
|
851
848
|
scrollVal = Math.floor(this._scrollStep * (0.8 + Math.random()));
|
852
849
|
}
|
853
850
|
|
854
|
-
|
855
|
-
for(
|
851
|
+
let len = this._hosts ? this._hosts.length : 0;
|
852
|
+
for(let i = 0; i < len; ++i) {
|
856
853
|
this._hosts[i].scrollRight(scrollVal);
|
857
854
|
}
|
858
855
|
};
|
@@ -876,7 +873,7 @@ ColumnDraggingPlugin.prototype._clearCache = function() {
|
|
876
873
|
* @return {!Object}
|
877
874
|
*/
|
878
875
|
ColumnDraggingPlugin.prototype._getSpan = function(colIndex, row, section) {
|
879
|
-
|
876
|
+
let cellSpan = section.getCellColSpan(colIndex, row);
|
880
877
|
|
881
878
|
if (cellSpan <= 0) { // The specified cell is being occupied
|
882
879
|
colIndex += cellSpan; // Convert the given negative index to the spanning cell
|
@@ -895,7 +892,7 @@ ColumnDraggingPlugin.prototype._findMoveableBorder = function(col, row, section)
|
|
895
892
|
if (row < 0 || (!row && row !== 0)) { // Guaranteed to get out of infinite loop by checking undefined, NaN, null
|
896
893
|
return { "left": 0, "right": (section.getColumnCount() - 1) };
|
897
894
|
}
|
898
|
-
|
895
|
+
let span = this._getSpan(col, row, section);
|
899
896
|
if (span["right"] >= span["left"]) {
|
900
897
|
return span;
|
901
898
|
} else {
|
@@ -906,29 +903,29 @@ ColumnDraggingPlugin.prototype._findMoveableBorder = function(col, row, section)
|
|
906
903
|
* @private
|
907
904
|
*/
|
908
905
|
ColumnDraggingPlugin.prototype._renderGuideline = function() {
|
909
|
-
|
906
|
+
let colIndex = this._pos["colIndex"];
|
910
907
|
if(colIndex == null || colIndex < 0) { // undefined, null or negative number
|
911
908
|
return;
|
912
909
|
}
|
913
910
|
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
for(
|
911
|
+
let currentSpan = this._getSpan(colIndex, this._clickedRow, this._clickedSection);
|
912
|
+
let colStart = currentSpan["left"]; // This can be different from colIndex
|
913
|
+
let colEnd = currentSpan["right"];
|
914
|
+
let colLeft = this._clickedGrid.getColumnLeft(colStart);
|
915
|
+
let colWidth = 0;
|
916
|
+
for(let i = colStart; i <= colEnd; ++i) {
|
920
917
|
colWidth += this._clickedGrid.getColumnWidth(i);
|
921
918
|
}
|
922
919
|
|
923
|
-
|
924
|
-
|
920
|
+
let rightHand = this._pos["x"] > colLeft + colWidth / 2;
|
921
|
+
let destColumn = (rightHand) ? colEnd + 1 : colStart;
|
925
922
|
|
926
|
-
|
923
|
+
let csp = this._getPlugin("ColumnStackPlugin");
|
927
924
|
if(csp){
|
928
|
-
|
925
|
+
let stackId = csp.getStackId(destColumn);
|
929
926
|
if(stackId){
|
930
|
-
|
931
|
-
|
927
|
+
let members = csp.getStackMemberIndices(stackId);
|
928
|
+
let memberCount = members.length;
|
932
929
|
if(members && memberCount){
|
933
930
|
destColumn = rightHand ? members[memberCount - 1] + 1 : members[0];
|
934
931
|
}
|
@@ -955,9 +952,9 @@ ColumnDraggingPlugin.prototype._renderGuideline = function() {
|
|
955
952
|
* @param {boolean} inOut
|
956
953
|
*/
|
957
954
|
ColumnDraggingPlugin.prototype._dimCol = function(inOut) {
|
958
|
-
|
959
|
-
|
960
|
-
|
955
|
+
let host = this._clickedGrid;
|
956
|
+
let titleCell = host.getSection("title").getColumn(this._startColumn).getCell(this._clickedRow);
|
957
|
+
let titleCellEl = titleCell.getElement();
|
961
958
|
if(inOut) {
|
962
959
|
titleCellEl.classList.add("drag-indicator");
|
963
960
|
} else {
|
package/lib/grid/index.js
CHANGED
@@ -20,6 +20,7 @@ import { Conflator } from "../../tr-grid-util/es6/Conflator.js";
|
|
20
20
|
* @property {string=} rowSpanningField="ROW_SPANNING" Field to be used for spanning segment header rows based on the field values
|
21
21
|
* @property {string=} segmentIdField="" Field used for initializing segments based on text id
|
22
22
|
* @property {string=} collapsingField="" Field used for indicating that the corresponding segment row is collapsed
|
23
|
+
* @property {string=} parentIdField="" Field used for specifying parent segment of the row
|
23
24
|
* @property {boolean=} defaultCollapsing=false If enabled, any newly created segment will be collapsed by default
|
24
25
|
* @property {(string|number)=} displayColumn=null Render tags in the given column. It can be either the column index, column ID, or field
|
25
26
|
*/
|
@@ -105,6 +106,10 @@ RowSegmentingPlugin.prototype._segmentIdField = "";
|
|
105
106
|
* @private
|
106
107
|
*/
|
107
108
|
RowSegmentingPlugin.prototype._collapsingField = "";
|
109
|
+
/** @type {string}
|
110
|
+
* @private
|
111
|
+
*/
|
112
|
+
RowSegmentingPlugin.prototype._parentIdField = "";
|
108
113
|
/** @type {number}
|
109
114
|
* @private
|
110
115
|
*/
|
@@ -241,17 +246,26 @@ RowSegmentingPlugin.prototype.requestSeparatorRefresh = function () {
|
|
241
246
|
let separatorArr = [];
|
242
247
|
let collapsingAry = [];
|
243
248
|
let expandingAry = [];
|
249
|
+
let parentId = "";
|
244
250
|
for(let i = 0; i < rowCount; i++) {
|
245
251
|
rowId = rowIds[i];
|
246
252
|
rowData = this._rowGetter(dt.getRowData(rowId));
|
247
253
|
segmentId = rowData[this._segmentIdField];
|
248
|
-
|
254
|
+
parentId = rowData[this._parentIdField];
|
255
|
+
if(segmentId == null && parentId == null) {
|
249
256
|
continue;
|
250
257
|
}
|
258
|
+
this._prevSegmentBySegmentId = true;
|
259
|
+
|
251
260
|
let segmentInfo = segmentMap[segmentId];
|
261
|
+
let parentInfo = parentId !== segmentId ? segmentMap[parentId] : null; // WARNING: parent must exist beforehand
|
252
262
|
if(segmentInfo) {
|
263
|
+
if(parentInfo) {
|
264
|
+
segmentInfo = parentInfo;
|
265
|
+
parentInfo = null;
|
266
|
+
}
|
253
267
|
segmentInfo.rowIds.push(rowId);
|
254
|
-
} else {
|
268
|
+
} else if(segmentId) {
|
255
269
|
segmentInfo = segmentMap[segmentId] = {
|
256
270
|
rowIds: [],
|
257
271
|
segmentId: rowId
|
@@ -268,7 +282,10 @@ RowSegmentingPlugin.prototype.requestSeparatorRefresh = function () {
|
|
268
282
|
}
|
269
283
|
}
|
270
284
|
}
|
271
|
-
|
285
|
+
|
286
|
+
if(parentInfo) {
|
287
|
+
parentInfo.rowIds.push(rowId);
|
288
|
+
}
|
272
289
|
}
|
273
290
|
if(segmentArr.length) {
|
274
291
|
this.setSegmentSeparators(separatorArr); // TODO: This method can be merged into setSegmentChildren
|
@@ -335,6 +352,9 @@ RowSegmentingPlugin.prototype.config = function (options) {
|
|
335
352
|
if (option.collapsingField != null) {
|
336
353
|
this._collapsingField = option.collapsingField;
|
337
354
|
}
|
355
|
+
if (option.parentIdField != null) {
|
356
|
+
this._parentIdField = option.parentIdField;
|
357
|
+
}
|
338
358
|
if (option.predefinedColors != null && typeof option.predefinedColors === "object") {
|
339
359
|
this._predefinedColors = option.predefinedColors;
|
340
360
|
}
|
@@ -418,6 +438,9 @@ RowSegmentingPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
418
438
|
if(this._collapsingField) {
|
419
439
|
extOptions.collapsingField = this._collapsingField;
|
420
440
|
}
|
441
|
+
if(this._parentIdField) {
|
442
|
+
extOptions.parentIdField = this._parentIdField;
|
443
|
+
}
|
421
444
|
if(this._defaultCollapsing) {
|
422
445
|
extOptions.defaultCollapsing = true;
|
423
446
|
}
|
@@ -445,7 +468,32 @@ RowSegmentingPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
445
468
|
return obj;
|
446
469
|
};
|
447
470
|
|
448
|
-
|
471
|
+
/** @private
|
472
|
+
* @function
|
473
|
+
* @param {!Object} obj
|
474
|
+
* @param {string} field
|
475
|
+
* @param {*} val
|
476
|
+
*/
|
477
|
+
let _setObjectValue = function(obj, field, val) {
|
478
|
+
if(field) {
|
479
|
+
if(!obj.values) {
|
480
|
+
obj.values = {};
|
481
|
+
}
|
482
|
+
obj.values[field] = val;
|
483
|
+
}
|
484
|
+
};
|
485
|
+
/** @private
|
486
|
+
* @function
|
487
|
+
* @param {!Object} obj
|
488
|
+
* @param {string} field
|
489
|
+
*/
|
490
|
+
let _deleteObjectValue = function(obj, field) {
|
491
|
+
if(field && obj.values) {
|
492
|
+
if(obj.values[field]) {
|
493
|
+
delete obj.values[field]; // Slow
|
494
|
+
}
|
495
|
+
}
|
496
|
+
};
|
449
497
|
/** @public
|
450
498
|
* @param {Object} rowData row config object
|
451
499
|
* @param {string} rowId
|
@@ -453,37 +501,35 @@ RowSegmentingPlugin.prototype.getConfigObject = function (gridOptions) {
|
|
453
501
|
*/
|
454
502
|
RowSegmentingPlugin.prototype.getRowConfigObject = function (rowData, rowId) {
|
455
503
|
let obj = rowData || {};
|
456
|
-
|
457
|
-
if(!
|
504
|
+
let segmentIdField = this._segmentIdField;
|
505
|
+
if(!segmentIdField) {
|
458
506
|
return obj;
|
459
507
|
}
|
460
508
|
|
461
|
-
|
462
|
-
|
463
|
-
delete obj.values[this._segmentIdField]; // clear only segmentIdField
|
464
|
-
}
|
465
|
-
}
|
509
|
+
_deleteObjectValue(obj, segmentIdField);
|
510
|
+
_deleteObjectValue(obj, this._parentIdField);
|
466
511
|
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
512
|
+
let dv = this._getDataView();
|
513
|
+
let segment = dv.getSegment(rowId);
|
514
|
+
if(segment) {
|
515
|
+
_setObjectValue(obj, segmentIdField, ++this._runningId);
|
516
|
+
segment.runningId = this._runningId; // WANRING: Add
|
517
|
+
|
518
|
+
let collapsed = segment.isCollapsed();
|
519
|
+
_setObjectValue(obj, this._collapsingField, collapsed);
|
472
520
|
|
473
|
-
let collapsed = this.isSegmentCollapsed(rowId);
|
474
|
-
if(this._collapsingField) {
|
475
|
-
obj.values[this._collapsingField] = collapsed;
|
476
|
-
}
|
477
521
|
if(obj["collapsed"] == null) { // Avoid overriding value from real-time grid
|
478
522
|
obj["collapsed"] = collapsed;
|
479
523
|
}
|
480
|
-
}
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
obj
|
524
|
+
}
|
525
|
+
|
526
|
+
let parentSegment = dv.getSegmentParent(rowId);
|
527
|
+
if(parentSegment) {
|
528
|
+
if(this._parentIdField) {
|
529
|
+
// WARNING: this assumes the parent segment is always appeared before this row id
|
530
|
+
_setObjectValue(obj, this._parentIdField, parentSegment.runningId || this._runningId);
|
531
|
+
} else if(!segment) {
|
532
|
+
_setObjectValue(obj, segmentIdField, this._runningId);
|
487
533
|
}
|
488
534
|
}
|
489
535
|
|
@@ -601,12 +647,8 @@ RowSegmentingPlugin.prototype._hasSegmentation = function (settings) {
|
|
601
647
|
RowSegmentingPlugin.prototype.getSegmentParentRowId = function (rowRef) {
|
602
648
|
let dv = this._getDataView();
|
603
649
|
if(dv) {
|
604
|
-
|
605
|
-
|
606
|
-
rowId = dv.getRowId(rowRef); // WARNING: This is very slow
|
607
|
-
} else {
|
608
|
-
rowId = rowRef;
|
609
|
-
}
|
650
|
+
// WARNING: getRowId is slow
|
651
|
+
let rowId = (typeof rowRef === "number") ? dv.getRowId(rowRef) : rowRef;
|
610
652
|
return dv.getSegmentParentRowId(rowId);
|
611
653
|
}
|
612
654
|
return "";
|
@@ -711,9 +753,10 @@ RowSegmentingPlugin.prototype._updateHeader = function (settings, firstRowIndex,
|
|
711
753
|
} else {
|
712
754
|
arg.groupLevel = 0;
|
713
755
|
let indentLevel = 0;
|
714
|
-
let parentId =
|
756
|
+
let parentId = dv.getSegmentParentRowId(rowId);
|
715
757
|
if(parentId) {
|
716
|
-
|
758
|
+
let parentSegment = dv.getSegment(parentId);
|
759
|
+
indentLevel = parentSegment ? parentSegment.getSegmentLevel() + 1 : 1;
|
717
760
|
arg.nonGroupRow = false;
|
718
761
|
let parentRowData = parentRows[parentId];
|
719
762
|
if (!parentRowData) {
|
@@ -144,7 +144,6 @@ let RowDraggingPlugin = function (options) {
|
|
144
144
|
t._onDragStart = t._onDragStart.bind(t);
|
145
145
|
t._onMouseMove = t._onMouseMove.bind(t);
|
146
146
|
t._onDragEnd = t._onDragEnd.bind(t);
|
147
|
-
t._onThemeLoaded = t._onThemeLoaded.bind(t);
|
148
147
|
|
149
148
|
t._onJETDrop = t._onJETDrop.bind(t);
|
150
149
|
t._onJETDragOver = t._onJETDragOver.bind(t);
|
@@ -303,15 +302,6 @@ RowDraggingPlugin.prototype._jetContentHasField = false;
|
|
303
302
|
*/
|
304
303
|
RowDraggingPlugin.prototype._entryPoint = "";
|
305
304
|
|
306
|
-
/** Applied theme color in row dragging and dragUI
|
307
|
-
* @private
|
308
|
-
* @param {Object} host core grid instance
|
309
|
-
*/
|
310
|
-
let _applyStyles = function(host) {
|
311
|
-
RowDraggingPlugin._applyThemeColor(host);
|
312
|
-
DragUI.applyThemeColor(host);
|
313
|
-
};
|
314
|
-
|
315
305
|
/** Prevent built-in config
|
316
306
|
* @public
|
317
307
|
* @ignore
|
@@ -365,13 +355,11 @@ RowDraggingPlugin.prototype.initialize = function (host, options) {
|
|
365
355
|
dragBoxIcon: this._dragBoxIcon
|
366
356
|
});
|
367
357
|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
// TODO: Create a manager to manage styles. Currently, we have to use setTimeout to wait for an element to be created before applying styles
|
374
|
-
setTimeout(_applyStyles.bind(this, host), 0);
|
358
|
+
ElfUtil.getThemeColors().then(
|
359
|
+
RowDraggingPlugin._onThemeLoaded.bind(null, host)
|
360
|
+
).catch(
|
361
|
+
RowDraggingPlugin._onThemeLoaded.bind(null, host)
|
362
|
+
);
|
375
363
|
|
376
364
|
// In case of lazy loading
|
377
365
|
// host.getAllSections("content").forEach(this._registerSection);
|
@@ -406,8 +394,10 @@ RowDraggingPlugin.prototype.unload = function (host) {
|
|
406
394
|
};
|
407
395
|
|
408
396
|
/** @private
|
397
|
+
* @function
|
398
|
+
* @param {Object} grid Core grid instance
|
409
399
|
*/
|
410
|
-
RowDraggingPlugin.
|
400
|
+
RowDraggingPlugin._onThemeLoaded = function(grid) {
|
411
401
|
if(!RowDraggingPlugin._styles) {
|
412
402
|
let styles = [
|
413
403
|
":host .row-dragging .cover-layer .selection-bound", [
|
@@ -420,11 +410,9 @@ RowDraggingPlugin.prototype._onThemeLoaded = function() {
|
|
420
410
|
RowDraggingPlugin._styles = prettifyCss(styles);
|
421
411
|
}
|
422
412
|
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
_applyStyles(this._hosts[i]);
|
427
|
-
}
|
413
|
+
DragUI.initStyles();
|
414
|
+
RowDraggingPlugin._applyThemeColor(grid);
|
415
|
+
DragUI.applyThemeColor(grid);
|
428
416
|
};
|
429
417
|
/** @private
|
430
418
|
* @param {Object} grid core grid instance
|
@@ -36,12 +36,11 @@ DragUI.prototype._dragBoxIcon = null;
|
|
36
36
|
*/
|
37
37
|
DragUI.prototype._grid = null;
|
38
38
|
|
39
|
-
/**
|
39
|
+
/** Apply the theme colors to the specified grid after DragUI.initStyles
|
40
|
+
* @public
|
40
41
|
* @param {Object} grid core grid instance
|
41
42
|
*/
|
42
43
|
DragUI.applyThemeColor = function(grid) {
|
43
|
-
// This call after onThemeLoaded from extensions initialize
|
44
|
-
|
45
44
|
if(!grid || grid._dragUIStyles) {
|
46
45
|
return;
|
47
46
|
}
|
@@ -49,19 +48,31 @@ DragUI.applyThemeColor = function(grid) {
|
|
49
48
|
if(DragUI._styles) {
|
50
49
|
grid._dragUIStyles = true; // Prevent loading the same style twice
|
51
50
|
injectCss(DragUI._styles, grid.getElement());
|
52
|
-
} else {
|
53
|
-
// TODO : Handle if can not load DragUI._styles try to set new DragUI._styles
|
54
|
-
// Warning: This process have to use ElfUtil.getThemeColors() that async process for Backward compatability.
|
55
|
-
// When use async process, then it can be load theme multiple times.
|
56
|
-
|
57
51
|
}
|
52
|
+
// TO_DO : Handle if can not load DragUI._styles try to set new DragUI._styles
|
53
|
+
// Warning: This process have to use ElfUtil.getThemeColors() that async process for Backward compatability.
|
54
|
+
// When use async process, then it can be load theme multiple times.
|
58
55
|
};
|
59
56
|
|
60
|
-
/**
|
57
|
+
/** Deprecated in favor of DragUI.initStyles()
|
58
|
+
* @public
|
61
59
|
* @param {Object} colors
|
62
60
|
*/
|
63
61
|
DragUI.prototype.onThemeLoaded = function(colors) {
|
62
|
+
DragUI.initStyles(colors);
|
63
|
+
};
|
64
|
+
|
65
|
+
/** WARNING: This method should be called after the theme has been loaded in order to initialize with the correct colors.
|
66
|
+
* @public
|
67
|
+
* @function
|
68
|
+
* @param {Object=} colors
|
69
|
+
*/
|
70
|
+
DragUI.initStyles = function(colors) {
|
64
71
|
if(!DragUI._styles) {
|
72
|
+
if(!colors) {
|
73
|
+
colors = ElfUtil.getColors();
|
74
|
+
}
|
75
|
+
|
65
76
|
let ElfVersion = ElfUtil.getElfVersion();
|
66
77
|
let cursor = "grabbing";
|
67
78
|
if (ElfVersion < 3) {
|
package/lib/versions.json
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
{
|
2
|
-
"tr-grid-util": "1.3.
|
2
|
+
"tr-grid-util": "1.3.175",
|
3
3
|
"tr-grid-printer": "1.0.18",
|
4
|
-
"@grid/column-dragging": "1.0.
|
5
|
-
"@grid/row-segmenting": "2.0.
|
4
|
+
"@grid/column-dragging": "1.0.22",
|
5
|
+
"@grid/row-segmenting": "2.0.2",
|
6
6
|
"@grid/statistics-row": "1.0.17",
|
7
7
|
"@grid/zoom": "1.0.13",
|
8
8
|
"tr-grid-auto-tooltip": "1.1.9",
|
@@ -23,7 +23,7 @@
|
|
23
23
|
"tr-grid-pagination": "1.0.24",
|
24
24
|
"tr-grid-percent-bar": "1.0.24",
|
25
25
|
"tr-grid-range-bar": "2.0.9",
|
26
|
-
"tr-grid-row-dragging": "1.0.
|
26
|
+
"tr-grid-row-dragging": "1.0.39",
|
27
27
|
"tr-grid-row-filtering": "1.0.89",
|
28
28
|
"tr-grid-row-grouping": "1.0.88",
|
29
29
|
"tr-grid-row-selection": "1.0.33",
|
package/package.json
CHANGED