@refinitiv-ui/efx-grid 6.0.96 → 6.0.98
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/core/dist/core.js +32 -6
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataView.d.ts +3 -1
- package/lib/core/es6/data/DataView.js +31 -5
- package/lib/core/es6/grid/Core.js +1 -1
- package/lib/grid/index.js +1 -1
- package/lib/tr-grid-in-cell-editing/es6/InCellEditing.js +1447 -1301
- package/lib/tr-grid-row-filtering/es6/RowFiltering.js +20 -11
- package/lib/tr-grid-util/es6/MultiTableManager.js +7 -1
- package/lib/tr-grid-util/es6/Popup.d.ts +2 -0
- package/lib/tr-grid-util/es6/Popup.js +7 -0
- package/lib/tr-grid-util/es6/SubTable.d.ts +2 -0
- package/lib/tr-grid-util/es6/SubTable.js +6 -0
- package/lib/tr-grid-util/es6/Table.d.ts +5 -1
- package/lib/tr-grid-util/es6/Table.js +17 -1
- package/lib/tr-grid-util/es6/jet/DataGenerator.js +1 -1
- package/lib/versions.json +3 -3
- package/package.json +1 -1
@@ -154,29 +154,28 @@ import { CoralItems } from "../../tr-grid-util/es6/CoralItems.js";
|
|
154
154
|
* @param {InCellEditingPlugin~Options=} options
|
155
155
|
* @extends {GridPlugin}
|
156
156
|
*/
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
}
|
157
|
+
let InCellEditingPlugin = function (options) {
|
158
|
+
let t = this;
|
159
|
+
t._onDoubleClick = t._onDoubleClick.bind(t);
|
160
|
+
t._onPopupHide = t._onPopupHide.bind(t);
|
161
|
+
t._onScroll = t._onScroll.bind(t);
|
162
|
+
t._onTextKeyDown = t._onTextKeyDown.bind(t);
|
163
|
+
t._onTextKeyUp = t._onTextKeyUp.bind(t);
|
164
|
+
t._onTouchStart = t._onTouchStart.bind(t);
|
165
|
+
t._onTouchEnd = t._onTouchEnd.bind(t);
|
166
|
+
t._onTouchTimer = t._onTouchTimer.bind(t);
|
167
|
+
t._createContentEditor = t._createContentEditor.bind(t);
|
168
|
+
t._createTitleEditor = t._createTitleEditor.bind(t);
|
169
|
+
t._onColumnAdded = t._onColumnAdded.bind(t);
|
170
|
+
t._onValueChanged = t._onValueChanged.bind(t);
|
171
|
+
t._onMultiSelectionValueChanged = t._onMultiSelectionValueChanged.bind(t);
|
172
|
+
t._onMultiSelectionEditorChanged = t._onMultiSelectionEditorChanged.bind(t);
|
173
|
+
t._onAutoSuggestItemSelected = t._onAutoSuggestItemSelected.bind(t);
|
174
|
+
t._hosts = [];
|
175
|
+
|
176
|
+
if(options) {
|
177
|
+
this.config({"inCellEditing": options});
|
178
|
+
}
|
180
179
|
};
|
181
180
|
Ext.inherits(InCellEditingPlugin, GridPlugin);
|
182
181
|
|
@@ -185,15 +184,15 @@ Ext.inherits(InCellEditingPlugin, GridPlugin);
|
|
185
184
|
* @static
|
186
185
|
*/
|
187
186
|
InCellEditingPlugin._uiElementTypesMap = {
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
187
|
+
"input": "input",
|
188
|
+
"text": "input",
|
189
|
+
"number": "ef-number-field",
|
190
|
+
"select": "ef-select",
|
191
|
+
"dropdown": "ef-select",
|
192
|
+
"date": "ef-datetime-picker",
|
193
|
+
"checkbox": "ef-checkbox",
|
194
|
+
"boolean": "ef-checkbox",
|
195
|
+
"combobox": "ef-combo-box"
|
197
196
|
};
|
198
197
|
|
199
198
|
/** @type {boolean}
|
@@ -351,6 +350,7 @@ InCellEditingPlugin.prototype._editorTimerId = 0;
|
|
351
350
|
*/
|
352
351
|
InCellEditingPlugin._scrolling = false;
|
353
352
|
|
353
|
+
|
354
354
|
/** @type {number}
|
355
355
|
* @private
|
356
356
|
*/
|
@@ -363,13 +363,20 @@ InCellEditingPlugin._primaryColor = "";
|
|
363
363
|
/** @type {string}
|
364
364
|
* @private
|
365
365
|
*/
|
366
|
-
InCellEditingPlugin._styles = prettifyCss([
|
366
|
+
InCellEditingPlugin._styles = prettifyCss([
|
367
|
+
":host .cell.editing input[type=text]", [
|
368
|
+
"border-style: solid;"
|
369
|
+
],
|
370
|
+
":host .cell.editing", [
|
371
|
+
"z-index: 2;"
|
372
|
+
]
|
373
|
+
]);
|
367
374
|
|
368
375
|
/** @private
|
369
376
|
*/
|
370
377
|
InCellEditingPlugin._onThemeLoaded = function () {
|
371
|
-
|
372
|
-
|
378
|
+
let colors = ElfUtil.getColors();
|
379
|
+
InCellEditingPlugin._primaryColor = colors.primary;
|
373
380
|
};
|
374
381
|
|
375
382
|
/** @private
|
@@ -378,64 +385,71 @@ InCellEditingPlugin._onThemeLoaded = function () {
|
|
378
385
|
* @return {Element} input element
|
379
386
|
*/
|
380
387
|
InCellEditingPlugin.prototype._createInputElement = function (tag, attributes) {
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
388
|
+
let t = this;
|
389
|
+
let elem = document.createElement(tag);
|
390
|
+
for(let attribute in attributes) {
|
391
|
+
elem.setAttribute(attribute, attributes[attribute]);
|
392
|
+
}
|
393
|
+
|
394
|
+
let typeMap = InCellEditingPlugin._uiElementTypesMap;
|
395
|
+
// Resolve elf theme style
|
396
|
+
elem.style.width = "100%";
|
397
|
+
elem.style.height = "100%";
|
398
|
+
elem.style.margin = "0";
|
399
|
+
elem.style.borderColor = InCellEditingPlugin._primaryColor || "#ee7600";
|
400
|
+
elem.style.maxHeight = "unset";
|
401
|
+
|
402
|
+
if(tag === typeMap.checkbox) {
|
403
|
+
elem.style.borderStyle = "solid";
|
404
|
+
elem.style.borderWidth = "1px";
|
405
|
+
elem.style.boxSizing = "border-box";
|
406
|
+
elem.style.display = "flex";
|
407
|
+
elem.style.justifyContent = "center";
|
408
|
+
elem.addEventListener("keydown", function (e) {
|
409
|
+
if(e.keyCode === 13) {
|
410
|
+
e.preventDefault();
|
411
|
+
}
|
412
|
+
});
|
413
|
+
} else if(
|
414
|
+
tag === typeMap.select ||
|
415
|
+
tag === typeMap.combobox ||
|
416
|
+
tag === typeMap.date) {
|
417
|
+
|
418
|
+
if(tag === typeMap.combobox && attributes && attributes["multiple"]){
|
419
|
+
elem.addEventListener("value-changed", t._onMultiSelectionValueChanged);
|
420
|
+
elem.addEventListener("opened-changed", t._onMultiSelectionEditorChanged);
|
421
|
+
} else {
|
422
|
+
elem.addEventListener("value-changed", t._onValueChanged);
|
423
|
+
}
|
424
|
+
} else if(tag === "ef-input") {
|
425
|
+
elem.setAttribute("type", "number");
|
426
|
+
} else if(tag === typeMap.input) {
|
427
|
+
elem.setAttribute("type", "text");
|
428
|
+
}
|
429
|
+
if(this._autoSuggest) {
|
430
|
+
this._autoSuggest.addEventListener("item-select", t._onAutoSuggestItemSelected);
|
431
|
+
this._autoSuggest.addEventListener("wheel", t._stopPropagation, false);
|
432
|
+
}
|
433
|
+
|
434
|
+
elem.addEventListener("keydown", t._onTextKeyDown, false);
|
435
|
+
elem.addEventListener("keyup", t._onTextKeyUp, false);
|
436
|
+
elem.addEventListener("mousedown", t._stopPropagation, false);
|
437
|
+
elem.addEventListener("mouseup", t._stopPropagation, false);
|
438
|
+
elem.addEventListener("click", t._stopPropagation, false);
|
439
|
+
elem.addEventListener("copy", t._stopPropagation, false);
|
440
|
+
elem.addEventListener("cut", t._stopPropagation, false);
|
441
|
+
elem.addEventListener("paste", t._stopPropagation, false);
|
442
|
+
return elem;
|
429
443
|
};
|
430
444
|
|
431
445
|
/** @private
|
432
446
|
* @return {Element}
|
433
447
|
*/
|
434
448
|
InCellEditingPlugin.prototype._createEditor = function () {
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
449
|
+
let editor = document.createElement("div");
|
450
|
+
editor.className = "cell editing";
|
451
|
+
editor.style.position = "absolute";
|
452
|
+
return editor;
|
439
453
|
};
|
440
454
|
|
441
455
|
/** @private
|
@@ -443,10 +457,8 @@ InCellEditingPlugin.prototype._createEditor = function () {
|
|
443
457
|
* @return {Popup} popup instance
|
444
458
|
*/
|
445
459
|
InCellEditingPlugin.prototype._createBalloonPopup = function (editor) {
|
446
|
-
|
447
|
-
|
448
|
-
});
|
449
|
-
return popup;
|
460
|
+
let popup = new Popup(editor, { positioning: "over" });
|
461
|
+
return popup;
|
450
462
|
};
|
451
463
|
|
452
464
|
/** @private
|
@@ -456,19 +468,19 @@ InCellEditingPlugin.prototype._createBalloonPopup = function (editor) {
|
|
456
468
|
* @return {object} inCellCache
|
457
469
|
*/
|
458
470
|
InCellEditingPlugin.prototype._createInCellCache = function (grid, elemTag, attributes) {
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
471
|
+
let t = this;
|
472
|
+
|
473
|
+
let editor = t._createEditor();
|
474
|
+
let inputElement = t._createInputElement(elemTag, attributes);
|
475
|
+
let balloonPopup = new Popup(editor, { positioning: "over" });
|
476
|
+
editor.appendChild(inputElement);
|
477
|
+
|
478
|
+
return {
|
479
|
+
grid: grid,
|
480
|
+
inputElement: inputElement,
|
481
|
+
editor: editor,
|
482
|
+
balloonPopup: balloonPopup
|
483
|
+
};
|
472
484
|
};
|
473
485
|
|
474
486
|
/** @private
|
@@ -476,11 +488,12 @@ InCellEditingPlugin.prototype._createInCellCache = function (grid, elemTag, attr
|
|
476
488
|
* @return {object} inCellCache
|
477
489
|
*/
|
478
490
|
InCellEditingPlugin.prototype._createTitleEditor = function (grid) {
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
491
|
+
let t = this;
|
492
|
+
if(!t._headerInCellCache) {
|
493
|
+
t._headerInCellCache = t._createInCellCache(grid, "input");
|
494
|
+
}
|
495
|
+
|
496
|
+
return t._headerInCellCache;
|
484
497
|
};
|
485
498
|
|
486
499
|
/** @private
|
@@ -489,38 +502,40 @@ InCellEditingPlugin.prototype._createTitleEditor = function (grid) {
|
|
489
502
|
* @return {object} inCellCache
|
490
503
|
*/
|
491
504
|
InCellEditingPlugin.prototype._createContentEditor = function (columnIndex, grid) {
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
505
|
+
let t = this;
|
506
|
+
let typeMap = InCellEditingPlugin._uiElementTypesMap;
|
507
|
+
let columnData = t._getColumnData(columnIndex, grid);
|
508
|
+
let inCellColumnConfig = columnData["inCellEditing"];
|
509
|
+
let elemTag = typeMap[inCellColumnConfig && inCellColumnConfig.type] || t._defaultTag;
|
510
|
+
|
511
|
+
if(!columnData["inCellCache"]) {
|
512
|
+
let attributes = inCellColumnConfig ? inCellColumnConfig.attributes : null;
|
513
|
+
columnData["inCellCache"] = t._createInCellCache(grid, elemTag, attributes);
|
514
|
+
}
|
515
|
+
let inCellCache = columnData["inCellCache"];
|
516
|
+
|
517
|
+
// Setup initial value for the editor
|
518
|
+
if(elemTag === typeMap.select || elemTag === typeMap.combobox) {
|
519
|
+
inCellCache["inputElement"].data = inCellColumnConfig && inCellColumnConfig.entries;
|
520
|
+
}
|
521
|
+
|
522
|
+
return inCellCache;
|
508
523
|
};
|
509
524
|
/** @override
|
510
525
|
* @return {string}
|
511
526
|
*/
|
512
527
|
InCellEditingPlugin.prototype.getName = function () {
|
513
|
-
|
528
|
+
return "InCellEditingPlugin";
|
514
529
|
};
|
515
530
|
|
516
531
|
/** @private
|
517
532
|
* @param {Event|Element} e
|
518
533
|
*/
|
519
|
-
InCellEditingPlugin.prototype._onColumnAdded = function
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
534
|
+
InCellEditingPlugin.prototype._onColumnAdded = function(e) {
|
535
|
+
if(e.context && e.colIndex != null) {
|
536
|
+
// e.context is a columnOption;
|
537
|
+
this._retrieveColumnOption(e.context, e.colIndex);
|
538
|
+
}
|
524
539
|
};
|
525
540
|
|
526
541
|
/** Called by grid system when initial plugins.
|
@@ -529,40 +544,46 @@ InCellEditingPlugin.prototype._onColumnAdded = function (e) {
|
|
529
544
|
* @param {Object} options
|
530
545
|
*/
|
531
546
|
InCellEditingPlugin.prototype.initialize = function (host, options) {
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
547
|
+
if(this._hosts.indexOf(host) >= 0) { return; }
|
548
|
+
|
549
|
+
if(!this._hosts.length) {
|
550
|
+
window.addEventListener("scroll", this._onScroll);
|
551
|
+
}
|
552
|
+
|
553
|
+
host.listen("columnAdded", this._onColumnAdded);
|
554
|
+
host.getVScrollbar().listen("scroll", this._onScroll);
|
555
|
+
host.getHScrollbar().listen("scroll", this._onScroll);
|
556
|
+
|
557
|
+
if(this._dblClick) {
|
558
|
+
host.listen("dblclick", this._onDoubleClick);
|
559
|
+
|
560
|
+
// Make a comparable functionality for touchscreen
|
561
|
+
if(isTouchDevice()) {
|
562
|
+
host.listen("touchstart", this._onTouchStart);
|
563
|
+
host.listen("touchend", this._onTouchEnd);
|
564
|
+
host.listen("touchcancel", this._onTouchEnd);
|
565
|
+
}
|
566
|
+
}
|
567
|
+
|
568
|
+
this._hosts.push(host);
|
569
|
+
|
570
|
+
if(ElfUtil.getElfVersion() < 4) {
|
571
|
+
// ef-input available in elf version < 4
|
572
|
+
InCellEditingPlugin._uiElementTypesMap["number"] = "ef-input";
|
573
|
+
}
|
574
|
+
|
575
|
+
if(ElfUtil.isHaloTheme()) {
|
576
|
+
if(!host._inCellEditingStyles) {
|
577
|
+
host._inCellEditingStyles = true;
|
578
|
+
injectCss(InCellEditingPlugin._styles, host.getElement());
|
579
|
+
}
|
580
|
+
}
|
581
|
+
|
582
|
+
this.config(options);
|
583
|
+
|
584
|
+
if(!InCellEditingPlugin._primaryColor) {
|
585
|
+
ElfUtil.getThemeColors().then(InCellEditingPlugin._onThemeLoaded).catch(InCellEditingPlugin._onThemeLoaded);
|
586
|
+
}
|
566
587
|
};
|
567
588
|
/** Remove redundant built-in composite-grid feature
|
568
589
|
* @public
|
@@ -571,79 +592,102 @@ InCellEditingPlugin.prototype.initialize = function (host, options) {
|
|
571
592
|
* @return {*} The transformed value of the option
|
572
593
|
*/
|
573
594
|
InCellEditingPlugin.prototype.beforeProcessOption = function (optionName, optionVal) {
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
return; // eslint-disable-line
|
595
|
+
if(optionName == "cellEditing") {
|
596
|
+
return null; // eslint-disable-line
|
597
|
+
}
|
598
|
+
return; // eslint-disable-line
|
579
599
|
};
|
580
600
|
/** @private
|
581
601
|
* @override
|
582
602
|
*/
|
583
603
|
InCellEditingPlugin.prototype._afterInit = function () {
|
584
|
-
|
604
|
+
this._elfVersion = ElfUtil.getElfVersion();
|
585
605
|
};
|
586
606
|
|
587
607
|
/** @public
|
588
608
|
* @param {Object=} options
|
589
609
|
*/
|
590
|
-
InCellEditingPlugin.prototype.config = function
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
610
|
+
InCellEditingPlugin.prototype.config = function(options) {
|
611
|
+
if(!options) {
|
612
|
+
return;
|
613
|
+
}
|
614
|
+
let t = this;
|
615
|
+
|
616
|
+
// config column
|
617
|
+
let columns = options["columns"];
|
618
|
+
if(columns) {
|
619
|
+
let len = columns.length;
|
620
|
+
for(let c = 0; c < len; ++c) {
|
621
|
+
t._retrieveColumnOption(columns[c], c);
|
622
|
+
}
|
623
|
+
}
|
624
|
+
|
625
|
+
let pluginOption = options["inCellEditing"];
|
626
|
+
if(!pluginOption) return;
|
627
|
+
|
628
|
+
// options
|
629
|
+
if(pluginOption["type"])
|
630
|
+
t._defaultTag = InCellEditingPlugin._uiElementTypesMap[pluginOption["type"]];
|
631
|
+
|
632
|
+
if(pluginOption["balloonMode"])
|
633
|
+
t.enableBalloonMode(pluginOption["balloonMode"]);
|
634
|
+
|
635
|
+
if(pluginOption["editableTitle"])
|
636
|
+
t.enableTitleEditing(pluginOption["editableTitle"]);
|
637
|
+
|
638
|
+
if(pluginOption["editableContent"])
|
639
|
+
t._editableContent = true;
|
640
|
+
|
641
|
+
if(pluginOption["tabToMove"])
|
642
|
+
t._tabToMove = true;
|
643
|
+
|
644
|
+
if(pluginOption["autoCommitText"])
|
645
|
+
t.enableAutoCommitText(pluginOption["autoCommitText"]);
|
646
|
+
|
647
|
+
if(pluginOption["dataBinding"] != null)
|
648
|
+
t.disableDataBinding(!pluginOption["dataBinding"]);
|
649
|
+
|
650
|
+
if(pluginOption["contentSource"] != null)
|
651
|
+
t._contentSource = pluginOption["contentSource"];
|
652
|
+
|
653
|
+
if(pluginOption["popupElement"]){
|
654
|
+
t.setPopupElement(pluginOption["popupElement"]);
|
655
|
+
}
|
656
|
+
|
657
|
+
if(pluginOption["doubleClick"] != null)
|
658
|
+
t.disableDblClick(!pluginOption["doubleClick"]);
|
659
|
+
|
660
|
+
if(pluginOption["inlineStyling"]) {
|
661
|
+
t._inlineStyling = true;
|
662
|
+
}
|
663
|
+
|
664
|
+
if(pluginOption["disablingScroll"]) {
|
665
|
+
t._disablingScroll = true;
|
666
|
+
}
|
667
|
+
|
668
|
+
if(pluginOption["uiBlocking"]) {
|
669
|
+
t._uiBlocking = true;
|
670
|
+
}
|
671
|
+
|
672
|
+
if(pluginOption["autoSuggest"]) {
|
673
|
+
t._autoSuggest = pluginOption["autoSuggest"];
|
674
|
+
}
|
675
|
+
|
676
|
+
if(pluginOption["closingOnScroll"] == false) {
|
677
|
+
t._closingOnScroll = false;
|
678
|
+
}
|
679
|
+
if(pluginOption["autoHiding"] == false) {
|
680
|
+
t._autoHiding = false;
|
681
|
+
}
|
682
|
+
|
683
|
+
// event callback
|
684
|
+
t.addListener(pluginOption, "preEditorOpening");
|
685
|
+
t.addListener(pluginOption, "editorOpened");
|
686
|
+
t.addListener(pluginOption, "beforeCommit");
|
687
|
+
t.addListener(pluginOption, "editorClosed");
|
688
|
+
t.addListener(pluginOption, "keyUp");
|
689
|
+
t.addListener(pluginOption, "beforeRowCommit");
|
690
|
+
t.addListener(pluginOption, "rowEditorClosed");
|
647
691
|
};
|
648
692
|
|
649
693
|
/** @private
|
@@ -653,17 +697,17 @@ InCellEditingPlugin.prototype.config = function (options) {
|
|
653
697
|
* @param {boolean} defaultValue
|
654
698
|
* @returns {number} dirty
|
655
699
|
*/
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
700
|
+
let _setBooleanOption = function(obj, propName, propValue, defaultValue) {
|
701
|
+
if(defaultValue) {
|
702
|
+
if(!propValue) {
|
703
|
+
obj[propName] = false;
|
704
|
+
return true;
|
705
|
+
}
|
706
|
+
} else if(propValue) {
|
707
|
+
obj[propName] = true;
|
708
|
+
return true;
|
709
|
+
}
|
710
|
+
return false;
|
667
711
|
};
|
668
712
|
/** Get a current state of grid and extension config
|
669
713
|
* @public
|
@@ -671,65 +715,75 @@ var _setBooleanOption = function _setBooleanOption(obj, propName, propValue, def
|
|
671
715
|
* @returns {!Object}
|
672
716
|
*/
|
673
717
|
InCellEditingPlugin.prototype.getConfigObject = function (out_obj) {
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
718
|
+
let obj = out_obj || {};
|
719
|
+
|
720
|
+
let columns = obj.columns;
|
721
|
+
if(!columns) {
|
722
|
+
columns = obj.columns = [];
|
723
|
+
}
|
724
|
+
|
725
|
+
let len = this.getColumnCount();
|
726
|
+
let val, opt;
|
727
|
+
for(let i = 0; i < len; ++i) {
|
728
|
+
let col = columns[i];
|
729
|
+
if(!col) {
|
730
|
+
col = columns[i] = {};
|
731
|
+
}
|
732
|
+
|
733
|
+
opt = this._getColumnData(i);
|
734
|
+
|
735
|
+
if(!opt) { continue; }
|
736
|
+
if(opt.editableContent != null) {
|
737
|
+
col.editableContent = opt.editableContent;
|
738
|
+
}
|
739
|
+
if(opt.inCellEditing != null) {
|
740
|
+
col.inCellEditing = {};
|
741
|
+
|
742
|
+
val = opt.inCellEditing["type"];
|
743
|
+
if(val != null) {
|
744
|
+
col.inCellEditing["type"] = val;
|
745
|
+
}
|
746
|
+
|
747
|
+
val = opt.inCellEditing["entries"];
|
748
|
+
if(val != null) {
|
749
|
+
col.inCellEditing["entries"] = val;
|
750
|
+
}
|
751
|
+
|
752
|
+
val = opt.inCellEditing["attributes"];
|
753
|
+
if(val != null) {
|
754
|
+
col.inCellEditing["attributes"] = val;
|
755
|
+
}
|
756
|
+
}
|
757
|
+
}
|
758
|
+
|
759
|
+
let extOptions = obj.inCellEditing;
|
760
|
+
let dirty = 0;
|
761
|
+
if(!extOptions) {
|
762
|
+
extOptions = {};
|
763
|
+
}
|
764
|
+
dirty |= _setBooleanOption(extOptions, "balloonMode", this._balloonMode, false);
|
765
|
+
dirty |= _setBooleanOption(extOptions, "editableTitle", this._editableTitle, false);
|
766
|
+
dirty |= _setBooleanOption(extOptions, "editableContent", this._editableContent, false);
|
767
|
+
dirty |= _setBooleanOption(extOptions, "tabToMove", this._tabToMove, false);
|
768
|
+
dirty |= _setBooleanOption(extOptions, "autoCommitText", this._autoCommitText, false);
|
769
|
+
dirty |= _setBooleanOption(extOptions, "dataBinding", this._dataBinding, true);
|
770
|
+
dirty |= _setBooleanOption(extOptions, "doubleClick", this._dblClick, true);
|
771
|
+
dirty |= _setBooleanOption(extOptions, "inlineStyling", this._inlineStyling, false);
|
772
|
+
dirty |= _setBooleanOption(extOptions, "disablingScroll", this._disablingScroll, false);
|
773
|
+
dirty |= _setBooleanOption(extOptions, "uiBlocking", this._uiBlocking, false);
|
774
|
+
dirty |= _setBooleanOption(extOptions, "closingOnScroll", this._closingOnScroll, true);
|
775
|
+
dirty |= _setBooleanOption(extOptions, "autoHiding", this._autoHiding, true);
|
776
|
+
|
777
|
+
if(this._contentSource !== "textContent") {
|
778
|
+
dirty = 1;
|
779
|
+
extOptions.contentSource = this._contentSource;
|
780
|
+
}
|
781
|
+
|
782
|
+
if(dirty) {
|
783
|
+
obj.inCellEditing = extOptions;
|
784
|
+
}
|
785
|
+
|
786
|
+
return obj;
|
733
787
|
};
|
734
788
|
|
735
789
|
/** @private
|
@@ -737,41 +791,47 @@ InCellEditingPlugin.prototype.getConfigObject = function (out_obj) {
|
|
737
791
|
* @param {number} colIndex
|
738
792
|
*/
|
739
793
|
InCellEditingPlugin.prototype._retrieveColumnOption = function (columnOption, colIndex) {
|
740
|
-
|
741
|
-
|
742
|
-
if (pluginOptions != null || editableContent != null) {
|
743
|
-
var colData = this._newColumnData(colIndex);
|
744
|
-
if (pluginOptions != null) {
|
745
|
-
colData["inCellEditing"] = pluginOptions;
|
746
|
-
pluginOptions.entries = CoralItems.create(pluginOptions.entries); // Create entries for coral select and combobox
|
747
|
-
}
|
794
|
+
let pluginOptions = columnOption["inCellEditing"];
|
795
|
+
let editableContent = columnOption["editableContent"];
|
748
796
|
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
797
|
+
if(pluginOptions != null || editableContent != null) {
|
798
|
+
let colData = this._newColumnData(colIndex);
|
799
|
+
if(pluginOptions != null) {
|
800
|
+
colData["inCellEditing"] = pluginOptions;
|
801
|
+
pluginOptions.entries = CoralItems.create(pluginOptions.entries); // Create entries for coral select and combobox
|
802
|
+
}
|
803
|
+
if(editableContent != null) {
|
804
|
+
colData["editableContent"] = editableContent;
|
805
|
+
}
|
806
|
+
}
|
753
807
|
};
|
754
808
|
|
755
809
|
/** @override */
|
756
810
|
InCellEditingPlugin.prototype.unload = function (host) {
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
811
|
+
let at = this._hosts.indexOf(host);
|
812
|
+
if(at < 0) { return; }
|
813
|
+
this._hosts.splice(at, 1);
|
814
|
+
|
815
|
+
host.unlisten("columnAdded", this._onColumnAdded);
|
816
|
+
host.getVScrollbar().unlisten("scroll", this._onScroll);
|
817
|
+
host.getHScrollbar().unlisten("scroll", this._onScroll);
|
818
|
+
|
819
|
+
host.unlisten("dblclick", this._onDoubleClick);
|
820
|
+
host.unlisten("touchstart", this._onTouchStart);
|
821
|
+
host.unlisten("touchend", this._onTouchEnd);
|
822
|
+
host.unlisten("touchcancel", this._onTouchEnd);
|
823
|
+
|
824
|
+
if(!this._hosts.length) {
|
825
|
+
if(this._touchTimerId) {
|
826
|
+
clearTimeout(this._touchTimerId);
|
827
|
+
}
|
828
|
+
if(this._editorTimerId) {
|
829
|
+
clearTimeout(this._editorTimerId);
|
830
|
+
}
|
831
|
+
window.removeEventListener("scroll", this._onScroll);
|
832
|
+
}
|
833
|
+
|
834
|
+
this._dispose();
|
775
835
|
};
|
776
836
|
|
777
837
|
/** @public
|
@@ -782,33 +842,38 @@ InCellEditingPlugin.prototype.unload = function (host) {
|
|
782
842
|
* @fires InCellEditingPlugin#editorOpened
|
783
843
|
*/
|
784
844
|
InCellEditingPlugin.prototype.openEditor = function (colIndex, rowIndex, sectionRef, grid) {
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
845
|
+
if(!grid) {
|
846
|
+
grid = this._hosts[0];
|
847
|
+
if(!grid) {
|
848
|
+
return;
|
849
|
+
}
|
850
|
+
}
|
851
|
+
|
852
|
+
let sectionSettings = grid.getSectionSettings(sectionRef || "content");
|
853
|
+
let activePos = this._activePos;
|
854
|
+
if(activePos) {
|
855
|
+
let sectionName = sectionSettings ? sectionSettings.getType() : "";
|
856
|
+
|
857
|
+
if(activePos["colIndex"] === colIndex &&
|
858
|
+
activePos["rowIndex"] === rowIndex &&
|
859
|
+
activePos["sectionName"] === sectionName &&
|
860
|
+
activePos["grid"] === grid
|
861
|
+
) {
|
862
|
+
return; // The same cell is open twice
|
863
|
+
}
|
864
|
+
|
865
|
+
this.closeCellEditor(); // Close previously opened cell editor
|
866
|
+
}
|
867
|
+
let section = sectionSettings ? sectionSettings.getSection() : null;
|
868
|
+
let cell = section ? section.getCell(colIndex, rowIndex) : null;
|
869
|
+
if(!cell) {
|
870
|
+
return; // Some input is invalid
|
871
|
+
}
|
872
|
+
|
873
|
+
grid.scrollToColumn(colIndex);
|
874
|
+
grid.scrollToRow(null, rowIndex); // TODO: Fix this workaround
|
875
|
+
|
876
|
+
setTimeout(this._openEditor.bind(this, cell, grid), 100);
|
812
877
|
};
|
813
878
|
|
814
879
|
/** @public
|
@@ -816,21 +881,21 @@ InCellEditingPlugin.prototype.openEditor = function (colIndex, rowIndex, section
|
|
816
881
|
* @fires InCellEditingPlugin#cancelled
|
817
882
|
*/
|
818
883
|
InCellEditingPlugin.prototype.closeCellEditor = function (opt_forceCommit) {
|
819
|
-
|
884
|
+
this._commitText(opt_forceCommit || this._autoCommitText);
|
820
885
|
};
|
821
886
|
|
822
887
|
/** @public
|
823
888
|
* @param {boolean=} opt_enabled
|
824
889
|
*/
|
825
890
|
InCellEditingPlugin.prototype.enableBalloonMode = function (opt_enabled) {
|
826
|
-
|
891
|
+
this._balloonMode = opt_enabled !== false;
|
827
892
|
};
|
828
893
|
|
829
894
|
/** @public
|
830
895
|
* @param {boolean=} opt_enabled
|
831
896
|
*/
|
832
897
|
InCellEditingPlugin.prototype.enableTitleEditing = function (opt_enabled) {
|
833
|
-
|
898
|
+
this._editableTitle = opt_enabled !== false;
|
834
899
|
};
|
835
900
|
|
836
901
|
/** Disable editing on all title sections
|
@@ -838,7 +903,7 @@ InCellEditingPlugin.prototype.enableTitleEditing = function (opt_enabled) {
|
|
838
903
|
* @param {boolean=} opt_disabled
|
839
904
|
*/
|
840
905
|
InCellEditingPlugin.prototype.disableTitleEditing = function (opt_disabled) {
|
841
|
-
|
906
|
+
this._editableTitle = opt_disabled === false;
|
842
907
|
};
|
843
908
|
|
844
909
|
/** Disable editing on a per cell basis
|
@@ -847,29 +912,29 @@ InCellEditingPlugin.prototype.disableTitleEditing = function (opt_disabled) {
|
|
847
912
|
* @param {boolean=} opt_disabled
|
848
913
|
*/
|
849
914
|
InCellEditingPlugin.prototype.disableCellEditing = function (cell, opt_disabled) {
|
850
|
-
|
851
|
-
|
852
|
-
|
915
|
+
if(cell) {
|
916
|
+
cell.enableClass("no-editing", opt_disabled !== false);
|
917
|
+
}
|
853
918
|
};
|
854
919
|
|
855
920
|
/** @public
|
856
921
|
* @param {boolean=} opt_disabled
|
857
922
|
*/
|
858
923
|
InCellEditingPlugin.prototype.disableDataBinding = function (opt_disabled) {
|
859
|
-
|
924
|
+
this._dataBinding = (opt_disabled === false);
|
860
925
|
};
|
861
926
|
|
862
927
|
/** @public
|
863
928
|
* @param {boolean=} opt_disabled
|
864
929
|
*/
|
865
930
|
InCellEditingPlugin.prototype.disableDblClick = function (opt_disabled) {
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
931
|
+
let dblClick = (opt_disabled === false);
|
932
|
+
if(this._dblClick !== dblClick) {
|
933
|
+
this._dblClick = dblClick;
|
934
|
+
for(let i = this._hosts.length; --i >= 0;) {
|
935
|
+
this._listenForTriggering(this._hosts[i], dblClick);
|
936
|
+
}
|
937
|
+
}
|
873
938
|
};
|
874
939
|
|
875
940
|
/** Checking Editing is in process.
|
@@ -877,7 +942,7 @@ InCellEditingPlugin.prototype.disableDblClick = function (opt_disabled) {
|
|
877
942
|
* @return {boolean}
|
878
943
|
*/
|
879
944
|
InCellEditingPlugin.prototype.isEditing = function () {
|
880
|
-
|
945
|
+
return this._editing;
|
881
946
|
};
|
882
947
|
|
883
948
|
/**
|
@@ -890,29 +955,28 @@ InCellEditingPlugin.prototype.isEditing = function () {
|
|
890
955
|
* for cell editing mode. function not require param since only one editor can be opened at a time.
|
891
956
|
*/
|
892
957
|
InCellEditingPlugin.prototype.getTextBox = function (columnIndex, grid) {
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
return null; // no editor open
|
958
|
+
if(this._activeRowId) { // for row editing mode
|
959
|
+
// get rowEditor that's stored in column data
|
960
|
+
grid = grid || this._hosts[0];
|
961
|
+
if(grid) {
|
962
|
+
let columnData = this._getColumnData(columnIndex, grid);
|
963
|
+
let inCellCache = columnData["inCellCache"];
|
964
|
+
if(inCellCache) {
|
965
|
+
return inCellCache["inputElement"];
|
966
|
+
}
|
967
|
+
}
|
968
|
+
} else if(this._activeInCellCache) { // for cell editing mode
|
969
|
+
return this._activeInCellCache["inputElement"];
|
970
|
+
}
|
971
|
+
|
972
|
+
return null; // no editor open
|
909
973
|
};
|
910
974
|
|
911
975
|
/** @public
|
912
976
|
* @return {string}
|
913
977
|
*/
|
914
978
|
InCellEditingPlugin.prototype.getInitialText = function () {
|
915
|
-
|
979
|
+
return this._initialText;
|
916
980
|
};
|
917
981
|
|
918
982
|
/** @private
|
@@ -920,29 +984,31 @@ InCellEditingPlugin.prototype.getInitialText = function () {
|
|
920
984
|
* @param {number} rowIndex
|
921
985
|
* @param {string} field
|
922
986
|
* @param {Element=} content element that get from cell.getContent
|
987
|
+
* @param {string} sectionType
|
923
988
|
* @return {*}
|
924
989
|
*/
|
925
|
-
InCellEditingPlugin.prototype._getSourceContent = function (dataSource, rowIndex, field, content) {
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
990
|
+
InCellEditingPlugin.prototype._getSourceContent = function (dataSource, rowIndex, field, content, sectionType) {
|
991
|
+
if(this._contentSource == "field" && sectionType !== "title") {
|
992
|
+
return this._getData(dataSource, rowIndex, field);
|
993
|
+
} else {
|
994
|
+
let textNode, str;
|
995
|
+
if(content) {
|
996
|
+
let len = content.childNodes.length;
|
997
|
+
for(let i = 0; i < len; ++i) {
|
998
|
+
if(content.childNodes[i].nodeType === 3) {
|
999
|
+
textNode = content.childNodes[i]; // To preserve current content structure
|
1000
|
+
break;
|
1001
|
+
}
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
if(textNode) {
|
1006
|
+
str = textNode.textContent;
|
1007
|
+
} else if(content) {
|
1008
|
+
str = content.textContent;
|
1009
|
+
}
|
1010
|
+
return str;
|
1011
|
+
}
|
946
1012
|
};
|
947
1013
|
|
948
1014
|
/**
|
@@ -951,11 +1017,11 @@ InCellEditingPlugin.prototype._getSourceContent = function (dataSource, rowIndex
|
|
951
1017
|
* @return {!number} row index will return -1 if not found
|
952
1018
|
*/
|
953
1019
|
InCellEditingPlugin.prototype._getRowIndex = function (rowId) {
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
1020
|
+
if(rowId && this._lastActiveGrid) {
|
1021
|
+
let dv = this._lastActiveGrid.getDataSource();
|
1022
|
+
if(dv) return dv.getRowIndex(rowId);
|
1023
|
+
}
|
1024
|
+
return -1;
|
959
1025
|
};
|
960
1026
|
|
961
1027
|
/**
|
@@ -964,18 +1030,18 @@ InCellEditingPlugin.prototype._getRowIndex = function (rowId) {
|
|
964
1030
|
* @return {!string} return empty string if not found
|
965
1031
|
*/
|
966
1032
|
InCellEditingPlugin.prototype._getRowId = function (rowIndex) {
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
1033
|
+
if(rowIndex != null && this._lastActiveGrid) {
|
1034
|
+
let dv = this._lastActiveGrid.getDataSource();
|
1035
|
+
if(dv) return dv.getRowId(rowIndex);
|
1036
|
+
}
|
1037
|
+
return "";
|
972
1038
|
};
|
973
1039
|
|
974
1040
|
/** @private
|
975
1041
|
* @return {Object|null} core grid object
|
976
1042
|
*/
|
977
1043
|
InCellEditingPlugin.prototype.getActiveGrid = function () {
|
978
|
-
|
1044
|
+
return this._activePos ? this._activePos["grid"] : null;
|
979
1045
|
};
|
980
1046
|
|
981
1047
|
/** get active column index that editor had opended. Function can work only in cell editing mode.
|
@@ -983,11 +1049,11 @@ InCellEditingPlugin.prototype.getActiveGrid = function () {
|
|
983
1049
|
* @return {number} column index will return -1 if not found
|
984
1050
|
*/
|
985
1051
|
InCellEditingPlugin.prototype.getActiveColIndex = function () {
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
1052
|
+
if(this._activePos) {
|
1053
|
+
let colIndex = this._activePos["colIndex"];
|
1054
|
+
if(colIndex != null) return colIndex;
|
1055
|
+
}
|
1056
|
+
return -1;
|
991
1057
|
};
|
992
1058
|
|
993
1059
|
/** get active row index that editor had opended. Function Can work in both cell/row editing modes.
|
@@ -995,29 +1061,27 @@ InCellEditingPlugin.prototype.getActiveColIndex = function () {
|
|
995
1061
|
* @return {number} row index will return -1 if not found
|
996
1062
|
*/
|
997
1063
|
InCellEditingPlugin.prototype.getActiveRowIndex = function () {
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
}
|
1006
|
-
return -1;
|
1064
|
+
if(this._activeRowId) { // row editing mode
|
1065
|
+
return this._getRowIndex(this._activeRowId);
|
1066
|
+
} else if(this._activePos) { // cell editing mode
|
1067
|
+
let rowIndex = this._activePos["rowIndex"];
|
1068
|
+
if(rowIndex != null) return rowIndex;
|
1069
|
+
}
|
1070
|
+
return -1;
|
1007
1071
|
};
|
1008
1072
|
|
1009
1073
|
/** @public
|
1010
1074
|
* @return {Object}
|
1011
1075
|
*/
|
1012
1076
|
InCellEditingPlugin.prototype.getInputElementPosition = function () {
|
1013
|
-
|
1077
|
+
return this._activePos || null;
|
1014
1078
|
};
|
1015
1079
|
|
1016
1080
|
/** @public
|
1017
1081
|
* @param {boolean=} opt_enable
|
1018
1082
|
*/
|
1019
1083
|
InCellEditingPlugin.prototype.enableAutoCommitText = function (opt_enable) {
|
1020
|
-
|
1084
|
+
this._autoCommitText = (opt_enable !== false);
|
1021
1085
|
};
|
1022
1086
|
|
1023
1087
|
/** Check if the column can be edited by double click
|
@@ -1026,8 +1090,30 @@ InCellEditingPlugin.prototype.enableAutoCommitText = function (opt_enable) {
|
|
1026
1090
|
* @return {boolean}
|
1027
1091
|
*/
|
1028
1092
|
InCellEditingPlugin.prototype.isColumnEditable = function (colIndex) {
|
1029
|
-
|
1030
|
-
|
1093
|
+
let val = this._getColumnOption(colIndex, "editableContent");
|
1094
|
+
return val == null ? this._editableContent : val;
|
1095
|
+
};
|
1096
|
+
/** @public
|
1097
|
+
* @description Supply an keyboard input. This is for testing purpose.
|
1098
|
+
* @ignore
|
1099
|
+
* @param {string} keyName
|
1100
|
+
* @param {Object=} context
|
1101
|
+
*/
|
1102
|
+
InCellEditingPlugin.prototype.supplyKey = function(keyName, context) {
|
1103
|
+
let eventObj = this._mockKeyboardEvent(keyName, context);
|
1104
|
+
this._onTextKeyDown(eventObj);
|
1105
|
+
this._onTextKeyUp(eventObj);
|
1106
|
+
};
|
1107
|
+
/** @public
|
1108
|
+
* @description Supply an double click event. This is for testing purpose.
|
1109
|
+
* @ignore
|
1110
|
+
* @param {number} colIndex
|
1111
|
+
* @param {number} rowIndex
|
1112
|
+
* @param {Object=} context
|
1113
|
+
*/
|
1114
|
+
InCellEditingPlugin.prototype.mockDoubleClick = function(colIndex, rowIndex, context) {
|
1115
|
+
let eventObj = this._mockMouseEvent(colIndex, rowIndex, context);
|
1116
|
+
this._onDoubleClick(eventObj);
|
1031
1117
|
};
|
1032
1118
|
/** @private
|
1033
1119
|
* @param {Event|Element} e
|
@@ -1035,33 +1121,34 @@ InCellEditingPlugin.prototype.isColumnEditable = function (colIndex) {
|
|
1035
1121
|
* @fires InCellEditingPlugin#editorOpened
|
1036
1122
|
*/
|
1037
1123
|
InCellEditingPlugin.prototype._onDoubleClick = function (e, opt_host) {
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1124
|
+
let t = this;
|
1125
|
+
let host = opt_host || t.getRelativeGrid(e);
|
1126
|
+
if(t.isEditing() || !host) { return; }
|
1127
|
+
|
1128
|
+
let arg = host.getRelativePosition(e);
|
1129
|
+
let sectionType = arg["sectionType"];
|
1130
|
+
|
1131
|
+
if(sectionType === "content" && !t.isColumnEditable(arg["colIndex"])) {
|
1132
|
+
return;
|
1133
|
+
} else if(sectionType === "title" && !t._editableTitle) {
|
1134
|
+
return;
|
1135
|
+
} else if(sectionType === "header") {
|
1136
|
+
return;
|
1137
|
+
}
|
1138
|
+
|
1139
|
+
let dataSource = arg["dataSource"];
|
1140
|
+
if(dataSource != null) {
|
1141
|
+
let rowId = dataSource.getRowId(arg["rowIndex"]);
|
1142
|
+
if(dataSource.getGroupByRowId(rowId)) {
|
1143
|
+
return;
|
1144
|
+
}
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
// Initialize internal states
|
1148
|
+
if(e["preventDefault"]) {
|
1149
|
+
Dom.preventDefault(e);
|
1150
|
+
}
|
1151
|
+
t.openEditor(arg.colIndex, arg.rowIndex, arg.section, host);
|
1065
1152
|
};
|
1066
1153
|
|
1067
1154
|
/** @private
|
@@ -1070,159 +1157,175 @@ InCellEditingPlugin.prototype._onDoubleClick = function (e, opt_host) {
|
|
1070
1157
|
* @param {Object=} arg
|
1071
1158
|
*/
|
1072
1159
|
InCellEditingPlugin.prototype._openEditor = function (e, host, arg) {
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
1144
|
-
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
1220
|
-
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1160
|
+
let t = this;
|
1161
|
+
if(!host.getElement() || this._hosts.indexOf(host) < 0) { // Check validity due to asyncronous call
|
1162
|
+
return;
|
1163
|
+
}
|
1164
|
+
|
1165
|
+
if(!arg) {
|
1166
|
+
arg = host.getRelativePosition(e);
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
if(!arg["hit"]) { // The specified cell could be gone during the asyncronous process
|
1170
|
+
return;
|
1171
|
+
}
|
1172
|
+
|
1173
|
+
t._dispatch("preEditorOpening", arg);
|
1174
|
+
|
1175
|
+
if(arg["cancel"]) {
|
1176
|
+
return;
|
1177
|
+
}
|
1178
|
+
|
1179
|
+
let colIndex = arg["colIndex"];
|
1180
|
+
let rowIndex = arg["rowIndex"];
|
1181
|
+
let section = arg["section"];
|
1182
|
+
let cell = section.getCell(colIndex, rowIndex);
|
1183
|
+
let rowSpan = 1;
|
1184
|
+
let stretchedCell = section.getStretchedCell(cell, rowIndex);
|
1185
|
+
if(stretchedCell){
|
1186
|
+
cell = stretchedCell;
|
1187
|
+
} else {
|
1188
|
+
rowSpan = section.getCellRowSpan(colIndex, rowIndex);
|
1189
|
+
}
|
1190
|
+
|
1191
|
+
if(!cell || cell.hasClass("no-editing")) {
|
1192
|
+
return;
|
1193
|
+
}
|
1194
|
+
// Everything has been verified at this point. We can start the opening process.
|
1195
|
+
|
1196
|
+
// close row editor first
|
1197
|
+
t.closeRowEditor(false, host);
|
1198
|
+
|
1199
|
+
section.addClass("edit-mode");
|
1200
|
+
t._lastActiveGrid = host;
|
1201
|
+
t._activePos = arg;
|
1202
|
+
arg["cell"] = t._activeCell = cell;
|
1203
|
+
arg["content"] = t._prevContent = cell.getContent();
|
1204
|
+
arg["field"] = t._getField(colIndex);
|
1205
|
+
|
1206
|
+
let dataSource = arg["dataSource"];
|
1207
|
+
if(dataSource != null) {
|
1208
|
+
let rowId = arg["rowId"] = this._getRowId(arg["rowIndex"]);
|
1209
|
+
arg["segmentSeparator"] = dataSource.isSegmentSeparator(rowId);
|
1210
|
+
arg["groupHeader"] = dataSource.getGroupByRowId(rowId);
|
1211
|
+
arg["rowData"] = this._getRow(dataSource, rowId);
|
1212
|
+
|
1213
|
+
if(dataSource["stall"]) {
|
1214
|
+
dataSource["stall"](true);
|
1215
|
+
}
|
1216
|
+
}
|
1217
|
+
|
1218
|
+
// Initialize UIs
|
1219
|
+
if(arg["sectionType"] === "title") {
|
1220
|
+
t._activeInCellCache = t._createTitleEditor(host);
|
1221
|
+
} else {
|
1222
|
+
t._activeInCellCache = t._createContentEditor(colIndex, host);
|
1223
|
+
}
|
1224
|
+
|
1225
|
+
let inputElement = arg["inputElement"] = t._activeInCellCache["inputElement"];
|
1226
|
+
let editor = arg["editor"] = t._activeInCellCache["editor"];
|
1227
|
+
let balloonPopup = t._activeInCellCache["balloonPopup"];
|
1228
|
+
let sourceContent = arg ? t._getSourceContent(arg["dataSource"], arg["rowIndex"], arg["field"], arg["content"], arg["sectionType"]) : "";
|
1229
|
+
|
1230
|
+
if(rowIndex + 1 >= section.getRowCount()) {
|
1231
|
+
inputElement.classList.add("bottom");
|
1232
|
+
} else {
|
1233
|
+
inputElement.classList.remove("bottom");
|
1234
|
+
}
|
1235
|
+
|
1236
|
+
// Initialize Balloon
|
1237
|
+
t._usingBalloon = t._isBalloonMode(cell);
|
1238
|
+
if(t._usingBalloon) {
|
1239
|
+
editor.classList.add("balloon");
|
1240
|
+
} else {
|
1241
|
+
editor.classList.remove("balloon");
|
1242
|
+
}
|
1243
|
+
|
1244
|
+
let editorStyle = editor.style;
|
1245
|
+
if(this._elfVersion || t._inlineStyling) {
|
1246
|
+
editorStyle.backgroundColor = section.getComputedStyle().backgroundColor;
|
1247
|
+
}
|
1248
|
+
|
1249
|
+
let rowH = section.getRowHeight(rowIndex);
|
1250
|
+
let width = cell.getWidth();
|
1251
|
+
if(!host.isPinnedColumn(colIndex)) {
|
1252
|
+
let hScrollbar = host.getHScrollbar();
|
1253
|
+
if(hScrollbar.isActive()) {
|
1254
|
+
let paneSize = hScrollbar.getPaneSize();
|
1255
|
+
if(width > paneSize) {
|
1256
|
+
width = paneSize;
|
1257
|
+
}
|
1258
|
+
}
|
1259
|
+
}
|
1260
|
+
if(!t._usingBalloon || width > 208) {
|
1261
|
+
editorStyle.width = width + "px";
|
1262
|
+
} else {
|
1263
|
+
editorStyle.width = "";
|
1264
|
+
}
|
1265
|
+
|
1266
|
+
if(rowSpan > 1) {
|
1267
|
+
editorStyle.height = cell.getHeight() + "px";
|
1268
|
+
} else {
|
1269
|
+
editorStyle.height = rowH + "px";
|
1270
|
+
}
|
1271
|
+
|
1272
|
+
// Attach our popup (balloon element)
|
1273
|
+
let parentElement = document.body;
|
1274
|
+
if(t._compositeGrid || t._realTimeGrid) {
|
1275
|
+
let activeGrid = t.getActiveGrid();
|
1276
|
+
if(activeGrid) {
|
1277
|
+
parentElement = activeGrid.getElement().parentElement;
|
1278
|
+
}
|
1279
|
+
}
|
1280
|
+
|
1281
|
+
balloonPopup.enableUIBlocking(t._uiBlocking);
|
1282
|
+
balloonPopup.addEventListener("hidden", t._onPopupHide);
|
1283
|
+
balloonPopup.disableAutoHiding(!t._autoHiding);
|
1284
|
+
balloonPopup.disableHideOnScroll(true);
|
1285
|
+
balloonPopup.attachTo(cell.getElement());
|
1286
|
+
balloonPopup.show(true, parentElement);
|
1287
|
+
|
1288
|
+
this._updateEditorPopup(t._activeInCellCache, cell, host);
|
1289
|
+
|
1290
|
+
// Attach user element
|
1291
|
+
if(t._customElement) {
|
1292
|
+
t._customElementPopup.attachTo(editor);
|
1293
|
+
t._customElementPopup.show(true, parentElement);
|
1294
|
+
t._customElementPopup.disableAutoHiding(false);
|
1295
|
+
arg["popupElement"] = t._customElement;
|
1296
|
+
}
|
1297
|
+
|
1298
|
+
// WARNING: value-changed event from ELF v3 component may NOT be triggered due to their design flaw
|
1299
|
+
t._setText(sourceContent, inputElement);
|
1300
|
+
arg["initialText"] = t._initialText = sourceContent;
|
1301
|
+
|
1302
|
+
if(t._disablingScroll) {
|
1303
|
+
t._freezeScrolling(host, true);
|
1304
|
+
}
|
1305
|
+
|
1306
|
+
arg["autoSuggest"] = t._autoSuggest;
|
1307
|
+
if(t._autoSuggest) {
|
1308
|
+
if(t._autoSuggest.attach === inputElement) {
|
1309
|
+
t._autoSuggest.attach = null; // WORKAROUND: reset attach for re-attach target
|
1310
|
+
}
|
1311
|
+
|
1312
|
+
if(t._autoSuggest.parentNode !== editor ) { // if we appendChild all time when open editor, events won't work
|
1313
|
+
editor.appendChild(t._autoSuggest);
|
1314
|
+
}
|
1315
|
+
t._autoSuggest.attach = inputElement;
|
1316
|
+
t._autoSuggest.positionTarget = inputElement; // for re-position of autosuggest
|
1317
|
+
}
|
1318
|
+
|
1319
|
+
// Dispatch an event for user to setup stuff
|
1320
|
+
t._dispatch("editorOpened", arg); // User may modify the editor
|
1321
|
+
|
1322
|
+
inputElement.focus();
|
1323
|
+
if(typeof inputElement.select === "function") {
|
1324
|
+
inputElement.select();
|
1325
|
+
}
|
1326
|
+
|
1327
|
+
arg["initialText"] = t._initialText = t.getText(); // After all modifications, cache the string for text change event
|
1328
|
+
t._editing = true; // Editing state cannot be false until a text has been committed or cancelled
|
1226
1329
|
};
|
1227
1330
|
|
1228
1331
|
/** Using to open row editor.
|
@@ -1231,98 +1334,102 @@ InCellEditingPlugin.prototype._openEditor = function (e, host, arg) {
|
|
1231
1334
|
* @param {Object=} grid core grid object
|
1232
1335
|
*/
|
1233
1336
|
InCellEditingPlugin.prototype.openRowEditor = function (rowIndex, grid) {
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1303
|
-
|
1304
|
-
|
1305
|
-
|
1306
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
1325
|
-
|
1337
|
+
let t = this;
|
1338
|
+
grid = grid || t._hosts[0];
|
1339
|
+
// if open same row we will do nothing
|
1340
|
+
if(t._getRowIndex(t._activeRowId) === rowIndex || !grid) { return; }
|
1341
|
+
|
1342
|
+
// close all open editor
|
1343
|
+
t.closeRowEditor(false, grid);
|
1344
|
+
t._commitText(false);
|
1345
|
+
|
1346
|
+
let firstInput, firstPopup;
|
1347
|
+
let sectionType = "content";
|
1348
|
+
let section = grid.getSection(sectionType);
|
1349
|
+
let dataSource = grid.getDataSource();
|
1350
|
+
let lastIndex = (section.getColumnCount() || 0) - 1;
|
1351
|
+
let isBottom = (rowIndex + 1) >= section.getRowCount();
|
1352
|
+
let sectionBGColor = (this._elfVersion || t._inlineStyling) ? section.getComputedStyle().backgroundColor : null;
|
1353
|
+
let rowH = section.getRowHeight(rowIndex);
|
1354
|
+
|
1355
|
+
// if normally parent popup will be document.body
|
1356
|
+
let parentElement = document.body;
|
1357
|
+
|
1358
|
+
// but if grid is _compositeGrid or _realTimeGrid then
|
1359
|
+
// then we will use grid parent instead
|
1360
|
+
if(t._compositeGrid || t._realTimeGrid) {
|
1361
|
+
parentElement = grid.getElement().parentElement;
|
1362
|
+
}
|
1363
|
+
|
1364
|
+
// loop for all column
|
1365
|
+
for(let columnIndex = 0; columnIndex <= lastIndex; columnIndex++) {
|
1366
|
+
// ignore column that can't edit
|
1367
|
+
if(!t.isColumnEditable(columnIndex)) { continue; }
|
1368
|
+
let cell = section.getCell(columnIndex, rowIndex);
|
1369
|
+
if(!cell || cell.hasClass("no-editing")) {
|
1370
|
+
continue;
|
1371
|
+
} // all verify is done
|
1372
|
+
|
1373
|
+
// create editor, popup, inputElement
|
1374
|
+
let inCellCache = t._createContentEditor(columnIndex, grid);
|
1375
|
+
|
1376
|
+
let content = cell.getContent();
|
1377
|
+
let field = t._getField(columnIndex);
|
1378
|
+
let sourceContent = t._getSourceContent(dataSource, rowIndex, field, content, sectionType);
|
1379
|
+
let inputElement = inCellCache["inputElement"];
|
1380
|
+
let editor = inCellCache["editor"];
|
1381
|
+
let balloonPopup = inCellCache["balloonPopup"];
|
1382
|
+
|
1383
|
+
if(!firstInput) {
|
1384
|
+
firstInput = inputElement;
|
1385
|
+
firstPopup = balloonPopup;
|
1386
|
+
balloonPopup.enableUIBlocking(t._uiBlocking);
|
1387
|
+
} else {
|
1388
|
+
balloonPopup.enableUIBlocking(false);
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
t._setText(sourceContent, inputElement); // WARNING: value-changed event from ELF v3 component may be triggered due to their design flaw
|
1392
|
+
|
1393
|
+
if(isBottom) {
|
1394
|
+
inputElement.classList.add("bottom");
|
1395
|
+
} else {
|
1396
|
+
inputElement.classList.remove("bottom");
|
1397
|
+
}
|
1398
|
+
|
1399
|
+
let editorStyle = editor.style;
|
1400
|
+
if(sectionBGColor) {
|
1401
|
+
editorStyle.backgroundColor = sectionBGColor;
|
1402
|
+
}
|
1403
|
+
editorStyle.height = rowH + "px";
|
1404
|
+
|
1405
|
+
// this is different from single edit mode
|
1406
|
+
// row edit mode not support balloon mode
|
1407
|
+
let width = section.getCellWidth(columnIndex, rowIndex);
|
1408
|
+
editorStyle.width = width + "px";
|
1409
|
+
editor.classList.remove("balloon");
|
1410
|
+
|
1411
|
+
balloonPopup.disableAutoHiding(true);
|
1412
|
+
balloonPopup.disableHideOnScroll(true);
|
1413
|
+
balloonPopup.attachTo(cell.getElement());
|
1414
|
+
balloonPopup.show(true, parentElement);
|
1415
|
+
|
1416
|
+
this._updateEditorPopup(inCellCache, cell, grid);
|
1417
|
+
|
1418
|
+
// this._updateEditorLayout(inputElement); // Adjust sizes after append to the DOM
|
1419
|
+
}
|
1420
|
+
|
1421
|
+
// if firstInput not undefined that mean at lease one popup is open
|
1422
|
+
if(firstInput) {
|
1423
|
+
firstPopup.addEventListener("hidden", t._onPopupHide);
|
1424
|
+
t._lastActiveGrid = grid;
|
1425
|
+
t._editing = true; // Editing state cannot be false until a text has been committed or cancelled
|
1426
|
+
t._activeRowId = this._getRowId(rowIndex);
|
1427
|
+
firstInput.focus();
|
1428
|
+
section.addClass("edit-mode");
|
1429
|
+
if(t._disablingScroll) {
|
1430
|
+
t._freezeScrolling(grid, true);
|
1431
|
+
}
|
1432
|
+
}
|
1326
1433
|
};
|
1327
1434
|
|
1328
1435
|
/** Using to close row editor.
|
@@ -1332,105 +1439,108 @@ InCellEditingPlugin.prototype.openRowEditor = function (rowIndex, grid) {
|
|
1332
1439
|
* @fires InCellEditingPlugin#rowEditorClosed
|
1333
1440
|
*/
|
1334
1441
|
InCellEditingPlugin.prototype.closeRowEditor = function (isCommit) {
|
1335
|
-
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1396
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1433
|
-
|
1442
|
+
let t = this;
|
1443
|
+
let grid = t._lastActiveGrid;
|
1444
|
+
// if no row active then do nothing
|
1445
|
+
if(!t._activeRowId || !grid) { return; }
|
1446
|
+
|
1447
|
+
let rowId = t._activeRowId;
|
1448
|
+
let rowIndex = t._getRowIndex(rowId);
|
1449
|
+
if(rowIndex <= -1) {
|
1450
|
+
isCommit = false; // rowIndex -1 mean row is not found or already disposed
|
1451
|
+
} else {
|
1452
|
+
isCommit = isCommit !== false; // default is true
|
1453
|
+
}
|
1454
|
+
|
1455
|
+
let section = grid.getSection("content");
|
1456
|
+
let columnLength = grid.getColumnCount();
|
1457
|
+
let fieldValue = {};
|
1458
|
+
let inCellCaches = [];
|
1459
|
+
let inCellCache;
|
1460
|
+
|
1461
|
+
// in this section we just prepare data
|
1462
|
+
for(let columnIndex = 0; columnIndex < columnLength; columnIndex++) {
|
1463
|
+
let columnData = t._getColumnData(columnIndex, grid);
|
1464
|
+
inCellCache = columnData && columnData["inCellCache"];
|
1465
|
+
|
1466
|
+
// if not have inCellCache then this column not have editor
|
1467
|
+
if(!inCellCache) { continue; }
|
1468
|
+
|
1469
|
+
inCellCache.columnIndex = columnIndex;
|
1470
|
+
inCellCaches.push(inCellCache);
|
1471
|
+
|
1472
|
+
if(isCommit) {
|
1473
|
+
let field = t._getField(columnIndex);
|
1474
|
+
inCellCache.field = field;
|
1475
|
+
fieldValue[field] = this._getValue(inCellCache["inputElement"]);
|
1476
|
+
}
|
1477
|
+
}
|
1478
|
+
|
1479
|
+
let length = inCellCaches.length;
|
1480
|
+
let i, e;
|
1481
|
+
|
1482
|
+
// dispatch event beforeRowCommit
|
1483
|
+
if(isCommit) {
|
1484
|
+
if(t.hasListener("beforeRowCommit")) {
|
1485
|
+
e = {
|
1486
|
+
grid: grid,
|
1487
|
+
rowIndex: rowIndex,
|
1488
|
+
fieldValue: fieldValue,
|
1489
|
+
cancel: false,
|
1490
|
+
rowId: t._activeRowId
|
1491
|
+
};
|
1492
|
+
t._dispatch("beforeRowCommit", e);
|
1493
|
+
// e.cancel = true mean user want to cancel closeRowEditor operation
|
1494
|
+
isCommit = !e.cancel;
|
1495
|
+
}
|
1496
|
+
|
1497
|
+
if(isCommit) {
|
1498
|
+
let dataSource = grid.getDataSource();
|
1499
|
+
for(i = 0; i < length; i++) {
|
1500
|
+
inCellCache = inCellCaches[i];
|
1501
|
+
let value = fieldValue[inCellCache.field];
|
1502
|
+
// set data to datasource
|
1503
|
+
if(dataSource) {
|
1504
|
+
// only use value from fieldValue
|
1505
|
+
// because fieldValue maybe mutate from beforeRowCommit event
|
1506
|
+
t._setData(dataSource, rowIndex, inCellCache.field, value);
|
1507
|
+
}
|
1508
|
+
|
1509
|
+
// set value to ui if content is a build in text
|
1510
|
+
let cell = section.getCell(inCellCache.columnIndex, rowIndex);
|
1511
|
+
let content = cell.getContent();
|
1512
|
+
if(content && content.classList.contains("text")) {
|
1513
|
+
cell.setContent(value);
|
1514
|
+
}
|
1515
|
+
}
|
1516
|
+
}
|
1517
|
+
}
|
1518
|
+
|
1519
|
+
if(t.hasListener("rowEditorClosed")) {
|
1520
|
+
e = {
|
1521
|
+
grid: grid,
|
1522
|
+
rowIndex: rowIndex,
|
1523
|
+
fieldValue: fieldValue,
|
1524
|
+
committed: isCommit
|
1525
|
+
};
|
1526
|
+
t._dispatch("rowEditorClosed", e);
|
1527
|
+
}
|
1528
|
+
|
1529
|
+
// hide editor by remove popup from dom
|
1530
|
+
for(i = 0; i < length; i++) {
|
1531
|
+
let popup = inCellCaches[i].balloonPopup;
|
1532
|
+
popup.removeEventListener("hidden", t._onPopupHide); // remove event every popup to make sure nothing left
|
1533
|
+
popup.hide();
|
1534
|
+
}
|
1535
|
+
|
1536
|
+
t._freezeScrolling(grid, false);
|
1537
|
+
|
1538
|
+
// reset status and resource
|
1539
|
+
section.removeClass("edit-mode");
|
1540
|
+
t._editing = false;
|
1541
|
+
t._activeRowId = "";
|
1542
|
+
t._lastActiveGrid = null;
|
1543
|
+
grid.focus();
|
1434
1544
|
};
|
1435
1545
|
|
1436
1546
|
/** open row editor if no any row editor opened, and close row editor if it already opened
|
@@ -1442,14 +1552,14 @@ InCellEditingPlugin.prototype.closeRowEditor = function (isCommit) {
|
|
1442
1552
|
* @fires InCellEditingPlugin#rowEditorClosed
|
1443
1553
|
*/
|
1444
1554
|
InCellEditingPlugin.prototype.toggleRowEditor = function (rowIndex, isCommit, grid) {
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1555
|
+
if(this._getRowIndex(this._activeRowId) === rowIndex) {
|
1556
|
+
this.closeRowEditor(isCommit, grid);
|
1557
|
+
} else if(this._activeRowId) {
|
1558
|
+
this.closeRowEditor(isCommit, grid);
|
1559
|
+
this.openRowEditor(rowIndex, grid);
|
1560
|
+
} else {
|
1561
|
+
this.openRowEditor(rowIndex, grid);
|
1562
|
+
}
|
1453
1563
|
};
|
1454
1564
|
|
1455
1565
|
/** handle grid scrolling not window scroll
|
@@ -1457,30 +1567,31 @@ InCellEditingPlugin.prototype.toggleRowEditor = function (rowIndex, isCommit, gr
|
|
1457
1567
|
* @param {Object} e
|
1458
1568
|
*/
|
1459
1569
|
InCellEditingPlugin.prototype._onScroll = function (e) {
|
1460
|
-
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
1483
|
-
|
1570
|
+
this._scrolling = true;
|
1571
|
+
if(!this._closingOnScroll && this._editing){
|
1572
|
+
if(this._activeInCellCache){
|
1573
|
+
let popup = this._activeInCellCache.balloonPopup;
|
1574
|
+
popup.hide();
|
1575
|
+
}
|
1576
|
+
else if(this._activeRowId){
|
1577
|
+
let grid = this.getActiveGrid() || this._lastActiveGrid;
|
1578
|
+
let section = grid.getSection("content");
|
1579
|
+
let lastIndex = (section.getColumnCount() || 0) - 1;
|
1580
|
+
for(let columnIndex = 0; columnIndex <= lastIndex; columnIndex++) {
|
1581
|
+
let columnData = this._getColumnData(columnIndex, grid);
|
1582
|
+
let inCellCache = columnData["inCellCache"];
|
1583
|
+
if(!inCellCache){
|
1584
|
+
continue;
|
1585
|
+
}
|
1586
|
+
let popupCache = inCellCache["balloonPopup"];
|
1587
|
+
if(popupCache) {
|
1588
|
+
popupCache.hide();
|
1589
|
+
}
|
1590
|
+
}
|
1591
|
+
}
|
1592
|
+
}
|
1593
|
+
this._onPopupHide();
|
1594
|
+
this._scrolling = false;
|
1484
1595
|
};
|
1485
1596
|
|
1486
1597
|
/** handle popup hidden event
|
@@ -1488,152 +1599,157 @@ InCellEditingPlugin.prototype._onScroll = function (e) {
|
|
1488
1599
|
* @param {Object} e
|
1489
1600
|
*/
|
1490
1601
|
InCellEditingPlugin.prototype._onPopupHide = function (e) {
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1602
|
+
if(!this._closingOnScroll){
|
1603
|
+
if(this._scrolling){
|
1604
|
+
this.requestShowEditorPopup();
|
1605
|
+
return;
|
1606
|
+
}
|
1607
|
+
}
|
1608
|
+
// in cell editing mode, when popup hide for any reason
|
1609
|
+
// cell editing will be close and make a commit. (depend on _autoCommitText flag)
|
1610
|
+
// WARNING: when user scroll outside grid. it will call _onPopupHide as well
|
1611
|
+
this._commitText(this._autoCommitText);
|
1612
|
+
|
1613
|
+
// for row editing mode if editor hide by any reason
|
1614
|
+
// we will call close closeRowEditor to reset all internal flag status
|
1615
|
+
// row editing mode not care about _autoCommitText. (for the time being)
|
1616
|
+
this.closeRowEditor(false);
|
1506
1617
|
};
|
1507
1618
|
|
1508
1619
|
/** @private
|
1509
1620
|
* @param {Object} event
|
1510
1621
|
*/
|
1511
|
-
InCellEditingPlugin.prototype._onAutoSuggestItemSelected = function
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1622
|
+
InCellEditingPlugin.prototype._onAutoSuggestItemSelected = function(event) {
|
1623
|
+
let eventDetail = event.detail;
|
1624
|
+
if(!eventDetail) {
|
1625
|
+
return;
|
1626
|
+
}
|
1627
|
+
|
1628
|
+
let targetSelected = eventDetail.target;
|
1629
|
+
|
1630
|
+
if(!targetSelected) {
|
1631
|
+
return;
|
1632
|
+
}
|
1633
|
+
|
1634
|
+
let suggestionMethod = eventDetail.method;
|
1635
|
+
// Need to check the details of the methods, another method like a navigation, reset, clear shouldn't commit text
|
1636
|
+
// TODO: We need to handled tab to move. Currently, the property suggestionDetail in 'beforeCommit' event doesn't handlded when we use autosuggest with tab to move.
|
1637
|
+
if(suggestionMethod === "click" || suggestionMethod === "enter") {
|
1638
|
+
this.setText(targetSelected.value);
|
1639
|
+
this._commitText(true, eventDetail.suggestion);
|
1640
|
+
}
|
1527
1641
|
};
|
1528
1642
|
|
1529
1643
|
/** @private
|
1530
1644
|
* @param {Object} e
|
1531
1645
|
*/
|
1532
1646
|
InCellEditingPlugin.prototype._onValueChanged = function (e) {
|
1533
|
-
|
1534
|
-
return;
|
1535
|
-
} // do nothing in rowEditMode
|
1647
|
+
if(this._activeRowId) { return; } // do nothing in rowEditMode
|
1536
1648
|
|
1537
|
-
|
1649
|
+
this._commitText(true);
|
1538
1650
|
};
|
1539
1651
|
/** @private
|
1540
1652
|
* @param {Object} e
|
1541
1653
|
*/
|
1542
1654
|
InCellEditingPlugin.prototype._onMultiSelectionValueChanged = function (e) {
|
1543
|
-
|
1655
|
+
e.currentTarget.dirty = true;
|
1544
1656
|
};
|
1545
1657
|
/** @private
|
1546
1658
|
* @param {Object} e
|
1547
1659
|
*/
|
1548
1660
|
InCellEditingPlugin.prototype._onMultiSelectionEditorChanged = function (e) {
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1661
|
+
if(e.detail && e.detail.value === false){
|
1662
|
+
if(this._activePos){
|
1663
|
+
let inputElement = this._activePos["inputElement"];
|
1664
|
+
if(inputElement.dirty){
|
1665
|
+
this._onValueChanged(e);
|
1666
|
+
inputElement.dirty = false;
|
1667
|
+
}
|
1668
|
+
}
|
1669
|
+
}
|
1558
1670
|
};
|
1559
1671
|
|
1560
1672
|
/** @private
|
1561
1673
|
* @param {Object} e
|
1562
1674
|
*/
|
1563
1675
|
InCellEditingPlugin.prototype._onTextKeyDown = function (e) {
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
|
1580
|
-
|
1581
|
-
}
|
1676
|
+
e.stopPropagation();
|
1677
|
+
|
1678
|
+
if(this._activeRowId) { return; } // do nothing in rowEditMode
|
1679
|
+
|
1680
|
+
// KeyCodes.ESC = 27
|
1681
|
+
if(e.keyCode === 27) {
|
1682
|
+
this._commitText(this._autoCommitText);
|
1683
|
+
}
|
1684
|
+
// KeyCodes.TAB = 9
|
1685
|
+
if(e.keyCode === 9) {
|
1686
|
+
// For check press tab key when user tab on auto suggest list
|
1687
|
+
// When user tab on auto suggest, the focus should be in input and data doesn't commit
|
1688
|
+
if(this._autoSuggest && this._autoSuggest.suggestions.length > 0) {
|
1689
|
+
this._activeInCellCache.inputElement.focus();
|
1690
|
+
}
|
1691
|
+
e.preventDefault(); // stop losing focus
|
1692
|
+
}
|
1582
1693
|
};
|
1583
1694
|
|
1584
1695
|
/** @private
|
1585
1696
|
* @param {Object} e
|
1586
1697
|
*/
|
1587
1698
|
InCellEditingPlugin.prototype._onTextKeyUp = function (e) {
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1593
|
-
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
|
1624
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
1628
|
-
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1699
|
+
e.stopPropagation();
|
1700
|
+
|
1701
|
+
if(this._activeRowId) { return; } // do nothing in rowEditMode
|
1702
|
+
|
1703
|
+
if(this.hasListener("keyUp")) {
|
1704
|
+
this._activePos["text"] = this._activePos["enteredText"] = this._activeInCellCache["inputElement"].value;
|
1705
|
+
this._dispatch("keyUp", this._activePos);
|
1706
|
+
}
|
1707
|
+
|
1708
|
+
// KeyCodes.ENTER = 13 && KeyCodes.TAB = 9
|
1709
|
+
let tabKey = e.keyCode === 9;
|
1710
|
+
if(tabKey || e.keyCode === 13) {
|
1711
|
+
let text = this.getText();
|
1712
|
+
let cellInfo = this._activePos;
|
1713
|
+
|
1714
|
+
if(this._initialText !== text) {
|
1715
|
+
e.preventDefault(); // TODO: Check if this is needed
|
1716
|
+
// Clear auto suggest and doesn't commit when user tab on auto suggest item
|
1717
|
+
if(this._autoSuggest && this._autoSuggest.suggestions.length > 0) {
|
1718
|
+
this._activeInCellCache.inputElement.focus();
|
1719
|
+
this._autoSuggest.suggestions = [];
|
1720
|
+
return; // when use tabToMove with auto suggest, it shouldn't be effect when doesn't commit text
|
1721
|
+
} else {
|
1722
|
+
this._commitText(true);
|
1723
|
+
}
|
1724
|
+
} else {
|
1725
|
+
this._commitText(false);
|
1726
|
+
}
|
1727
|
+
|
1728
|
+
if(tabKey && this._tabToMove && !e.altKey && !e.ctrlKey) {
|
1729
|
+
let host = cellInfo ? cellInfo["grid"] : null;
|
1730
|
+
if(host && host["getCellInfo"]) {
|
1731
|
+
let dv = host.getDataSource();
|
1732
|
+
while (cellInfo) {
|
1733
|
+
cellInfo = (e.shiftKey) ? host.getPrevCell(cellInfo) : host.getNextCell(cellInfo);
|
1734
|
+
if(cellInfo && cellInfo["cell"]) {
|
1735
|
+
if(dv.getRowDataAt(cellInfo["rowIndex"])) { // Check group header row
|
1736
|
+
if(this.isColumnEditable(cellInfo["colIndex"])) {
|
1737
|
+
this.openEditor(
|
1738
|
+
cellInfo["colIndex"],
|
1739
|
+
cellInfo["rowIndex"],
|
1740
|
+
cellInfo["sectionName"],
|
1741
|
+
cellInfo["grid"]
|
1742
|
+
);
|
1743
|
+
break;
|
1744
|
+
}
|
1745
|
+
}
|
1746
|
+
} else {
|
1747
|
+
cellInfo = null;
|
1748
|
+
}
|
1749
|
+
}
|
1750
|
+
}
|
1751
|
+
}
|
1752
|
+
}
|
1637
1753
|
};
|
1638
1754
|
/** Commit text from editor to cell.
|
1639
1755
|
* @private
|
@@ -1641,97 +1757,103 @@ InCellEditingPlugin.prototype._onTextKeyUp = function (e) {
|
|
1641
1757
|
* @param {Object} suggestionDetail suggestion detail for auto suggest element
|
1642
1758
|
*/
|
1643
1759
|
InCellEditingPlugin.prototype._commitText = function (committed, suggestionDetail) {
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
1653
|
-
|
1654
|
-
|
1655
|
-
|
1656
|
-
|
1657
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
1697
|
-
|
1698
|
-
|
1699
|
-
|
1700
|
-
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1715
|
-
|
1716
|
-
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1760
|
+
let t = this;
|
1761
|
+
let arg = t._activePos;
|
1762
|
+
if(!t.isEditing() || !arg) {
|
1763
|
+
return;
|
1764
|
+
}
|
1765
|
+
|
1766
|
+
arg["section"].removeClass("edit-mode");
|
1767
|
+
t._editing = false;
|
1768
|
+
|
1769
|
+
let enteredValue = arg["text"] = this.getValue();
|
1770
|
+
let groupHeader = arg["groupHeader"] || false;
|
1771
|
+
|
1772
|
+
if(committed){
|
1773
|
+
if(suggestionDetail) { // This property is only available when the user commits text from the 'item-select' event of the auto suggest.
|
1774
|
+
arg["suggestionDetail"] = suggestionDetail;
|
1775
|
+
}
|
1776
|
+
if(t.hasListener("beforeCommit")) {
|
1777
|
+
t._dispatch("beforeCommit", arg);
|
1778
|
+
committed = !arg["cancel"];
|
1779
|
+
enteredValue = arg["text"];
|
1780
|
+
}
|
1781
|
+
|
1782
|
+
if(committed && t._dataBinding && !groupHeader) {
|
1783
|
+
let sectionSettings = arg["sectionSettings"];
|
1784
|
+
let sectionType = sectionSettings.getType();
|
1785
|
+
// case edit content
|
1786
|
+
if("content" === sectionType) {
|
1787
|
+
if(this._realTimeGrid && arg["field"] === "X_RIC_NAME") {
|
1788
|
+
let ricOpt = null;
|
1789
|
+
if(suggestionDetail) {
|
1790
|
+
let suggestionVal = suggestionDetail["value"];
|
1791
|
+
if(suggestionVal["p"]) {
|
1792
|
+
let permId = suggestionVal["p"]["PermId"];
|
1793
|
+
if(permId) {
|
1794
|
+
ricOpt = { permId: permId };
|
1795
|
+
}
|
1796
|
+
}
|
1797
|
+
}
|
1798
|
+
|
1799
|
+
this._realTimeGrid.setRic(arg["rowId"], enteredValue, ricOpt);
|
1800
|
+
} else {
|
1801
|
+
let dv = sectionSettings.getDataSource();
|
1802
|
+
if(dv) {
|
1803
|
+
if(this._realTimeGrid) {
|
1804
|
+
t._setStaticData(dv, arg["rowIndex"], arg["field"], enteredValue);
|
1805
|
+
} else {
|
1806
|
+
t._setData(dv, arg["rowIndex"], arg["field"], enteredValue);
|
1807
|
+
}
|
1808
|
+
}
|
1809
|
+
}
|
1810
|
+
|
1811
|
+
if(!t._prevContent || t._prevContent.classList.contains("text")) { // Bind data only if previous content is a build in text
|
1812
|
+
t._activeCell.setContent(enteredValue);
|
1813
|
+
}
|
1814
|
+
} else if("title" === sectionType) {
|
1815
|
+
let gridApi = this.getGridApi();
|
1816
|
+
if(gridApi) {
|
1817
|
+
gridApi.setColumnName(arg["colIndex"], enteredValue);
|
1818
|
+
}
|
1819
|
+
} else {
|
1820
|
+
t._activeCell.setContent(enteredValue);
|
1821
|
+
}
|
1822
|
+
}
|
1823
|
+
}
|
1824
|
+
|
1825
|
+
if(t.hasListener("editorClosed")) {
|
1826
|
+
arg["canceled"] = arg["cancelled"] = !committed;
|
1827
|
+
arg["committed"] = committed;
|
1828
|
+
t._dispatch("editorClosed", arg);
|
1829
|
+
}
|
1830
|
+
|
1831
|
+
if(t._activeInCellCache && t._activeInCellCache.balloonPopup) {
|
1832
|
+
t._activeInCellCache.balloonPopup.removeEventListener("hidden", t._onPopupHide);
|
1833
|
+
t._activeInCellCache.balloonPopup.hide();
|
1834
|
+
}
|
1835
|
+
Dom.removeParent(t._customElement);
|
1836
|
+
|
1837
|
+
let grid = arg["grid"];
|
1838
|
+
if(grid) {
|
1839
|
+
t._freezeScrolling(grid, false);
|
1840
|
+
grid.focus();
|
1841
|
+
}
|
1842
|
+
let dataSource = arg["dataSource"];
|
1843
|
+
if(dataSource) {
|
1844
|
+
if(dataSource["stall"]) {
|
1845
|
+
dataSource["stall"](false);
|
1846
|
+
}
|
1847
|
+
}
|
1848
|
+
|
1849
|
+
t._activePos = t._activeCell = t._prevContent = t._lastActiveGrid = t._activeInCellCache = null;
|
1728
1850
|
};
|
1729
1851
|
|
1730
1852
|
/** @private
|
1731
1853
|
* @param {Event} e
|
1732
1854
|
*/
|
1733
1855
|
InCellEditingPlugin.prototype._stopPropagation = function (e) {
|
1734
|
-
|
1856
|
+
e.stopPropagation();
|
1735
1857
|
};
|
1736
1858
|
|
1737
1859
|
/** Using for Check balloon mode is turn on/off.
|
@@ -1740,9 +1862,10 @@ InCellEditingPlugin.prototype._stopPropagation = function (e) {
|
|
1740
1862
|
* @return {boolean}
|
1741
1863
|
*/
|
1742
1864
|
InCellEditingPlugin.prototype._isBalloonMode = function (cell) {
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
1865
|
+
let cellElem = cell.getElement();
|
1866
|
+
let compStyles = (cellElem) ? window.getComputedStyle(cellElem) : {};
|
1867
|
+
|
1868
|
+
return (this._balloonMode || compStyles.display === "none" || compStyles.visibility === "hidden");
|
1746
1869
|
};
|
1747
1870
|
|
1748
1871
|
/** @private
|
@@ -1750,30 +1873,31 @@ InCellEditingPlugin.prototype._isBalloonMode = function (cell) {
|
|
1750
1873
|
* @param {boolean} bool
|
1751
1874
|
*/
|
1752
1875
|
InCellEditingPlugin.prototype._listenForTriggering = function (host, bool) {
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
1762
|
-
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1876
|
+
if(bool) {
|
1877
|
+
host.listen("dblclick", this._onDoubleClick);
|
1878
|
+
|
1879
|
+
// Make a comparable functionality for touchscreen
|
1880
|
+
if(isTouchDevice()) {
|
1881
|
+
host.listen("touchstart", this._onTouchStart);
|
1882
|
+
host.listen("touchend", this._onTouchEnd);
|
1883
|
+
host.listen("touchcancel", this._onTouchEnd);
|
1884
|
+
}
|
1885
|
+
} else {
|
1886
|
+
host.unlisten("dblclick", this._onDoubleClick);
|
1887
|
+
host.unlisten("touchstart", this._onTouchStart);
|
1888
|
+
host.unlisten("touchend", this._onTouchEnd);
|
1889
|
+
host.unlisten("touchcancel", this._onTouchEnd);
|
1890
|
+
}
|
1768
1891
|
};
|
1769
1892
|
|
1893
|
+
|
1770
1894
|
/** Use only On-Touch-Start event on mobile devices.
|
1771
1895
|
* @private
|
1772
1896
|
* @param {Object} e
|
1773
1897
|
*/
|
1774
1898
|
InCellEditingPlugin.prototype._onTouchStart = function (e) {
|
1775
|
-
|
1776
|
-
|
1899
|
+
this._resetTouchTimer();
|
1900
|
+
this._touchTimerId = setTimeout(this._onTouchTimer, this._longPressTime);
|
1777
1901
|
};
|
1778
1902
|
|
1779
1903
|
/** Use only press time on mobile devices.
|
@@ -1781,7 +1905,7 @@ InCellEditingPlugin.prototype._onTouchStart = function (e) {
|
|
1781
1905
|
* @param {Object} e
|
1782
1906
|
*/
|
1783
1907
|
InCellEditingPlugin.prototype._onTouchTimer = function (e) {
|
1784
|
-
|
1908
|
+
this._touchTimerId = 0;
|
1785
1909
|
};
|
1786
1910
|
|
1787
1911
|
/** Use only On-Touch-End event on mobile devices.
|
@@ -1789,9 +1913,9 @@ InCellEditingPlugin.prototype._onTouchTimer = function (e) {
|
|
1789
1913
|
* @param {Event} e
|
1790
1914
|
*/
|
1791
1915
|
InCellEditingPlugin.prototype._onTouchEnd = function (e) {
|
1792
|
-
|
1793
|
-
|
1794
|
-
|
1916
|
+
if(!this._resetTouchTimer()) {
|
1917
|
+
this._onDoubleClick(e); // Trigger cell editor
|
1918
|
+
}
|
1795
1919
|
};
|
1796
1920
|
|
1797
1921
|
/** Use only to reset timer on mobile devices.
|
@@ -1799,12 +1923,12 @@ InCellEditingPlugin.prototype._onTouchEnd = function (e) {
|
|
1799
1923
|
* @return {boolean}
|
1800
1924
|
*/
|
1801
1925
|
InCellEditingPlugin.prototype._resetTouchTimer = function () {
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
1805
|
-
|
1806
|
-
|
1807
|
-
|
1926
|
+
if(this._touchTimerId) {
|
1927
|
+
clearTimeout(this._touchTimerId);
|
1928
|
+
this._touchTimerId = 0;
|
1929
|
+
return true;
|
1930
|
+
}
|
1931
|
+
return false;
|
1808
1932
|
};
|
1809
1933
|
|
1810
1934
|
/** Set other elements to using like popup when editing cell.
|
@@ -1812,17 +1936,19 @@ InCellEditingPlugin.prototype._resetTouchTimer = function () {
|
|
1812
1936
|
* @param {Element} elm
|
1813
1937
|
*/
|
1814
1938
|
InCellEditingPlugin.prototype.setPopupElement = function (elm) {
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
1818
|
-
|
1819
|
-
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
1823
|
-
|
1824
|
-
|
1825
|
-
|
1939
|
+
let balloonPopup = this._activeInCellCache && this._activeInCellCache["balloonPopup"];
|
1940
|
+
if(this._customElement) {
|
1941
|
+
balloonPopup && balloonPopup.removeFocusElement(this._customElement);
|
1942
|
+
this._customElementPopup.dispose();
|
1943
|
+
this._customElementPopup = null;
|
1944
|
+
}
|
1945
|
+
|
1946
|
+
this._customElement = elm;
|
1947
|
+
|
1948
|
+
if(this._customElement) {
|
1949
|
+
this._customElementPopup = new Popup(this._customElement);
|
1950
|
+
balloonPopup && balloonPopup.addFocusElement(this._customElement);
|
1951
|
+
}
|
1826
1952
|
};
|
1827
1953
|
|
1828
1954
|
/** Set content to the editor but do not commit anything to internal storage.
|
@@ -1830,9 +1956,9 @@ InCellEditingPlugin.prototype.setPopupElement = function (elm) {
|
|
1830
1956
|
* @param {*} content
|
1831
1957
|
*/
|
1832
1958
|
InCellEditingPlugin.prototype.setText = function (content) {
|
1833
|
-
|
1834
|
-
|
1835
|
-
|
1959
|
+
// TODO: since we have inputElement per each column
|
1960
|
+
// we should receive column index to set value in specific column
|
1961
|
+
this._activeInCellCache && this._setText(content, this._activeInCellCache["inputElement"]);
|
1836
1962
|
};
|
1837
1963
|
|
1838
1964
|
/** @private
|
@@ -1840,43 +1966,41 @@ InCellEditingPlugin.prototype.setText = function (content) {
|
|
1840
1966
|
* @param {Element} inputElement editor element
|
1841
1967
|
*/
|
1842
1968
|
InCellEditingPlugin.prototype._setText = function (content, inputElement) {
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1859
|
-
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
|
1864
|
-
|
1865
|
-
|
1866
|
-
|
1867
|
-
|
1868
|
-
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
|
1873
|
-
|
1874
|
-
|
1875
|
-
|
1876
|
-
|
1877
|
-
|
1878
|
-
inputElement.value = txt;
|
1879
|
-
}
|
1969
|
+
inputElement._origValue = content;
|
1970
|
+
|
1971
|
+
let inputTag = inputElement.tagName.toLowerCase();
|
1972
|
+
let typeMap = InCellEditingPlugin._uiElementTypesMap;
|
1973
|
+
if(inputTag === typeMap.checkbox) {
|
1974
|
+
let checked = (content) ? !(content === "f" || content === "false") : false;
|
1975
|
+
if(checked) {
|
1976
|
+
inputElement.setAttribute("checked", "true");
|
1977
|
+
} else {
|
1978
|
+
inputElement.removeAttribute("checked");
|
1979
|
+
}
|
1980
|
+
} else if(inputTag === typeMap.combobox) {
|
1981
|
+
let isMultiple = inputElement.getAttribute("multiple");
|
1982
|
+
|
1983
|
+
if(isMultiple){
|
1984
|
+
inputElement.values = content.split(/, */);
|
1985
|
+
} else if(this._elfVersion <= 3) {
|
1986
|
+
inputElement.value = "";
|
1987
|
+
inputElement.value = { value: content, label: content };
|
1988
|
+
} else {
|
1989
|
+
inputElement.value = content;
|
1990
|
+
}
|
1991
|
+
} else if(inputTag === typeMap.date) {
|
1992
|
+
ElfDate.setDate(inputElement, content);
|
1993
|
+
} else {
|
1994
|
+
let txt = "";
|
1995
|
+
if(content != null) {
|
1996
|
+
if(typeof content === "string") {
|
1997
|
+
txt = content;
|
1998
|
+
} else { // content could be false, 0, NaN or etc.
|
1999
|
+
txt = content + "";
|
2000
|
+
}
|
2001
|
+
}
|
2002
|
+
inputElement.value = txt;
|
2003
|
+
}
|
1880
2004
|
};
|
1881
2005
|
|
1882
2006
|
/** Get current text from the editor
|
@@ -1885,9 +2009,12 @@ InCellEditingPlugin.prototype._setText = function (content, inputElement) {
|
|
1885
2009
|
* @see {@link InCellEditingPlugin#getValue}
|
1886
2010
|
*/
|
1887
2011
|
InCellEditingPlugin.prototype.getText = function () {
|
1888
|
-
|
1889
|
-
|
1890
|
-
|
2012
|
+
// TODO: since we have inputElement per each column
|
2013
|
+
// we should receive column index to return text of inputElement in specific column
|
2014
|
+
if(this._activeInCellCache)
|
2015
|
+
return this._getText(this._activeInCellCache["inputElement"]);
|
2016
|
+
else
|
2017
|
+
return "";
|
1891
2018
|
};
|
1892
2019
|
|
1893
2020
|
/** @private
|
@@ -1895,18 +2022,18 @@ InCellEditingPlugin.prototype.getText = function () {
|
|
1895
2022
|
* @return {string}
|
1896
2023
|
*/
|
1897
2024
|
InCellEditingPlugin.prototype._getText = function (inputElement) {
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
2025
|
+
let inputTag = inputElement.tagName.toLowerCase();
|
2026
|
+
let typeMap = InCellEditingPlugin._uiElementTypesMap;
|
2027
|
+
if(inputTag === typeMap.checkbox) {
|
2028
|
+
return inputElement.checked + "";
|
2029
|
+
} else if(inputTag === typeMap.combobox) {
|
2030
|
+
if(this._elfVersion <= 3) {
|
2031
|
+
return inputElement.value ? inputElement.value.value : "";
|
2032
|
+
}
|
2033
|
+
} else if(inputTag === typeMap.date) {
|
2034
|
+
return inputElement.value + "";
|
2035
|
+
}
|
2036
|
+
return inputElement.value;
|
1910
2037
|
};
|
1911
2038
|
|
1912
2039
|
/** Convert current text from the editor to value corresponding to the type of the editor
|
@@ -1915,9 +2042,9 @@ InCellEditingPlugin.prototype._getText = function (inputElement) {
|
|
1915
2042
|
* @see {@link InCellEditingPlugin#getText}
|
1916
2043
|
*/
|
1917
2044
|
InCellEditingPlugin.prototype.getValue = function () {
|
1918
|
-
|
1919
|
-
|
1920
|
-
|
2045
|
+
// TODO: since we have inputElement per each column
|
2046
|
+
// we should receive column index to return value of inputElement in specific column
|
2047
|
+
return this._activeInCellCache ? this._getValue(this._activeInCellCache["inputElement"]) : null;
|
1921
2048
|
};
|
1922
2049
|
|
1923
2050
|
/** @private
|
@@ -1925,26 +2052,29 @@ InCellEditingPlugin.prototype.getValue = function () {
|
|
1925
2052
|
* @return {*} Returned type is based on the type of the editor
|
1926
2053
|
*/
|
1927
2054
|
InCellEditingPlugin.prototype._getValue = function (inputElement) {
|
1928
|
-
|
1929
|
-
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
|
1936
|
-
|
1937
|
-
|
1938
|
-
|
1939
|
-
|
1940
|
-
|
2055
|
+
let inputTag = inputElement.tagName.toLowerCase();
|
2056
|
+
let typeMap = InCellEditingPlugin._uiElementTypesMap;
|
2057
|
+
if(inputTag === typeMap.checkbox) {
|
2058
|
+
return inputElement.checked ? true : false;
|
2059
|
+
} else if(inputTag === typeMap.date) {
|
2060
|
+
return ElfDate.getDate(inputElement);
|
2061
|
+
} else if(
|
2062
|
+
inputTag === typeMap.number ||
|
2063
|
+
typeof inputElement._origValue === "number" // Smart data conversion based orignal value
|
2064
|
+
) {
|
2065
|
+
return +inputElement.value;
|
2066
|
+
} else if(inputTag === typeMap.combobox && inputElement.getAttribute("multiple")) {
|
2067
|
+
return inputElement.values.join(", ");
|
2068
|
+
}
|
2069
|
+
|
2070
|
+
return this._getText(inputElement);
|
1941
2071
|
};
|
1942
2072
|
|
1943
2073
|
/** Use to clear text in text editor.
|
1944
2074
|
* @public
|
1945
2075
|
*/
|
1946
2076
|
InCellEditingPlugin.prototype.clearText = function () {
|
1947
|
-
|
2077
|
+
this.setText("");
|
1948
2078
|
};
|
1949
2079
|
|
1950
2080
|
/** Use to append text in text editor. WARNING: Only works with the text type editor
|
@@ -1952,11 +2082,11 @@ InCellEditingPlugin.prototype.clearText = function () {
|
|
1952
2082
|
* @param {string} word
|
1953
2083
|
*/
|
1954
2084
|
InCellEditingPlugin.prototype.appendText = function (word) {
|
1955
|
-
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
2085
|
+
// TODO: since we have inputElement per each column
|
2086
|
+
// we should receive column index to return append text in specific column
|
2087
|
+
if(word && this._activeInCellCache) {
|
2088
|
+
this._activeInCellCache["inputElement"].value += word;
|
2089
|
+
}
|
1960
2090
|
};
|
1961
2091
|
|
1962
2092
|
/** Commit text will set text and commit to cell.
|
@@ -1964,10 +2094,10 @@ InCellEditingPlugin.prototype.appendText = function (word) {
|
|
1964
2094
|
* @param {string=} word
|
1965
2095
|
*/
|
1966
2096
|
InCellEditingPlugin.prototype.commitText = function (word) {
|
1967
|
-
|
1968
|
-
|
1969
|
-
|
1970
|
-
|
2097
|
+
if(word) {
|
2098
|
+
this.setText(word);
|
2099
|
+
}
|
2100
|
+
this._commitText(true);
|
1971
2101
|
};
|
1972
2102
|
|
1973
2103
|
/** Get Balloon Popup Element to access any API provided.
|
@@ -1975,9 +2105,9 @@ InCellEditingPlugin.prototype.commitText = function (word) {
|
|
1975
2105
|
* @return {Popup|null}
|
1976
2106
|
*/
|
1977
2107
|
InCellEditingPlugin.prototype.getBalloonPopup = function () {
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
2108
|
+
// TODO: since we have balloonPopup per each column
|
2109
|
+
// we should receive column index to return balloonPopup in specific column
|
2110
|
+
return this._activeInCellCache ? this._activeInCellCache["balloonPopup"] : null;
|
1981
2111
|
};
|
1982
2112
|
|
1983
2113
|
/** Get ef-autosuggest or atlas-autosuggest
|
@@ -1985,7 +2115,7 @@ InCellEditingPlugin.prototype.getBalloonPopup = function () {
|
|
1985
2115
|
* @return {Element}
|
1986
2116
|
*/
|
1987
2117
|
InCellEditingPlugin.prototype.getAutoSuggest = function () {
|
1988
|
-
|
2118
|
+
return this._autoSuggest;
|
1989
2119
|
};
|
1990
2120
|
|
1991
2121
|
/**
|
@@ -1994,9 +2124,9 @@ InCellEditingPlugin.prototype.getAutoSuggest = function () {
|
|
1994
2124
|
* @return {boolean} previous disablingScroll status
|
1995
2125
|
*/
|
1996
2126
|
InCellEditingPlugin.prototype.setDisablingScroll = function (disabled) {
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
2127
|
+
let prev = disabled;
|
2128
|
+
this._disablingScroll = disabled;
|
2129
|
+
return prev;
|
2000
2130
|
};
|
2001
2131
|
|
2002
2132
|
/** stop scrolling to move to prevent editor close
|
@@ -2005,71 +2135,77 @@ InCellEditingPlugin.prototype.setDisablingScroll = function (disabled) {
|
|
2005
2135
|
* @param {boolean=} frozen
|
2006
2136
|
*/
|
2007
2137
|
InCellEditingPlugin.prototype._freezeScrolling = function (grid, frozen) {
|
2008
|
-
|
2009
|
-
|
2010
|
-
|
2011
|
-
|
2012
|
-
|
2138
|
+
if(!grid) return;
|
2139
|
+
|
2140
|
+
let vs = grid.getVScrollbar();
|
2141
|
+
let hs = grid.getHScrollbar();
|
2142
|
+
vs && vs.freezeScrolling(frozen);
|
2143
|
+
hs && hs.freezeScrolling(frozen);
|
2013
2144
|
};
|
2014
2145
|
|
2015
2146
|
/** Set a timer to call onUpdateEditorPopup only once to avoid performance issue
|
2016
2147
|
* @public
|
2017
2148
|
*/
|
2018
|
-
InCellEditingPlugin.prototype.requestShowEditorPopup = function
|
2019
|
-
|
2020
|
-
|
2021
|
-
|
2149
|
+
InCellEditingPlugin.prototype.requestShowEditorPopup = function() {
|
2150
|
+
if(!this._editorTimerId) {
|
2151
|
+
this._editorTimerId = setTimeout(this._onUpdateEditorPopup.bind(this), 100);
|
2152
|
+
}
|
2022
2153
|
};
|
2023
2154
|
|
2024
2155
|
/** @private */
|
2025
|
-
InCellEditingPlugin.prototype._onUpdateEditorPopup = function
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
2060
|
-
|
2061
|
-
|
2062
|
-
|
2063
|
-
|
2064
|
-
|
2065
|
-
|
2066
|
-
|
2067
|
-
|
2068
|
-
|
2069
|
-
|
2070
|
-
|
2071
|
-
|
2072
|
-
|
2156
|
+
InCellEditingPlugin.prototype._onUpdateEditorPopup = function() {
|
2157
|
+
this._editorTimerId = 0;
|
2158
|
+
let grid = this.getActiveGrid() || this._lastActiveGrid;
|
2159
|
+
if(!grid){
|
2160
|
+
return;
|
2161
|
+
}
|
2162
|
+
let parentElement = document.body;
|
2163
|
+
if(this._compositeGrid || this._realTimeGrid) {
|
2164
|
+
parentElement = grid.getElement().parentElement;
|
2165
|
+
}
|
2166
|
+
|
2167
|
+
let rowIndex, colIndex;
|
2168
|
+
|
2169
|
+
if(this._activeInCellCache){
|
2170
|
+
let activePos = this._activePos;
|
2171
|
+
if(activePos){
|
2172
|
+
rowIndex = activePos["rowIndex"];
|
2173
|
+
colIndex = activePos["colIndex"];
|
2174
|
+
let section = grid.getSection(activePos["sectionType"]);
|
2175
|
+
let cell = section.getCell(colIndex, rowIndex);
|
2176
|
+
let stretchedCell = section.getStretchedCell(cell, rowIndex);
|
2177
|
+
if(stretchedCell){
|
2178
|
+
cell = stretchedCell;
|
2179
|
+
}
|
2180
|
+
if(cell){
|
2181
|
+
let popup = this._activeInCellCache["balloonPopup"];
|
2182
|
+
popup.attachTo(cell.getElement());
|
2183
|
+
popup.show(true, parentElement);
|
2184
|
+
|
2185
|
+
this._updateEditorPopup(this._activeInCellCache, cell, grid);
|
2186
|
+
}
|
2187
|
+
}
|
2188
|
+
}
|
2189
|
+
else if(this._activeRowId){
|
2190
|
+
let sectionContent = grid.getSection("content");
|
2191
|
+
rowIndex = this._getRowIndex(this._activeRowId);
|
2192
|
+
if(sectionContent.isRowVisible(rowIndex)){
|
2193
|
+
let lastIndex = (sectionContent.getColumnCount() || 0) - 1;
|
2194
|
+
for(let columnIndex = 0; columnIndex <= lastIndex; columnIndex++) {
|
2195
|
+
let columnData = this._getColumnData(columnIndex, grid);
|
2196
|
+
let inCellCache = columnData["inCellCache"];
|
2197
|
+
let cellContent = sectionContent.getCell(columnIndex, rowIndex);
|
2198
|
+
if(!inCellCache || !cellContent){
|
2199
|
+
continue;
|
2200
|
+
}
|
2201
|
+
let popupCache = inCellCache["balloonPopup"];
|
2202
|
+
popupCache.attachTo(cellContent.getElement());
|
2203
|
+
popupCache.show(true, parentElement);
|
2204
|
+
|
2205
|
+
this._updateEditorPopup(inCellCache, cellContent, grid);
|
2206
|
+
}
|
2207
|
+
}
|
2208
|
+
}
|
2073
2209
|
};
|
2074
2210
|
/** Update editor popup position and styles
|
2075
2211
|
* @private
|
@@ -2077,82 +2213,92 @@ InCellEditingPlugin.prototype._onUpdateEditorPopup = function () {
|
|
2077
2213
|
* @param {Object} cell
|
2078
2214
|
* @param {Object} grid grid instance
|
2079
2215
|
*/
|
2080
|
-
InCellEditingPlugin.prototype._updateEditorPopup = function
|
2081
|
-
|
2082
|
-
|
2083
|
-
|
2084
|
-
|
2085
|
-
|
2086
|
-
|
2087
|
-
|
2088
|
-
|
2089
|
-
|
2090
|
-
|
2091
|
-
|
2092
|
-
|
2093
|
-
|
2094
|
-
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2105
|
-
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2110
|
-
|
2111
|
-
|
2112
|
-
|
2113
|
-
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2118
|
-
|
2119
|
-
|
2120
|
-
|
2121
|
-
|
2122
|
-
|
2123
|
-
|
2124
|
-
|
2125
|
-
|
2126
|
-
|
2127
|
-
|
2128
|
-
|
2129
|
-
|
2130
|
-
|
2131
|
-
|
2132
|
-
|
2133
|
-
|
2134
|
-
|
2135
|
-
|
2136
|
-
|
2137
|
-
|
2138
|
-
|
2139
|
-
|
2140
|
-
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2144
|
-
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2150
|
-
|
2151
|
-
|
2152
|
-
|
2153
|
-
|
2154
|
-
|
2155
|
-
|
2216
|
+
InCellEditingPlugin.prototype._updateEditorPopup = function(contentEditor, cell, grid) {
|
2217
|
+
let popup = contentEditor["balloonPopup"];
|
2218
|
+
let editor = contentEditor["editor"];
|
2219
|
+
let inputElement = contentEditor["inputElement"];
|
2220
|
+
let popupElem = popup.getElement();
|
2221
|
+
let pos = grid.getRelativePosition(cell);
|
2222
|
+
let width = cell.getWidth();
|
2223
|
+
let height = cell.getHeight();
|
2224
|
+
let colRect = grid.getColumnRect(0, grid.getColumnCount());
|
2225
|
+
let rowRect = grid.getRowRect(0, grid.getRowCount());
|
2226
|
+
let offsetWidth = colRect.scrollViewSize;
|
2227
|
+
let offsetHeight = rowRect.scrollViewSize;
|
2228
|
+
let offsetLeft = 0;
|
2229
|
+
let offsetTop = pos["sectionType"] == "content" ? rowRect.scrollViewTop : 0;
|
2230
|
+
|
2231
|
+
let newHeight = height;
|
2232
|
+
let newWidth = width;
|
2233
|
+
let displayStyle = "inline-block";
|
2234
|
+
let marginLeft = 0;
|
2235
|
+
let marginTop = 0;
|
2236
|
+
|
2237
|
+
if(colRect.leftPinnedIndex != -1){
|
2238
|
+
let diff = 0;
|
2239
|
+
if(grid.getVScrollbar().isActive()){
|
2240
|
+
diff -= 8; // If column is left pinned, scrollbar width need to be subtracted
|
2241
|
+
}
|
2242
|
+
diff += colRect.width - colRect.scrollViewSize;
|
2243
|
+
offsetWidth += diff;
|
2244
|
+
offsetLeft += diff;
|
2245
|
+
}
|
2246
|
+
|
2247
|
+
if(editor.classList.contains("balloon") && !this._activeRowId){
|
2248
|
+
popupElem.style.display = "";
|
2249
|
+
editor.style.width = "";
|
2250
|
+
editor.style.marginLeft = "";
|
2251
|
+
editor.style.marginTop = "";
|
2252
|
+
marginLeft = -4;
|
2253
|
+
marginTop = -4;
|
2254
|
+
|
2255
|
+
newWidth = popup.getElement().offsetWidth;
|
2256
|
+
}
|
2257
|
+
|
2258
|
+
if(!pos["hit"]){
|
2259
|
+
displayStyle = "none";
|
2260
|
+
} else {
|
2261
|
+
let acquiredWidth = pos["x"] + newWidth;
|
2262
|
+
let acquiredHeight = pos["y"] - offsetTop + newHeight;
|
2263
|
+
|
2264
|
+
let isPinned = grid.isPinnedColumn(pos["colIndex"]);
|
2265
|
+
// if column is pinned, doesn't need to calculate left overflow
|
2266
|
+
if(!isPinned) {
|
2267
|
+
// Left overflow
|
2268
|
+
if(pos["x"] < offsetLeft){
|
2269
|
+
newWidth = (newWidth - (offsetLeft - pos["x"]));
|
2270
|
+
marginLeft = marginLeft + Math.abs(pos["x"] - offsetLeft);
|
2271
|
+
}
|
2272
|
+
}
|
2273
|
+
|
2274
|
+
// Right overflow
|
2275
|
+
if(acquiredWidth > offsetWidth){
|
2276
|
+
newWidth = newWidth - (acquiredWidth - offsetWidth);
|
2277
|
+
}
|
2278
|
+
// Top overflow
|
2279
|
+
if(pos["y"] < offsetTop){
|
2280
|
+
newHeight = (newHeight + pos["y"] - offsetTop);
|
2281
|
+
marginTop = marginTop + Math.abs(pos["y"] - offsetTop);
|
2282
|
+
}
|
2283
|
+
// Bottom overflow
|
2284
|
+
if(acquiredHeight > offsetHeight){
|
2285
|
+
newHeight = newHeight - (acquiredHeight - offsetHeight);
|
2286
|
+
}
|
2287
|
+
|
2288
|
+
if((newWidth < 48 && newWidth != width) || (newHeight < 16 && newHeight != height)){
|
2289
|
+
displayStyle = "none";
|
2290
|
+
}
|
2291
|
+
}
|
2292
|
+
|
2293
|
+
popupElem.style.display = displayStyle;
|
2294
|
+
editor.style.width = newWidth ? newWidth + "px" : "";
|
2295
|
+
editor.style.height = newHeight ? newHeight + "px" : "";
|
2296
|
+
editor.style.marginLeft = marginLeft ? marginLeft + "px" : 0;
|
2297
|
+
editor.style.marginTop = marginTop ? marginTop + "px" : 0;
|
2298
|
+
inputElement.focus();
|
2156
2299
|
};
|
2300
|
+
|
2301
|
+
|
2302
|
+
|
2157
2303
|
export default InCellEditingPlugin;
|
2158
|
-
export { InCellEditingPlugin, InCellEditingPlugin as InCellEditing, InCellEditingPlugin as InCellEditingExtension };
|
2304
|
+
export { InCellEditingPlugin, InCellEditingPlugin as InCellEditing, InCellEditingPlugin as InCellEditingExtension };
|