@refinitiv-ui/efx-grid 6.0.98 → 6.0.99

Sign up to get free protection for your applications and to get access to all the features.
@@ -184,6 +184,8 @@ declare class Grid extends EventDispatcher {
184
184
 
185
185
  public insertRow(rowOption?: (RowDefinition.Options|string)|null, rowRef?: Grid.RowReference|null): RowDefinition|null;
186
186
 
187
+ public insertSegmentSeparator(rowOption?: RowDefinition.Options|null, rowRef?: Grid.RowReference|null): RowDefinition|null;
188
+
187
189
  public insertRows(rowOptions: (RowDefinition.Options|string)[]|null, rowRef?: Grid.RowReference|null, opt_fields?: (string)[]|null): void;
188
190
 
189
191
  public addStaticDataRows(dataRows: any[]|null, fields?: (string)[]|null): void;
@@ -2321,6 +2321,22 @@ Grid.prototype.insertRow = function(rowOption, rowRef) {
2321
2321
  this._connector.addRic(rowDef);
2322
2322
  return rowDef;
2323
2323
  };
2324
+ /** Insert a row as a segment separator
2325
+ * @public
2326
+ * @param {RowDefinition~Options=} rowOption
2327
+ * @param {Grid~RowReference=} rowRef Reference (i.e. row index, row id, or row definition) of the insert position
2328
+ * @returns {RowDefinition}
2329
+ */
2330
+ Grid.prototype.insertSegmentSeparator = function(rowOption, rowRef) {
2331
+ if(!rowOption) {
2332
+ rowOption = {};
2333
+ }
2334
+ if(typeof rowOption === "object") {
2335
+ rowOption.asSegment = true;
2336
+ return this.insertRow(rowOption, rowRef);
2337
+ }
2338
+ return null;
2339
+ };
2324
2340
  /** @public
2325
2341
  * @param {Array.<RowDefinition~Options|string>} rowOptions Array of row option object
2326
2342
  * @param {Grid~RowReference=} rowRef Reference (i.e. row index, row id, or row definition) of the insert position
@@ -142,7 +142,5 @@ declare const ROW_DEF: string;
142
142
 
143
143
  declare const ROW_TYPES: RowDefinition.RowTypes;
144
144
 
145
- declare function rowData(userInput: string, extractedOptions: any): boolean;
146
-
147
145
  export {RowDefinition, ROW_DEF, ROW_TYPES};
148
146
  export default RowDefinition;
@@ -12,7 +12,7 @@ import { DataTable } from "../../core/es6/data/DataTable.js";
12
12
  * @property {Array.<string>=} fields=null Field that corresponds to the given static values
13
13
  * @property {boolean=} asChain=false The given ric will be treated as a chain
14
14
  * @property {string=} chainRic="" RIC to be used for chain request (overiding ric property)
15
- * @property {boolean=} collapsed=true Chain is collapsed by default
15
+ * @property {boolean=} collapsed=true Chain or segment is collapsed by default
16
16
  * @property {(string|null)=} label=null
17
17
  * @property {boolean=} hidden=true When this row is hidden
18
18
  * @property {boolean=} realTime=true Realtime row, able to request for JET/RTK
@@ -104,6 +104,10 @@ RowDefinition.prototype._isChain = null;
104
104
  /** @type {boolean}
105
105
  * @private
106
106
  */
107
+ RowDefinition.prototype._asSegment = false;
108
+ /** @type {boolean}
109
+ * @private
110
+ */
107
111
  RowDefinition.prototype._realTime = true;
108
112
 
109
113
  /** @type {string}
@@ -258,8 +262,8 @@ RowDefinition.prototype.initialize = function(rowOptions) {
258
262
  }
259
263
 
260
264
  val = extractedOptions["asChain"];
261
- if(val !== null) {
262
- this._isChain = val;
265
+ if(val != null) {
266
+ this._isChain = val ? true : false;
263
267
  }
264
268
 
265
269
  val = rowOptions["realTime"];
@@ -272,6 +276,12 @@ RowDefinition.prototype.initialize = function(rowOptions) {
272
276
  if(val != null || !collapsed){
273
277
  this._expanded = !collapsed;
274
278
  }
279
+
280
+ val = rowOptions["asSegment"];
281
+ if(val != null) {
282
+ this._asSegment = val ? true : false;
283
+ }
284
+
275
285
  val = rowOptions["keepModel"];
276
286
  if(val) {
277
287
  this._userModel = rowOptions;
@@ -315,6 +325,41 @@ RowDefinition.prototype._initializeAsConstituent = function(rowOptions) {
315
325
  this.setStaticRowData(val, rowOptions["fields"]);
316
326
  }
317
327
  };
328
+ /** @private
329
+ * @param {DataView} view
330
+ * @param {string} rowId
331
+ * @returns {string}
332
+ */
333
+ let _getEndOfSegmentRowId = function(view, rowId) {
334
+ let rowIndex = view.getRowIndex(rowId);
335
+ do {
336
+ rowId = view.getRowId(++rowIndex);
337
+ if(rowId && !view.getSegmentParentRowId(rowId)) {
338
+ break;
339
+ }
340
+ } while(rowId);
341
+ return rowId;
342
+ };
343
+
344
+ /** @private
345
+ * @param {DataView} view
346
+ * @param {boolean} newState
347
+ * @param {boolean} prevState
348
+ * @returns {boolean} Current state
349
+ */
350
+ let _stallSorting = function(view, newState, prevState) {
351
+ if(view && view.isSorting()) {
352
+ newState = newState ? true : false;
353
+ if(newState !== prevState) {
354
+ if(newState) {
355
+ view.synchronizeRowOrder();
356
+ }
357
+ view.stallSorting(newState);
358
+ }
359
+ return newState;
360
+ }
361
+ return false;
362
+ };
318
363
  /** @public
319
364
  * @ignore
320
365
  * @param {string} userInput RIC
@@ -342,44 +387,53 @@ RowDefinition.prototype.setContent = function(userInput, extractedOptions) {
342
387
  return false;
343
388
  }
344
389
 
390
+ let asChain = extractedOptions["asChain"];
391
+ let realtimeRow = true;
392
+ if(userInput.charAt(0) === "'") { // Single quote is used as a marker for non realtime row
393
+ realtimeRow = false;
394
+ this._ric = this._chainRic = ""; // No ric for realtime request
395
+ }
396
+
397
+ let dv = this._view;
398
+ let stalledSorting = _stallSorting(dv, realtimeRow && asChain, false); // To preserve current position of the segment/chain
399
+
345
400
  if(!this.unsubscribeForUpdates()){
346
401
  this._clearStaticData();
347
402
  }
348
403
  this.resetUpdates(); // Remove all previous data updates because a new content is just entered
349
404
 
350
405
  this._userInput = userInput;
351
- if(this._userInput.charAt(0) === "'") { // This is a row header
352
- this._ric = this._chainRic = ""; // No ric for realtime request
353
- } else {
354
- let asChain = extractedOptions["asChain"];
406
+ if(realtimeRow) {
355
407
  let expanded = !extractedOptions["collapsed"];
356
408
  let chainRic = extractedOptions["chainRic"];
357
409
  if(asChain === true){
358
- this._ric = expanded === false ? this._userInput : this._userInput.replace("0#", "");
410
+ this._ric = expanded === false ? userInput : userInput.replace("0#", "");
359
411
  this._expanded = expanded; // Only chain can be expanded by 0#
360
412
  } else {
361
- this._ric = this._userInput;
413
+ this._ric = userInput;
362
414
  }
363
415
  this._isChain = asChain != null ? asChain : null; // this could be null or undefined
364
416
  this._chainRic = chainRic || "";
365
417
  }
418
+ // A symbol can be either RIC or permId
419
+ // JET/RTK will generate data id to be rowId (given from this rowDef) + ric
420
+ this._dataId = this._rowId + this.getSymbol();
366
421
 
367
- let segmentId = "";
368
- if(this._view) {
369
- segmentId = this._view.getSegmentParentRowId(this._rowId);
422
+ if(dv) {
423
+ let segmentId = dv.getSegmentParentRowId(this._rowId);
370
424
  if(segmentId) {
371
425
  if(this._isChain){ // If the row was a normal row and has been changed to a chain, remove it from existing segment
372
- let targetRowId = _getEndOfSegmentRowId(this._view, this._rowId);
373
- this._view.removeSegmentChild(segmentId, this._rowId);
374
- this._view.moveRow(this._rowId, targetRowId);
426
+ let targetRowId = _getEndOfSegmentRowId(dv, this._rowId);
427
+ dv.removeSegmentChild(segmentId, this._rowId);
428
+ dv.moveRow(this._rowId, targetRowId);
375
429
 
376
430
  segmentId = "";
377
431
  }
378
- } else if(this._view.getSegment(this._rowId)) {
379
- this._view.setSegmentSeparator(this._rowId, false); // Remove existing segment
432
+ } else if(dv.getSegment(this._rowId)) {
433
+ dv.setSegmentSeparator(this._rowId, false); // Remove existing segment
380
434
  }
381
435
  if(this._isChain) {
382
- this._view.setSegmentSeparator(this._rowId, true);
436
+ dv.setSegmentSeparator(this._rowId, true);
383
437
  }
384
438
  if(this.isChainCollapsed()) {
385
439
  if(this._expanded){
@@ -390,11 +444,10 @@ RowDefinition.prototype.setContent = function(userInput, extractedOptions) {
390
444
  this.collapseChain();
391
445
  }
392
446
  }
393
- }
394
-
395
- this._dataId = this._rowId + this.getSymbol(); // JET/RTK will generate data id to be rowId (given from this rowDef) + ric
396
- if(segmentId) { // If data id is changed and the row is a child of a segment, then segment child data id must be updated
397
- this._view.addSegmentChild(segmentId, this._rowId, this._dataId);
447
+ _stallSorting(dv, false, stalledSorting);
448
+ if(segmentId) { // If data id is changed and the row is a child of a segment, then segment child data id must be updated
449
+ dv.addSegmentChild(segmentId, this._rowId, this._dataId);
450
+ }
398
451
  }
399
452
 
400
453
  if(!this.subscribeForUpdates()) {
@@ -903,22 +956,6 @@ RowDefinition.prototype.resetUpdates = function() {
903
956
  }
904
957
  };
905
958
 
906
- /** @private
907
- * @param {DataView} view
908
- * @param {string} rowId
909
- * @returns {string}
910
- */
911
- let _getEndOfSegmentRowId = function(view, rowId) {
912
- let rowIndex = view.getRowIndex(rowId);
913
- do {
914
- rowId = view.getRowId(++rowIndex);
915
- if(rowId && !view.getSegmentParentRowId(rowId)) {
916
- break;
917
- }
918
- } while(rowId);
919
- return rowId;
920
- };
921
-
922
959
  /** @public
923
960
  * @param {DataView} view
924
961
  * @param {string=} rowId
@@ -942,28 +979,32 @@ RowDefinition.prototype.registerToView = function(view, rowId) {
942
979
  rowData[ROW_DEF] = this;
943
980
 
944
981
  let parentRowId = "";
982
+ let isSegment = this._isChain || this._asSegment;
945
983
  if(rowId) {
946
984
  parentRowId = view.getSegmentParentRowId(rowId);
947
985
  if(parentRowId) {
948
- if(this._isChain) { // A chain cannot be put inside another segment
986
+ if(isSegment) { // A chain or a segment cannot be put inside another segment
949
987
  rowId = _getEndOfSegmentRowId(view, rowId);
950
988
  } // else { // Normal row is inserted into a segment
951
989
  }
952
990
  }
953
991
 
992
+ let stalledSorting = _stallSorting(view, isSegment, false);
993
+
954
994
  let newRowId = view.insertRow(rowId, rowData, this.getRowId());
955
995
  if(newRowId !== this._rowId) {
956
996
  this._rowId = newRowId; // In case there is some duplicate row id
957
997
  this._userId = false;
958
998
  }
959
999
 
960
- if(this._isChain) {
961
- view.setSegmentSeparator(this._rowId);
1000
+ if(isSegment) {
1001
+ view.setSegmentSeparator(newRowId);
1002
+ _stallSorting(view, false, stalledSorting);
962
1003
  if(!this._expanded) {
963
- this.collapseChain();
1004
+ view.collapseSegment(newRowId);
964
1005
  }
965
1006
  } else if(!this._parent && parentRowId) { // Constituent cannot be added to another segment
966
- view.addSegmentChild(parentRowId, this._rowId, this._dataId);
1007
+ view.addSegmentChild(parentRowId, newRowId, this._dataId);
967
1008
  }
968
1009
  };
969
1010
  /** @private
@@ -1093,7 +1093,18 @@ ColumnGroupingPlugin.prototype._onBeforeColumnBoundUpdate = function (e) {
1093
1093
  }
1094
1094
  }
1095
1095
  }
1096
- e.topBoundRowIndex = topBoundRowIndex;
1096
+
1097
+ // Find maximum spanned row count
1098
+ var section = this._hosts[0].getSection("title");
1099
+ var minRowSpanCount = 0;
1100
+ var bottomRowIndex = this._maxDepth;
1101
+ for (i = 0; i < selectedColumns.length; i++) {
1102
+ var rowSpanCount = section.getCellRowSpan(selectedColumns[i], bottomRowIndex);
1103
+ if (rowSpanCount < minRowSpanCount) {
1104
+ minRowSpanCount = rowSpanCount;
1105
+ }
1106
+ }
1107
+ e.topBoundRowIndex = bottomRowIndex + minRowSpanCount;
1097
1108
  };
1098
1109
  /** Deprecated. Column should be directly added through grid APIs.
1099
1110
  * @deprecated
@@ -236,7 +236,9 @@ declare class DataView extends EventDispatcher {
236
236
 
237
237
  public searchNext(rowRef: number|string|null, searchLogic: ((...params: any[]) => any)|null): number;
238
238
 
239
- public stall(opt_bool?: boolean|null): boolean;
239
+ public stall(bool?: boolean|null): boolean;
240
+
241
+ public stallSorting(bool?: boolean|null): boolean;
240
242
 
241
243
  public enableAutoGroupRemoval(opt_bool?: boolean|null): boolean;
242
244
 
@@ -221,6 +221,8 @@ declare class Grid extends EventDispatcher {
221
221
 
222
222
  public insertRow(rowOption?: (RowDefinition.Options|string)|null, rowRef?: Grid.RowReference|null): RowDefinition|null;
223
223
 
224
+ public insertSegmentSeparator(rowOption?: RowDefinition.Options|null, rowRef?: Grid.RowReference|null): RowDefinition|null;
225
+
224
226
  public insertRows(rowOptions: (RowDefinition.Options|string)[]|null, rowRef?: Grid.RowReference|null, opt_fields?: (string)[]|null): void;
225
227
 
226
228
  public addStaticDataRows(dataRows: any[]|null, fields?: (string)[]|null): void;
@@ -142,7 +142,5 @@ declare const ROW_DEF: string;
142
142
 
143
143
  declare const ROW_TYPES: RowDefinition.RowTypes;
144
144
 
145
- declare function rowData(userInput: string, extractedOptions: any): boolean;
146
-
147
145
  export {RowDefinition, ROW_DEF, ROW_TYPES};
148
146
  export default RowDefinition;
package/lib/versions.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "tr-grid-util": "1.3.149",
2
+ "tr-grid-util": "1.3.151",
3
3
  "tr-grid-printer": "1.0.17",
4
4
  "@grid/column-dragging": "1.0.20",
5
5
  "@grid/row-segmenting": "1.0.31",
@@ -10,7 +10,7 @@
10
10
  "tr-grid-checkbox": "1.0.67",
11
11
  "tr-grid-column-fitter": "1.0.40",
12
12
  "tr-grid-column-formatting": "0.9.36",
13
- "tr-grid-column-grouping": "1.0.60",
13
+ "tr-grid-column-grouping": "1.0.61",
14
14
  "tr-grid-column-resizing": "1.0.28",
15
15
  "tr-grid-column-selection": "1.0.33",
16
16
  "tr-grid-column-stack": "1.0.75",
package/package.json CHANGED
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "version": "6.0.98"
69
+ "version": "6.0.99"
70
70
  }