@refinitiv-ui/efx-grid 6.0.92 → 6.0.93
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/filter-dialog/lib/filter-dialog.js +1 -0
- package/lib/grid/index.js +1 -1
- package/lib/tr-grid-checkbox/es6/Checkbox.js +268 -268
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.d.ts +1 -2
- package/lib/tr-grid-column-grouping/es6/ColumnGrouping.js +36 -36
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +279 -279
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +227 -207
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +11 -11
- package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +1 -2
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +120 -121
- package/lib/tr-grid-util/es6/CellPainter.js +2 -13
- package/lib/tr-grid-util/es6/DateTime.js +2 -2
- package/lib/tr-grid-util/es6/Delay.d.ts +3 -3
- package/lib/tr-grid-util/es6/Delay.js +13 -2
- package/lib/tr-grid-util/es6/FilterBuilder.js +1 -2
- package/lib/tr-grid-util/es6/GridPlugin.js +0 -1
- package/lib/tr-grid-util/es6/MultiTableManager.js +4 -13
- package/lib/tr-grid-util/es6/NumberFormatter.js +1 -1
- package/lib/tr-grid-util/es6/TextHighlighter.js +3 -3
- package/lib/types/es6/RowDragging.d.ts +1 -2
- package/lib/versions.json +10 -10
- package/package.json +1 -1
@@ -49,8 +49,8 @@ import {injectCss, prettifyCss} from "../../tr-grid-util/es6/Util.js";
|
|
49
49
|
* @extends {GridPlugin}
|
50
50
|
* @param {CheckboxPlugin~Options=} options
|
51
51
|
*/
|
52
|
-
|
53
|
-
|
52
|
+
let CheckboxPlugin = function (options) {
|
53
|
+
let t = this;
|
54
54
|
t._onPreSectionRender = t._onPreSectionRender.bind(t);
|
55
55
|
t._onPostSectionDataBinding = t._onPostSectionDataBinding.bind(t);
|
56
56
|
t._onCheckboxClicked = t._onCheckboxClicked.bind(t);
|
@@ -136,7 +136,7 @@ CheckboxPlugin._setBooleanProp = function (elem, prop, bool) {
|
|
136
136
|
*/
|
137
137
|
CheckboxPlugin._collectRowMemberId = function (dv, rids, rid) {
|
138
138
|
if(rid) {
|
139
|
-
|
139
|
+
let subGroup = dv.getGroupByRowId(rid);
|
140
140
|
if(subGroup) {
|
141
141
|
if(subGroup.isCollapsed()) {
|
142
142
|
return rids.concat(subGroup.getAllRowIds(true));
|
@@ -237,7 +237,7 @@ CheckboxPlugin._runningId = 0;
|
|
237
237
|
* @return {string}
|
238
238
|
*/
|
239
239
|
CheckboxPlugin._toCheckState = function (val) {
|
240
|
-
if
|
240
|
+
if(val === "partial") {
|
241
241
|
return "partial";
|
242
242
|
} else {
|
243
243
|
return (val) ? "checked" : "unchecked";
|
@@ -255,9 +255,9 @@ CheckboxPlugin._getCheckState = function (chkbox) {
|
|
255
255
|
// WORKAROUND
|
256
256
|
// in elf v3, v4 chkbox.indeterminate can represent 'partial' state
|
257
257
|
// but we check class 'square-shape' instead to support elf v1 and native checkbox input
|
258
|
-
else if
|
258
|
+
else if(chkbox.classList.contains('square-shape')) {
|
259
259
|
return "partial";
|
260
|
-
} else if
|
260
|
+
} else if(chkbox.checked) {
|
261
261
|
return "checked";
|
262
262
|
} else {
|
263
263
|
return "unchecked";
|
@@ -270,10 +270,10 @@ CheckboxPlugin._getCheckState = function (chkbox) {
|
|
270
270
|
* @return {number} Return non-zero value if there is a state change
|
271
271
|
*/
|
272
272
|
CheckboxPlugin._setCheckState = function (chkbox, state) {
|
273
|
-
if
|
273
|
+
if(chkbox._forceNewState) { // WORKAROUND: to force checkbox move to next state
|
274
274
|
state = chkbox._forceNewState;
|
275
275
|
chkbox._forceNewState = null;
|
276
|
-
} else if
|
276
|
+
} else if(CheckboxPlugin._getCheckState(chkbox) === state) { // Process change only when necessary
|
277
277
|
return 0;
|
278
278
|
}
|
279
279
|
|
@@ -324,10 +324,10 @@ CheckboxPlugin._mergeState = function(curState, state) {
|
|
324
324
|
* @return {string} checked|unchecked|partial
|
325
325
|
*/
|
326
326
|
CheckboxPlugin._mergeStates = function(states) {
|
327
|
-
|
328
|
-
for
|
327
|
+
let state = "";
|
328
|
+
for(let i = states.length; --i >= 0; ) {
|
329
329
|
state = CheckboxPlugin._mergeState(state, states[i]);
|
330
|
-
if
|
330
|
+
if(state === "partial") {
|
331
331
|
return state;
|
332
332
|
}
|
333
333
|
}
|
@@ -365,7 +365,7 @@ CheckboxPlugin.prototype.initialize = function (host, options) {
|
|
365
365
|
* @param {Object} host core grid object
|
366
366
|
*/
|
367
367
|
CheckboxPlugin.prototype.unload = function (host) {
|
368
|
-
|
368
|
+
let at = this._hosts.indexOf(host);
|
369
369
|
if(at < 0) { return; }
|
370
370
|
|
371
371
|
host.unlisten("preSectionRender", this._onPreSectionRender);
|
@@ -393,7 +393,7 @@ CheckboxPlugin.prototype.unload = function (host) {
|
|
393
393
|
* @return {*} The transformed value of the option
|
394
394
|
*/
|
395
395
|
CheckboxPlugin.prototype.beforeProcessOption = function (optionName, optionVal) {
|
396
|
-
if
|
396
|
+
if(optionName == "checkboxSelector") {
|
397
397
|
return null; // eslint-disable-line
|
398
398
|
}
|
399
399
|
return; // eslint-disable-line
|
@@ -405,12 +405,12 @@ CheckboxPlugin.prototype.beforeProcessOption = function (optionName, optionVal)
|
|
405
405
|
CheckboxPlugin.prototype.config = function (options) {
|
406
406
|
if(!options) { return; }
|
407
407
|
|
408
|
-
|
408
|
+
let chkboxOpt = /** @type{Object} */(options["checkbox"]);
|
409
409
|
if(!chkboxOpt) {
|
410
410
|
return;
|
411
411
|
}
|
412
412
|
|
413
|
-
|
413
|
+
let val;
|
414
414
|
val = chkboxOpt["rowSelection"]; // previously named "selectCheckedRow"
|
415
415
|
if(val != null) {
|
416
416
|
this._autoRowSelection = val ? true : false;
|
@@ -442,27 +442,27 @@ CheckboxPlugin.prototype.config = function (options) {
|
|
442
442
|
* @return {!Object}
|
443
443
|
*/
|
444
444
|
CheckboxPlugin.prototype.getConfigObject = function (gridOptions) {
|
445
|
-
|
445
|
+
let obj = gridOptions || {};
|
446
446
|
|
447
|
-
|
448
|
-
if
|
447
|
+
let columns = obj.columns;
|
448
|
+
if(!columns) {
|
449
449
|
columns = obj.columns = [];
|
450
450
|
}
|
451
451
|
|
452
|
-
|
453
|
-
for(
|
454
|
-
|
455
|
-
if
|
452
|
+
let len = this.getColumnCount();
|
453
|
+
for(let i = 0; i < len; ++i) {
|
454
|
+
let col = columns[i];
|
455
|
+
if(!col) {
|
456
456
|
col = columns[i] = {};
|
457
457
|
}
|
458
458
|
|
459
|
-
|
459
|
+
let colOptions = this._getColumnData(i);
|
460
460
|
if(colOptions.isCheckboxColumn || i === this._userCheckboxIdx) {
|
461
461
|
col.checkboxColumn = true;
|
462
462
|
}
|
463
463
|
}
|
464
464
|
|
465
|
-
|
465
|
+
let extOptions = obj.checkbox;
|
466
466
|
if(!extOptions) {
|
467
467
|
extOptions = obj.checkbox = {};
|
468
468
|
}
|
@@ -496,32 +496,32 @@ CheckboxPlugin.prototype.beforeInit = function(elem, config, runTime) {
|
|
496
496
|
if(runTime) {
|
497
497
|
return; // Since this is runTime loading, there is no point of processing config object.
|
498
498
|
}
|
499
|
-
|
499
|
+
let t = this;
|
500
500
|
t._displayColumn = -1;
|
501
501
|
|
502
502
|
// Add missing fields to avoid shifting of data due to adding of checkbox column
|
503
|
-
|
504
|
-
if
|
503
|
+
let columns = config["columns"];
|
504
|
+
if(config.dataModel) {
|
505
505
|
config.dataModel = t._prepareData(columns, config.dataModel);
|
506
506
|
}
|
507
|
-
if
|
507
|
+
if(config.staticDataRows) {
|
508
508
|
config.staticDataRows = t._prepareData(columns, config.staticDataRows);
|
509
509
|
}
|
510
510
|
|
511
|
-
|
512
|
-
if
|
511
|
+
let chbxConfig = config["checkbox"];
|
512
|
+
if(chbxConfig) {
|
513
513
|
// Set checkbox column width here to ensure the column width will not blink during the initialization
|
514
|
-
if
|
514
|
+
if(chbxConfig["width"] != null) {
|
515
515
|
t._width = chbxConfig["width"];
|
516
516
|
}
|
517
517
|
|
518
|
-
if
|
518
|
+
if(chbxConfig["field"] != null) {
|
519
519
|
t._checkboxField = chbxConfig["field"];
|
520
520
|
}
|
521
521
|
}
|
522
522
|
|
523
523
|
t._userCheckboxIdx = t._findCheckboxColumnIndexFromConfig(columns);
|
524
|
-
if
|
524
|
+
if(t._userCheckboxIdx >= 0) {
|
525
525
|
t._genCheckboxColumn(columns[t._userCheckboxIdx]);
|
526
526
|
} else {
|
527
527
|
columns.unshift(t._genCheckboxColumn());
|
@@ -534,7 +534,7 @@ CheckboxPlugin.prototype.beforeInit = function(elem, config, runTime) {
|
|
534
534
|
* @return {!Object} checkbox column config
|
535
535
|
*/
|
536
536
|
CheckboxPlugin.prototype._genCheckboxColumn = function (userObj) {
|
537
|
-
|
537
|
+
let defaultObj = {
|
538
538
|
width: this._width,
|
539
539
|
sortable: false,
|
540
540
|
className: "tr-checkbox-column", // For rt-grid
|
@@ -564,8 +564,8 @@ CheckboxPlugin.prototype._genCheckboxColumn = function (userObj) {
|
|
564
564
|
this._width = +userObj.width;
|
565
565
|
}
|
566
566
|
|
567
|
-
for(
|
568
|
-
|
567
|
+
for(let key in defaultObj) {
|
568
|
+
let userVal = userObj[key];
|
569
569
|
if(userVal == null) {
|
570
570
|
userObj[key] = defaultObj[key];
|
571
571
|
}
|
@@ -583,13 +583,13 @@ CheckboxPlugin.prototype._genCheckboxColumn = function (userObj) {
|
|
583
583
|
* @return {Object} data model
|
584
584
|
*/
|
585
585
|
CheckboxPlugin.prototype._prepareData = function (columns, dataModel) {
|
586
|
-
|
587
|
-
if
|
586
|
+
let model = dataModel;
|
587
|
+
if(Array.isArray(dataModel)) {
|
588
588
|
model = { data: dataModel };
|
589
589
|
}
|
590
|
-
if
|
590
|
+
if(model.data && !model.fields) {
|
591
591
|
// if data is 2D then we should add fields into dataModel
|
592
|
-
if
|
592
|
+
if(Array.isArray(model.data[0])) {
|
593
593
|
model.fields = this._getFieldsFromColumns(columns);
|
594
594
|
}
|
595
595
|
}
|
@@ -602,13 +602,13 @@ CheckboxPlugin.prototype._prepareData = function (columns, dataModel) {
|
|
602
602
|
* @return {Array.<string>} list of fields
|
603
603
|
*/
|
604
604
|
CheckboxPlugin.prototype._getFieldsFromColumns = function (columns) {
|
605
|
-
|
606
|
-
|
607
|
-
for
|
608
|
-
|
605
|
+
let colCount = columns.length;
|
606
|
+
let fields = new Array(colCount);
|
607
|
+
for(let c = 0; c < colCount; c++) {
|
608
|
+
let col = columns[c];
|
609
609
|
if(!col) {
|
610
610
|
fields[c] = "";
|
611
|
-
} else if
|
611
|
+
} else if(typeof col === "string") {
|
612
612
|
fields[c] = col;
|
613
613
|
} else {
|
614
614
|
fields[c] = col.field || "";
|
@@ -622,10 +622,10 @@ CheckboxPlugin.prototype._getFieldsFromColumns = function (columns) {
|
|
622
622
|
* @return {number} Return negative number if the column not found
|
623
623
|
*/
|
624
624
|
CheckboxPlugin.prototype._findCheckboxColumnIndexFromConfig = function (columns) {
|
625
|
-
if
|
626
|
-
|
627
|
-
for
|
628
|
-
if
|
625
|
+
if(Array.isArray(columns)) {
|
626
|
+
let colCount = columns.length;
|
627
|
+
for(let i = 0; i < colCount; i++) {
|
628
|
+
if(columns[i].checkboxColumn) {
|
629
629
|
return i;
|
630
630
|
}
|
631
631
|
}
|
@@ -638,10 +638,10 @@ CheckboxPlugin.prototype._findCheckboxColumnIndexFromConfig = function (columns)
|
|
638
638
|
*/
|
639
639
|
CheckboxPlugin.prototype.getCheckboxColumnIndex = function () {
|
640
640
|
if(this._displayColumn < 0) {
|
641
|
-
|
642
|
-
|
643
|
-
for(
|
644
|
-
|
641
|
+
let host = this._hosts[0];
|
642
|
+
let colCount = host ? host.getColumnCount() : 0;
|
643
|
+
for(let c = 0; c < colCount; ++c) {
|
644
|
+
let colData = this._getColumnData(c, host);
|
645
645
|
if(colData && colData.isCheckboxColumn) {
|
646
646
|
this._displayColumn = c;
|
647
647
|
break;
|
@@ -662,9 +662,9 @@ CheckboxPlugin.prototype.getDisplayColumn = CheckboxPlugin.prototype.getCheckbox
|
|
662
662
|
* @return {Element}
|
663
663
|
*/
|
664
664
|
CheckboxPlugin.prototype.getCheckbox = function (sectionRef, rowIndex) {
|
665
|
-
|
666
|
-
|
667
|
-
if
|
665
|
+
let host = this._hosts[0];
|
666
|
+
let sectionSettings = host.getSectionSettings(sectionRef);
|
667
|
+
if(sectionSettings) {
|
668
668
|
return this._getCheckbox(sectionSettings, rowIndex);
|
669
669
|
}
|
670
670
|
|
@@ -679,22 +679,22 @@ CheckboxPlugin.prototype.getCheckbox = function (sectionRef, rowIndex) {
|
|
679
679
|
* @return {Element}
|
680
680
|
*/
|
681
681
|
CheckboxPlugin.prototype._createCheckbox = function (sectionSettings, colIndex, rowIndex) {
|
682
|
-
|
682
|
+
let section = sectionSettings.getSection();
|
683
683
|
|
684
|
-
|
684
|
+
let cell = section.getCell(colIndex, rowIndex);
|
685
685
|
if(!cell) {
|
686
686
|
return null;
|
687
687
|
}
|
688
|
-
|
688
|
+
let content = cell.getContent();
|
689
689
|
if(content && content._chkbox) {
|
690
690
|
return content;
|
691
691
|
}
|
692
692
|
|
693
|
-
if
|
693
|
+
if(this._coralCheckboxVer === -1) {
|
694
694
|
this._coralCheckboxVer = ElfUtil.hasComponent("ef-checkbox");
|
695
695
|
}
|
696
696
|
|
697
|
-
|
697
|
+
let chkbox;
|
698
698
|
if(this._coralCheckboxVer) {
|
699
699
|
chkbox = document.createElement("ef-checkbox");
|
700
700
|
} else {
|
@@ -709,11 +709,11 @@ CheckboxPlugin.prototype._createCheckbox = function (sectionSettings, colIndex,
|
|
709
709
|
// chkbox.addEventListener("checked-changed", this._onCheckboxClicked, false); // Elf v3
|
710
710
|
|
711
711
|
cell.setContent(chkbox);
|
712
|
-
|
712
|
+
let sectionType = sectionSettings.getType();
|
713
713
|
|
714
714
|
if(!this._coralCheckboxVer) { // Workaround for UIFR theme styling
|
715
|
-
|
716
|
-
|
715
|
+
let lbl = document.createElement("label");
|
716
|
+
let id = "tr_grid_checkbox_" + CheckboxPlugin._runningId++;
|
717
717
|
chkbox.setAttribute("id", id);
|
718
718
|
lbl.setAttribute("for", id);
|
719
719
|
chkbox.parentElement.appendChild(lbl); // HACK
|
@@ -772,25 +772,25 @@ CheckboxPlugin.prototype.setCheckStates = function (rowRefs, checked) {
|
|
772
772
|
if(!rowRefs) {
|
773
773
|
return;
|
774
774
|
}
|
775
|
-
|
776
|
-
|
775
|
+
let ary = Array.isArray(rowRefs) ? rowRefs : [rowRefs];
|
776
|
+
let len = ary.length;
|
777
777
|
if(!len) {
|
778
778
|
return;
|
779
779
|
}
|
780
780
|
|
781
781
|
// TODO: Support multi-table mode
|
782
|
-
|
783
|
-
|
784
|
-
|
782
|
+
let host = this._hosts[0];
|
783
|
+
let sectionSettings = host.getSectionSettings("content");
|
784
|
+
let dv = sectionSettings.getDataSource();
|
785
785
|
if(!dv) {
|
786
786
|
return;
|
787
787
|
}
|
788
788
|
|
789
|
-
|
790
|
-
|
791
|
-
for
|
792
|
-
|
793
|
-
|
789
|
+
let rids = [];
|
790
|
+
let i;
|
791
|
+
for(i = 0; i < len; ++i) {
|
792
|
+
let ref = ary[i];
|
793
|
+
let rid = (typeof ref === "string") ? ref : dv.getRowId(ref);
|
794
794
|
rids = CheckboxPlugin._collectRowMemberId(dv, rids, rid);
|
795
795
|
}
|
796
796
|
if(rids.length) {
|
@@ -806,13 +806,13 @@ CheckboxPlugin.prototype.setCheckStates = function (rowRefs, checked) {
|
|
806
806
|
* @see {@link CheckboxPlugin#setAllCheckStates}
|
807
807
|
*/
|
808
808
|
CheckboxPlugin.prototype.checkAll = function (checked) {
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
if
|
809
|
+
let state = CheckboxPlugin._toCheckState(checked != null ? checked : true);
|
810
|
+
let host = this._hosts[0];
|
811
|
+
let titles = host ? host.getAllSectionSettings("title") : null;
|
812
|
+
if(!titles) return;
|
813
813
|
|
814
|
-
|
815
|
-
for(
|
814
|
+
let rootSettings;
|
815
|
+
for(let i = 0; i < titles.length; ++i) { // Find the root settings
|
816
816
|
if(titles[i].getChildren()) {
|
817
817
|
rootSettings = titles[i];
|
818
818
|
break;
|
@@ -830,13 +830,13 @@ CheckboxPlugin.prototype.checkAll = function (checked) {
|
|
830
830
|
*/
|
831
831
|
CheckboxPlugin.prototype.setAllCheckStates = function (checked) {
|
832
832
|
checked = checked ? true : false;
|
833
|
-
|
834
|
-
|
835
|
-
|
833
|
+
let host = this._hosts[0];
|
834
|
+
let dv = host ? host.getDataSource() : null;
|
835
|
+
let dt = dv ? dv.getDataSource() : null;
|
836
836
|
|
837
837
|
if(dt) {
|
838
838
|
// TODO: Check if we need to omit disabled checkboxes
|
839
|
-
|
839
|
+
let rids = dt.getAllRowIds(true); // TODO: Check if we can use shallow copy
|
840
840
|
this._setColumnData(dv, this._checkboxField, checked, rids);
|
841
841
|
}
|
842
842
|
};
|
@@ -847,16 +847,16 @@ CheckboxPlugin.prototype.setAllCheckStates = function (checked) {
|
|
847
847
|
* @see {@link CheckboxPlugin#checkAll}
|
848
848
|
*/
|
849
849
|
CheckboxPlugin.prototype.selectAllPages = function (checked) {
|
850
|
-
|
851
|
-
|
850
|
+
let host = this._hosts[0];
|
851
|
+
let dv = host ? host.getDataSource() : null;
|
852
852
|
if(!dv) {
|
853
853
|
return;
|
854
854
|
}
|
855
855
|
|
856
|
-
|
856
|
+
let allRids = dv.getSortedRowIds(true); // All row ids with filter applied, including disabled and pagination
|
857
857
|
allRids = allRids.filter(CheckboxPlugin._checkableRow.bind(null, dv, this._isCheckboxDisabled));
|
858
858
|
|
859
|
-
|
859
|
+
let state = checked != null ? checked : true;
|
860
860
|
this._setColumnData(dv, this._checkboxField, state, allRids);
|
861
861
|
};
|
862
862
|
|
@@ -865,8 +865,8 @@ CheckboxPlugin.prototype.selectAllPages = function (checked) {
|
|
865
865
|
* @param {boolean} disabled Truthy or Falsy value
|
866
866
|
*/
|
867
867
|
CheckboxPlugin.prototype.disableCheckbox = function(rowRef, disabled) {
|
868
|
-
|
869
|
-
|
868
|
+
let host = this._hosts[0];
|
869
|
+
let dv = host ? host.getDataSource() : null;
|
870
870
|
if(!dv) { return; }
|
871
871
|
|
872
872
|
if(typeof rowRef === "string") {
|
@@ -886,7 +886,7 @@ CheckboxPlugin.prototype.disableCheckbox = function(rowRef, disabled) {
|
|
886
886
|
* @returns {boolean} disabled Truthy or Falsy value
|
887
887
|
*/
|
888
888
|
CheckboxPlugin.prototype._isCheckboxDisabled = function(view, rowId) {
|
889
|
-
|
889
|
+
let rowData = this._getRowFromId(view, rowId);
|
890
890
|
if(rowData) {
|
891
891
|
return rowData[this._disablingField] ? true : false;
|
892
892
|
}
|
@@ -910,32 +910,32 @@ CheckboxPlugin.prototype.enableCheckbox = function(rowRef) {
|
|
910
910
|
* @see {@link CheckboxPlugin#getSelectedRowData}
|
911
911
|
*/
|
912
912
|
CheckboxPlugin.prototype.getAllCheckedIndices = function (sectionRef, state) {
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
if
|
919
|
-
if
|
920
|
-
|
921
|
-
if
|
922
|
-
|
923
|
-
|
913
|
+
let ary = [];
|
914
|
+
let colIndex = this.getCheckboxColumnIndex();
|
915
|
+
let host = colIndex >= 0 ? this._hosts[0] : null;
|
916
|
+
let sectionSettings = host ? host.getSectionSettings(sectionRef) : null;
|
917
|
+
|
918
|
+
if(sectionSettings) {
|
919
|
+
if(state == null) { state = "checked"; }
|
920
|
+
let r, rowCount;
|
921
|
+
if(this._isDataBound(sectionSettings)) {
|
922
|
+
let dv = sectionSettings.getDataSource();
|
923
|
+
let rowIds = dv.getVisibleRowIds(true); // Filter and pagination are applied
|
924
924
|
rowCount = rowIds.length;
|
925
|
-
for
|
926
|
-
|
925
|
+
for(r = 0; r < rowCount; ++r) {
|
926
|
+
let rowData = this._getRowFromId(dv, rowIds[r]);
|
927
927
|
if(rowData) {
|
928
|
-
if
|
928
|
+
if(CheckboxPlugin._toCheckState(rowData[this._checkboxField]) === state) {
|
929
929
|
ary.push(r);
|
930
930
|
}
|
931
931
|
}
|
932
932
|
}
|
933
933
|
} else {
|
934
|
-
|
934
|
+
let section = sectionSettings.getSection();
|
935
935
|
rowCount = section.getRowCount();
|
936
|
-
for
|
937
|
-
|
938
|
-
if
|
936
|
+
for(r = 0; r < rowCount; ++r) {
|
937
|
+
let chkbox = this._getCheckbox(section, r);
|
938
|
+
if(CheckboxPlugin._getCheckState(chkbox) === state) {
|
939
939
|
ary.push(r);
|
940
940
|
}
|
941
941
|
}
|
@@ -950,7 +950,7 @@ CheckboxPlugin.prototype.getAllCheckedIndices = function (sectionRef, state) {
|
|
950
950
|
* @return {!Array} Returns selected rows
|
951
951
|
*/
|
952
952
|
CheckboxPlugin.prototype.getFilteredSelectedData = function (field) {
|
953
|
-
|
953
|
+
let host = this._hosts[0];
|
954
954
|
return this._getSelectedRowData(host ? host.getDataSource() : null, field);
|
955
955
|
};
|
956
956
|
|
@@ -964,9 +964,9 @@ CheckboxPlugin.prototype.getFilteredSelectedData = function (field) {
|
|
964
964
|
* chkBoxExtension.getSelectedRowData("field"); // Get all field values from selected row data in this format [value1, value2, ... values, valueN]
|
965
965
|
*/
|
966
966
|
CheckboxPlugin.prototype.getAllSelectedData = function (field) {
|
967
|
-
|
968
|
-
|
969
|
-
|
967
|
+
let host = this._hosts[0];
|
968
|
+
let dv = host ? host.getDataSource() : null;
|
969
|
+
let dt = dv ? dv.getDataSource() : null; // get All selected Data we use dataTable instead
|
970
970
|
return this._getSelectedRowData(dt, field);
|
971
971
|
};
|
972
972
|
|
@@ -983,17 +983,17 @@ CheckboxPlugin.prototype.getSelectedRowData = CheckboxPlugin.prototype.getAllSel
|
|
983
983
|
* @return {!Array} Returns selected row ids
|
984
984
|
*/
|
985
985
|
CheckboxPlugin.prototype._getSelectedRowIds = function (dataSource) {
|
986
|
-
if
|
986
|
+
if(!dataSource || this.getCheckboxColumnIndex() < 0) {
|
987
987
|
return [];
|
988
988
|
}
|
989
989
|
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
for
|
990
|
+
let rowIds = this._getRowMemberIdsInView(dataSource);
|
991
|
+
let rowCount = rowIds.length;
|
992
|
+
let selRowIds = [];
|
993
|
+
let i, rowId;
|
994
|
+
for(i = 0; i < rowCount; ++i) {
|
995
995
|
rowId = rowIds[i];
|
996
|
-
if
|
996
|
+
if(this._getCheckboxValue(dataSource, rowId)) {
|
997
997
|
selRowIds.push(rowId);
|
998
998
|
}
|
999
999
|
}
|
@@ -1006,18 +1006,18 @@ CheckboxPlugin.prototype._getSelectedRowIds = function (dataSource) {
|
|
1006
1006
|
* @return {!Array} Returns selected rows
|
1007
1007
|
*/
|
1008
1008
|
CheckboxPlugin.prototype._getSelectedRowData = function (dataSource, field) {
|
1009
|
-
|
1010
|
-
|
1011
|
-
if
|
1009
|
+
let selRowIds = this._getSelectedRowIds(dataSource);
|
1010
|
+
let i, rowCount = selRowIds.length;
|
1011
|
+
if(field === "ROW_ID" || rowCount === 0) {
|
1012
1012
|
return selRowIds; // Row Ids
|
1013
1013
|
} else {
|
1014
|
-
|
1015
|
-
for
|
1014
|
+
let selRows = new Array(rowCount);
|
1015
|
+
for(i = 0; i < rowCount; ++i) {
|
1016
1016
|
selRows[i] = this._getRowFromId(dataSource, selRowIds[i]);
|
1017
1017
|
}
|
1018
|
-
if
|
1019
|
-
|
1020
|
-
for
|
1018
|
+
if(field) {
|
1019
|
+
let values = new Array(rowCount);
|
1020
|
+
for(i = 0; i < rowCount; ++i) {
|
1021
1021
|
values[i] = selRows[i][field];
|
1022
1022
|
}
|
1023
1023
|
return values; // Field values
|
@@ -1042,7 +1042,7 @@ CheckboxPlugin.prototype._getRowFromId = function (dv, rowId) {
|
|
1042
1042
|
* @return {boolean} Check State
|
1043
1043
|
*/
|
1044
1044
|
CheckboxPlugin.prototype._getCheckboxValue = function (dv, rowId) {
|
1045
|
-
|
1045
|
+
let row = this._getRowFromId(dv, rowId);
|
1046
1046
|
if(row) {
|
1047
1047
|
return row[this._checkboxField] ? true : false;
|
1048
1048
|
}
|
@@ -1053,25 +1053,25 @@ CheckboxPlugin.prototype._getCheckboxValue = function (dv, rowId) {
|
|
1053
1053
|
* @return {string} state
|
1054
1054
|
*/
|
1055
1055
|
CheckboxPlugin.prototype._getGroupState = function (dv) {
|
1056
|
-
if
|
1056
|
+
if(!dv) {
|
1057
1057
|
return "unchecked";
|
1058
1058
|
}
|
1059
1059
|
|
1060
|
-
|
1061
|
-
if
|
1060
|
+
let rowIds = null;
|
1061
|
+
if(dv.getGroupLevel && dv.getGroupLevel() === 0) { // Root group
|
1062
1062
|
rowIds = this._getRowMemberIdsInView(dv);
|
1063
1063
|
} else { // Subgroup
|
1064
1064
|
rowIds = dv.getAllRowIds(true); // Getting shallow copy and excluding header rows
|
1065
1065
|
rowIds = rowIds.filter(CheckboxPlugin._checkableRow.bind(null, dv, this._isCheckboxDisabled));
|
1066
1066
|
}
|
1067
1067
|
|
1068
|
-
|
1069
|
-
if
|
1068
|
+
let len = rowIds.length;
|
1069
|
+
if(!len) {
|
1070
1070
|
return "unchecked";
|
1071
1071
|
}
|
1072
1072
|
|
1073
|
-
|
1074
|
-
for(
|
1073
|
+
let state = "";
|
1074
|
+
for(let i = 0; i < len; ++i) {
|
1075
1075
|
state = CheckboxPlugin._mergeState(
|
1076
1076
|
state,
|
1077
1077
|
CheckboxPlugin._toCheckState(this._getCheckboxValue(dv, rowIds[i]))
|
@@ -1084,13 +1084,13 @@ CheckboxPlugin.prototype._getGroupState = function (dv) {
|
|
1084
1084
|
* @return {boolean} state
|
1085
1085
|
*/
|
1086
1086
|
CheckboxPlugin.prototype._getGroupDisabledState = function (dv) {
|
1087
|
-
if
|
1087
|
+
if(!dv) {
|
1088
1088
|
return false;
|
1089
1089
|
}
|
1090
1090
|
|
1091
|
-
|
1092
|
-
|
1093
|
-
for(
|
1091
|
+
let rowIds = this._getRowMemberIdsInView(dv);
|
1092
|
+
let len = rowIds.length;
|
1093
|
+
for(let i = 0; i < len; ++i) {
|
1094
1094
|
if(!this._isCheckboxDisabled(dv, rowIds[i])) {
|
1095
1095
|
return false;
|
1096
1096
|
}
|
@@ -1102,11 +1102,11 @@ CheckboxPlugin.prototype._getGroupDisabledState = function (dv) {
|
|
1102
1102
|
* @return {string}
|
1103
1103
|
*/
|
1104
1104
|
CheckboxPlugin.prototype._getSectionState = function (sectionSettings) {
|
1105
|
-
if
|
1105
|
+
if(this._isDataBound(sectionSettings)) {
|
1106
1106
|
return this._getGroupState(sectionSettings.getDataSource());
|
1107
1107
|
} else {
|
1108
|
-
|
1109
|
-
|
1108
|
+
let checkboxes = this._getAllCheckboxes(sectionSettings);
|
1109
|
+
let states = checkboxes.map(CheckboxPlugin._getCheckState);
|
1110
1110
|
return CheckboxPlugin._mergeStates(states);
|
1111
1111
|
}
|
1112
1112
|
};
|
@@ -1116,11 +1116,11 @@ CheckboxPlugin.prototype._getSectionState = function (sectionSettings) {
|
|
1116
1116
|
* @return {Element}
|
1117
1117
|
*/
|
1118
1118
|
CheckboxPlugin.prototype._getCheckbox = function (sectionSettings, rowIndex) {
|
1119
|
-
|
1120
|
-
|
1121
|
-
if
|
1119
|
+
let section = sectionSettings.getSection ? sectionSettings.getSection() : sectionSettings;
|
1120
|
+
let chkbox = /** @type{Element} */(section.getCellContent(this._displayColumn, rowIndex));
|
1121
|
+
if(!chkbox) {
|
1122
1122
|
return null;
|
1123
|
-
} else if
|
1123
|
+
} else if(chkbox.tagName === "EF-CHECKBOX") {
|
1124
1124
|
return chkbox;
|
1125
1125
|
} else if(chkbox.type === "checkbox") {
|
1126
1126
|
return chkbox;
|
@@ -1136,11 +1136,11 @@ CheckboxPlugin.prototype._getCheckbox = function (sectionSettings, rowIndex) {
|
|
1136
1136
|
CheckboxPlugin.prototype._getAllCheckboxes = function (sectionSettings, ary) {
|
1137
1137
|
ary = ary || [];
|
1138
1138
|
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
for(
|
1143
|
-
|
1139
|
+
let section = sectionSettings.getSection();
|
1140
|
+
let fi = section.getFirstIndexInView();
|
1141
|
+
let li = section.getLastIndexInView();
|
1142
|
+
for(let r = fi; r <= li; ++r) { // WARNING: Index could be shifted
|
1143
|
+
let chkbox = this._getCheckbox(sectionSettings, r);
|
1144
1144
|
if(chkbox) { // WARNING: Index is shifted
|
1145
1145
|
ary.push(chkbox);
|
1146
1146
|
}
|
@@ -1156,10 +1156,10 @@ CheckboxPlugin.prototype._setDescendantCheckState = function (sectionSettings, s
|
|
1156
1156
|
if(!this._topCheckboxHandler){
|
1157
1157
|
return;
|
1158
1158
|
}
|
1159
|
-
|
1160
|
-
if
|
1161
|
-
for
|
1162
|
-
|
1159
|
+
let children = sectionSettings.getChildren();
|
1160
|
+
if(children) {
|
1161
|
+
for(let i = 0; i < children.length; ++i) {
|
1162
|
+
let child = children[i];
|
1163
1163
|
this._setSectionState(child, state);
|
1164
1164
|
this._setDescendantCheckState(child, state);
|
1165
1165
|
}
|
@@ -1171,25 +1171,25 @@ CheckboxPlugin.prototype._setDescendantCheckState = function (sectionSettings, s
|
|
1171
1171
|
* @param {Object=} dv DataView
|
1172
1172
|
*/
|
1173
1173
|
CheckboxPlugin.prototype._syncAscendantState = function (sectionSettings, callerState, dv) {
|
1174
|
-
|
1175
|
-
|
1176
|
-
if
|
1174
|
+
let parent = sectionSettings.getParent();
|
1175
|
+
let host = this._hosts[0];
|
1176
|
+
if(!host || !parent || !parent.getSection().isVisible()) { return; }
|
1177
1177
|
|
1178
|
-
|
1179
|
-
|
1180
|
-
if
|
1178
|
+
let i;
|
1179
|
+
let state = callerState || "";
|
1180
|
+
if(state !== "partial") {
|
1181
1181
|
if(!callerState) {
|
1182
1182
|
sectionSettings = null; // Force checking state of the caller
|
1183
1183
|
}
|
1184
1184
|
|
1185
|
-
|
1185
|
+
let children = parent.getChildren();
|
1186
1186
|
if(children) {
|
1187
|
-
for
|
1188
|
-
|
1189
|
-
if
|
1190
|
-
|
1187
|
+
for(i = children.length; --i >= 0; ) {
|
1188
|
+
let child = children[i];
|
1189
|
+
if(child !== sectionSettings) {
|
1190
|
+
let childState = this._getSectionState(child);
|
1191
1191
|
state = CheckboxPlugin._mergeState(childState, state);
|
1192
|
-
if
|
1192
|
+
if(state === "partial") {
|
1193
1193
|
break;
|
1194
1194
|
}
|
1195
1195
|
}
|
@@ -1199,9 +1199,9 @@ CheckboxPlugin.prototype._syncAscendantState = function (sectionSettings, caller
|
|
1199
1199
|
|
1200
1200
|
// sync disable status to header checkbox
|
1201
1201
|
if(dv) {
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1202
|
+
let titleSection = host.getSectionSettings("title");
|
1203
|
+
let disabled = this._getGroupDisabledState(dv);
|
1204
|
+
let checkboxes = this._getAllCheckboxes(titleSection);
|
1205
1205
|
checkboxes.forEach(disabled ? CheckboxPlugin._addDisabledProp : CheckboxPlugin._removeDisabledProp);
|
1206
1206
|
}
|
1207
1207
|
|
@@ -1213,18 +1213,18 @@ CheckboxPlugin.prototype._syncAscendantState = function (sectionSettings, caller
|
|
1213
1213
|
* @param {string} state
|
1214
1214
|
*/
|
1215
1215
|
CheckboxPlugin.prototype._setSectionState = function (sectionSettings, state) {
|
1216
|
-
if
|
1216
|
+
if(!state) {
|
1217
1217
|
return;
|
1218
1218
|
}
|
1219
1219
|
|
1220
|
-
if
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1220
|
+
if(this._isDataBound(sectionSettings)) {
|
1221
|
+
let checked = (state !== "unchecked");
|
1222
|
+
let dv = /** @type{DataView} */(sectionSettings.getDataSource());
|
1223
|
+
let memberRids = this._getRowMemberIdsInView(dv);
|
1224
1224
|
this._setColumnData(dv, this._checkboxField, checked, memberRids);
|
1225
1225
|
} else {
|
1226
|
-
|
1227
|
-
for
|
1226
|
+
let checkboxes = this._getAllCheckboxes(sectionSettings);
|
1227
|
+
for(let i = checkboxes.length; --i >= 0; ) {
|
1228
1228
|
CheckboxPlugin._setCheckState(checkboxes[i], state);
|
1229
1229
|
}
|
1230
1230
|
}
|
@@ -1236,9 +1236,9 @@ CheckboxPlugin.prototype._setSectionState = function (sectionSettings, state) {
|
|
1236
1236
|
* @return {boolean}
|
1237
1237
|
*/
|
1238
1238
|
CheckboxPlugin.prototype._isDataBound = function (sectionSettings) {
|
1239
|
-
if
|
1240
|
-
if
|
1241
|
-
if
|
1239
|
+
if(this._checkboxField) {
|
1240
|
+
if(sectionSettings.getDataSource()) {
|
1241
|
+
if(sectionSettings.getType() === "content") {
|
1242
1242
|
return true;
|
1243
1243
|
}
|
1244
1244
|
}
|
@@ -1260,15 +1260,15 @@ CheckboxPlugin.prototype._onColumnAdded = function(e) {
|
|
1260
1260
|
return;
|
1261
1261
|
}
|
1262
1262
|
|
1263
|
-
|
1263
|
+
let host = this._hosts[0];
|
1264
1264
|
if(host) {
|
1265
|
-
|
1265
|
+
let column = e.context;
|
1266
1266
|
if(column) {
|
1267
1267
|
if(column.checkboxColumn) { // Ignore this if we already have one
|
1268
|
-
|
1268
|
+
let existingCheckbox = this.getCheckboxColumnIndex();
|
1269
1269
|
if(existingCheckbox < 0) { // Only if there is no existing checkbox column
|
1270
1270
|
this._displayColumn = e.colIndex;
|
1271
|
-
|
1271
|
+
let colData = this._newColumnData(e.colIndex, host);
|
1272
1272
|
colData.isCheckboxColumn = true; // Mark the column for later referencing
|
1273
1273
|
// TODO: Extend or replace the column options with our checkbox column
|
1274
1274
|
}
|
@@ -1290,10 +1290,10 @@ CheckboxPlugin.prototype._requestUIPopulation = function (e) {
|
|
1290
1290
|
CheckboxPlugin.prototype._populateUIs = function () {
|
1291
1291
|
this._updateTimer = 0;
|
1292
1292
|
|
1293
|
-
if
|
1293
|
+
if(this._initializing) { return; }
|
1294
1294
|
|
1295
|
-
|
1296
|
-
if
|
1295
|
+
let host = this._hosts[0];
|
1296
|
+
if(!host) { return; }
|
1297
1297
|
|
1298
1298
|
this._initializing = true;
|
1299
1299
|
|
@@ -1307,15 +1307,15 @@ CheckboxPlugin.prototype._populateUIs = function () {
|
|
1307
1307
|
|
1308
1308
|
if(this._displayColumn < 0) {
|
1309
1309
|
// In case checkbox extension doesn't load during grid beforeInit (eg. load checkbox extension at runtime)
|
1310
|
-
|
1310
|
+
let chbxCol = this._genCheckboxColumn();
|
1311
1311
|
if(this._compositeGrid) { // TODO: This could be unnecessary workaround
|
1312
|
-
|
1313
|
-
|
1312
|
+
let model = this._compositeGrid.getModel();
|
1313
|
+
let columns = model ? model.columns : null;
|
1314
1314
|
if(columns) {
|
1315
1315
|
columns.unshift(chbxCol); // TODO: Check if this is appropriate
|
1316
1316
|
}
|
1317
1317
|
host.insertColumn(0, chbxCol); // preSectionRender and columnAdded is fired
|
1318
|
-
} else if
|
1318
|
+
} else if(this._realTimeGrid) { // TODO: Handle multiple grids
|
1319
1319
|
this._realTimeGrid.insertColumn(chbxCol, 0);
|
1320
1320
|
}
|
1321
1321
|
|
@@ -1323,11 +1323,11 @@ CheckboxPlugin.prototype._populateUIs = function () {
|
|
1323
1323
|
}
|
1324
1324
|
}
|
1325
1325
|
|
1326
|
-
|
1326
|
+
let colData = this._newColumnData(this._displayColumn, host);
|
1327
1327
|
colData.isCheckboxColumn = true; // Mark the column for later referencing
|
1328
1328
|
|
1329
1329
|
// HACK: for filter-input extension
|
1330
|
-
|
1330
|
+
let filterInput = colData.filterInputOption;
|
1331
1331
|
if(!filterInput) {
|
1332
1332
|
filterInput = colData.filterInputOption = {};
|
1333
1333
|
}
|
@@ -1343,7 +1343,7 @@ CheckboxPlugin.prototype._populateUIs = function () {
|
|
1343
1343
|
* @param {boolean=} toggling
|
1344
1344
|
*/
|
1345
1345
|
CheckboxPlugin.prototype._onCheckboxChanged = function (e, toggling) {
|
1346
|
-
|
1346
|
+
let chkbox = e ? /** @type{Element} */(e.currentTarget) : null;
|
1347
1347
|
if(!chkbox) {
|
1348
1348
|
return;
|
1349
1349
|
}
|
@@ -1353,33 +1353,33 @@ CheckboxPlugin.prototype._onCheckboxChanged = function (e, toggling) {
|
|
1353
1353
|
// so we must remove 'square-shape' class that use in only 'partial' state
|
1354
1354
|
chkbox.classList.remove('square-shape');
|
1355
1355
|
|
1356
|
-
|
1356
|
+
let newState = CheckboxPlugin._getCheckState(chkbox);
|
1357
1357
|
if(toggling) {
|
1358
1358
|
newState = CheckboxPlugin._toggleState(newState);
|
1359
1359
|
}
|
1360
1360
|
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1361
|
+
let host = this._hosts[0];
|
1362
|
+
let pos = host.getRelativePosition(e); // Getting row index
|
1363
|
+
let sectionSettings = pos["sectionSettings"];
|
1364
1364
|
if(!sectionSettings) {
|
1365
1365
|
return; // Unsuccessful hit testing
|
1366
1366
|
}
|
1367
1367
|
|
1368
|
-
if
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1368
|
+
if(this._isDataBound(sectionSettings)) {
|
1369
|
+
let dv = sectionSettings.getDataSource();
|
1370
|
+
let rowIndex = pos["rowIndex"];
|
1371
|
+
let rid = dv.getRowId(rowIndex);
|
1372
1372
|
|
1373
1373
|
if(this._isCheckboxDisabled(dv, rid)) { // TODO: Check if this is necessary
|
1374
1374
|
return;
|
1375
1375
|
}
|
1376
1376
|
|
1377
1377
|
|
1378
|
-
|
1378
|
+
let changeRange = null;
|
1379
1379
|
if(e.shiftKey && this._anchorRowId) { // Select/deselect range of checkboxes
|
1380
|
-
|
1380
|
+
let prevIndex = dv.getRowIndex(this._anchorRowId);
|
1381
1381
|
if(prevIndex >= 0) {
|
1382
|
-
|
1382
|
+
let i;
|
1383
1383
|
if(prevIndex < rowIndex) {
|
1384
1384
|
changeRange = [];
|
1385
1385
|
for(i = prevIndex; i <= rowIndex; ++i) {
|
@@ -1394,17 +1394,17 @@ CheckboxPlugin.prototype._onCheckboxChanged = function (e, toggling) {
|
|
1394
1394
|
}
|
1395
1395
|
}
|
1396
1396
|
|
1397
|
-
|
1397
|
+
let checked = newState !== "unchecked";
|
1398
1398
|
if(changeRange) {
|
1399
1399
|
this.setCheckStates(changeRange, !e.altKey);
|
1400
1400
|
} else {
|
1401
|
-
|
1402
|
-
if
|
1403
|
-
|
1401
|
+
let subGroup = dv.getGroupByRowId(rid);
|
1402
|
+
if(subGroup) {
|
1403
|
+
let rowMemberIds = this._getRowMemberIdsOfSubgroup(dv, subGroup);
|
1404
1404
|
this._setColumnData(dv, this._checkboxField, checked, rowMemberIds);
|
1405
1405
|
|
1406
1406
|
// WORKAROUND: to force group move to next state from partial state
|
1407
|
-
if
|
1407
|
+
if(newState === 'checked' && chkbox._prevState === 'partial') {
|
1408
1408
|
chkbox._forceNewState = newState;
|
1409
1409
|
}
|
1410
1410
|
} else {
|
@@ -1416,7 +1416,7 @@ CheckboxPlugin.prototype._onCheckboxChanged = function (e, toggling) {
|
|
1416
1416
|
this._setDescendantCheckState(sectionSettings, newState); // This only works with root section where root UI is linked with its children section.
|
1417
1417
|
this._syncAscendantState(sectionSettings); // The clicked row may be a member of row group and thus the state has to be calculated
|
1418
1418
|
|
1419
|
-
if
|
1419
|
+
if(this.hasListener("clicked")) {
|
1420
1420
|
pos["checkbox"] = chkbox;
|
1421
1421
|
pos["checkState"] = newState;
|
1422
1422
|
pos["checked"] = checked;
|
@@ -1434,15 +1434,15 @@ CheckboxPlugin.prototype._onCheckboxChanged = function (e, toggling) {
|
|
1434
1434
|
* @param {Object=} context
|
1435
1435
|
*/
|
1436
1436
|
CheckboxPlugin.prototype.toggleCheckByMouse = function(sectionRef, rowIndex, context) {
|
1437
|
-
|
1437
|
+
let eventObj = context || {};
|
1438
1438
|
eventObj.sectionType = sectionRef;
|
1439
1439
|
eventObj = this._mockMouseEvent(this._displayColumn, rowIndex, eventObj);
|
1440
1440
|
|
1441
|
-
|
1441
|
+
let checkbox = this.getCheckbox(sectionRef, rowIndex);
|
1442
1442
|
if(!checkbox) {
|
1443
1443
|
return;
|
1444
1444
|
}
|
1445
|
-
|
1445
|
+
let curState = CheckboxPlugin._getCheckState(checkbox);
|
1446
1446
|
CheckboxPlugin._setBooleanProp(checkbox, "checked", curState !== "checked");
|
1447
1447
|
eventObj.currentTarget = eventObj.target = checkbox;
|
1448
1448
|
|
@@ -1457,8 +1457,8 @@ CheckboxPlugin.prototype.toggleCheckByMouse = function(sectionRef, rowIndex, con
|
|
1457
1457
|
* @param {Object} context
|
1458
1458
|
*/
|
1459
1459
|
CheckboxPlugin.prototype.supplyKey = function(keyName, rowIndex, context) {
|
1460
|
-
|
1461
|
-
|
1460
|
+
let checkbox = this.getCheckbox("content", rowIndex);
|
1461
|
+
let eventObj = this._mockKeyboardEvent(keyName, context);
|
1462
1462
|
eventObj.currentTarget = eventObj.target = checkbox;
|
1463
1463
|
this._onCheckboxKeydown(eventObj);
|
1464
1464
|
};
|
@@ -1467,7 +1467,7 @@ CheckboxPlugin.prototype.supplyKey = function(keyName, rowIndex, context) {
|
|
1467
1467
|
* @param {Event} e
|
1468
1468
|
*/
|
1469
1469
|
CheckboxPlugin.prototype._onCheckboxClicked = function (e) {
|
1470
|
-
|
1470
|
+
let v1 = this._coralCheckboxVer === 1;
|
1471
1471
|
if(v1) {
|
1472
1472
|
// Workaround for duplicate event from ef-checkbox
|
1473
1473
|
if(e.target.tagName === "LABEL") {
|
@@ -1482,22 +1482,22 @@ CheckboxPlugin.prototype._onCheckboxClicked = function (e) {
|
|
1482
1482
|
* @param {Event} e
|
1483
1483
|
*/
|
1484
1484
|
CheckboxPlugin.prototype._onCheckboxKeydown = function (e) {
|
1485
|
-
|
1485
|
+
let keyCode = e.keyCode;
|
1486
1486
|
if(keyCode === 32) {
|
1487
1487
|
this._onCheckboxMousedown(e); // Set anchor if no shift key is pressed
|
1488
1488
|
this._onCheckboxChanged(e, true);
|
1489
1489
|
e.preventDefault();
|
1490
1490
|
} if(keyCode === 38 || keyCode === 40) { // Arrow key up and down
|
1491
|
-
|
1492
|
-
|
1491
|
+
let host = this._hosts[0];
|
1492
|
+
let pos = host.getRelativePosition(e.currentTarget);
|
1493
1493
|
if(pos.sectionType === "content") {
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1494
|
+
let dv = host.getDataSource();
|
1495
|
+
let offset = (keyCode === 38) ? -1 : 1;
|
1496
|
+
let nextIndex = pos.rowIndex + offset;
|
1497
|
+
let rowId = dv.getRowId(nextIndex);
|
1498
1498
|
if(rowId) {
|
1499
1499
|
host.scrollToRow(null, nextIndex);
|
1500
|
-
|
1500
|
+
let chkbox = this._getCheckbox(pos.section, nextIndex);
|
1501
1501
|
if(chkbox) {
|
1502
1502
|
chkbox.focus();
|
1503
1503
|
}
|
@@ -1514,10 +1514,10 @@ CheckboxPlugin.prototype._onCheckboxKeydown = function (e) {
|
|
1514
1514
|
CheckboxPlugin.prototype._onCheckboxMousedown = function (e) {
|
1515
1515
|
if(!e.shiftKey) {
|
1516
1516
|
this._anchorRowId = "";
|
1517
|
-
|
1518
|
-
|
1517
|
+
let host = this._hosts[0];
|
1518
|
+
let pos = host.getRelativePosition(e.currentTarget);
|
1519
1519
|
if(pos.sectionType === "content") {
|
1520
|
-
|
1520
|
+
let dv = host.getDataSource();
|
1521
1521
|
this._anchorRowId = dv.getRowId(pos.rowIndex);
|
1522
1522
|
}
|
1523
1523
|
}
|
@@ -1530,18 +1530,18 @@ CheckboxPlugin.prototype._onCheckboxMousedown = function (e) {
|
|
1530
1530
|
* @return {!Array.<string>} list of row member ids of group in view
|
1531
1531
|
*/
|
1532
1532
|
CheckboxPlugin.prototype._getRowMemberIdsOfSubgroup = function (view, targetGroup) {
|
1533
|
-
|
1533
|
+
let memberIds = this._getRowMemberIdsInView(view); // Slow
|
1534
1534
|
|
1535
1535
|
// WARNING: Subgroup header row may not be in the view
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1536
|
+
let subgroupMembers = targetGroup.isCollapsed() ? targetGroup.getAllRowIds(true) : targetGroup.getVisibleRowIds(true);
|
1537
|
+
let beginPos = 0;
|
1538
|
+
let result = [];
|
1539
|
+
let len = subgroupMembers.length;
|
1540
1540
|
// TODO: Use object map instead of indexOf for checking
|
1541
|
-
for
|
1542
|
-
|
1543
|
-
|
1544
|
-
if
|
1541
|
+
for(let i = 0; i < len; i++) {
|
1542
|
+
let subgroupMember = subgroupMembers[i];
|
1543
|
+
let pos = memberIds.indexOf(subgroupMember, beginPos);
|
1544
|
+
if(pos >= 0) {
|
1545
1545
|
beginPos = pos + 1;
|
1546
1546
|
result.push(subgroupMember);
|
1547
1547
|
}
|
@@ -1557,13 +1557,13 @@ CheckboxPlugin.prototype._getRowMemberIdsOfSubgroup = function (view, targetGrou
|
|
1557
1557
|
* @return {!Array.<string>} list of row member ids in view
|
1558
1558
|
*/
|
1559
1559
|
CheckboxPlugin.prototype._getRowMemberIdsInView = function (view) {
|
1560
|
-
if
|
1560
|
+
if(view.getDataSource()) { // check is dataView
|
1561
1561
|
// TODO: support multi-level grouping
|
1562
1562
|
// if view is DataView -> view.getVisibleRowIds(true) will get member and group rowIds in view
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
for
|
1563
|
+
let rids = view.isCollapsed() ? view.getAllRowIds(true) : view.getVisibleRowIds(true); // get All member and group rowIds
|
1564
|
+
let len = rids.length;
|
1565
|
+
let allRids = [];
|
1566
|
+
for(let i = 0; i < len; i++) { // loop check whether rowIds is group or just row member
|
1567
1567
|
allRids = CheckboxPlugin._collectRowMemberId(view, allRids, rids[i]);
|
1568
1568
|
}
|
1569
1569
|
|
@@ -1579,12 +1579,12 @@ CheckboxPlugin.prototype._getRowMemberIdsInView = function (view) {
|
|
1579
1579
|
* @param {Object} e
|
1580
1580
|
*/
|
1581
1581
|
CheckboxPlugin.prototype._onPreSectionRender = function (e) {
|
1582
|
-
|
1582
|
+
let displayCol = this.getCheckboxColumnIndex();
|
1583
1583
|
if(displayCol < e["fromColIndex"] || displayCol >= e["toColIndex"]) {
|
1584
1584
|
return;
|
1585
1585
|
}
|
1586
1586
|
|
1587
|
-
|
1587
|
+
let sectionSettings = /** @type{SectionSettings} */(e["sectionSettings"]);
|
1588
1588
|
if(sectionSettings.getType() !== "title") {
|
1589
1589
|
return;
|
1590
1590
|
}
|
@@ -1597,7 +1597,7 @@ CheckboxPlugin.prototype._onPreSectionRender = function (e) {
|
|
1597
1597
|
* @param {number=} toRow
|
1598
1598
|
*/
|
1599
1599
|
CheckboxPlugin.prototype._createCheckboxes = function (sectionSettings, fromRow, toRow) {
|
1600
|
-
|
1600
|
+
let displayCol = this.getCheckboxColumnIndex();
|
1601
1601
|
if(displayCol < 0) {
|
1602
1602
|
return;
|
1603
1603
|
}
|
@@ -1608,11 +1608,11 @@ CheckboxPlugin.prototype._createCheckboxes = function (sectionSettings, fromRow,
|
|
1608
1608
|
return;
|
1609
1609
|
}
|
1610
1610
|
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1611
|
+
let section = sectionSettings.getSection();
|
1612
|
+
let fi = (fromRow != null) ? fromRow : section.getFirstIndexInView();
|
1613
|
+
let li = (toRow != null) ? toRow : section.getLastIndexInView() + 1;
|
1614
1614
|
|
1615
|
-
for
|
1615
|
+
for(let r = fi; r < li; ++r) {
|
1616
1616
|
this._createCheckbox(sectionSettings, displayCol, r);
|
1617
1617
|
}
|
1618
1618
|
};
|
@@ -1620,45 +1620,45 @@ CheckboxPlugin.prototype._createCheckboxes = function (sectionSettings, fromRow,
|
|
1620
1620
|
* @param {Object} e
|
1621
1621
|
*/
|
1622
1622
|
CheckboxPlugin.prototype._onPostSectionDataBinding = function (e) {
|
1623
|
-
if
|
1623
|
+
if(!this._checkboxField) {
|
1624
1624
|
return;
|
1625
1625
|
}
|
1626
|
-
|
1626
|
+
let displayCol = this.getCheckboxColumnIndex();
|
1627
1627
|
if(displayCol < 0) { return; }
|
1628
1628
|
|
1629
|
-
|
1630
|
-
|
1629
|
+
let section = /** @type{ILayoutGrid} */(e["section"]);
|
1630
|
+
let dv = /** @type{DataView} */(e["dataSource"]);
|
1631
1631
|
|
1632
|
-
|
1632
|
+
let fromR = /** @type{number} */(e["fromRowIndex"]);
|
1633
1633
|
if(dv.hasGroup()) { // This is because we need to update group header when any group member is updated
|
1634
1634
|
fromR = section.getFirstIndexInView();
|
1635
1635
|
}
|
1636
1636
|
|
1637
|
-
|
1638
|
-
|
1637
|
+
let toR = /** @type{number} */(e["toRowIndex"]);
|
1638
|
+
let bindingCount = toR - fromR;
|
1639
1639
|
if(bindingCount <= 0) {
|
1640
1640
|
return;
|
1641
1641
|
}
|
1642
1642
|
|
1643
|
-
|
1643
|
+
let checkboxes = new Array(bindingCount);
|
1644
1644
|
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1645
|
+
let i, rowIndex, chkbox, rowData;
|
1646
|
+
let arg = null;
|
1647
|
+
let hasBinding = this.hasListener("checkboxBinding");
|
1648
1648
|
if(hasBinding) {
|
1649
1649
|
arg = {
|
1650
1650
|
"colIndex": displayCol
|
1651
1651
|
};
|
1652
1652
|
}
|
1653
1653
|
|
1654
|
-
|
1654
|
+
let sectionSettings = /** @type{SectionSettings} */(e["sectionSettings"]);
|
1655
1655
|
for(i = 0; i < bindingCount; ++i) {
|
1656
1656
|
rowIndex = fromR + i;
|
1657
1657
|
chkbox = checkboxes[i] = this._getCheckbox(sectionSettings, rowIndex);
|
1658
|
-
if
|
1658
|
+
if(!chkbox) {
|
1659
1659
|
chkbox = checkboxes[i] = this._createCheckbox(sectionSettings, this._displayColumn, rowIndex);
|
1660
1660
|
}
|
1661
|
-
|
1661
|
+
let rowId = dv.getRowId(rowIndex); // Slow
|
1662
1662
|
rowData = this._getRowFromId(dv, rowId);
|
1663
1663
|
if(hasBinding && chkbox) {
|
1664
1664
|
arg["checkbox"] = chkbox;
|
@@ -1667,17 +1667,17 @@ CheckboxPlugin.prototype._onPostSectionDataBinding = function (e) {
|
|
1667
1667
|
this._dispatch("checkboxBinding", arg);
|
1668
1668
|
}
|
1669
1669
|
|
1670
|
-
|
1671
|
-
|
1670
|
+
let disabled = false;
|
1671
|
+
let state = "";
|
1672
1672
|
if(rowData) {
|
1673
1673
|
state = CheckboxPlugin._toCheckState(rowData[this._checkboxField]);
|
1674
1674
|
disabled = rowData[this._disablingField] === true;
|
1675
1675
|
} else { // Group header row has no rowData
|
1676
|
-
|
1676
|
+
let groupSetting = dv.getGroupByRowId(rowId);
|
1677
1677
|
disabled = this._getGroupDisabledState(groupSetting);
|
1678
1678
|
state = disabled ? "unchecked" : this._getGroupState(groupSetting);
|
1679
1679
|
}
|
1680
|
-
if
|
1680
|
+
if(this._autoRowSelection) {
|
1681
1681
|
section.setSelectedRow(rowIndex, (rowData || false) && state === "checked");
|
1682
1682
|
}
|
1683
1683
|
|