@refinitiv-ui/efx-grid 6.0.128 → 6.0.129

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.
@@ -346,6 +346,35 @@ DataCache.prototype.cloneRowData = function (rid) {
346
346
  return values;
347
347
  };
348
348
 
349
+ /**
350
+ * @protected
351
+ * @ignore
352
+ * @param {string} fromRid
353
+ * @param {string} toRid
354
+ * @return {boolean}
355
+ */
356
+ DataCache.prototype._replaceRowId = function(fromRid, toRid) {
357
+ let rows = this._rows;
358
+ if(rows[fromRid]) {
359
+ rows[toRid] = rows[fromRid];
360
+ delete rows[fromRid];
361
+ return true;
362
+ }
363
+ return false;
364
+ };
365
+ /**
366
+ * @public
367
+ * @ignore
368
+ * @param {Object} ridPair
369
+ */
370
+ DataCache.prototype.replaceRowIds = function(ridPair) {
371
+ if(typeof ridPair === "object") {
372
+ for(let oldRid in ridPair) {
373
+ this._replaceRowId(oldRid, ridPair[oldRid]);
374
+ }
375
+ }
376
+ };
377
+
349
378
  /** Deprecated. Built-in Data Service is deprecated due to the lack of flexibility.
350
379
  * @public
351
380
  * @ignore
@@ -80,6 +80,8 @@ declare class DataTable extends DataCache {
80
80
 
81
81
  public isFrozen(): boolean;
82
82
 
83
+ public setSegmentSeparators(rids: (string)[]|null, enabled?: boolean|null): boolean;
84
+
83
85
  public setSegmentSeparator(rid: string, enabled?: boolean|null): boolean;
84
86
 
85
87
  public unsetAllSegmentSeparators(): boolean;
@@ -106,6 +108,8 @@ declare class DataTable extends DataCache {
106
108
 
107
109
  public addSegmentChildren(segmentId: string, rids: (string)[]|null, dataIds?: (string)[]|null): boolean;
108
110
 
111
+ public setSegmentChildren(segmentArr: (any)[]|null): boolean;
112
+
109
113
  public removeSegmentChild(segmentId: string, rid: string): boolean;
110
114
 
111
115
  public removeSegmentChildren(segmentId: string, rids: (string)[]|null): boolean;
@@ -823,6 +823,45 @@ DataTable.prototype.swapRow = function(fromIndex, toIndex) { // No event is fire
823
823
  this._rids[toIndex] = rid;
824
824
  };
825
825
 
826
+ /**
827
+ * @protected
828
+ * @override
829
+ * @ignore
830
+ * @param {string} fromRid
831
+ * @param {string} toRid
832
+ * @return {boolean}
833
+ */
834
+ DataTable.prototype._replaceRowId = function(fromRid, toRid) {
835
+ let rids = this._rids;
836
+ let idx = rids.indexOf(fromRid);
837
+ if(idx >= 0) {
838
+ rids[idx] = toRid;
839
+ this._rows[toRid] = this._rows[fromRid];
840
+ delete this._rows[fromRid];
841
+ this._prevData[toRid] = this._prevData[fromRid];
842
+ delete this._prevData[fromRid];
843
+ return true;
844
+ }
845
+ return false;
846
+ };
847
+ /**
848
+ * @public
849
+ * @override
850
+ * @ignore
851
+ * @param {Object} ridPair
852
+ */
853
+ DataTable.prototype.replaceRowIds = function(ridPair) {
854
+ if(typeof ridPair === "object") {
855
+ let dirty = false;
856
+ for(let oldRid in ridPair) {
857
+ dirty |= this._replaceRowId(oldRid, ridPair[oldRid]);
858
+ }
859
+ if(dirty) {
860
+ this.dispatchGlobalChange();
861
+ }
862
+ }
863
+ };
864
+
826
865
  /** @public
827
866
  * @function
828
867
  * @param {string} rid
@@ -964,6 +1003,55 @@ DataTable.prototype.isFrozen = function() {
964
1003
  return this._frozen;
965
1004
  };
966
1005
 
1006
+ /**
1007
+ * @public
1008
+ * @param {Array.<string>} rids
1009
+ * @param {boolean=} enabled
1010
+ * @return {boolean} Return true if there is any change
1011
+ */
1012
+ DataTable.prototype.setSegmentSeparators = function(rids, enabled) {
1013
+ let change = false;
1014
+ if (rids) {
1015
+ let len = rids.length;
1016
+ let segmentChanged = false;
1017
+ for (let i = 0; i < len; i++) {
1018
+ if(enabled !== false) {
1019
+ let rid = rids[i];
1020
+ if (!this._segments) {
1021
+ this._segments = new SegmentCollection();
1022
+ this._segments.addEventListener("subSegmentChanged", this._onSubSegmentChanged);
1023
+ }
1024
+ if(this._autoSegmentFilling) {
1025
+ let parentId = this._segments.getParentRowId(rid);
1026
+ if(parentId) {
1027
+ this._segments.removeSegmentChild(parentId, rid);
1028
+ }
1029
+ }
1030
+ segmentChanged = this._segments.addSegment(rid);
1031
+ } else if (this._segments) { // remove case
1032
+ let segment = this._segments.getSegment(rid);
1033
+ if(segment) {
1034
+ if(this._segments.removeSegment(rid)) {
1035
+ change = true;
1036
+ if(!this._segments.getSegmentCount()) {
1037
+ this._segments = null;
1038
+ }
1039
+ }
1040
+ }
1041
+ }
1042
+
1043
+ }
1044
+ if (enabled !== false && segmentChanged) {
1045
+ this._segments.calcSegmentOrder(this._rids);
1046
+ change = true;
1047
+ }
1048
+ if(change) {
1049
+ this.dispatchGlobalChange();
1050
+ }
1051
+ }
1052
+ return change;
1053
+
1054
+ };
967
1055
 
