@sankhyalabs/ezui 0.0.0-bugfix-dev-KB-75609.0 → 0.0.0-bugfix-dev-KB-75609.1
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/dist/cjs/DataBinder-aff1dcc7.js +445 -0
- package/dist/cjs/FocusResolver-885f2173.js +35 -0
- package/dist/cjs/ez-card-item_3.cjs.entry.js +8 -2
- package/dist/cjs/ez-combo-box.cjs.entry.js +46 -10
- package/dist/cjs/ez-date-input.cjs.entry.js +8 -2
- package/dist/cjs/ez-date-time-input.cjs.entry.js +8 -2
- package/dist/cjs/ez-dialog.cjs.entry.js +9 -1
- package/dist/cjs/ez-form.cjs.entry.js +3 -324
- package/dist/cjs/ez-grid.cjs.entry.js +254 -62
- package/dist/cjs/ez-number-input.cjs.entry.js +7 -0
- package/dist/cjs/ez-search.cjs.entry.js +27 -11
- package/dist/cjs/ez-text-area.cjs.entry.js +6 -0
- package/dist/cjs/ez-text-input.cjs.entry.js +7 -1
- package/dist/cjs/ez-time-input.cjs.entry.js +6 -0
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +75 -14
- package/dist/collection/components/ez-date-input/ez-date-input.js +35 -4
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +35 -4
- package/dist/collection/components/ez-dialog/ez-dialog.js +9 -1
- package/dist/collection/components/ez-filter-input/ez-filter-input.js +35 -4
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +52 -14
- package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +3 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +166 -45
- package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js +7 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +4 -1
- package/dist/collection/components/ez-grid/ez-grid.js +83 -1
- package/dist/collection/components/ez-number-input/ez-number-input.js +25 -0
- package/dist/collection/components/ez-search/ez-search.js +54 -13
- package/dist/collection/components/ez-text-area/ez-text-area.js +24 -0
- package/dist/collection/components/ez-text-input/ez-text-input.css +14 -38
- package/dist/collection/components/ez-text-input/ez-text-input.js +24 -0
- package/dist/collection/components/ez-time-input/ez-time-input.js +24 -0
- package/dist/collection/utils/FocusResolver.js +31 -0
- package/dist/collection/utils/form/DataBinder.js +18 -3
- package/dist/custom-elements/index.js +442 -102
- package/dist/esm/DataBinder-bd240826.js +441 -0
- package/dist/esm/FocusResolver-1ccbf850.js +33 -0
- package/dist/esm/ez-card-item_3.entry.js +8 -2
- package/dist/esm/ez-combo-box.entry.js +47 -11
- package/dist/esm/ez-date-input.entry.js +8 -2
- package/dist/esm/ez-date-time-input.entry.js +8 -2
- package/dist/esm/ez-dialog.entry.js +9 -1
- package/dist/esm/ez-form.entry.js +2 -323
- package/dist/esm/ez-grid.entry.js +253 -61
- package/dist/esm/ez-number-input.entry.js +7 -0
- package/dist/esm/ez-search.entry.js +27 -11
- package/dist/esm/ez-text-area.entry.js +6 -0
- package/dist/esm/ez-text-input.entry.js +7 -1
- package/dist/esm/ez-time-input.entry.js +6 -0
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-03a2c7d1.entry.js +1 -0
- package/dist/ezui/p-0a75bb05.entry.js +1 -0
- package/dist/ezui/{p-37219d42.entry.js → p-0db68715.entry.js} +1 -1
- package/dist/ezui/p-19098a3f.entry.js +1 -0
- package/dist/ezui/p-1f830a2f.entry.js +1 -0
- package/dist/ezui/p-3dd919b7.entry.js +1 -0
- package/dist/ezui/p-7bfae0fc.entry.js +1 -0
- package/dist/ezui/p-81f06699.js +1 -0
- package/dist/ezui/p-97af4b13.entry.js +1 -0
- package/dist/ezui/p-9ceefe4d.entry.js +1 -0
- package/dist/ezui/{p-c3c3d640.entry.js → p-b0a5c2cd.entry.js} +2 -2
- package/dist/ezui/p-d0ca26fe.entry.js +1 -0
- package/dist/ezui/p-dc628ed3.js +1 -0
- package/dist/ezui/p-ffd246f5.entry.js +1 -0
- package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +7 -1
- package/dist/types/components/ez-date-input/ez-date-input.d.ts +6 -1
- package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +6 -1
- package/dist/types/components/ez-dialog/ez-dialog.d.ts +2 -0
- package/dist/types/components/ez-filter-input/ez-filter-input.d.ts +6 -1
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +10 -0
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +4 -0
- package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +18 -6
- package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.d.ts +2 -0
- package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +1 -0
- package/dist/types/components/ez-grid/ez-grid.d.ts +10 -0
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +4 -0
- package/dist/types/components/ez-search/ez-search.d.ts +6 -1
- package/dist/types/components/ez-text-area/ez-text-area.d.ts +4 -0
- package/dist/types/components/ez-text-input/ez-text-input.d.ts +4 -0
- package/dist/types/components/ez-time-input/ez-time-input.d.ts +4 -0
- package/dist/types/components.d.ts +91 -6
- package/dist/types/utils/FocusResolver.d.ts +5 -0
- package/dist/types/utils/form/DataBinder.d.ts +3 -0
- package/package.json +1 -1
- package/dist/cjs/RecordValidationProcessor-10846595.js +0 -108
- package/dist/esm/RecordValidationProcessor-9c6cc267.js +0 -105
- package/dist/ezui/p-0f3b2e67.entry.js +0 -1
- package/dist/ezui/p-49456b34.entry.js +0 -1
- package/dist/ezui/p-5a90d7d1.entry.js +0 -1
- package/dist/ezui/p-62732269.entry.js +0 -1
- package/dist/ezui/p-b95632e8.entry.js +0 -1
- package/dist/ezui/p-c25f0e92.entry.js +0 -1
- package/dist/ezui/p-d2c06f38.entry.js +0 -1
- package/dist/ezui/p-e85c48d7.entry.js +0 -1
- package/dist/ezui/p-f0e2ce9d.entry.js +0 -1
- package/dist/ezui/p-f299c608.entry.js +0 -1
- package/dist/ezui/p-f42855b9.js +0 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { UserInterface } from '@sankhyalabs/core';
|
|
1
|
+
import { LockManager, LockManagerOperation, UserInterface } from '@sankhyalabs/core';
|
|
2
2
|
import { KeyCode, } from 'ag-grid-community';
|
|
3
3
|
import { RecordValidationProcessor } from '../../../../utils/validators/recordvalidator/RecordValidationProcessor';
|
|
4
4
|
import EzCellEditor from './editor/EzCellEditor';
|
|
5
5
|
import EzGridCustomCellEditor from './components/EzGridCustomCellEditor';
|
|
6
6
|
import EzGridCustomCellRender from './components/EzGridCustomCellRender';
|
|
7
|
+
import { DataBinder } from '../../../../utils';
|
|
7
8
|
export default class GridEditionManager {
|
|
8
|
-
constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert, enableGridInsert) {
|
|
9
|
+
constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled, customEditors, customRenders, enableContinuousInsert, enableGridInsert, lockerId) {
|
|
9
10
|
this._dataUnit = dataUnit;
|
|
10
11
|
this._recordValidationProcessor = new RecordValidationProcessor(this._dataUnit, {
|
|
11
12
|
getRequiredFields: () => this.getRequiredFields(),
|
|
12
|
-
markAsInvalid: (invalidField, recordId) => { this.
|
|
13
|
+
markAsInvalid: (invalidField, recordId) => { this.pushInvalidCell(invalidField, recordId); },
|
|
13
14
|
getMessageForField: () => null,
|
|
14
15
|
}, recordsValidator);
|
|
15
16
|
this._useEnterLikeTab = useEnterLikeTab;
|
|
@@ -18,16 +19,34 @@ export default class GridEditionManager {
|
|
|
18
19
|
this._enableGridInsert = enableGridInsert;
|
|
19
20
|
this._customEditors = customEditors;
|
|
20
21
|
this._customRenders = customRenders;
|
|
22
|
+
this._lockerId = lockerId;
|
|
21
23
|
}
|
|
22
24
|
configureGrid(options) {
|
|
23
25
|
this._gridOptions = options;
|
|
24
26
|
options.readOnlyEdit = true;
|
|
25
27
|
options.onCellEditRequest = evt => this.onCellEditRequest(evt);
|
|
28
|
+
options.onCellEditingStarted = async (evt) => {
|
|
29
|
+
var _a;
|
|
30
|
+
if (this._dataUnit.hasNewRecord()) {
|
|
31
|
+
this.handleCellEditingStartedRowAdd(evt);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
this._lastCellOpened = this._lastCellEdited = { rowIndex: evt.rowIndex, column: evt.column, rowPinned: undefined };
|
|
35
|
+
}
|
|
36
|
+
(_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
37
|
+
this._currentEditLock = LockManager.lock(this._lockerId, LockManagerOperation.TASKBAR_CLICK);
|
|
38
|
+
};
|
|
39
|
+
options.onCellEditingStopped = () => {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
42
|
+
};
|
|
26
43
|
options.onCellKeyDown = evt => {
|
|
27
44
|
if (evt.event && evt["column"]) {
|
|
28
45
|
this.onCellKeyDown(evt);
|
|
29
46
|
}
|
|
30
47
|
};
|
|
48
|
+
options.isRowSelectable = (node) => this.isSelectableRow(node);
|
|
49
|
+
options.onCellFocused = () => this.lockFocusWhenAddRow();
|
|
31
50
|
return options;
|
|
32
51
|
}
|
|
33
52
|
updateCurrentEditorGuiValue(updatedRowValue) {
|
|
@@ -40,37 +59,82 @@ export default class GridEditionManager {
|
|
|
40
59
|
const value = updatedRowValue[fieldName];
|
|
41
60
|
currentEditor.setGuiValue(value);
|
|
42
61
|
}
|
|
62
|
+
lockFocusWhenAddRow() {
|
|
63
|
+
var _a, _b, _c, _d;
|
|
64
|
+
const api = this._gridOptions.api;
|
|
65
|
+
const newFocusCell = api.getFocusedCell();
|
|
66
|
+
const rowIndex = newFocusCell === null || newFocusCell === void 0 ? void 0 : newFocusCell.rowIndex;
|
|
67
|
+
const recordId = (_b = (_a = this._dataUnit.getAddedRecords()) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.__record__id__;
|
|
68
|
+
const rowNode = api.getRowNode(recordId);
|
|
69
|
+
if (!this._dataUnit.hasNewRecord() || rowIndex == (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex)) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const lastCell = (_d = (_c = this._lastCellOpened) !== null && _c !== void 0 ? _c : this._lastCellEdited) !== null && _d !== void 0 ? _d : this._lastCellClicked;
|
|
73
|
+
if ((lastCell === null || lastCell === void 0 ? void 0 : lastCell.rowIndex) < (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex)) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
api.clearFocusedCell();
|
|
77
|
+
if (!lastCell || (rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex) == undefined) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
lastCell.rowIndex = rowNode === null || rowNode === void 0 ? void 0 : rowNode.rowIndex;
|
|
81
|
+
this.focusOnCell(lastCell);
|
|
82
|
+
}
|
|
83
|
+
handleCellEditingStartedRowAdd(evt) {
|
|
84
|
+
var _a, _b, _c, _d, _e;
|
|
85
|
+
const nodeId = (_a = evt.node) === null || _a === void 0 ? void 0 : _a.id;
|
|
86
|
+
const addedRecordId = (_c = (_b = this._dataUnit.getAddedRecords()) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
|
|
87
|
+
if (nodeId == addedRecordId) {
|
|
88
|
+
this._lastCellOpened = this._lastCellEdited = { rowIndex: evt.rowIndex, column: evt === null || evt === void 0 ? void 0 : evt.column, rowPinned: undefined };
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
evt.api.stopEditing();
|
|
92
|
+
const rowIndex = (_d = evt.api.getRowNode(addedRecordId)) === null || _d === void 0 ? void 0 : _d.rowIndex;
|
|
93
|
+
this._lastCellOpened = this._lastCellEdited = { rowIndex: rowIndex, column: (_e = this._lastCellEdited) === null || _e === void 0 ? void 0 : _e.column, rowPinned: undefined };
|
|
94
|
+
}
|
|
95
|
+
isSelectableRow(node) {
|
|
96
|
+
if (!this._dataUnit.hasNewRecord()) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
if (!this._dataUnit.isNewRecord(node.id)) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
43
104
|
canContinuousInsert() {
|
|
44
105
|
var _a;
|
|
45
106
|
return this._enableContinuousInsert && (this._dataUnit.records.length - 1) === ((_a = this._lastCellEdited) === null || _a === void 0 ? void 0 : _a.rowIndex);
|
|
46
107
|
}
|
|
47
|
-
proceedAutoSave() {
|
|
108
|
+
async proceedAutoSave() {
|
|
48
109
|
if (!this._dataUnit.isDirty()) {
|
|
49
110
|
this.saveSuccess();
|
|
50
|
-
return;
|
|
111
|
+
return true;
|
|
51
112
|
}
|
|
52
|
-
|
|
53
|
-
|
|
113
|
+
const currentRecord = this._dataUnit.getSelectedRecord();
|
|
114
|
+
if (currentRecord == undefined) {
|
|
115
|
+
return true;
|
|
54
116
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
117
|
+
this.clearInvalidCells(false);
|
|
118
|
+
try {
|
|
119
|
+
await this._recordValidationProcessor.validate(true);
|
|
120
|
+
await this.saveDataUnit();
|
|
121
|
+
this.saveSuccess();
|
|
122
|
+
return true;
|
|
58
123
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
.catch(reason => this.saveFail(reason));
|
|
124
|
+
catch (reason) {
|
|
125
|
+
this.saveFail(reason);
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async saveDataUnit() {
|
|
130
|
+
await this._dataUnit.saveData();
|
|
131
|
+
return true;
|
|
68
132
|
}
|
|
69
133
|
async recordValidate() {
|
|
70
134
|
if (!this._dataUnit.isDirty())
|
|
71
135
|
return;
|
|
72
136
|
try {
|
|
73
|
-
this.
|
|
137
|
+
this.clearInvalidCells(false);
|
|
74
138
|
await this._recordValidationProcessor.validate(false);
|
|
75
139
|
}
|
|
76
140
|
catch (error) { }
|
|
@@ -98,6 +162,13 @@ export default class GridEditionManager {
|
|
|
98
162
|
return { ezCellEditor: EzCellEditor };
|
|
99
163
|
}
|
|
100
164
|
verifyClickToEdition(api, cellClicked) {
|
|
165
|
+
var _a, _b;
|
|
166
|
+
const selectedRecordID = (_a = this._dataUnit.getSelectedRecord()) === null || _a === void 0 ? void 0 : _a.__record__id__;
|
|
167
|
+
if (this._dataUnit.hasNewRecord() && selectedRecordID) {
|
|
168
|
+
const dataUnitRecordIndex = (_b = api.getRowNode(selectedRecordID)) === null || _b === void 0 ? void 0 : _b.rowIndex;
|
|
169
|
+
if (dataUnitRecordIndex != cellClicked.rowIndex)
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
101
172
|
if (this.isSecondClick(cellClicked)) {
|
|
102
173
|
api.startEditingCell({ rowIndex: cellClicked.rowIndex, colKey: cellClicked.column.getColId() });
|
|
103
174
|
}
|
|
@@ -107,6 +178,9 @@ export default class GridEditionManager {
|
|
|
107
178
|
col.cellEditor = 'ezCellEditor';
|
|
108
179
|
col.editable = params => this.canEdit(params);
|
|
109
180
|
col.suppressKeyboardEvent = (params) => {
|
|
181
|
+
if (params.event.key === KeyCode.ESCAPE && params.editing) {
|
|
182
|
+
return this._dataUnit.isDirty();
|
|
183
|
+
}
|
|
110
184
|
return params.event.key === KeyCode.ENTER;
|
|
111
185
|
};
|
|
112
186
|
col.cellEditorSelector = (params) => {
|
|
@@ -136,10 +210,21 @@ export default class GridEditionManager {
|
|
|
136
210
|
return col;
|
|
137
211
|
}
|
|
138
212
|
getRequiredFields() {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
213
|
+
const formRequiredFields = this.getFormRequiredFields();
|
|
214
|
+
return this._gridOptions.columnApi.getAllDisplayedColumns()
|
|
215
|
+
.filter(column => {
|
|
216
|
+
const fieldDefinition = this._dataUnit.getField(column.getColId());
|
|
217
|
+
return (fieldDefinition && fieldDefinition.required) || formRequiredFields.includes(column.getColId());
|
|
218
|
+
})
|
|
219
|
+
.map(column => column.getColId());
|
|
220
|
+
}
|
|
221
|
+
getFormRequiredFields() {
|
|
222
|
+
const formRequiredFields = [];
|
|
223
|
+
const dataBinders = DataBinder.getDataBindersByDataUnit(this._dataUnit);
|
|
224
|
+
dataBinders.forEach(dataBinder => {
|
|
225
|
+
formRequiredFields.push(...dataBinder.getFormRequiredFields());
|
|
226
|
+
});
|
|
227
|
+
return formRequiredFields;
|
|
143
228
|
}
|
|
144
229
|
saveSuccess() {
|
|
145
230
|
var _a;
|
|
@@ -152,10 +237,11 @@ export default class GridEditionManager {
|
|
|
152
237
|
this._isGridEdition = false;
|
|
153
238
|
}
|
|
154
239
|
saveFail(reason) {
|
|
155
|
-
|
|
240
|
+
var _a;
|
|
241
|
+
this.focusOnCell((_a = this._lastCellOpened) !== null && _a !== void 0 ? _a : this._lastCellEdited);
|
|
156
242
|
this._isGridEdition = false;
|
|
157
243
|
if (reason) {
|
|
158
|
-
|
|
244
|
+
throw reason;
|
|
159
245
|
}
|
|
160
246
|
}
|
|
161
247
|
focusOnCell(cell) {
|
|
@@ -220,6 +306,9 @@ export default class GridEditionManager {
|
|
|
220
306
|
this.moveEditionVertically(api, 1);
|
|
221
307
|
}
|
|
222
308
|
moveEditionVertically(api, offset) {
|
|
309
|
+
if (this._dataUnit.hasNewRecord() && this._isGridEdition) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
223
312
|
const editionCell = api.getEditingCells()[0];
|
|
224
313
|
if (!editionCell) {
|
|
225
314
|
return;
|
|
@@ -264,41 +353,66 @@ export default class GridEditionManager {
|
|
|
264
353
|
return true;
|
|
265
354
|
}
|
|
266
355
|
onCellEditRequest(event) {
|
|
267
|
-
|
|
356
|
+
var _a;
|
|
268
357
|
const value = event.newValue;
|
|
269
|
-
if (event.oldValue
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
358
|
+
if (event.oldValue == value) {
|
|
359
|
+
(_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
if (value instanceof Promise) {
|
|
363
|
+
this.handlePromiseValue(event, value);
|
|
364
|
+
return;
|
|
365
|
+
}
|
|
366
|
+
this.updateCellValue(event, value);
|
|
367
|
+
}
|
|
368
|
+
async handlePromiseValue(event, value) {
|
|
369
|
+
const fieldName = event.colDef.field;
|
|
370
|
+
const fieldDescriptor = this._dataUnit.getField(event.colDef.colId);
|
|
371
|
+
const initialValue = (fieldDescriptor === null || fieldDescriptor === void 0 ? void 0 : fieldDescriptor.userInterface) === UserInterface.SEARCH ? value : event.oldValue;
|
|
372
|
+
event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: initialValue }));
|
|
373
|
+
const resolved = await value;
|
|
374
|
+
return this.updateCellValue(event, resolved);
|
|
375
|
+
}
|
|
376
|
+
updateCellValue(event, newValue) {
|
|
377
|
+
var _a;
|
|
378
|
+
const fieldName = event.colDef.field;
|
|
379
|
+
event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: newValue }));
|
|
380
|
+
(_a = this._currentEditLock) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
381
|
+
if (event.oldValue !== newValue) {
|
|
278
382
|
this._isGridEdition = true;
|
|
279
|
-
this._dataUnit.setFieldValue(fieldName,
|
|
383
|
+
this._dataUnit.setFieldValue(fieldName, newValue, [event.data.__record__id__], { suppressCreateNewRecord: true });
|
|
280
384
|
this._lastCellEdited = { rowIndex: event.rowIndex, column: event.column, rowPinned: undefined };
|
|
281
385
|
}
|
|
282
386
|
}
|
|
283
387
|
setCellEditors(customEditors) {
|
|
388
|
+
var _a, _b;
|
|
284
389
|
this._customEditors = customEditors;
|
|
390
|
+
if (!customEditors.has((_b = (_a = this._lastCellOpened) === null || _a === void 0 ? void 0 : _a.column) === null || _b === void 0 ? void 0 : _b.getColId()))
|
|
391
|
+
return;
|
|
392
|
+
this._gridOptions.api.stopEditing();
|
|
393
|
+
window.requestAnimationFrame(() => this.focusOnCell(this._lastCellOpened));
|
|
285
394
|
}
|
|
286
395
|
setCellRenders(customRenders) {
|
|
287
396
|
this._customRenders = customRenders;
|
|
288
397
|
}
|
|
289
|
-
|
|
290
|
-
this.
|
|
398
|
+
pushInvalidCell(invalidField, recordId) {
|
|
399
|
+
this._invalidCells.push({ field: invalidField, recordId });
|
|
400
|
+
this._nextInvalidCell = this._invalidCells[0];
|
|
401
|
+
}
|
|
402
|
+
getInvalidCells() {
|
|
403
|
+
return this._invalidCells;
|
|
291
404
|
}
|
|
292
|
-
|
|
293
|
-
return this.
|
|
405
|
+
getNextInvalidCell() {
|
|
406
|
+
return this._nextInvalidCell;
|
|
294
407
|
}
|
|
295
|
-
processContinuousInsert() {
|
|
408
|
+
async processContinuousInsert() {
|
|
296
409
|
if (!this.canContinuousInsert())
|
|
297
410
|
return;
|
|
298
411
|
this._dataUnit.addRecord();
|
|
299
412
|
}
|
|
300
413
|
clearInvalidCells(stopEdition) {
|
|
301
|
-
this.
|
|
414
|
+
this._invalidCells = [];
|
|
415
|
+
this._nextInvalidCell = undefined;
|
|
302
416
|
if (stopEdition) {
|
|
303
417
|
this._isGridEdition = false;
|
|
304
418
|
}
|
|
@@ -309,10 +423,17 @@ export default class GridEditionManager {
|
|
|
309
423
|
hasInvalidField(fieldName, recordId) {
|
|
310
424
|
if (!this.hasInvalidCell())
|
|
311
425
|
return false;
|
|
312
|
-
|
|
426
|
+
this._nextInvalidCell = this._invalidCells[0];
|
|
427
|
+
const containsFieldName = this._nextInvalidCell.field.name === fieldName;
|
|
428
|
+
const containsRecordId = this._nextInvalidCell.recordId === recordId;
|
|
429
|
+
return containsFieldName && containsRecordId;
|
|
313
430
|
}
|
|
314
431
|
hasInvalidCell() {
|
|
315
|
-
|
|
432
|
+
var _a, _b, _c;
|
|
433
|
+
const hasInvalidCell = ((_a = this._invalidCells) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
434
|
+
const hasField = (_b = this._invalidCells) === null || _b === void 0 ? void 0 : _b.filter(invalidCell => { invalidCell.field; });
|
|
435
|
+
const hasRecordId = (_c = this._invalidCells) === null || _c === void 0 ? void 0 : _c.filter(invalidCell => { invalidCell.recordId; });
|
|
436
|
+
if (!hasInvalidCell || !hasField || !hasRecordId)
|
|
316
437
|
return false;
|
|
317
438
|
return true;
|
|
318
439
|
}
|
package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomCellEditor.js
CHANGED
|
@@ -2,6 +2,7 @@ import { HTMLBuilder } from "@sankhyalabs/core";
|
|
|
2
2
|
import { CustomEditorSource } from "../../../../../utils/customEditor/interfaces/ICustomEditor";
|
|
3
3
|
import EzCellEditor from "../editor/EzCellEditor";
|
|
4
4
|
import { getViewPortHeight } from "../editor/GridEditorUtils";
|
|
5
|
+
import FocusResolver from "../../../../../utils/FocusResolver";
|
|
5
6
|
export default class EzGridCustomCellEditor extends EzCellEditor {
|
|
6
7
|
init(params) {
|
|
7
8
|
var _a, _b;
|
|
@@ -65,4 +66,10 @@ export default class EzGridCustomCellEditor extends EzCellEditor {
|
|
|
65
66
|
return this._customGui.value;
|
|
66
67
|
return this._value;
|
|
67
68
|
}
|
|
69
|
+
afterGuiAttached() {
|
|
70
|
+
this.focusIn();
|
|
71
|
+
}
|
|
72
|
+
focusIn() {
|
|
73
|
+
FocusResolver.resolveFocus(this._customGui);
|
|
74
|
+
}
|
|
68
75
|
}
|
package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js
CHANGED
|
@@ -19,6 +19,7 @@ export const buildComboBox = ({ required, props, eGridCell }) => {
|
|
|
19
19
|
combo.options = options;
|
|
20
20
|
combo.stopPropagateEnterKeyEvent = true;
|
|
21
21
|
combo.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
|
|
22
|
+
combo.autoFocus = true;
|
|
22
23
|
return combo;
|
|
23
24
|
};
|
|
24
25
|
export const buildSwitch = (fieldMetadata) => {
|
package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js
CHANGED
|
@@ -13,6 +13,7 @@ export const buildSearch = ({ name, required, readOnly, eGridCell, dataUnit }) =
|
|
|
13
13
|
ezSearch.suppressPreLoad = true;
|
|
14
14
|
ezSearch.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
|
|
15
15
|
ezSearch.stopPropagateEnterKeyEvent = true;
|
|
16
|
+
ezSearch.autoFocus = true;
|
|
16
17
|
ezSearch.valueGetter = () => ezSearch.getValueAsync();
|
|
17
18
|
return ezSearch;
|
|
18
19
|
};
|
package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js
CHANGED
|
@@ -2,12 +2,14 @@ import { HTMLBuilder } from "@sankhyalabs/core";
|
|
|
2
2
|
const MINIMIUM_WIDTH_TEXTAREA = 210;
|
|
3
3
|
const PADDING_VALUE_TEXTAREA = 12;
|
|
4
4
|
export const buildTextInput = ({ name, contextName }) => {
|
|
5
|
-
|
|
5
|
+
const textInput = HTMLBuilder.parseElement(`<ez-text-input
|
|
6
6
|
class="ez-grid grid_editor"
|
|
7
7
|
data-field-name=${name}
|
|
8
8
|
data-context-name=${contextName}
|
|
9
9
|
mode="slim"
|
|
10
10
|
/>`);
|
|
11
|
+
textInput.autoFocus = true;
|
|
12
|
+
return textInput;
|
|
11
13
|
};
|
|
12
14
|
export const buildTextAreaInput = ({ eGridCell, editionManager }) => {
|
|
13
15
|
const element = HTMLBuilder.parseElement(`<ez-text-area
|
|
@@ -17,6 +19,7 @@ export const buildTextAreaInput = ({ eGridCell, editionManager }) => {
|
|
|
17
19
|
element.addEventListener('keydown', event => handlePressEnterEvent(event, element, editionManager));
|
|
18
20
|
setElementInitialWidth(eGridCell, element);
|
|
19
21
|
element.isPopUp = true;
|
|
22
|
+
element.autoFocus = true;
|
|
20
23
|
return element;
|
|
21
24
|
};
|
|
22
25
|
function setElementInitialWidth(eGridCell, element) {
|
|
@@ -39,6 +39,7 @@ export class EzGrid {
|
|
|
39
39
|
this.paginationCounterMode = 'show';
|
|
40
40
|
this.enableGridInsert = false;
|
|
41
41
|
this.enableContinuousInsert = true;
|
|
42
|
+
this.enableLockManger = true;
|
|
42
43
|
}
|
|
43
44
|
/**
|
|
44
45
|
* Aplica a definição de colunas.
|
|
@@ -163,6 +164,18 @@ export class EzGrid {
|
|
|
163
164
|
async setFocus() {
|
|
164
165
|
this._gridController.setFocus();
|
|
165
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Para a edição da grade.
|
|
169
|
+
*/
|
|
170
|
+
async stopEdit() {
|
|
171
|
+
this._gridController.stopEdit();
|
|
172
|
+
}
|
|
173
|
+
async checkStopEditOutsideClick(event) {
|
|
174
|
+
var _a;
|
|
175
|
+
if ((_a = this._container) === null || _a === void 0 ? void 0 : _a.contains(event.target))
|
|
176
|
+
return;
|
|
177
|
+
this._gridController.stopEdit();
|
|
178
|
+
}
|
|
166
179
|
observeConfig(config) {
|
|
167
180
|
this._gridController.setColumnsState(config === null || config === void 0 ? void 0 : config.columns);
|
|
168
181
|
}
|
|
@@ -188,6 +201,9 @@ export class EzGrid {
|
|
|
188
201
|
this.setSelection(this.dataUnit.getSelectionInfo());
|
|
189
202
|
}
|
|
190
203
|
}
|
|
204
|
+
async handleClick(event) {
|
|
205
|
+
this.checkStopEditOutsideClick(event);
|
|
206
|
+
}
|
|
191
207
|
setSelection(selectionInfo) {
|
|
192
208
|
var _a;
|
|
193
209
|
this._selectionCount = (_a = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.length) !== null && _a !== void 0 ? _a : 0;
|
|
@@ -384,7 +400,8 @@ export class EzGrid {
|
|
|
384
400
|
if (this.dataUnit) {
|
|
385
401
|
this.setSelection(this.dataUnit.getSelectionInfo());
|
|
386
402
|
}
|
|
387
|
-
}
|
|
403
|
+
},
|
|
404
|
+
enableLockManger: this.enableLockManger
|
|
388
405
|
});
|
|
389
406
|
if (this.config) {
|
|
390
407
|
this.observeConfig(this.config);
|
|
@@ -778,6 +795,24 @@ export class EzGrid {
|
|
|
778
795
|
"attribute": "enable-continuous-insert",
|
|
779
796
|
"reflect": false,
|
|
780
797
|
"defaultValue": "true"
|
|
798
|
+
},
|
|
799
|
+
"enableLockManger": {
|
|
800
|
+
"type": "boolean",
|
|
801
|
+
"mutable": false,
|
|
802
|
+
"complexType": {
|
|
803
|
+
"original": "boolean",
|
|
804
|
+
"resolved": "boolean",
|
|
805
|
+
"references": {}
|
|
806
|
+
},
|
|
807
|
+
"required": false,
|
|
808
|
+
"optional": true,
|
|
809
|
+
"docs": {
|
|
810
|
+
"tags": [],
|
|
811
|
+
"text": "Ativa inser\u00E7\u00E3o de registros no modo grade."
|
|
812
|
+
},
|
|
813
|
+
"attribute": "enable-lock-manger",
|
|
814
|
+
"reflect": false,
|
|
815
|
+
"defaultValue": "true"
|
|
781
816
|
}
|
|
782
817
|
};
|
|
783
818
|
}
|
|
@@ -1282,6 +1317,47 @@ export class EzGrid {
|
|
|
1282
1317
|
"text": "Atribui o foco para a grade.",
|
|
1283
1318
|
"tags": []
|
|
1284
1319
|
}
|
|
1320
|
+
},
|
|
1321
|
+
"stopEdit": {
|
|
1322
|
+
"complexType": {
|
|
1323
|
+
"signature": "() => Promise<void>",
|
|
1324
|
+
"parameters": [],
|
|
1325
|
+
"references": {
|
|
1326
|
+
"Promise": {
|
|
1327
|
+
"location": "global"
|
|
1328
|
+
}
|
|
1329
|
+
},
|
|
1330
|
+
"return": "Promise<void>"
|
|
1331
|
+
},
|
|
1332
|
+
"docs": {
|
|
1333
|
+
"text": "Para a edi\u00E7\u00E3o da grade.",
|
|
1334
|
+
"tags": []
|
|
1335
|
+
}
|
|
1336
|
+
},
|
|
1337
|
+
"checkStopEditOutsideClick": {
|
|
1338
|
+
"complexType": {
|
|
1339
|
+
"signature": "(event: MouseEvent) => Promise<void>",
|
|
1340
|
+
"parameters": [{
|
|
1341
|
+
"tags": [],
|
|
1342
|
+
"text": ""
|
|
1343
|
+
}],
|
|
1344
|
+
"references": {
|
|
1345
|
+
"Promise": {
|
|
1346
|
+
"location": "global"
|
|
1347
|
+
},
|
|
1348
|
+
"MouseEvent": {
|
|
1349
|
+
"location": "global"
|
|
1350
|
+
},
|
|
1351
|
+
"Node": {
|
|
1352
|
+
"location": "global"
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
"return": "Promise<void>"
|
|
1356
|
+
},
|
|
1357
|
+
"docs": {
|
|
1358
|
+
"text": "",
|
|
1359
|
+
"tags": []
|
|
1360
|
+
}
|
|
1285
1361
|
}
|
|
1286
1362
|
};
|
|
1287
1363
|
}
|
|
@@ -1305,6 +1381,12 @@ export class EzGrid {
|
|
|
1305
1381
|
"target": undefined,
|
|
1306
1382
|
"capture": false,
|
|
1307
1383
|
"passive": false
|
|
1384
|
+
}, {
|
|
1385
|
+
"name": "click",
|
|
1386
|
+
"method": "handleClick",
|
|
1387
|
+
"target": undefined,
|
|
1388
|
+
"capture": true,
|
|
1389
|
+
"passive": false
|
|
1308
1390
|
}];
|
|
1309
1391
|
}
|
|
1310
1392
|
}
|
|
@@ -16,6 +16,7 @@ export class EzNumberInput {
|
|
|
16
16
|
this.precision = undefined;
|
|
17
17
|
this.prettyPrecision = undefined;
|
|
18
18
|
this.mode = "regular";
|
|
19
|
+
this.autoFocus = false;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* Aplica o foco no campo.
|
|
@@ -156,11 +157,17 @@ export class EzNumberInput {
|
|
|
156
157
|
const textValue = this.getTextValue(this.value) || '';
|
|
157
158
|
if ((this._value || '') !== textValue) {
|
|
158
159
|
this._value = textValue;
|
|
160
|
+
this._textInput.value = this._value;
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
componentDidLoad() {
|
|
162
164
|
CSSVarsUtils.applyVarsTextInput(this._elem, this._textInput);
|
|
163
165
|
this.setInputValue();
|
|
166
|
+
if (this.autoFocus) {
|
|
167
|
+
requestAnimationFrame(() => {
|
|
168
|
+
this.setFocus({ selectText: true });
|
|
169
|
+
});
|
|
170
|
+
}
|
|
164
171
|
}
|
|
165
172
|
render() {
|
|
166
173
|
ElementIDUtils.addIDInfoIfNotExists(this._elem, 'input');
|
|
@@ -340,6 +347,24 @@ export class EzNumberInput {
|
|
|
340
347
|
"attribute": "mode",
|
|
341
348
|
"reflect": true,
|
|
342
349
|
"defaultValue": "\"regular\""
|
|
350
|
+
},
|
|
351
|
+
"autoFocus": {
|
|
352
|
+
"type": "boolean",
|
|
353
|
+
"mutable": false,
|
|
354
|
+
"complexType": {
|
|
355
|
+
"original": "boolean",
|
|
356
|
+
"resolved": "boolean",
|
|
357
|
+
"references": {}
|
|
358
|
+
},
|
|
359
|
+
"required": false,
|
|
360
|
+
"optional": false,
|
|
361
|
+
"docs": {
|
|
362
|
+
"tags": [],
|
|
363
|
+
"text": "Se true o campo de texto receber\u00E1 o foco ao ser renderizado."
|
|
364
|
+
},
|
|
365
|
+
"attribute": "auto-focus",
|
|
366
|
+
"reflect": false,
|
|
367
|
+
"defaultValue": "false"
|
|
343
368
|
}
|
|
344
369
|
};
|
|
345
370
|
}
|