@sankhyalabs/ezui 5.10.8 → 5.11.0-dev.10
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/README.md +8 -11
- package/dist/cjs/{CSSVarsUtils-af809e73.js → CSSVarsUtils-b136a156.js} +5 -0
- package/dist/cjs/RecordValidationProcessor-edd23705.js +102 -0
- package/dist/cjs/ez-actions-button.cjs.entry.js +1 -1
- package/dist/cjs/ez-calendar.cjs.entry.js +34 -5
- package/dist/cjs/ez-card-item.cjs.entry.js +1 -1
- package/dist/cjs/ez-combo-box.cjs.entry.js +99 -16
- package/dist/cjs/ez-date-input.cjs.entry.js +53 -22
- package/dist/cjs/ez-date-time-input.cjs.entry.js +53 -19
- package/dist/cjs/ez-filter-input_2.cjs.entry.js +1 -1
- package/dist/cjs/ez-form-view.cjs.entry.js +42 -1
- package/dist/cjs/ez-form.cjs.entry.js +11 -84
- package/dist/cjs/ez-grid.cjs.entry.js +575 -44
- package/dist/cjs/ez-multi-selection-list.cjs.entry.js +3 -1
- package/dist/cjs/ez-number-input.cjs.entry.js +39 -15
- package/dist/cjs/ez-search.cjs.entry.js +13 -2
- package/dist/cjs/ez-text-area.cjs.entry.js +6 -2
- package/dist/cjs/ez-text-input.cjs.entry.js +7 -4
- package/dist/cjs/ez-time-input.cjs.entry.js +11 -7
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/filter-column.cjs.entry.js +30 -7
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/ez-calendar/ez-calendar.js +63 -6
- package/dist/collection/components/ez-card-item/ez-card-item.css +1 -0
- package/dist/collection/components/ez-combo-box/ez-combo-box.css +6 -0
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +168 -14
- package/dist/collection/components/ez-date-input/ez-date-input.js +71 -21
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +71 -18
- package/dist/collection/components/ez-form/ez-form.js +20 -0
- package/dist/collection/components/ez-form-view/ez-form-view.js +23 -0
- package/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder.js +4 -1
- package/dist/collection/components/ez-form-view/structure/index.js +34 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +41 -8
- package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +1 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +230 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.js +1 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/EzCellEditor.js +49 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/GridEditorUtils.js +10 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/IEditorMetadata.js +4 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js +38 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js +40 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js +20 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.js +15 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js +41 -0
- package/dist/collection/components/ez-grid/ez-grid.js +78 -39
- package/dist/collection/components/ez-grid/subcomponents/filter-column.js +50 -8
- package/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource.js +78 -0
- package/dist/collection/components/ez-multi-selection-list/ez-multi-selection-list.js +21 -1
- package/dist/collection/components/ez-number-input/ez-number-input.css +4 -0
- package/dist/collection/components/ez-number-input/ez-number-input.js +62 -15
- package/dist/collection/components/ez-search/ez-search.css +1 -1
- package/dist/collection/components/ez-search/ez-search.js +84 -1
- package/dist/collection/components/ez-text-area/ez-text-area.css +4 -0
- package/dist/collection/components/ez-text-area/ez-text-area.js +23 -1
- package/dist/collection/components/ez-text-input/ez-text-input.css +8 -1
- package/dist/collection/components/ez-text-input/ez-text-input.js +14 -5
- package/dist/collection/components/ez-time-input/ez-time-input.css +4 -0
- package/dist/collection/components/ez-time-input/ez-time-input.js +18 -7
- package/dist/collection/utils/CSSVarsUtils.js +5 -0
- package/dist/collection/utils/form/DataBinder.js +8 -63
- package/dist/collection/utils/form/FormMetadata.js +3 -22
- package/dist/collection/utils/interfaces/AbstractFieldMetadata.js +21 -0
- package/dist/collection/utils/validators/recordvalidator/IValidationResult.js +1 -0
- package/dist/collection/utils/validators/recordvalidator/IValidationSource.js +1 -0
- package/dist/collection/utils/validators/recordvalidator/RecordValidationProcessor.js +74 -0
- package/dist/custom-elements/index.js +1101 -256
- package/dist/esm/{CSSVarsUtils-00f67f32.js → CSSVarsUtils-a97cfa29.js} +5 -0
- package/dist/esm/RecordValidationProcessor-abc814af.js +99 -0
- package/dist/esm/ez-actions-button.entry.js +1 -1
- package/dist/esm/ez-calendar.entry.js +35 -6
- package/dist/esm/ez-card-item.entry.js +1 -1
- package/dist/esm/ez-combo-box.entry.js +99 -16
- package/dist/esm/ez-date-input.entry.js +53 -22
- package/dist/esm/ez-date-time-input.entry.js +53 -19
- package/dist/esm/ez-filter-input_2.entry.js +1 -1
- package/dist/esm/ez-form-view.entry.js +42 -1
- package/dist/esm/ez-form.entry.js +12 -85
- package/dist/esm/ez-grid.entry.js +576 -45
- package/dist/esm/ez-multi-selection-list.entry.js +3 -1
- package/dist/esm/ez-number-input.entry.js +39 -15
- package/dist/esm/ez-search.entry.js +13 -2
- package/dist/esm/ez-text-area.entry.js +6 -2
- package/dist/esm/ez-text-input.entry.js +7 -4
- package/dist/esm/ez-time-input.entry.js +11 -7
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/filter-column.entry.js +30 -7
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-028f264f.entry.js +1 -0
- package/dist/ezui/p-061f4d73.entry.js +1 -0
- package/dist/ezui/p-25562cf8.entry.js +1 -0
- package/dist/ezui/p-3078d25c.entry.js +1 -0
- package/dist/ezui/p-391de0e4.entry.js +1 -0
- package/dist/ezui/{p-68352e41.entry.js → p-47afb974.entry.js} +1 -1
- package/dist/ezui/p-5cef0264.entry.js +1 -0
- package/dist/ezui/p-5e55a42b.entry.js +1 -0
- package/dist/ezui/p-7526f2b6.entry.js +1 -0
- package/dist/ezui/p-7eb3e1a5.js +1 -0
- package/dist/ezui/p-86a2036d.js +1 -0
- package/dist/ezui/{p-12303d2e.entry.js → p-87e85160.entry.js} +1 -1
- package/dist/ezui/{p-c7a23be9.entry.js → p-964e5571.entry.js} +2 -2
- package/dist/ezui/p-ce035beb.entry.js +1 -0
- package/dist/ezui/p-d43b22f3.entry.js +1 -0
- package/dist/ezui/p-df93558d.entry.js +1 -0
- package/dist/ezui/p-e2dfd935.entry.js +1 -0
- package/dist/ezui/p-e67d0bd5.entry.js +1 -0
- package/dist/ezui/{p-f1a537e3.entry.js → p-ff82b176.entry.js} +1 -1
- package/dist/types/components/ez-calendar/ez-calendar.d.ts +9 -1
- package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +23 -0
- package/dist/types/components/ez-date-input/ez-date-input.d.ts +4 -0
- package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +4 -0
- package/dist/types/components/ez-form/ez-form.d.ts +5 -0
- package/dist/types/components/ez-form-view/ez-form-view.d.ts +5 -0
- package/dist/types/components/ez-form-view/interfaces/IFormViewField.d.ts +2 -14
- package/dist/types/components/ez-form-view/structure/index.d.ts +15 -0
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +18 -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 +38 -0
- package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.d.ts +1 -1
- package/dist/types/components/ez-grid/controller/ag-grid/editor/EzCellEditor.d.ts +10 -0
- package/dist/types/components/ez-grid/controller/ag-grid/editor/GridEditorUtils.d.ts +1 -0
- package/dist/types/components/ez-grid/controller/ag-grid/editor/IEditorMetadata.d.ts +9 -0
- package/dist/types/components/ez-grid/controller/ag-grid/editor/IUICellEditor.d.ts +10 -0
- package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.d.ts +4 -0
- package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.d.ts +5 -0
- package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.d.ts +4 -0
- package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/Search.tpl.d.ts +3 -0
- package/dist/types/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.d.ts +4 -0
- package/dist/types/components/ez-grid/ez-grid.d.ts +16 -5
- package/dist/types/components/ez-grid/subcomponents/filter-column.d.ts +8 -0
- package/dist/types/components/ez-grid/utils/InMemoryFilterColumnDataSource.d.ts +16 -0
- package/dist/types/components/ez-multi-selection-list/ez-multi-selection-list.d.ts +4 -0
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +5 -1
- package/dist/types/components/ez-search/ez-search.d.ts +14 -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 -1
- package/dist/types/components/ez-time-input/ez-time-input.d.ts +2 -1
- package/dist/types/components.d.ts +116 -6
- package/dist/types/utils/form/DataBinder.d.ts +1 -3
- package/dist/types/utils/form/interfaces/IFormConfig.d.ts +1 -1
- package/dist/types/utils/form/interfaces/index.d.ts +4 -4
- package/dist/types/utils/interfaces/AbstractFieldMetadata.d.ts +17 -0
- package/dist/types/utils/{form/interfaces → interfaces}/IFieldConfig.d.ts +2 -2
- package/dist/types/utils/validators/recordvalidator/IValidationSource.d.ts +6 -0
- package/dist/types/utils/validators/recordvalidator/RecordValidationProcessor.d.ts +13 -0
- package/package.json +3 -3
- package/dist/ezui/p-00c7c25d.entry.js +0 -1
- package/dist/ezui/p-0b160fec.entry.js +0 -1
- package/dist/ezui/p-0bd54a6f.entry.js +0 -1
- package/dist/ezui/p-2a0e1679.entry.js +0 -1
- package/dist/ezui/p-39153935.entry.js +0 -1
- package/dist/ezui/p-4a5e37a7.js +0 -1
- package/dist/ezui/p-4c8b029b.entry.js +0 -1
- package/dist/ezui/p-4e31b69b.entry.js +0 -1
- package/dist/ezui/p-5782443e.entry.js +0 -1
- package/dist/ezui/p-5d45e384.entry.js +0 -1
- package/dist/ezui/p-70ea4beb.entry.js +0 -1
- package/dist/ezui/p-78a6e049.entry.js +0 -1
- package/dist/ezui/p-8bcb197f.entry.js +0 -1
- package/dist/ezui/p-a4c9f3c4.entry.js +0 -1
- /package/dist/collection/{utils/form/interfaces/IFieldConfig.js → components/ez-grid/controller/ag-grid/editor/IUICellEditor.js} +0 -0
- /package/dist/collection/utils/{form/interfaces/IInvalidField.js → interfaces/IFieldConfig.js} +0 -0
- /package/dist/collection/utils/{form/interfaces/IRecordValidator.js → validators/recordvalidator/IInvalidField.js} +0 -0
- /package/dist/collection/utils/{form/interfaces/IValidationResult.js → validators/recordvalidator/IRecordValidator.js} +0 -0
- /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IInvalidField.d.ts +0 -0
- /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IRecordValidator.d.ts +0 -0
- /package/dist/types/utils/{form/interfaces → validators/recordvalidator}/IValidationResult.d.ts +0 -0
|
@@ -6,6 +6,7 @@ const index = require('./index-1064511f.js');
|
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
|
7
7
|
const DataUnit = require('@sankhyalabs/core/dist/dataunit/DataUnit');
|
|
8
8
|
const constants = require('./constants-3a1d64fb.js');
|
|
9
|
+
const RecordValidationProcessor = require('./RecordValidationProcessor-edd23705.js');
|
|
9
10
|
const ApplicationUtils = require('./ApplicationUtils-2e444734.js');
|
|
10
11
|
require('./DialogType-2114c337.js');
|
|
11
12
|
require('./CheckMode-ecb90b87.js');
|
|
@@ -118854,6 +118855,7 @@ class DataSource {
|
|
|
118854
118855
|
case core.Action.DATA_SAVED:
|
|
118855
118856
|
case core.Action.EDITION_CANCELED:
|
|
118856
118857
|
case core.Action.DATA_CHANGED:
|
|
118858
|
+
case core.Action.DATA_RESOLVED:
|
|
118857
118859
|
this._controller.refresh();
|
|
118858
118860
|
break;
|
|
118859
118861
|
case core.Action.SELECTION_CHANGED:
|
|
@@ -118976,7 +118978,7 @@ class EzGridCustomHeader {
|
|
|
118976
118978
|
onClickFilter() {
|
|
118977
118979
|
var _a;
|
|
118978
118980
|
const iconLeft = (_a = this.filterButton) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().left;
|
|
118979
|
-
this.params.showColumnFilter(`${calcFilterColumnLeftPosition(iconLeft)}px
|
|
118981
|
+
this.params.showColumnFilter(`${calcFilterColumnLeftPosition(iconLeft)}px`, true);
|
|
118980
118982
|
}
|
|
118981
118983
|
configSortIcon() {
|
|
118982
118984
|
this.sortDownIcon.style.display = this.params.column.isSortDescending() ? 'flex' : 'none';
|
|
@@ -119187,6 +119189,443 @@ const gridTerms = {
|
|
|
119187
119189
|
ctrlV: "Ctrl+V"
|
|
119188
119190
|
};
|
|
119189
119191
|
|
|
119192
|
+
const buildEditorMetadata = (descriptor, eGridCell, dataUnit, editionManager) => {
|
|
119193
|
+
return Object.assign(Object.assign({}, RecordValidationProcessor.buildFieldMetadata(descriptor)), { eGridCell, dataUnit, editionManager });
|
|
119194
|
+
};
|
|
119195
|
+
|
|
119196
|
+
const MINIMIUM_WIDTH_TEXTAREA = 210;
|
|
119197
|
+
const PADDING_VALUE_TEXTAREA = 12;
|
|
119198
|
+
const buildTextInput = ({ name, contextName }) => {
|
|
119199
|
+
return core.HTMLBuilder.parseElement(`<ez-text-input
|
|
119200
|
+
class="ez-grid grid_editor"
|
|
119201
|
+
data-field-name=${name}
|
|
119202
|
+
data-context-name=${contextName}
|
|
119203
|
+
mode="slim"
|
|
119204
|
+
/>`);
|
|
119205
|
+
};
|
|
119206
|
+
const buildTextAreaInput = ({ eGridCell, editionManager }) => {
|
|
119207
|
+
const element = core.HTMLBuilder.parseElement(`<ez-text-area
|
|
119208
|
+
can-show-error="false"
|
|
119209
|
+
enable-resize="true"
|
|
119210
|
+
/>`);
|
|
119211
|
+
element.addEventListener('keydown', event => handlePressEnterEvent(event, element, editionManager));
|
|
119212
|
+
setElementInitialWidth(eGridCell, element);
|
|
119213
|
+
element.isPopUp = true;
|
|
119214
|
+
return element;
|
|
119215
|
+
};
|
|
119216
|
+
function setElementInitialWidth(eGridCell, element) {
|
|
119217
|
+
const { width } = eGridCell.getBoundingClientRect();
|
|
119218
|
+
const newValue = width > MINIMIUM_WIDTH_TEXTAREA ? width : MINIMIUM_WIDTH_TEXTAREA;
|
|
119219
|
+
element.style.minWidth = `${newValue - PADDING_VALUE_TEXTAREA}px`;
|
|
119220
|
+
element.style.resize = "both";
|
|
119221
|
+
}
|
|
119222
|
+
function handlePressEnterEvent(event, element, editionManager) {
|
|
119223
|
+
if (isEnter(event)) {
|
|
119224
|
+
const shouldBreakLine = event.ctrlKey;
|
|
119225
|
+
if (shouldBreakLine) {
|
|
119226
|
+
element.appendTextToSelection('\n');
|
|
119227
|
+
event.preventDefault();
|
|
119228
|
+
return;
|
|
119229
|
+
}
|
|
119230
|
+
editionManager.navigateByEnterKey(event);
|
|
119231
|
+
}
|
|
119232
|
+
}
|
|
119233
|
+
function isEnter(event) {
|
|
119234
|
+
return [event.key, event.code].includes('Enter');
|
|
119235
|
+
}
|
|
119236
|
+
|
|
119237
|
+
const LIMIT_TIME_VALUE = 2359;
|
|
119238
|
+
const buildDate = () => {
|
|
119239
|
+
const dateInput = core.HTMLBuilder.parseElement(`<ez-date-input
|
|
119240
|
+
class="ez-grid grid_editor"
|
|
119241
|
+
mode="slim"
|
|
119242
|
+
data-is-fixed="true"
|
|
119243
|
+
/>`);
|
|
119244
|
+
dateInput.valueGetter = () => dateInput.getValueAsync();
|
|
119245
|
+
return dateInput;
|
|
119246
|
+
};
|
|
119247
|
+
const buildTime = ({ readOnly }) => {
|
|
119248
|
+
const timeInputElement = core.HTMLBuilder.parseElement(`<ez-time-input
|
|
119249
|
+
class="ez-grid grid_editor"
|
|
119250
|
+
enabled=${!readOnly}
|
|
119251
|
+
mode="slim"
|
|
119252
|
+
/>`);
|
|
119253
|
+
timeInputElement.valueGetter = () => {
|
|
119254
|
+
const value = timeInputElement.value;
|
|
119255
|
+
const isAllowedTime = parseInt(value) <= LIMIT_TIME_VALUE;
|
|
119256
|
+
return isAllowedTime ? value : null;
|
|
119257
|
+
};
|
|
119258
|
+
timeInputElement.valueSetter = (value) => {
|
|
119259
|
+
const isAllowedTime = parseInt(value) <= LIMIT_TIME_VALUE;
|
|
119260
|
+
if (!isAllowedTime)
|
|
119261
|
+
return timeInputElement.value = null;
|
|
119262
|
+
return timeInputElement.value = value;
|
|
119263
|
+
};
|
|
119264
|
+
return timeInputElement;
|
|
119265
|
+
};
|
|
119266
|
+
const buildDateTime = ({ readOnly }) => {
|
|
119267
|
+
const dateTimeInput = core.HTMLBuilder.parseElement(`<ez-date-time-input
|
|
119268
|
+
class="ez-grid grid_editor"
|
|
119269
|
+
mode="slim"
|
|
119270
|
+
enabled=${!readOnly}
|
|
119271
|
+
data-is-fixed="true"
|
|
119272
|
+
/>`);
|
|
119273
|
+
dateTimeInput.valueGetter = () => dateTimeInput.getValueAsync();
|
|
119274
|
+
return dateTimeInput;
|
|
119275
|
+
};
|
|
119276
|
+
|
|
119277
|
+
const buildDecimal = ({ readOnly, props }) => {
|
|
119278
|
+
const precision = Number((props === null || props === void 0 ? void 0 : props.precision) || 2);
|
|
119279
|
+
const prettyPrecision = Number((props === null || props === void 0 ? void 0 : props.prettyPrecision) || precision);
|
|
119280
|
+
return buildNumeric(readOnly, precision, prettyPrecision);
|
|
119281
|
+
};
|
|
119282
|
+
const buildInteger = ({ readOnly }) => {
|
|
119283
|
+
return buildNumeric(readOnly, 0, 0);
|
|
119284
|
+
};
|
|
119285
|
+
function buildNumeric(readOnly, precision, prettyPrecision) {
|
|
119286
|
+
const input = core.HTMLBuilder.parseElement(`<ez-number-input
|
|
119287
|
+
class="ez-grid grid_editor"
|
|
119288
|
+
enabled=${!readOnly}
|
|
119289
|
+
precision=${precision}
|
|
119290
|
+
pretty-precision=${prettyPrecision}
|
|
119291
|
+
mode="slim"
|
|
119292
|
+
/>`);
|
|
119293
|
+
input.valueGetter = () => input.getValueAsync();
|
|
119294
|
+
return input;
|
|
119295
|
+
}
|
|
119296
|
+
|
|
119297
|
+
function getViewPortHeight(cell) {
|
|
119298
|
+
let currentElem = cell;
|
|
119299
|
+
while (currentElem) {
|
|
119300
|
+
const viewPort = currentElem.querySelector("[ref=eBodyViewport]");
|
|
119301
|
+
if (viewPort) {
|
|
119302
|
+
return viewPort.getBoundingClientRect().bottom;
|
|
119303
|
+
}
|
|
119304
|
+
currentElem = currentElem.parentElement;
|
|
119305
|
+
}
|
|
119306
|
+
}
|
|
119307
|
+
|
|
119308
|
+
const BOOLEAN_OPTIONS = new Map([[true, { value: "S", label: "Sim" }], [false, { value: "N", label: "Não" }]]);
|
|
119309
|
+
const buildComboBox = ({ required, props, eGridCell }) => {
|
|
119310
|
+
const prop = props === null || props === void 0 ? void 0 : props.options;
|
|
119311
|
+
let options;
|
|
119312
|
+
if (typeof prop === "string") {
|
|
119313
|
+
const parsed = JSON.parse(prop);
|
|
119314
|
+
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
119315
|
+
}
|
|
119316
|
+
else {
|
|
119317
|
+
options = prop;
|
|
119318
|
+
}
|
|
119319
|
+
const combo = core.HTMLBuilder.parseElement(`<ez-combo-box
|
|
119320
|
+
class="grid_editor"
|
|
119321
|
+
suppress-empty-option=${required}
|
|
119322
|
+
mode="slim"
|
|
119323
|
+
/>`);
|
|
119324
|
+
combo.options = options;
|
|
119325
|
+
combo.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
|
|
119326
|
+
return combo;
|
|
119327
|
+
};
|
|
119328
|
+
const buildSwitch = (fieldMetadata) => {
|
|
119329
|
+
const combo = buildComboBox(Object.assign(Object.assign({}, fieldMetadata), { props: Object.assign(Object.assign({}, fieldMetadata.props), { options: Array.from(BOOLEAN_OPTIONS.values()) }) }));
|
|
119330
|
+
combo.valueGetter = () => {
|
|
119331
|
+
const value = combo.value;
|
|
119332
|
+
if (value == undefined) {
|
|
119333
|
+
return;
|
|
119334
|
+
}
|
|
119335
|
+
return value.value == "S";
|
|
119336
|
+
};
|
|
119337
|
+
combo.valueSetter = (value) => {
|
|
119338
|
+
if (value != undefined) {
|
|
119339
|
+
combo.value = BOOLEAN_OPTIONS.get(value);
|
|
119340
|
+
}
|
|
119341
|
+
};
|
|
119342
|
+
return combo;
|
|
119343
|
+
};
|
|
119344
|
+
|
|
119345
|
+
const buildSearch = ({ name, required, readOnly, eGridCell, dataUnit }) => {
|
|
119346
|
+
const ezSearch = core.HTMLBuilder.parseElement(`<ez-search
|
|
119347
|
+
class="ez-grid grid_editor"
|
|
119348
|
+
mode="slim"
|
|
119349
|
+
suppress-empty-option=${required}
|
|
119350
|
+
enabled=${!readOnly}
|
|
119351
|
+
/>`);
|
|
119352
|
+
const loader = core.ApplicationContext.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");
|
|
119353
|
+
ezSearch.optionLoader = (argument) => loader(argument, name, dataUnit);
|
|
119354
|
+
ezSearch.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
|
|
119355
|
+
ezSearch.valueGetter = () => ezSearch.getValueAsync();
|
|
119356
|
+
return ezSearch;
|
|
119357
|
+
};
|
|
119358
|
+
|
|
119359
|
+
const uiBuilders = new Map();
|
|
119360
|
+
uiBuilders.set(core.UserInterface.DATE, buildDate);
|
|
119361
|
+
uiBuilders.set(core.UserInterface.TIME, buildTime);
|
|
119362
|
+
uiBuilders.set(core.UserInterface.DATETIME, buildDateTime);
|
|
119363
|
+
uiBuilders.set(core.UserInterface.DECIMALNUMBER, buildDecimal);
|
|
119364
|
+
uiBuilders.set(core.UserInterface.INTEGERNUMBER, buildInteger);
|
|
119365
|
+
uiBuilders.set(core.UserInterface.SWITCH, buildSwitch);
|
|
119366
|
+
uiBuilders.set(core.UserInterface.CHECKBOX, buildSwitch);
|
|
119367
|
+
uiBuilders.set(core.UserInterface.OPTIONSELECTOR, buildComboBox);
|
|
119368
|
+
uiBuilders.set(core.UserInterface.LONGTEXT, buildTextAreaInput);
|
|
119369
|
+
uiBuilders.set(core.UserInterface.SEARCH, buildSearch);
|
|
119370
|
+
class EzCellEditor {
|
|
119371
|
+
init(params) {
|
|
119372
|
+
const fieldName = params.column.getColId();
|
|
119373
|
+
const dataUnit = params.context.dataUnit;
|
|
119374
|
+
const fieldMetadata = buildEditorMetadata(dataUnit.getField(fieldName), params.eGridCell, dataUnit, params.context.editionManager);
|
|
119375
|
+
const builder = uiBuilders.get(fieldMetadata.userInterface) || buildTextInput;
|
|
119376
|
+
this._gui = builder(fieldMetadata);
|
|
119377
|
+
if (this._gui.valueSetter != undefined) {
|
|
119378
|
+
this._gui.valueSetter(params.value);
|
|
119379
|
+
}
|
|
119380
|
+
else {
|
|
119381
|
+
this._gui.value = params.value;
|
|
119382
|
+
}
|
|
119383
|
+
}
|
|
119384
|
+
getGui() {
|
|
119385
|
+
return this._gui;
|
|
119386
|
+
}
|
|
119387
|
+
afterGuiAttached() {
|
|
119388
|
+
this.focusIn();
|
|
119389
|
+
}
|
|
119390
|
+
focusIn() {
|
|
119391
|
+
this._gui.focus();
|
|
119392
|
+
this._gui.setFocus({ selectText: true });
|
|
119393
|
+
}
|
|
119394
|
+
getValue() {
|
|
119395
|
+
return this._gui.valueGetter != undefined ? this._gui.valueGetter() : this._gui.value;
|
|
119396
|
+
}
|
|
119397
|
+
isPopup() {
|
|
119398
|
+
return this._gui.isPopUp;
|
|
119399
|
+
}
|
|
119400
|
+
}
|
|
119401
|
+
|
|
119402
|
+
class GridEditionManager {
|
|
119403
|
+
constructor(dataUnit, useEnterLikeTab, recordsValidator, editionIsDisabled) {
|
|
119404
|
+
this._dataUnit = dataUnit;
|
|
119405
|
+
this._recordValidationProcessor = new RecordValidationProcessor.RecordValidationProcessor(this._dataUnit, {
|
|
119406
|
+
getRequiredFields: () => this.getRequiredFields(),
|
|
119407
|
+
markAsInvalid: () => { },
|
|
119408
|
+
getMessageForField: () => null
|
|
119409
|
+
}, recordsValidator);
|
|
119410
|
+
this._useEnterLikeTab = useEnterLikeTab;
|
|
119411
|
+
this._editionIsDisabled = editionIsDisabled;
|
|
119412
|
+
}
|
|
119413
|
+
configureGrid(options) {
|
|
119414
|
+
this._gridOptions = options;
|
|
119415
|
+
options.readOnlyEdit = true;
|
|
119416
|
+
options.onCellEditRequest = evt => this.onCellEditRequest(evt);
|
|
119417
|
+
options.onCellKeyDown = evt => {
|
|
119418
|
+
if (evt.event && evt["column"]) {
|
|
119419
|
+
this.onCellKeyDown(evt);
|
|
119420
|
+
}
|
|
119421
|
+
};
|
|
119422
|
+
return options;
|
|
119423
|
+
}
|
|
119424
|
+
proceedAutoSave() {
|
|
119425
|
+
if (!this._dataUnit.isDirty()) {
|
|
119426
|
+
this.saveSuccess();
|
|
119427
|
+
return;
|
|
119428
|
+
}
|
|
119429
|
+
if (!this._isGridEdition) {
|
|
119430
|
+
return;
|
|
119431
|
+
}
|
|
119432
|
+
const currentRercord = this._dataUnit.getSelectedRecord();
|
|
119433
|
+
if (currentRercord == undefined) {
|
|
119434
|
+
return;
|
|
119435
|
+
}
|
|
119436
|
+
this._recordValidationProcessor
|
|
119437
|
+
.validate()
|
|
119438
|
+
.then(() => {
|
|
119439
|
+
this._dataUnit.saveData()
|
|
119440
|
+
.then(() => this.saveSuccess())
|
|
119441
|
+
.catch(reason => this.saveFail(reason));
|
|
119442
|
+
})
|
|
119443
|
+
.catch(reason => this.saveFail(reason));
|
|
119444
|
+
}
|
|
119445
|
+
navigateByEnterKey(keyboardEvent) {
|
|
119446
|
+
const backwards = keyboardEvent.shiftKey;
|
|
119447
|
+
if (this._useEnterLikeTab) {
|
|
119448
|
+
if (backwards) {
|
|
119449
|
+
this._gridOptions.api.tabToPreviousCell(keyboardEvent);
|
|
119450
|
+
}
|
|
119451
|
+
else {
|
|
119452
|
+
this._gridOptions.api.tabToNextCell(keyboardEvent);
|
|
119453
|
+
}
|
|
119454
|
+
}
|
|
119455
|
+
else {
|
|
119456
|
+
const editionCell = this._gridOptions.api.getEditingCells()[0];
|
|
119457
|
+
if (editionCell) {
|
|
119458
|
+
let { rowIndex } = editionCell;
|
|
119459
|
+
this.nextEditionRow(rowIndex, editionCell.column, backwards);
|
|
119460
|
+
}
|
|
119461
|
+
}
|
|
119462
|
+
}
|
|
119463
|
+
getComponents() {
|
|
119464
|
+
return { ezCellEditor: EzCellEditor };
|
|
119465
|
+
}
|
|
119466
|
+
verifyClickToEdition(api, cellClicked) {
|
|
119467
|
+
if (this.isSecondClick(cellClicked)) {
|
|
119468
|
+
api.startEditingCell({ rowIndex: cellClicked.rowIndex, colKey: cellClicked.column.getColId() });
|
|
119469
|
+
}
|
|
119470
|
+
this._lastCellClicked = cellClicked;
|
|
119471
|
+
}
|
|
119472
|
+
configureColumn(col) {
|
|
119473
|
+
col.cellEditor = 'ezCellEditor';
|
|
119474
|
+
col.editable = params => this.canEdit(params);
|
|
119475
|
+
col.suppressKeyboardEvent = (params) => {
|
|
119476
|
+
return params.event.key === KeyCode.ENTER;
|
|
119477
|
+
};
|
|
119478
|
+
return col;
|
|
119479
|
+
}
|
|
119480
|
+
getRequiredFields() {
|
|
119481
|
+
return this._gridOptions.columnApi.getAllDisplayedColumns().filter(c => {
|
|
119482
|
+
const fieldDefinition = this._dataUnit.getField(c.getColId());
|
|
119483
|
+
return fieldDefinition && fieldDefinition.required;
|
|
119484
|
+
}).map(c => c.getColId());
|
|
119485
|
+
}
|
|
119486
|
+
saveSuccess() {
|
|
119487
|
+
this.focusOnCell(this._targetEditionCell);
|
|
119488
|
+
this._lastCellEdited = undefined;
|
|
119489
|
+
this._targetEditionCell = undefined;
|
|
119490
|
+
this._isGridEdition = false;
|
|
119491
|
+
}
|
|
119492
|
+
saveFail(reason) {
|
|
119493
|
+
this.focusOnCell(this._lastCellEdited);
|
|
119494
|
+
this._isGridEdition = false;
|
|
119495
|
+
if (reason) {
|
|
119496
|
+
Promise.reject(reason);
|
|
119497
|
+
}
|
|
119498
|
+
}
|
|
119499
|
+
focusOnCell(cell) {
|
|
119500
|
+
if (cell == undefined) {
|
|
119501
|
+
return;
|
|
119502
|
+
}
|
|
119503
|
+
const { rowIndex, column } = cell;
|
|
119504
|
+
this._gridOptions.api.getDisplayedRowAtIndex(rowIndex).setSelected(true, true);
|
|
119505
|
+
this._gridOptions.api.clearRangeSelection();
|
|
119506
|
+
this._gridOptions.api.addCellRange({ rowStartIndex: rowIndex, rowEndIndex: rowIndex, columns: [column] });
|
|
119507
|
+
this._gridOptions.api.startEditingCell({ colKey: column.getColId(), rowIndex });
|
|
119508
|
+
this._gridOptions.api.setFocusedCell(rowIndex, column.getColId());
|
|
119509
|
+
const cellEditor = this._gridOptions.api.getCellEditorInstances()[0];
|
|
119510
|
+
if (cellEditor) {
|
|
119511
|
+
cellEditor.focusIn();
|
|
119512
|
+
}
|
|
119513
|
+
}
|
|
119514
|
+
onCellKeyDown(event) {
|
|
119515
|
+
const keyboardEvent = event.event;
|
|
119516
|
+
switch (keyboardEvent.key) {
|
|
119517
|
+
case KeyCode.ENTER:
|
|
119518
|
+
this.processEnterKey(keyboardEvent, event);
|
|
119519
|
+
break;
|
|
119520
|
+
case KeyCode.UP:
|
|
119521
|
+
this.editPreviousRow(event.api);
|
|
119522
|
+
break;
|
|
119523
|
+
case KeyCode.DOWN:
|
|
119524
|
+
this.editNextRow(event.api);
|
|
119525
|
+
break;
|
|
119526
|
+
}
|
|
119527
|
+
}
|
|
119528
|
+
processEnterKey(keyboardEvent, event) {
|
|
119529
|
+
const editionCell = event.api.getEditingCells()[0];
|
|
119530
|
+
if (!editionCell) {
|
|
119531
|
+
event.api.startEditingCell({ colKey: event.column.getColId(), rowIndex: event.rowIndex });
|
|
119532
|
+
return;
|
|
119533
|
+
}
|
|
119534
|
+
this.navigateByEnterKey(keyboardEvent);
|
|
119535
|
+
}
|
|
119536
|
+
nextEditionRow(rowIndex, column, backwards) {
|
|
119537
|
+
if (backwards) {
|
|
119538
|
+
rowIndex = rowIndex - 1;
|
|
119539
|
+
if (rowIndex < 0) {
|
|
119540
|
+
rowIndex = this._dataUnit.records.length - 1;
|
|
119541
|
+
}
|
|
119542
|
+
}
|
|
119543
|
+
else {
|
|
119544
|
+
rowIndex = rowIndex + 1;
|
|
119545
|
+
if (rowIndex >= this._dataUnit.records.length) {
|
|
119546
|
+
rowIndex = 0;
|
|
119547
|
+
}
|
|
119548
|
+
}
|
|
119549
|
+
this._targetEditionCell = new TargetEdition(rowIndex, column, true);
|
|
119550
|
+
this.finishEdition();
|
|
119551
|
+
}
|
|
119552
|
+
editPreviousRow(api) {
|
|
119553
|
+
this.moveEditionVertically(api, -1);
|
|
119554
|
+
}
|
|
119555
|
+
editNextRow(api) {
|
|
119556
|
+
this.moveEditionVertically(api, 1);
|
|
119557
|
+
}
|
|
119558
|
+
moveEditionVertically(api, offset) {
|
|
119559
|
+
const editionCell = api.getEditingCells()[0];
|
|
119560
|
+
if (!editionCell) {
|
|
119561
|
+
return;
|
|
119562
|
+
}
|
|
119563
|
+
const rowIndex = editionCell.rowIndex + offset;
|
|
119564
|
+
if (api.getDisplayedRowAtIndex(rowIndex)) {
|
|
119565
|
+
this._targetEditionCell = new TargetEdition(rowIndex, editionCell.column, offset < 0);
|
|
119566
|
+
this.finishEdition();
|
|
119567
|
+
}
|
|
119568
|
+
}
|
|
119569
|
+
finishEdition() {
|
|
119570
|
+
this._gridOptions.api.stopEditing();
|
|
119571
|
+
setTimeout(() => {
|
|
119572
|
+
//O Timeout foi inserido para permitir que o ciclo de finalização prossiga
|
|
119573
|
+
//pois precisamos aguardar o fim da edição para executar o autosave.
|
|
119574
|
+
this.proceedAutoSave();
|
|
119575
|
+
}, 0);
|
|
119576
|
+
}
|
|
119577
|
+
canEdit(params) {
|
|
119578
|
+
if (this._editionIsDisabled()) {
|
|
119579
|
+
return false;
|
|
119580
|
+
}
|
|
119581
|
+
return this.isColEditable(params.colDef.field);
|
|
119582
|
+
}
|
|
119583
|
+
isColEditable(fieldName) {
|
|
119584
|
+
const fieldDefinition = this._dataUnit.getField(fieldName);
|
|
119585
|
+
if (fieldDefinition) {
|
|
119586
|
+
return !fieldDefinition.readOnly;
|
|
119587
|
+
}
|
|
119588
|
+
return false;
|
|
119589
|
+
}
|
|
119590
|
+
isSecondClick(cellClicked) {
|
|
119591
|
+
if (!this._lastCellClicked) {
|
|
119592
|
+
return false;
|
|
119593
|
+
}
|
|
119594
|
+
if (this._lastCellClicked.column != cellClicked.column) {
|
|
119595
|
+
return false;
|
|
119596
|
+
}
|
|
119597
|
+
if (this._lastCellClicked.rowIndex != cellClicked.rowIndex) {
|
|
119598
|
+
return false;
|
|
119599
|
+
}
|
|
119600
|
+
return true;
|
|
119601
|
+
}
|
|
119602
|
+
onCellEditRequest(event) {
|
|
119603
|
+
const fieldName = event.colDef.field;
|
|
119604
|
+
const value = event.newValue;
|
|
119605
|
+
if (event.oldValue != value) {
|
|
119606
|
+
if (value instanceof Promise) {
|
|
119607
|
+
const fieldDescriptor = this._dataUnit.getField(event.colDef.colId);
|
|
119608
|
+
event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: (fieldDescriptor === null || fieldDescriptor === void 0 ? void 0 : fieldDescriptor.userInterface) === core.UserInterface.SEARCH ? value : event.oldValue }));
|
|
119609
|
+
value.then(resolved => event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: resolved })));
|
|
119610
|
+
}
|
|
119611
|
+
else {
|
|
119612
|
+
event.node.setData(Object.assign(Object.assign({}, event.data), { [fieldName]: value }));
|
|
119613
|
+
}
|
|
119614
|
+
this._isGridEdition = true;
|
|
119615
|
+
this._dataUnit.setFieldValue(fieldName, value, [event.data.__record__id__]);
|
|
119616
|
+
this._lastCellEdited = { rowIndex: event.rowIndex, column: event.column, rowPinned: undefined };
|
|
119617
|
+
}
|
|
119618
|
+
}
|
|
119619
|
+
}
|
|
119620
|
+
class TargetEdition {
|
|
119621
|
+
constructor(rowIndex, column, backwards) {
|
|
119622
|
+
this.rowPinned = null;
|
|
119623
|
+
this.rowIndex = rowIndex;
|
|
119624
|
+
this.column = column;
|
|
119625
|
+
this.backwards = backwards;
|
|
119626
|
+
}
|
|
119627
|
+
}
|
|
119628
|
+
|
|
119190
119629
|
class AgGridController {
|
|
119191
119630
|
configFilterColumn(filterColumn) {
|
|
119192
119631
|
this._filterColumn = filterColumn;
|
|
@@ -119222,6 +119661,9 @@ class AgGridController {
|
|
|
119222
119661
|
getGridConfig() {
|
|
119223
119662
|
return this._gridConfig;
|
|
119224
119663
|
}
|
|
119664
|
+
getGridApi() {
|
|
119665
|
+
return this._gridOptions.api;
|
|
119666
|
+
}
|
|
119225
119667
|
getSort() {
|
|
119226
119668
|
const sortedColumns = [];
|
|
119227
119669
|
this._gridOptions.columnApi
|
|
@@ -119282,6 +119724,7 @@ class AgGridController {
|
|
|
119282
119724
|
this._doubleClickCallBack = options.onDoubleClick;
|
|
119283
119725
|
this._multipleSelection = options.allowMultipleSelection;
|
|
119284
119726
|
this._dataUnit = options.dataUnit;
|
|
119727
|
+
this._editionManager = new GridEditionManager(this._dataUnit, options.useEnterLikeTab, options.recordsValidator, options.editionIsDisabled);
|
|
119285
119728
|
this._statusResolver = options.statusResolver;
|
|
119286
119729
|
if (this._dataUnit) {
|
|
119287
119730
|
this._dataUnit.sortingProvider = this;
|
|
@@ -119301,12 +119744,14 @@ class AgGridController {
|
|
|
119301
119744
|
defaultColDef: {
|
|
119302
119745
|
headerClass: 'ez-grid__cell-header',
|
|
119303
119746
|
cellClass: 'ez-grid__cell-body',
|
|
119747
|
+
cellStyle: {
|
|
119748
|
+
height: '100%'
|
|
119749
|
+
}
|
|
119304
119750
|
},
|
|
119305
|
-
components: {
|
|
119306
|
-
ezGridHeaderComponent: SelectionHeader,
|
|
119307
|
-
ezGridCustomHeader: EzGridCustomHeader,
|
|
119308
|
-
},
|
|
119751
|
+
components: Object.assign({ ezGridHeaderComponent: SelectionHeader, ezGridCustomHeader: EzGridCustomHeader }, this._editionManager.getComponents()),
|
|
119309
119752
|
context: {
|
|
119753
|
+
editionManager: this._editionManager,
|
|
119754
|
+
dataUnit: this._dataUnit,
|
|
119310
119755
|
headerCheckStatusGetter: () => this.getSelectionHeaderStatus(),
|
|
119311
119756
|
headerCheckStatusSetter: (selectAll) => this.updateSelectionForAll(selectAll),
|
|
119312
119757
|
},
|
|
@@ -119314,6 +119759,7 @@ class AgGridController {
|
|
|
119314
119759
|
this.defineRowModelType(this._gridOptions, options);
|
|
119315
119760
|
this.setOptionsEvents(this._gridOptions);
|
|
119316
119761
|
this.setOptionsSupress(this._gridOptions);
|
|
119762
|
+
this._gridOptions = this._editionManager.configureGrid(this._gridOptions);
|
|
119317
119763
|
if (this._enterprise) {
|
|
119318
119764
|
this._grid = new Grid(container, this._gridOptions);
|
|
119319
119765
|
}
|
|
@@ -119460,6 +119906,7 @@ class AgGridController {
|
|
|
119460
119906
|
opt.onSelectionChanged = e => this.onSelectionChange(e);
|
|
119461
119907
|
opt.onRowDoubleClicked = evt => this.onRowDoubleClick(evt);
|
|
119462
119908
|
opt.onDragStopped = evt => this.onCallStateChange('columnMovedEnd', evt);
|
|
119909
|
+
opt.onCellClicked = evt => this.onCellClicked(evt);
|
|
119463
119910
|
}
|
|
119464
119911
|
setOptionsSupress(opt) {
|
|
119465
119912
|
opt.suppressDragLeaveHidesColumns = true;
|
|
@@ -119763,7 +120210,7 @@ class AgGridController {
|
|
|
119763
120210
|
else if (propSortable === false) {
|
|
119764
120211
|
tooltip = 'Coluna não pode ser ordenada';
|
|
119765
120212
|
}
|
|
119766
|
-
return {
|
|
120213
|
+
return this._editionManager.configureColumn({
|
|
119767
120214
|
headerName: source.label,
|
|
119768
120215
|
field: source.name,
|
|
119769
120216
|
sortable: propSortable,
|
|
@@ -119773,13 +120220,22 @@ class AgGridController {
|
|
|
119773
120220
|
tooltip: tooltip,
|
|
119774
120221
|
isSortable: propSortable,
|
|
119775
120222
|
hasFilter: () => this.hasFilterColumn(source.name),
|
|
119776
|
-
showColumnFilter: (leftPosition) => this.showFilterColumn({ columnName: source.name, columnLabel: source.label, leftPosition, filteredOptions: this._filteredColumns.get(source.name) }),
|
|
120223
|
+
showColumnFilter: (leftPosition, fromIcon) => this.showFilterColumn({ columnName: source.name, columnLabel: source.label, leftPosition, filteredOptions: this._filteredColumns.get(source.name), fromIcon }),
|
|
119777
120224
|
},
|
|
119778
120225
|
valueFormatter: params => {
|
|
120226
|
+
if (params.value == undefined) {
|
|
120227
|
+
return "";
|
|
120228
|
+
}
|
|
120229
|
+
if (params.value instanceof Promise) {
|
|
120230
|
+
return "Carregando...";
|
|
120231
|
+
}
|
|
120232
|
+
if (this._dataUnit) {
|
|
120233
|
+
return this._dataUnit.getFormattedValue(source.name, params.value);
|
|
120234
|
+
}
|
|
119779
120235
|
return this.getFormatterByColumn(params, source);
|
|
119780
120236
|
},
|
|
119781
120237
|
cellStyle: this.getStyleByColumn(source),
|
|
119782
|
-
};
|
|
120238
|
+
});
|
|
119783
120239
|
}
|
|
119784
120240
|
getInitCellStyle() {
|
|
119785
120241
|
return {
|
|
@@ -119852,6 +120308,13 @@ class AgGridController {
|
|
|
119852
120308
|
return params.value.toLocaleDateString();
|
|
119853
120309
|
}
|
|
119854
120310
|
}
|
|
120311
|
+
if ((source === null || source === void 0 ? void 0 : source.userInterface) === core.UserInterface.ELAPSEDTIME || (source === null || source === void 0 ? void 0 : source.userInterface) === core.UserInterface.TIME) {
|
|
120312
|
+
if (!!params.value) {
|
|
120313
|
+
const maskFormatter = new core.MaskFormatter("##:##");
|
|
120314
|
+
const formattedValue = String(params.value).padStart(4, '0');
|
|
120315
|
+
return maskFormatter.format(formattedValue);
|
|
120316
|
+
}
|
|
120317
|
+
}
|
|
119855
120318
|
}
|
|
119856
120319
|
onCallStateChange(type, e) {
|
|
119857
120320
|
const finished = !('finished' in e) || e['finished'];
|
|
@@ -119866,6 +120329,13 @@ class AgGridController {
|
|
|
119866
120329
|
this._columnStateChangeCallback(type, this.getColumnsState(), info);
|
|
119867
120330
|
}
|
|
119868
120331
|
}
|
|
120332
|
+
onCellClicked(event) {
|
|
120333
|
+
this._editionManager.verifyClickToEdition(event.api, {
|
|
120334
|
+
rowIndex: event.rowIndex,
|
|
120335
|
+
column: event.column,
|
|
120336
|
+
rowPinned: undefined
|
|
120337
|
+
});
|
|
120338
|
+
}
|
|
119869
120339
|
isElementResize(e) {
|
|
119870
120340
|
return e['target'] && e['target'].getAttribute('ref') === 'eResize';
|
|
119871
120341
|
}
|
|
@@ -119883,6 +120353,7 @@ class AgGridController {
|
|
|
119883
120353
|
if (this._selectionChangeCallback) {
|
|
119884
120354
|
clearTimeout(this._selectionChangeDeboucing);
|
|
119885
120355
|
this._selectionChangeDeboucing = window.setTimeout(() => {
|
|
120356
|
+
this._editionManager.proceedAutoSave();
|
|
119886
120357
|
if (this._dataUnit) {
|
|
119887
120358
|
if (event.context.selectionChangeQuietly) {
|
|
119888
120359
|
const selectionInfo = this._dataUnit;
|
|
@@ -119972,6 +120443,84 @@ function getElementID(sufix) {
|
|
|
119972
120443
|
};
|
|
119973
120444
|
}
|
|
119974
120445
|
|
|
120446
|
+
class InMemoryFilterColumnDataSource {
|
|
120447
|
+
constructor(dataUnit) {
|
|
120448
|
+
var _a;
|
|
120449
|
+
this.onDataUnitAction = (action) => {
|
|
120450
|
+
if (action.type === core.Action.DATA_SAVED || action.type === core.Action.RECORDS_REMOVED) {
|
|
120451
|
+
this.originalRecords = this.dataUnit.records;
|
|
120452
|
+
}
|
|
120453
|
+
};
|
|
120454
|
+
this.dataUnit = dataUnit;
|
|
120455
|
+
this.originalRecords = (_a = this.dataUnit.records) !== null && _a !== void 0 ? _a : [];
|
|
120456
|
+
this.dataUnit.subscribe(this.onDataUnitAction);
|
|
120457
|
+
}
|
|
120458
|
+
fetchData(filterTerm, fieldName) {
|
|
120459
|
+
return new Promise(resolve => {
|
|
120460
|
+
const filteredRecords = this.originalRecords.filter(record => this.includesSearchTerm(record, fieldName, filterTerm));
|
|
120461
|
+
const options = filteredRecords.map(item => this.buildFieldOption(item, fieldName));
|
|
120462
|
+
resolve(this.removeDuplicatedOptions(options));
|
|
120463
|
+
});
|
|
120464
|
+
}
|
|
120465
|
+
buildFieldOption(item, fieldName) {
|
|
120466
|
+
return {
|
|
120467
|
+
value: this.buildValue(item, fieldName),
|
|
120468
|
+
label: this.formatLabel(fieldName, item[fieldName]),
|
|
120469
|
+
check: true,
|
|
120470
|
+
};
|
|
120471
|
+
}
|
|
120472
|
+
buildValue(item, fieldName) {
|
|
120473
|
+
var _a;
|
|
120474
|
+
let value = item[fieldName];
|
|
120475
|
+
if (((_a = this.dataUnit.getField(fieldName)) === null || _a === void 0 ? void 0 : _a.dataType) === core.DataType.OBJECT) {
|
|
120476
|
+
value = value.value;
|
|
120477
|
+
}
|
|
120478
|
+
return value === null || value === void 0 ? void 0 : value.toString();
|
|
120479
|
+
}
|
|
120480
|
+
removeDuplicatedOptions(options) {
|
|
120481
|
+
const noDuplicatedOptions = [];
|
|
120482
|
+
options.forEach(option => {
|
|
120483
|
+
if (!noDuplicatedOptions.find(({ label }) => label === option.label)) {
|
|
120484
|
+
noDuplicatedOptions.push(option);
|
|
120485
|
+
}
|
|
120486
|
+
});
|
|
120487
|
+
return noDuplicatedOptions;
|
|
120488
|
+
}
|
|
120489
|
+
includesSearchTerm(record, fieldName, filterTerm) {
|
|
120490
|
+
let label = this.buildLabel(fieldName, record[fieldName]);
|
|
120491
|
+
return label.toLowerCase().includes(filterTerm.toLowerCase());
|
|
120492
|
+
}
|
|
120493
|
+
buildLabel(fieldName, value) {
|
|
120494
|
+
var _a;
|
|
120495
|
+
const { dataType } = this.dataUnit.getField(fieldName);
|
|
120496
|
+
if (dataType === core.DataType.NUMBER) {
|
|
120497
|
+
return value === null || value === void 0 ? void 0 : value.toString().replace('.', ',');
|
|
120498
|
+
}
|
|
120499
|
+
if (dataType === core.DataType.DATE) {
|
|
120500
|
+
return (typeof value === 'object')
|
|
120501
|
+
? (_a = core.DateUtils.formatDate(this.dataUnit.valueFromString(fieldName, value))) === null || _a === void 0 ? void 0 : _a.toString()
|
|
120502
|
+
: value === null || value === void 0 ? void 0 : value.toString();
|
|
120503
|
+
}
|
|
120504
|
+
if (dataType === core.DataType.OBJECT) {
|
|
120505
|
+
return `${value === null || value === void 0 ? void 0 : value.value} - ${value === null || value === void 0 ? void 0 : value.label}`;
|
|
120506
|
+
}
|
|
120507
|
+
return value === null || value === void 0 ? void 0 : value.toString();
|
|
120508
|
+
}
|
|
120509
|
+
formatLabel(fieldName, value) {
|
|
120510
|
+
var _a, _b;
|
|
120511
|
+
const { userInterface, dataType } = this.dataUnit.getField(fieldName);
|
|
120512
|
+
if (dataType === core.DataType.DATE) {
|
|
120513
|
+
return (typeof value === 'object')
|
|
120514
|
+
? core.DateUtils.formatDate(this.dataUnit.valueFromString(fieldName, value))
|
|
120515
|
+
: value === null || value === void 0 ? void 0 : value.toString();
|
|
120516
|
+
}
|
|
120517
|
+
if (dataType === core.DataType.NUMBER && userInterface !== core.UserInterface.DECIMALNUMBER) {
|
|
120518
|
+
return (_a = parseInt(this.dataUnit.getFormattedValue(fieldName, value))) === null || _a === void 0 ? void 0 : _a.toString();
|
|
120519
|
+
}
|
|
120520
|
+
return (_b = this.dataUnit.getFormattedValue(fieldName, value)) === null || _b === void 0 ? void 0 : _b.toString();
|
|
120521
|
+
}
|
|
120522
|
+
}
|
|
120523
|
+
|
|
119975
120524
|
const ezGridCss = ".sc-ez-grid-h{display:grid;grid-template-rows:auto 1fr auto;height:100%;width:100%;--ez-grid__header--background-color:var(--background--xlight, #FFF);--ez-grid__selection-counter--z-index:var(--visible, 1);--ez-grid__container--shadow:0 0 16px 0 rgb(0 38 111 / 12%)}.grid-header.sc-ez-grid{display:grid;justify-content:space-between;align-items:center;grid-template-columns:1fr;background-color:var(--ez-grid__header--background-color, #FFF);z-index:var(--more-visible, 2)}.grid__container.sc-ez-grid{padding-top:15px;margin-top:-12px;box-shadow:var(--ez-grid__container--shadow);background-color:var(--ez-grid__header--background-color)}.grid-header__popover.sc-ez-grid{position:relative;top:var(--space--sm, 16px)}.grid-header__container.sc-ez-grid{display:flex;align-items:center}.grid-header__position.sc-ez-grid{display:flex;align-items:center;justify-content:space-between}.grid__selection-counter.sc-ez-grid{position:fixed;white-space:nowrap;transform:translate(-50%, 0px);left:50%;opacity:0;bottom:-100%;transition:opacity 0.1s, bottom 0.5s;z-index:var(--ez-grid__selection-counter--z-index)}.grid__selection-counter--opened.sc-ez-grid{opacity:1;bottom:0px}.grid__btn-close.sc-ez-grid{display:flex;align-items:center;justify-content:center;padding:0;outline:none;width:20px;height:20px;border:none;background-color:unset;cursor:pointer}.grid__btn-clear.sc-ez-grid{--ez-button--link-color:var(--color--alert-warning-900, #8C6B00);--ez-button--link--hover-color:var(--color--alert-warning-900, #8C6B00)}[no-header].sc-ez-grid-h .grid-header.sc-ez-grid{height:0;padding:0}";
|
|
119976
120525
|
|
|
119977
120526
|
const windowInstace = window;
|
|
@@ -119985,18 +120534,13 @@ const EzGrid = class {
|
|
|
119985
120534
|
this.componentReady = index.createEvent(this, "componentReady", 7);
|
|
119986
120535
|
this._gridController = new AgGridController(false);
|
|
119987
120536
|
this._messageFilterAppliedSuccess = 'Filtro de coluna aplicado com sucesso!';
|
|
119988
|
-
this.onDataUnitAction = (action) => {
|
|
119989
|
-
if (action.type === core.Action.DATA_SAVED || action.type === core.Action.RECORDS_REMOVED) {
|
|
119990
|
-
this._originalRecords = this.dataUnit.records;
|
|
119991
|
-
}
|
|
119992
|
-
};
|
|
119993
120537
|
this._paginationInfo = undefined;
|
|
119994
120538
|
this._paginationChangedByKeyboard = true;
|
|
119995
120539
|
this._showSelectionCounter = false;
|
|
119996
120540
|
this._isAllSelection = false;
|
|
119997
120541
|
this._currentPageSelected = undefined;
|
|
119998
120542
|
this._selectionCount = undefined;
|
|
119999
|
-
this.
|
|
120543
|
+
this._hasLeftButtons = false;
|
|
120000
120544
|
this.multipleSelection = undefined;
|
|
120001
120545
|
this.config = undefined;
|
|
120002
120546
|
this.selectionToastConfig = undefined;
|
|
@@ -120004,6 +120548,9 @@ const EzGrid = class {
|
|
|
120004
120548
|
this.dataUnit = undefined;
|
|
120005
120549
|
this.statusResolver = undefined;
|
|
120006
120550
|
this.columnfilterDataSource = undefined;
|
|
120551
|
+
this.useEnterLikeTab = false;
|
|
120552
|
+
this.recordsValidator = undefined;
|
|
120553
|
+
this.canEdit = true;
|
|
120007
120554
|
}
|
|
120008
120555
|
/**
|
|
120009
120556
|
* Aplica a definição de colunas.
|
|
@@ -120237,6 +120784,9 @@ const EzGrid = class {
|
|
|
120237
120784
|
serverURL: this.serverUrl,
|
|
120238
120785
|
dataUnit: this.dataUnit,
|
|
120239
120786
|
statusResolver: this.statusResolver,
|
|
120787
|
+
useEnterLikeTab: this.useEnterLikeTab,
|
|
120788
|
+
recordsValidator: this.recordsValidator,
|
|
120789
|
+
editionIsDisabled: () => !this.canEdit
|
|
120240
120790
|
});
|
|
120241
120791
|
if (this.config) {
|
|
120242
120792
|
this.observeConfig(this.config);
|
|
@@ -120245,6 +120795,11 @@ const EzGrid = class {
|
|
|
120245
120795
|
this.setEvents();
|
|
120246
120796
|
this.componentReady.emit();
|
|
120247
120797
|
this._gridController.configFilterColumn(this._filterColumn);
|
|
120798
|
+
this._container.addEventListener('focusout', (event) => {
|
|
120799
|
+
const api = this._gridController.getGridApi();
|
|
120800
|
+
if (api && !this._container.contains(event.relatedTarget))
|
|
120801
|
+
api.clearFocusedCell();
|
|
120802
|
+
});
|
|
120248
120803
|
}
|
|
120249
120804
|
componentWillRender() {
|
|
120250
120805
|
this.configSelectionCounter();
|
|
@@ -120255,44 +120810,20 @@ const EzGrid = class {
|
|
|
120255
120810
|
});
|
|
120256
120811
|
}
|
|
120257
120812
|
componentWillLoad() {
|
|
120813
|
+
this._hasLeftButtons = !!this._element.querySelector('[slot="leftButtons"]');
|
|
120258
120814
|
if (!this.dataUnit.name.includes("InMemoryDataUnit"))
|
|
120259
120815
|
return;
|
|
120260
|
-
this.dataUnit.subscribe(this.onDataUnitAction);
|
|
120261
120816
|
}
|
|
120262
120817
|
getDataSource() {
|
|
120263
|
-
|
|
120264
|
-
|
|
120265
|
-
buildDefaultDataSource() {
|
|
120266
|
-
var _a, _b;
|
|
120267
|
-
if (this._originalRecords.length === 0) {
|
|
120268
|
-
this._originalRecords = (_b = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : [];
|
|
120269
|
-
}
|
|
120270
|
-
return {
|
|
120271
|
-
fetchData: (filterTerm, fieldName) => {
|
|
120272
|
-
return new Promise(resolve => {
|
|
120273
|
-
const filteredRecords = this._originalRecords.filter(record => {
|
|
120274
|
-
var _a, _b;
|
|
120275
|
-
const label = typeof record[fieldName] === "object" ? `${(_a = record[fieldName]) === null || _a === void 0 ? void 0 : _a.value} - ${(_b = record[fieldName]) === null || _b === void 0 ? void 0 : _b.label}` : record[fieldName];
|
|
120276
|
-
return label === null || label === void 0 ? void 0 : label.toString().toLowerCase().includes(filterTerm.toLowerCase());
|
|
120277
|
-
});
|
|
120278
|
-
const options = filteredRecords.map(item => {
|
|
120279
|
-
return { value: item[fieldName].toString(), label: this.formatLabel(fieldName, item[fieldName]), check: true };
|
|
120280
|
-
});
|
|
120281
|
-
resolve(options);
|
|
120282
|
-
});
|
|
120283
|
-
}
|
|
120284
|
-
};
|
|
120818
|
+
var _a;
|
|
120819
|
+
return (_a = this.columnfilterDataSource) !== null && _a !== void 0 ? _a : new InMemoryFilterColumnDataSource(this.dataUnit);
|
|
120285
120820
|
}
|
|
120286
|
-
|
|
120287
|
-
|
|
120288
|
-
if (userInterface === core.UserInterface.DATETIME) {
|
|
120289
|
-
return core.DateUtils.formatDate(this.dataUnit.valueFromString(fieldName, value));
|
|
120290
|
-
}
|
|
120291
|
-
return String(this.dataUnit.getFormattedValue(fieldName, value));
|
|
120821
|
+
hideHeader() {
|
|
120822
|
+
return (!!this._element.getAttribute("no-header") && !this._paginationInfo);
|
|
120292
120823
|
}
|
|
120293
120824
|
render() {
|
|
120294
120825
|
var _a;
|
|
120295
|
-
return (index.h(index.Host,
|
|
120826
|
+
return (index.h(index.Host, { "no-header": this.hideHeader() }, index.h("div", { class: "ez-box ez-box--shadow ez-padding--medium grid-header" }, index.h("filter-column", { class: "grid-header__popover", noHeaderTaskBar: !this._hasLeftButtons, dataSource: this.getDataSource(), dataUnit: this.dataUnit, gridHeaderHidden: this.hideHeader(), ref: (element) => (this._filterColumn = element) }), index.h("div", { class: "grid-header__position" }, index.h("div", { class: "grid-header__container" }, index.h("slot", { name: "leftButtons" })), index.h("div", { class: "grid-header__container", ref: ref => (this._refPaginationControl = ref) }, this.getPaginationControl()))), index.h("div", { ref: (ref) => (this._gridSelectionCounter = ref), class: `grid__selection-counter
|
|
120296
120827
|
${this._showSelectionCounter ? 'grid__selection-counter--opened' : ''}
|
|
120297
120828
|
` }, index.h(SelectionCounter, { selectionCount: this._selectionCount, currentPageSelected: this._currentPageSelected, paginationInfo: this._paginationInfo, canSelectAll: (_a = this.selectionToastConfig) === null || _a === void 0 ? void 0 : _a.canSelectAll, allRecordSelected: this._isAllSelection, onSelectAll: () => this.onSelectAllRecords(), onSelectPage: () => this.onSelectPageRecords(), onClearAll: () => this.onClearSelectedRecords(), onClose: () => (this._showSelectionCounter = false) })), index.h("div", { class: "grid__container ez-grid", ref: elem => (this._container = elem) }), index.h("div", { class: "grid__footer" }, index.h("slot", { name: "footer" }))));
|
|
120298
120829
|
}
|