968
1056
  /**
969
1057
  * @public
@@ -990,7 +1078,7 @@ DataTable.prototype.setSegmentSeparator = function(rid, enabled) {
990
1078
  this._segments.calcSegmentOrder(this._rids);
991
1079
  change = true;
992
1080
  }
993
- } else if(this._segments) {
1081
+ } else if(this._segments) { // mean remove separator
994
1082
  let segment = this._segments.getSegment(rid);
995
1083
  if(segment) {
996
1084
  memberCount = segment.getChildCount();
@@ -1216,6 +1304,34 @@ DataTable.prototype.addSegmentChildren = function(segmentId, rids, dataIds) {
1216
1304
  }
1217
1305
  return false;
1218
1306
  };
1307
+
1308
+ /** @public
1309
+ * @param {Array.<Object>} segmentArr Segment array that contain "segmentId", "rowIds" to set segment children
1310
+ * @return {boolean} Return true if there is any change
1311
+ */
1312
+ DataTable.prototype.setSegmentChildren = function(segmentArr) {
1313
+ if(!this._segments) {
1314
+ return false;
1315
+ }
1316
+ this.removeAllSegmentChildren();
1317
+ let len = segmentArr.length;
1318
+ let dirty;
1319
+ for (let i = 0; i < len; i++) {
1320
+ let obj = segmentArr[i];
1321
+ if(this._segments.addSegmentChildren(obj.segmentId, obj.rowIds)) {
1322
+ dirty = true;
1323
+ }
1324
+ }
1325
+ if(dirty) {
1326
+ this._sort(null);
1327
+ this._dispatchPositionChange(); // Force rerendering, even if there is no position change
1328
+
1329
+ this.requestClassifying();
1330
+ return true;
1331
+ }
1332
+
1333
+ return false;
1334
+ };
1219
1335
  /** @public
1220
1336
  * @param {string} segmentId Row id
1221
1337
  * @param {string} rid Row id
@@ -246,6 +246,8 @@ declare class DataView extends EventDispatcher {
246
246
 
247
247
  public synchronizeRowOrder(): void;
248
248
 
249
+ public setSegmentSeparators(rowIds: (string)[]|null, enabled?: boolean|null): boolean;
250
+
249
251
  public setSegmentSeparator(rowRef: string|number|null, enabled?: boolean|null): boolean;
250
252
 
251
253
  public unsetAllSegmentSeparators(): boolean;
@@ -264,6 +266,8 @@ declare class DataView extends EventDispatcher {
264
266
 
265
267
  public collapseSegment(rowRef: string|number|null, collapsed?: boolean|null): boolean;
266
268
 
269
+ public collapseSegments(rowIds: (string|number)[]|null, collapsed?: boolean|null): boolean;
270
+
267
271
  public expandSegment(rowRef: string|number|null, expanded?: boolean|null): boolean;
268
272
 
269
273
  public expandAllSegments(): boolean;
@@ -278,6 +282,8 @@ declare class DataView extends EventDispatcher {
278
282
 
279
283
  public addSegmentChildren(segmentRef: string|number|null, rowRefs: (string|number)[]|null, dataIds?: (string)[]|null): boolean;
280
284
 
285
+ public setSegmentChildren(segmentArr: (any)[]|null): boolean;
286
+
281
287
  public removeSegmentChild(segmentRef: string|number|null, rowRef: string|number|null): boolean;
282
288
 
283
289
  public removeSegmentChildren(segmentRef: string|number|null, rowRefs: (string|number)[]|null): boolean;
@@ -2428,6 +2428,23 @@ DataView.prototype.synchronizeRowOrder = function() {
2428
2428
  this._dt._sort(this._sortingDefs);
2429
2429
  }
2430
2430
  };
2431
+ /**
2432
+ * @public
2433
+ * @param {Array<string>} rowIds
2434
+ * @param {boolean=} enabled
2435
+ * @return {boolean} Return true if there is any change
2436
+ */
2437
+ DataView.prototype.setSegmentSeparators = function(rowIds, enabled) {
2438
+ if(rowIds) {
2439
+ enabled = enabled !== false;
2440
+ if(enabled) {
2441
+ this.synchronizeRowOrder();
2442
+ }
2443
+ // TODO: Force expanding of segment before unsetting segment separator
2444
+ return this._dt.setSegmentSeparators(rowIds, enabled);
2445
+ }
2446
+ return false;
2447
+ };
2431
2448
  /** Set visible row as segment separator (hidden or filtered rows cannot be a segment separator)
2432
2449
  * @public
2433
2450
  * @param {string|number} rowRef Row id or row index
@@ -2528,6 +2545,22 @@ DataView.prototype.collapseSegment = function(rowRef, collapsed) {
2528
2545
  return false;
2529
2546
  };
2530
2547
  /** @public
2548
+ * @param {Array<string|number>} rowIds
2549
+ * @param {boolean=} collapsed
2550
+ * @return {boolean} Return true if there is any change
2551
+ */
2552
+ DataView.prototype.collapseSegments = function(rowIds, collapsed) {
2553
+ collapsed = collapsed !== false;
2554
+ let segments = this._dt._getSegmentSeparators();
2555
+ if(segments) {
2556
+ if(segments.collapseSegments(rowIds, collapsed)) {
2557
+ this._refreshAndNotify(); // dispatch global change event
2558
+ return true;
2559
+ }
2560
+ }
2561
+ return false;
2562
+ };
2563
+ /** @public
2531
2564
  * @param {string|number} rowRef Row id or row index
2532
2565
  * @param {boolean=} expanded
2533
2566
  * @return {boolean} Return true if there is any change
@@ -2606,6 +2639,16 @@ DataView.prototype.addSegmentChildren = function(segmentRef, rowRefs, dataIds) {
2606
2639
  return false;
2607
2640
  };
2608
2641
  /** @public
2642
+ * @param {Array<Object>} segmentArr Segment array that contain "segmentId", "rowIds" to set segment children
2643
+ * @return {boolean} Return true if there is any change
2644
+ */
2645
+ DataView.prototype.setSegmentChildren = function(segmentArr) {
2646
+ if(this._dt._getSegmentSeparators()) {
2647
+ return this._dt.setSegmentChildren(segmentArr);
2648
+ }
2649
+ return false;
2650
+ };
2651
+ /** @public
2609
2652
  * @param {string|number} segmentRef Row id or row index
2610
2653
  * @param {string|number} rowRef Row id, row index
2611
2654
  * @return {boolean} Return true if there is any change
@@ -30,6 +30,8 @@ declare class SegmentCollection extends EventDispatcher {
30
30
 
31
31
  public getSegmentIds(): (string)[];
32
32
 
33
+ public collapseSegments(segmentIds: (string)[]|null, bool?: boolean|null): boolean;
34
+
33
35
  public collapseSegment(segmentId: string, bool?: boolean|null): boolean;
34
36
 
35
37
  public expandSegment(segmentId: string, bool?: boolean|null): boolean;
@@ -208,6 +208,27 @@ SegmentCollection.prototype.getSegmentIds = function() {
208
208
  };
209
209
 
210
210
 
211
+ /** @public
212
+ * @param {Array.<string>} segmentIds
213
+ * @param {boolean=} bool
214
+ * @return {boolean} Returns true if there is any change. Otherwise, returns false
215
+ */
216
+ SegmentCollection.prototype.collapseSegments = function(segmentIds, bool) {
217
+ if(this._segmentCount) {
218
+ let dirty = 0;
219
+ let len = segmentIds.length;
220
+ for (let i = 0; i < len; i++) {
221
+ let rowId = segmentIds[i];
222
+ dirty |= this._segments[rowId].collapse(bool);
223
+
224
+ }
225
+ if(dirty) {
226
+ return true;
227
+ }
228
+ }
229
+ return false;
230
+ };
231
+
211
232
  /** @public
212
233
  * @param {string} segmentId
213
234
  * @param {boolean=} bool
@@ -621,7 +621,7 @@ Core.prototype._hasPendingRowChange = false;
621
621
  * @return {string}
622
622
  */
623
623
  Core.getVersion = function () {
624
- return "5.1.125";
624
+ return "5.1.129";
625
625
  };
626
626
  /** {@link ElementWrapper#dispose}
627
627
  * @override
@@ -803,7 +803,15 @@ SortableTitlePlugin.prototype.isSorting = function () {
803
803
  * @fires SortableTitlePlugin#columnSorted
804
804
  */
805
805
  SortableTitlePlugin.prototype.sortColumn = function (colRef, sortOrder, opt_arg) {
806
- this._sortColumn(this._prepareSorting(colRef, sortOrder), opt_arg);
806
+ let sortOptions = this._prepareSorting(colRef, sortOrder);
807
+ this._sortColumn(sortOptions, opt_arg);
808
+ if (opt_arg && opt_arg["isUserAction"]) { // Currently, the 'isUserAction' flag is triggered by a user clicking on the title and clicking the filter dialog. TODO: preClicked should be firing too.
809
+ let ce = {};
810
+ ce["colIndex"] = sortOptions.colIndex;
811
+ ce["sortOrder"] = this.getSortOrder(sortOptions.colIndex);
812
+ ce["dataColumnName"] = this.getColumnSortingField(sortOptions.colIndex); // This should be deprecated
813
+ this._dispatch("clicked", ce);
814
+ }
807
815
  };
808
816
 
809
817
  /** Sort multiple columns at once
@@ -1202,14 +1210,6 @@ SortableTitlePlugin.prototype._proceedSorting = function (hitObj) {
1202
1210
  if(grid && grid["focus"]) {
1203
1211
  grid["focus"]();
1204
1212
  }
1205
-
1206
- if (this._hasListener("clicked")) {
1207
- let ce = {};
1208
- ce["colIndex"] = colIndex;
1209
- ce["sortOrder"] = this.getSortOrder(colIndex);
1210
- ce["dataColumnName"] = this.getColumnSortingField(colIndex); // This should be deprecated
1211
- this._dispatch("clicked", ce);
1212
- }
1213
1213
  }
1214
1214
  };
1215
1215
 
package/lib/grid/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import {Grid} from "./lib/efx-grid.js";
2
2
  export {Grid}
3
- window.EFX_GRID = { version: "6.0.128" };
3
+ window.EFX_GRID = { version: "6.0.129" };
@@ -51,6 +51,8 @@ declare class RowSegmentingPlugin extends GridPlugin {
51
51
 
52
52
  public _resolveDisplayColumn(): number;
53
53
 
54
+ public setSegmentSeparators(rowIds: (string)[]|null, enabled?: boolean|null): boolean;
55
+
54
56
  public setSegmentSeparator(rowRef: string|number|null, enabled?: boolean|null): boolean;
55
57
 
56
58
  public setSegmentClassification(rowRef: string|number|null, fields: string|(string)[]|null): boolean;
@@ -61,6 +63,8 @@ declare class RowSegmentingPlugin extends GridPlugin {
61
63
 
62
64
  public isSegmentSeparator(rowRef: string|number|null): boolean;
63
65
 
66
+ public collapseSegments(rowIds: (string )[]|null, collapsed: (string )[]|null): boolean;
67
+
64
68
  public collapseSegment(rowRef: string|number|null, collapsed?: boolean|null): boolean;
65
69
 
66
70
  public expandSegment(rowRef: string|number|null, expanded?: boolean|null): boolean;
@@ -77,6 +81,8 @@ declare class RowSegmentingPlugin extends GridPlugin {
77
81
 
78
82
  public addSegmentChild(segmentRef: string|number|null, rowRef: string|number|null): void;
79
83
 
84
+ public setSegmentChildren(segmentArr: (any)[]|null): void;
85
+
80
86
  public addSegmentChildren(segmentRef: string|number|null, rowRefs: (string|number)[]|null): void;
81
87
 
82
88
  public removeSegmentChild(segmentRef: string|number|null, rowRef: string|number|null): void;
@@ -220,24 +220,35 @@ RowSegmentingPlugin.prototype._refreshSegmentSeparator = function () {
220
220
  var rowIds = dt.getAllRowIds();
221
221
  var rowCount = rowIds.length;
222
222
  var separatorMap = {};
223
+ var segmentArr = [];
224
+ var separatorArr = [];
225
+ var collapseArr = [];
223
226
  for(var i = 0; i < rowCount; i++) {
224
227
  rowId = rowIds[i];
225
228
  rowData = this._rowGetter(dt.getRowData(rowId));
226
229
  segmentId = rowData[this._segmentIdField];
227
-
228
- if (segmentId != null) {
229
- if (separatorMap[segmentId] != null ) {
230
- this.addSegmentChild(separatorMap[segmentId], rowId);
231
- } else {
232
- separatorMap[segmentId] = rowId;
233
- this.setSegmentSeparator(rowId);
234
- if (collapsingMap[segmentId] != null) {
235
- this.collapseSegment(rowId, collapsingMap[segmentId]);
236
- }
230
+ if(segmentId == null) {
231
+ continue;
232
+ }
233
+ if(separatorMap[segmentId] == null) {
234
+ separatorMap[segmentId] = {
235
+ rowIds: [],
236
+ segmentId: rowId // Row id of parent
237
+ };
238
+ segmentArr.push(separatorMap[segmentId]);
239
+ separatorArr.push(rowId);
240
+ if (collapsingMap[segmentId] === true) { // TODO: Currenly is expand by default, then it need to only collapse some row from prev segment id
241
+ collapseArr.push(rowId);
237
242
  }
238
- this._prevSegmentBySegmentId = true;
243
+ } else {
244
+ // Add rowId to set segment separator
245
+ separatorMap[segmentId].rowIds.push(rowId);
239
246
  }
247
+ this._prevSegmentBySegmentId = true;
240
248
  }
249
+ this.setSegmentSeparators(separatorArr);
250
+ this.setSegmentChildren(segmentArr);
251
+ this.collapseSegments(collapseArr);
241
252
  };
242
253
  /** @public
243
254
  * @param {Object=} host core grid instance
@@ -728,6 +739,20 @@ RowSegmentingPlugin.prototype._getDataView = function () {
728
739
  return host ? host.getDataSource() : null;
729
740
  };
730
741
 
742
+ /** Set specified row ids as a segment separator
743
+ * @public
744
+ * @param {Array<string>} rowIds
745
+ * @param {boolean=} enabled
746
+ * @return {boolean} Return true if there is any change
747
+ */
748
+ RowSegmentingPlugin.prototype.setSegmentSeparators = function(rowIds, enabled) {
749
+ var dv = this._getDataView();
750
+ if(dv) {
751
+ return dv.setSegmentSeparators(rowIds, enabled);
752
+ }
753
+ return false;
754
+ };
755
+
731
756
  /** Set specified row as a segment separator
732
757
  * @public
733
758
  * @param {string|number} rowRef Row id or row index
@@ -796,6 +821,21 @@ RowSegmentingPlugin.prototype.isSegmentSeparator = function(rowRef) {
796
821
  return false;
797
822
  };
798
823
 
824
+ /**
825
+ * @public
826
+ * @param {Array.<string >} rowIds
827
+ * @param {Array.<string >} collapsed
828
+
829
+ * @return {boolean} Return true if there is any change
830
+ */
831
+ RowSegmentingPlugin.prototype.collapseSegments = function(rowIds, collapsed) {
832
+ var dv = this._getDataView();
833
+ if(dv) {
834
+ return dv.collapseSegments(rowIds, collapsed);
835
+ }
836
+ return false;
837
+ };
838
+
799
839
  /** Hide all members in the segment
800
840
  * @public
801
841
  * @param {string|number} rowRef Row id or row index of the segment separator
@@ -888,6 +928,17 @@ RowSegmentingPlugin.prototype.addSegmentChild = function(segmentRef, rowRef) {
888
928
  dv.addSegmentChild(segmentRef, rowRef, dataId);
889
929
  }
890
930
  };
931
+
932
+ /** @public
933
+ * @param {Array<Object>} segmentArr Segment array that contain "segmentId", "rowIds" to set segment children
934
+ */
935
+ RowSegmentingPlugin.prototype.setSegmentChildren = function(segmentArr) {
936
+ let dv = this._getDataView();
937
+ if(dv) {
938
+ dv.setSegmentChildren(segmentArr);
939
+ }
940
+ };
941
+
891
942
  /** @public
892
943
  * @param {string|number} segmentRef Row id or row index
893
944
  * @param {Array.<string|number>} rowRefs Array of row ids or row indices. If null is given, no child will be removed.