@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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { UserInterface } from "@sankhyalabs/core";
|
|
2
|
+
import { buildEditorMetadata } from "./IEditorMetadata";
|
|
3
|
+
import { buildTextAreaInput, buildTextInput } from "./templates/TextInput.tpl";
|
|
4
|
+
import { buildDate, buildDateTime, buildTime } from "./templates/DateInput.tpl";
|
|
5
|
+
import { buildDecimal, buildInteger } from "./templates/NumberInput.tpl";
|
|
6
|
+
import { buildComboBox, buildSwitch } from "./templates/ComboBox.tpl";
|
|
7
|
+
import { buildSearch } from "./templates/Search.tpl";
|
|
8
|
+
const uiBuilders = new Map();
|
|
9
|
+
uiBuilders.set(UserInterface.DATE, buildDate);
|
|
10
|
+
uiBuilders.set(UserInterface.TIME, buildTime);
|
|
11
|
+
uiBuilders.set(UserInterface.DATETIME, buildDateTime);
|
|
12
|
+
uiBuilders.set(UserInterface.DECIMALNUMBER, buildDecimal);
|
|
13
|
+
uiBuilders.set(UserInterface.INTEGERNUMBER, buildInteger);
|
|
14
|
+
uiBuilders.set(UserInterface.SWITCH, buildSwitch);
|
|
15
|
+
uiBuilders.set(UserInterface.CHECKBOX, buildSwitch);
|
|
16
|
+
uiBuilders.set(UserInterface.OPTIONSELECTOR, buildComboBox);
|
|
17
|
+
uiBuilders.set(UserInterface.LONGTEXT, buildTextAreaInput);
|
|
18
|
+
uiBuilders.set(UserInterface.SEARCH, buildSearch);
|
|
19
|
+
export default class EzCellEditor {
|
|
20
|
+
init(params) {
|
|
21
|
+
const fieldName = params.column.getColId();
|
|
22
|
+
const dataUnit = params.context.dataUnit;
|
|
23
|
+
const fieldMetadata = buildEditorMetadata(dataUnit.getField(fieldName), params.eGridCell, dataUnit, params.context.editionManager);
|
|
24
|
+
const builder = uiBuilders.get(fieldMetadata.userInterface) || buildTextInput;
|
|
25
|
+
this._gui = builder(fieldMetadata);
|
|
26
|
+
if (this._gui.valueSetter != undefined) {
|
|
27
|
+
this._gui.valueSetter(params.value);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this._gui.value = params.value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
getGui() {
|
|
34
|
+
return this._gui;
|
|
35
|
+
}
|
|
36
|
+
afterGuiAttached() {
|
|
37
|
+
this.focusIn();
|
|
38
|
+
}
|
|
39
|
+
focusIn() {
|
|
40
|
+
this._gui.focus();
|
|
41
|
+
this._gui.setFocus({ selectText: true });
|
|
42
|
+
}
|
|
43
|
+
getValue() {
|
|
44
|
+
return this._gui.valueGetter != undefined ? this._gui.valueGetter() : this._gui.value;
|
|
45
|
+
}
|
|
46
|
+
isPopup() {
|
|
47
|
+
return this._gui.isPopUp;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function getViewPortHeight(cell) {
|
|
2
|
+
let currentElem = cell;
|
|
3
|
+
while (currentElem) {
|
|
4
|
+
const viewPort = currentElem.querySelector("[ref=eBodyViewport]");
|
|
5
|
+
if (viewPort) {
|
|
6
|
+
return viewPort.getBoundingClientRect().bottom;
|
|
7
|
+
}
|
|
8
|
+
currentElem = currentElem.parentElement;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { buildFieldMetadata } from '../../../../../utils/interfaces/AbstractFieldMetadata';
|
|
2
|
+
export const buildEditorMetadata = (descriptor, eGridCell, dataUnit, editionManager) => {
|
|
3
|
+
return Object.assign(Object.assign({}, buildFieldMetadata(descriptor)), { eGridCell, dataUnit, editionManager });
|
|
4
|
+
};
|
package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/ComboBox.tpl.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { HTMLBuilder } from "@sankhyalabs/core";
|
|
2
|
+
import { getViewPortHeight } from '../GridEditorUtils';
|
|
3
|
+
const BOOLEAN_OPTIONS = new Map([[true, { value: "S", label: "Sim" }], [false, { value: "N", label: "Não" }]]);
|
|
4
|
+
export const buildComboBox = ({ required, props, eGridCell }) => {
|
|
5
|
+
const prop = props === null || props === void 0 ? void 0 : props.options;
|
|
6
|
+
let options;
|
|
7
|
+
if (typeof prop === "string") {
|
|
8
|
+
const parsed = JSON.parse(prop);
|
|
9
|
+
options = Object.keys(parsed).map(key => { return { value: key, label: parsed[key] }; });
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
options = prop;
|
|
13
|
+
}
|
|
14
|
+
const combo = HTMLBuilder.parseElement(`<ez-combo-box
|
|
15
|
+
class="grid_editor"
|
|
16
|
+
suppress-empty-option=${required}
|
|
17
|
+
mode="slim"
|
|
18
|
+
/>`);
|
|
19
|
+
combo.options = options;
|
|
20
|
+
combo.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
|
|
21
|
+
return combo;
|
|
22
|
+
};
|
|
23
|
+
export const buildSwitch = (fieldMetadata) => {
|
|
24
|
+
const combo = buildComboBox(Object.assign(Object.assign({}, fieldMetadata), { props: Object.assign(Object.assign({}, fieldMetadata.props), { options: Array.from(BOOLEAN_OPTIONS.values()) }) }));
|
|
25
|
+
combo.valueGetter = () => {
|
|
26
|
+
const value = combo.value;
|
|
27
|
+
if (value == undefined) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
return value.value == "S";
|
|
31
|
+
};
|
|
32
|
+
combo.valueSetter = (value) => {
|
|
33
|
+
if (value != undefined) {
|
|
34
|
+
combo.value = BOOLEAN_OPTIONS.get(value);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return combo;
|
|
38
|
+
};
|
package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/DateInput.tpl.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { HTMLBuilder } from "@sankhyalabs/core";
|
|
2
|
+
const LIMIT_TIME_VALUE = 2359;
|
|
3
|
+
export const buildDate = () => {
|
|
4
|
+
const dateInput = HTMLBuilder.parseElement(`<ez-date-input
|
|
5
|
+
class="ez-grid grid_editor"
|
|
6
|
+
mode="slim"
|
|
7
|
+
data-is-fixed="true"
|
|
8
|
+
/>`);
|
|
9
|
+
dateInput.valueGetter = () => dateInput.getValueAsync();
|
|
10
|
+
return dateInput;
|
|
11
|
+
};
|
|
12
|
+
export const buildTime = ({ readOnly }) => {
|
|
13
|
+
const timeInputElement = HTMLBuilder.parseElement(`<ez-time-input
|
|
14
|
+
class="ez-grid grid_editor"
|
|
15
|
+
enabled=${!readOnly}
|
|
16
|
+
mode="slim"
|
|
17
|
+
/>`);
|
|
18
|
+
timeInputElement.valueGetter = () => {
|
|
19
|
+
const value = timeInputElement.value;
|
|
20
|
+
const isAllowedTime = parseInt(value) <= LIMIT_TIME_VALUE;
|
|
21
|
+
return isAllowedTime ? value : null;
|
|
22
|
+
};
|
|
23
|
+
timeInputElement.valueSetter = (value) => {
|
|
24
|
+
const isAllowedTime = parseInt(value) <= LIMIT_TIME_VALUE;
|
|
25
|
+
if (!isAllowedTime)
|
|
26
|
+
return timeInputElement.value = null;
|
|
27
|
+
return timeInputElement.value = value;
|
|
28
|
+
};
|
|
29
|
+
return timeInputElement;
|
|
30
|
+
};
|
|
31
|
+
export const buildDateTime = ({ readOnly }) => {
|
|
32
|
+
const dateTimeInput = HTMLBuilder.parseElement(`<ez-date-time-input
|
|
33
|
+
class="ez-grid grid_editor"
|
|
34
|
+
mode="slim"
|
|
35
|
+
enabled=${!readOnly}
|
|
36
|
+
data-is-fixed="true"
|
|
37
|
+
/>`);
|
|
38
|
+
dateTimeInput.valueGetter = () => dateTimeInput.getValueAsync();
|
|
39
|
+
return dateTimeInput;
|
|
40
|
+
};
|
package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/NumberInput.tpl.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { HTMLBuilder } from "@sankhyalabs/core";
|
|
2
|
+
export const buildDecimal = ({ readOnly, props }) => {
|
|
3
|
+
const precision = Number((props === null || props === void 0 ? void 0 : props.precision) || 2);
|
|
4
|
+
const prettyPrecision = Number((props === null || props === void 0 ? void 0 : props.prettyPrecision) || precision);
|
|
5
|
+
return buildNumeric(readOnly, precision, prettyPrecision);
|
|
6
|
+
};
|
|
7
|
+
export const buildInteger = ({ readOnly }) => {
|
|
8
|
+
return buildNumeric(readOnly, 0, 0);
|
|
9
|
+
};
|
|
10
|
+
function buildNumeric(readOnly, precision, prettyPrecision) {
|
|
11
|
+
const input = HTMLBuilder.parseElement(`<ez-number-input
|
|
12
|
+
class="ez-grid grid_editor"
|
|
13
|
+
enabled=${!readOnly}
|
|
14
|
+
precision=${precision}
|
|
15
|
+
pretty-precision=${prettyPrecision}
|
|
16
|
+
mode="slim"
|
|
17
|
+
/>`);
|
|
18
|
+
input.valueGetter = () => input.getValueAsync();
|
|
19
|
+
return input;
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ApplicationContext, HTMLBuilder } from '@sankhyalabs/core';
|
|
2
|
+
import { getViewPortHeight } from '../GridEditorUtils';
|
|
3
|
+
export const buildSearch = ({ name, required, readOnly, eGridCell, dataUnit }) => {
|
|
4
|
+
const ezSearch = HTMLBuilder.parseElement(`<ez-search
|
|
5
|
+
class="ez-grid grid_editor"
|
|
6
|
+
mode="slim"
|
|
7
|
+
suppress-empty-option=${required}
|
|
8
|
+
enabled=${!readOnly}
|
|
9
|
+
/>`);
|
|
10
|
+
const loader = ApplicationContext.getContextValue("__EZUI__SEARCH__OPTION__LOADER__");
|
|
11
|
+
ezSearch.optionLoader = (argument) => loader(argument, name, dataUnit);
|
|
12
|
+
ezSearch.listOptionsPosition = { verticalPosition: 29, bottomLimit: getViewPortHeight(eGridCell), hardPosition: true };
|
|
13
|
+
ezSearch.valueGetter = () => ezSearch.getValueAsync();
|
|
14
|
+
return ezSearch;
|
|
15
|
+
};
|
package/dist/collection/components/ez-grid/controller/ag-grid/editor/templates/TextInput.tpl.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { HTMLBuilder } from "@sankhyalabs/core";
|
|
2
|
+
const MINIMIUM_WIDTH_TEXTAREA = 210;
|
|
3
|
+
const PADDING_VALUE_TEXTAREA = 12;
|
|
4
|
+
export const buildTextInput = ({ name, contextName }) => {
|
|
5
|
+
return HTMLBuilder.parseElement(`<ez-text-input
|
|
6
|
+
class="ez-grid grid_editor"
|
|
7
|
+
data-field-name=${name}
|
|
8
|
+
data-context-name=${contextName}
|
|
9
|
+
mode="slim"
|
|
10
|
+
/>`);
|
|
11
|
+
};
|
|
12
|
+
export const buildTextAreaInput = ({ eGridCell, editionManager }) => {
|
|
13
|
+
const element = HTMLBuilder.parseElement(`<ez-text-area
|
|
14
|
+
can-show-error="false"
|
|
15
|
+
enable-resize="true"
|
|
16
|
+
/>`);
|
|
17
|
+
element.addEventListener('keydown', event => handlePressEnterEvent(event, element, editionManager));
|
|
18
|
+
setElementInitialWidth(eGridCell, element);
|
|
19
|
+
element.isPopUp = true;
|
|
20
|
+
return element;
|
|
21
|
+
};
|
|
22
|
+
function setElementInitialWidth(eGridCell, element) {
|
|
23
|
+
const { width } = eGridCell.getBoundingClientRect();
|
|
24
|
+
const newValue = width > MINIMIUM_WIDTH_TEXTAREA ? width : MINIMIUM_WIDTH_TEXTAREA;
|
|
25
|
+
element.style.minWidth = `${newValue - PADDING_VALUE_TEXTAREA}px`;
|
|
26
|
+
element.style.resize = "both";
|
|
27
|
+
}
|
|
28
|
+
function handlePressEnterEvent(event, element, editionManager) {
|
|
29
|
+
if (isEnter(event)) {
|
|
30
|
+
const shouldBreakLine = event.ctrlKey;
|
|
31
|
+
if (shouldBreakLine) {
|
|
32
|
+
element.appendTextToSelection('\n');
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
editionManager.navigateByEnterKey(event);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function isEnter(event) {
|
|
40
|
+
return [event.key, event.code].includes('Enter');
|
|
41
|
+
}
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import { ElementIDUtils, JSUtils,
|
|
1
|
+
import { ElementIDUtils, JSUtils, } from '@sankhyalabs/core';
|
|
2
2
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
|
3
|
-
import {
|
|
3
|
+
import { h, Host } from '@stencil/core';
|
|
4
4
|
import AgGridController from './controller/ag-grid/AgGridController';
|
|
5
5
|
import { SelectionCounter } from './subcomponents/selection-counter';
|
|
6
6
|
import { ApplicationUtils } from '../../utils';
|
|
7
|
+
import InMemoryFilterColumnDataSource from './utils/InMemoryFilterColumnDataSource';
|
|
7
8
|
const windowInstace = window;
|
|
8
9
|
export class EzGrid {
|
|
9
10
|
constructor() {
|
|
10
11
|
this._gridController = new AgGridController(false);
|
|
11
12
|
this._messageFilterAppliedSuccess = 'Filtro de coluna aplicado com sucesso!';
|
|
12
|
-
this.onDataUnitAction = (action) => {
|
|
13
|
-
if (action.type === Action.DATA_SAVED || action.type === Action.RECORDS_REMOVED) {
|
|
14
|
-
this._originalRecords = this.dataUnit.records;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
13
|
this._paginationInfo = undefined;
|
|
18
14
|
this._paginationChangedByKeyboard = true;
|
|
19
15
|
this._showSelectionCounter = false;
|
|
20
16
|
this._isAllSelection = false;
|
|
21
17
|
this._currentPageSelected = undefined;
|
|
22
18
|
this._selectionCount = undefined;
|
|
23
|
-
this.
|
|
19
|
+
this._hasLeftButtons = false;
|
|
24
20
|
this.multipleSelection = undefined;
|
|
25
21
|
this.config = undefined;
|
|
26
22
|
this.selectionToastConfig = undefined;
|
|
@@ -28,6 +24,9 @@ export class EzGrid {
|
|
|
28
24
|
this.dataUnit = undefined;
|
|
29
25
|
this.statusResolver = undefined;
|
|
30
26
|
this.columnfilterDataSource = undefined;
|
|
27
|
+
this.useEnterLikeTab = false;
|
|
28
|
+
this.recordsValidator = undefined;
|
|
29
|
+
this.canEdit = true;
|
|
31
30
|
}
|
|
32
31
|
/**
|
|
33
32
|
* Aplica a definição de colunas.
|
|
@@ -261,6 +260,9 @@ export class EzGrid {
|
|
|
261
260
|
serverURL: this.serverUrl,
|
|
262
261
|
dataUnit: this.dataUnit,
|
|
263
262
|
statusResolver: this.statusResolver,
|
|
263
|
+
useEnterLikeTab: this.useEnterLikeTab,
|
|
264
|
+
recordsValidator: this.recordsValidator,
|
|
265
|
+
editionIsDisabled: () => !this.canEdit
|
|
264
266
|
});
|
|
265
267
|
if (this.config) {
|
|
266
268
|
this.observeConfig(this.config);
|
|
@@ -269,6 +271,11 @@ export class EzGrid {
|
|
|
269
271
|
this.setEvents();
|
|
270
272
|
this.componentReady.emit();
|
|
271
273
|
this._gridController.configFilterColumn(this._filterColumn);
|
|
274
|
+
this._container.addEventListener('focusout', (event) => {
|
|
275
|
+
const api = this._gridController.getGridApi();
|
|
276
|
+
if (api && !this._container.contains(event.relatedTarget))
|
|
277
|
+
api.clearFocusedCell();
|
|
278
|
+
});
|
|
272
279
|
}
|
|
273
280
|
componentWillRender() {
|
|
274
281
|
this.configSelectionCounter();
|
|
@@ -279,44 +286,20 @@ export class EzGrid {
|
|
|
279
286
|
});
|
|
280
287
|
}
|
|
281
288
|
componentWillLoad() {
|
|
289
|
+
this._hasLeftButtons = !!this._element.querySelector('[slot="leftButtons"]');
|
|
282
290
|
if (!this.dataUnit.name.includes("InMemoryDataUnit"))
|
|
283
291
|
return;
|
|
284
|
-
this.dataUnit.subscribe(this.onDataUnitAction);
|
|
285
292
|
}
|
|
286
293
|
getDataSource() {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
buildDefaultDataSource() {
|
|
290
|
-
var _a, _b;
|
|
291
|
-
if (this._originalRecords.length === 0) {
|
|
292
|
-
this._originalRecords = (_b = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.records) !== null && _b !== void 0 ? _b : [];
|
|
293
|
-
}
|
|
294
|
-
return {
|
|
295
|
-
fetchData: (filterTerm, fieldName) => {
|
|
296
|
-
return new Promise(resolve => {
|
|
297
|
-
const filteredRecords = this._originalRecords.filter(record => {
|
|
298
|
-
var _a, _b;
|
|
299
|
-
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];
|
|
300
|
-
return label === null || label === void 0 ? void 0 : label.toString().toLowerCase().includes(filterTerm.toLowerCase());
|
|
301
|
-
});
|
|
302
|
-
const options = filteredRecords.map(item => {
|
|
303
|
-
return { value: item[fieldName].toString(), label: this.formatLabel(fieldName, item[fieldName]), check: true };
|
|
304
|
-
});
|
|
305
|
-
resolve(options);
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
};
|
|
294
|
+
var _a;
|
|
295
|
+
return (_a = this.columnfilterDataSource) !== null && _a !== void 0 ? _a : new InMemoryFilterColumnDataSource(this.dataUnit);
|
|
309
296
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (userInterface === UserInterface.DATETIME) {
|
|
313
|
-
return DateUtils.formatDate(this.dataUnit.valueFromString(fieldName, value));
|
|
314
|
-
}
|
|
315
|
-
return String(this.dataUnit.getFormattedValue(fieldName, value));
|
|
297
|
+
hideHeader() {
|
|
298
|
+
return (!!this._element.getAttribute("no-header") && !this._paginationInfo);
|
|
316
299
|
}
|
|
317
300
|
render() {
|
|
318
301
|
var _a;
|
|
319
|
-
return (h(Host,
|
|
302
|
+
return (h(Host, { "no-header": this.hideHeader() }, h("div", { class: "ez-box ez-box--shadow ez-padding--medium grid-header" }, h("filter-column", { class: "grid-header__popover", noHeaderTaskBar: !this._hasLeftButtons, dataSource: this.getDataSource(), dataUnit: this.dataUnit, gridHeaderHidden: this.hideHeader(), ref: (element) => (this._filterColumn = element) }), h("div", { class: "grid-header__position" }, h("div", { class: "grid-header__container" }, h("slot", { name: "leftButtons" })), h("div", { class: "grid-header__container", ref: ref => (this._refPaginationControl = ref) }, this.getPaginationControl()))), h("div", { ref: (ref) => (this._gridSelectionCounter = ref), class: `grid__selection-counter
|
|
320
303
|
${this._showSelectionCounter ? 'grid__selection-counter--opened' : ''}
|
|
321
304
|
` }, 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) })), h("div", { class: "grid__container ez-grid", ref: elem => (this._container = elem) }), h("div", { class: "grid__footer" }, h("slot", { name: "footer" }))));
|
|
322
305
|
}
|
|
@@ -472,6 +455,62 @@ export class EzGrid {
|
|
|
472
455
|
"tags": [],
|
|
473
456
|
"text": "Define um `IMultiSelectionListDataSource` respons\u00E1vel por alimentar o filtro de colunas."
|
|
474
457
|
}
|
|
458
|
+
},
|
|
459
|
+
"useEnterLikeTab": {
|
|
460
|
+
"type": "boolean",
|
|
461
|
+
"mutable": false,
|
|
462
|
+
"complexType": {
|
|
463
|
+
"original": "boolean",
|
|
464
|
+
"resolved": "boolean",
|
|
465
|
+
"references": {}
|
|
466
|
+
},
|
|
467
|
+
"required": false,
|
|
468
|
+
"optional": false,
|
|
469
|
+
"docs": {
|
|
470
|
+
"tags": [],
|
|
471
|
+
"text": "Quando verdadeiro, o ENTER far\u00E1 a navega\u00E7\u00E3o como se fosse a tecla TAB na grade."
|
|
472
|
+
},
|
|
473
|
+
"attribute": "use-enter-like-tab",
|
|
474
|
+
"reflect": false,
|
|
475
|
+
"defaultValue": "false"
|
|
476
|
+
},
|
|
477
|
+
"recordsValidator": {
|
|
478
|
+
"type": "unknown",
|
|
479
|
+
"mutable": false,
|
|
480
|
+
"complexType": {
|
|
481
|
+
"original": "IRecordValidator",
|
|
482
|
+
"resolved": "IRecordValidator",
|
|
483
|
+
"references": {
|
|
484
|
+
"IRecordValidator": {
|
|
485
|
+
"location": "import",
|
|
486
|
+
"path": "../../utils/form/interfaces"
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
"required": false,
|
|
491
|
+
"optional": false,
|
|
492
|
+
"docs": {
|
|
493
|
+
"tags": [],
|
|
494
|
+
"text": "Define um validador respons\u00E1vel pela integridade dos registros."
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
"canEdit": {
|
|
498
|
+
"type": "boolean",
|
|
499
|
+
"mutable": false,
|
|
500
|
+
"complexType": {
|
|
501
|
+
"original": "boolean",
|
|
502
|
+
"resolved": "boolean",
|
|
503
|
+
"references": {}
|
|
504
|
+
},
|
|
505
|
+
"required": false,
|
|
506
|
+
"optional": false,
|
|
507
|
+
"docs": {
|
|
508
|
+
"tags": [],
|
|
509
|
+
"text": "Define se a edi\u00E7\u00E3o est\u00E1 habilitada na grid."
|
|
510
|
+
},
|
|
511
|
+
"attribute": "can-edit",
|
|
512
|
+
"reflect": false,
|
|
513
|
+
"defaultValue": "true"
|
|
475
514
|
}
|
|
476
515
|
};
|
|
477
516
|
}
|
|
@@ -483,7 +522,7 @@ export class EzGrid {
|
|
|
483
522
|
"_isAllSelection": {},
|
|
484
523
|
"_currentPageSelected": {},
|
|
485
524
|
"_selectionCount": {},
|
|
486
|
-
"
|
|
525
|
+
"_hasLeftButtons": {}
|
|
487
526
|
};
|
|
488
527
|
}
|
|
489
528
|
static get events() {
|
|
@@ -8,19 +8,23 @@ const onSubmitFilter = new CustomEvent('onSubmitFilter', {
|
|
|
8
8
|
});
|
|
9
9
|
export class FilterColumn {
|
|
10
10
|
constructor() {
|
|
11
|
-
this.TOP_POSITION = '
|
|
11
|
+
this.TOP_POSITION = '65';
|
|
12
12
|
this.TOP_POSITION_HEADER_HIDDEN = '18';
|
|
13
|
+
this.TOP_POSITION_NO_TASKBAR = '32';
|
|
14
|
+
this.TOP_POSITION_NO_TASKBAR_HEADER_HIDDEN = '20';
|
|
13
15
|
this.DEFAULT_HEIGHT = 430;
|
|
14
16
|
this.opened = true;
|
|
15
17
|
this.columnName = undefined;
|
|
16
18
|
this.columnLabel = undefined;
|
|
17
19
|
this.gridHeaderHidden = false;
|
|
20
|
+
this.noHeaderTaskBar = false;
|
|
18
21
|
this.dataSource = undefined;
|
|
19
22
|
this.dataUnit = undefined;
|
|
20
23
|
this.options = undefined;
|
|
21
24
|
this.selectedItems = undefined;
|
|
22
25
|
this.fieldDescriptor = undefined;
|
|
23
26
|
this.useOptions = false;
|
|
27
|
+
this.isTextSearch = false;
|
|
24
28
|
}
|
|
25
29
|
async hide() {
|
|
26
30
|
await this.ezPopoverElement.hide();
|
|
@@ -34,26 +38,45 @@ export class FilterColumn {
|
|
|
34
38
|
if (this.canShow(configs)) {
|
|
35
39
|
await this.hide();
|
|
36
40
|
this.fieldDescriptor = this.dataUnit.getField(configs.columnName);
|
|
41
|
+
this.buildIsTextSearch();
|
|
37
42
|
this.setOptions(configs.filteredOptions);
|
|
38
43
|
this.columnName = configs.columnName;
|
|
39
44
|
this.columnLabel = configs.columnLabel;
|
|
40
|
-
await this.ezPopoverElement.show(this.calcTopPosition(), configs
|
|
45
|
+
await this.ezPopoverElement.show(this.calcTopPosition(), this.calculateLeftPosition(configs));
|
|
41
46
|
}
|
|
42
47
|
}
|
|
48
|
+
calculateLeftPosition(configs) {
|
|
49
|
+
if (!configs.fromIcon) {
|
|
50
|
+
return configs.leftPosition;
|
|
51
|
+
}
|
|
52
|
+
const difference = this.ezPopoverElement.getBoundingClientRect().left;
|
|
53
|
+
const leftReference = parseInt(configs.leftPosition.replace('px', ''));
|
|
54
|
+
const leftResolved = (leftReference + 16) - difference;
|
|
55
|
+
return `${(leftResolved > 0 ? leftResolved : 0)}px`;
|
|
56
|
+
}
|
|
57
|
+
buildIsTextSearch() {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
const userInterface = (_b = (_a = this.fieldDescriptor) === null || _a === void 0 ? void 0 : _a.userInterface) !== null && _b !== void 0 ? _b : UserInterface.SHORTTEXT;
|
|
60
|
+
this.isTextSearch = !(userInterface === UserInterface.DECIMALNUMBER || userInterface === UserInterface.INTEGERNUMBER);
|
|
61
|
+
}
|
|
43
62
|
calcTopPosition() {
|
|
44
|
-
const referencePosition = this.
|
|
45
|
-
? this.TOP_POSITION_HEADER_HIDDEN
|
|
46
|
-
: this.TOP_POSITION.replace('px', '');
|
|
63
|
+
const referencePosition = this.buildReferenceTopPosition();
|
|
47
64
|
const totalPopoverHeight = parseInt(referencePosition) + this.DEFAULT_HEIGHT;
|
|
48
65
|
const popoverPosition = Math.round(this.ezPopoverElement.getBoundingClientRect().top);
|
|
49
66
|
const popoverBottomPosition = popoverPosition + totalPopoverHeight;
|
|
50
67
|
const windowHeight = window.innerHeight;
|
|
51
68
|
if (windowHeight > popoverBottomPosition) {
|
|
52
|
-
return referencePosition
|
|
69
|
+
return `${referencePosition}px`;
|
|
53
70
|
}
|
|
54
71
|
const differenceBetween = windowHeight - popoverBottomPosition;
|
|
55
72
|
return `${differenceBetween}px`;
|
|
56
73
|
}
|
|
74
|
+
buildReferenceTopPosition() {
|
|
75
|
+
if (this.noHeaderTaskBar) {
|
|
76
|
+
return this.gridHeaderHidden ? this.TOP_POSITION_NO_TASKBAR_HEADER_HIDDEN : this.TOP_POSITION_NO_TASKBAR;
|
|
77
|
+
}
|
|
78
|
+
return this.gridHeaderHidden ? this.TOP_POSITION_HEADER_HIDDEN : this.TOP_POSITION;
|
|
79
|
+
}
|
|
57
80
|
async clearConfigs() {
|
|
58
81
|
var _a;
|
|
59
82
|
await ((_a = this.ezMultiSelectionList) === null || _a === void 0 ? void 0 : _a.clearFilteredOptions());
|
|
@@ -111,7 +134,7 @@ export class FilterColumn {
|
|
|
111
134
|
}
|
|
112
135
|
}
|
|
113
136
|
render() {
|
|
114
|
-
return (h("ez-popover", { class: 'filter-column__popover', "overlay-type": 'none', ref: (element) => (this.ezPopoverElement = element), autoClose: true, onEzVisibilityChange: this.handleEzVisibilityChange.bind(this) }, h("section", { class: 'filter-column' }, h("header", { class: 'filter-column__header' }, h("span", { class: 'ez-text ez-text--medium filter-column__header-title' }, "Filtro da coluna ", this.columnLabel), h("ez-button", { mode: 'icon', "icon-name": 'close', class: 'ez-button--tertiary', onClick: () => this.hide() })), h("ez-multi-selection-list", { columnName: this.columnName, dataSource: this.dataSource, options: this.options, useOptions: this.useOptions, ref: (element) => (this.ezMultiSelectionList = element), onChangeFilteredOptions: (event) => this.changeSelectedItems(event.detail) }), h("footer", { class: 'filter-column__footer' }, h("ez-button", { label: 'Aplicar', class: 'ez-button--primary', onClick: this.submit.bind(this) })))));
|
|
137
|
+
return (h("ez-popover", { class: 'filter-column__popover', "overlay-type": 'none', ref: (element) => (this.ezPopoverElement = element), autoClose: true, onEzVisibilityChange: this.handleEzVisibilityChange.bind(this) }, h("section", { class: 'filter-column' }, h("header", { class: 'filter-column__header' }, h("span", { class: 'ez-text ez-text--medium filter-column__header-title' }, "Filtro da coluna ", this.columnLabel), h("ez-button", { mode: 'icon', "icon-name": 'close', class: 'ez-button--tertiary', onClick: () => this.hide() })), h("ez-multi-selection-list", { columnName: this.columnName, dataSource: this.dataSource, options: this.options, useOptions: this.useOptions, ref: (element) => (this.ezMultiSelectionList = element), onChangeFilteredOptions: (event) => this.changeSelectedItems(event.detail), isTextSearch: this.isTextSearch }), h("footer", { class: 'filter-column__footer' }, h("ez-button", { label: 'Aplicar', class: 'ez-button--primary', onClick: this.submit.bind(this) })))));
|
|
115
138
|
}
|
|
116
139
|
static get is() { return "filter-column"; }
|
|
117
140
|
static get originalStyleUrls() {
|
|
@@ -196,6 +219,24 @@ export class FilterColumn {
|
|
|
196
219
|
"reflect": false,
|
|
197
220
|
"defaultValue": "false"
|
|
198
221
|
},
|
|
222
|
+
"noHeaderTaskBar": {
|
|
223
|
+
"type": "boolean",
|
|
224
|
+
"mutable": true,
|
|
225
|
+
"complexType": {
|
|
226
|
+
"original": "boolean",
|
|
227
|
+
"resolved": "boolean",
|
|
228
|
+
"references": {}
|
|
229
|
+
},
|
|
230
|
+
"required": false,
|
|
231
|
+
"optional": false,
|
|
232
|
+
"docs": {
|
|
233
|
+
"tags": [],
|
|
234
|
+
"text": ""
|
|
235
|
+
},
|
|
236
|
+
"attribute": "no-header-task-bar",
|
|
237
|
+
"reflect": false,
|
|
238
|
+
"defaultValue": "false"
|
|
239
|
+
},
|
|
199
240
|
"dataSource": {
|
|
200
241
|
"type": "unknown",
|
|
201
242
|
"mutable": false,
|
|
@@ -262,7 +303,8 @@ export class FilterColumn {
|
|
|
262
303
|
return {
|
|
263
304
|
"selectedItems": {},
|
|
264
305
|
"fieldDescriptor": {},
|
|
265
|
-
"useOptions": {}
|
|
306
|
+
"useOptions": {},
|
|
307
|
+
"isTextSearch": {}
|
|
266
308
|
};
|
|
267
309
|
}
|
|
268
310
|
static get events() {
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Action, DataType, DateUtils, UserInterface } from '@sankhyalabs/core';
|
|
2
|
+
export default class InMemoryFilterColumnDataSource {
|
|
3
|
+
constructor(dataUnit) {
|
|
4
|
+
var _a;
|
|
5
|
+
this.onDataUnitAction = (action) => {
|
|
6
|
+
if (action.type === Action.DATA_SAVED || action.type === Action.RECORDS_REMOVED) {
|
|
7
|
+
this.originalRecords = this.dataUnit.records;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
this.dataUnit = dataUnit;
|
|
11
|
+
this.originalRecords = (_a = this.dataUnit.records) !== null && _a !== void 0 ? _a : [];
|
|
12
|
+
this.dataUnit.subscribe(this.onDataUnitAction);
|
|
13
|
+
}
|
|
14
|
+
fetchData(filterTerm, fieldName) {
|
|
15
|
+
return new Promise(resolve => {
|
|
16
|
+
const filteredRecords = this.originalRecords.filter(record => this.includesSearchTerm(record, fieldName, filterTerm));
|
|
17
|
+
const options = filteredRecords.map(item => this.buildFieldOption(item, fieldName));
|
|
18
|
+
resolve(this.removeDuplicatedOptions(options));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
buildFieldOption(item, fieldName) {
|
|
22
|
+
return {
|
|
23
|
+
value: this.buildValue(item, fieldName),
|
|
24
|
+
label: this.formatLabel(fieldName, item[fieldName]),
|
|
25
|
+
check: true,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
buildValue(item, fieldName) {
|
|
29
|
+
var _a;
|
|
30
|
+
let value = item[fieldName];
|
|
31
|
+
if (((_a = this.dataUnit.getField(fieldName)) === null || _a === void 0 ? void 0 : _a.dataType) === DataType.OBJECT) {
|
|
32
|
+
value = value.value;
|
|
33
|
+
}
|
|
34
|
+
return value === null || value === void 0 ? void 0 : value.toString();
|
|
35
|
+
}
|
|
36
|
+
removeDuplicatedOptions(options) {
|
|
37
|
+
const noDuplicatedOptions = [];
|
|
38
|
+
options.forEach(option => {
|
|
39
|
+
if (!noDuplicatedOptions.find(({ label }) => label === option.label)) {
|
|
40
|
+
noDuplicatedOptions.push(option);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return noDuplicatedOptions;
|
|
44
|
+
}
|
|
45
|
+
includesSearchTerm(record, fieldName, filterTerm) {
|
|
46
|
+
let label = this.buildLabel(fieldName, record[fieldName]);
|
|
47
|
+
return label.toLowerCase().includes(filterTerm.toLowerCase());
|
|
48
|
+
}
|
|
49
|
+
buildLabel(fieldName, value) {
|
|
50
|
+
var _a;
|
|
51
|
+
const { dataType } = this.dataUnit.getField(fieldName);
|
|
52
|
+
if (dataType === DataType.NUMBER) {
|
|
53
|
+
return value === null || value === void 0 ? void 0 : value.toString().replace('.', ',');
|
|
54
|
+
}
|
|
55
|
+
if (dataType === DataType.DATE) {
|
|
56
|
+
return (typeof value === 'object')
|
|
57
|
+
? (_a = DateUtils.formatDate(this.dataUnit.valueFromString(fieldName, value))) === null || _a === void 0 ? void 0 : _a.toString()
|
|
58
|
+
: value === null || value === void 0 ? void 0 : value.toString();
|
|
59
|
+
}
|
|
60
|
+
if (dataType === DataType.OBJECT) {
|
|
61
|
+
return `${value === null || value === void 0 ? void 0 : value.value} - ${value === null || value === void 0 ? void 0 : value.label}`;
|
|
62
|
+
}
|
|
63
|
+
return value === null || value === void 0 ? void 0 : value.toString();
|
|
64
|
+
}
|
|
65
|
+
formatLabel(fieldName, value) {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
const { userInterface, dataType } = this.dataUnit.getField(fieldName);
|
|
68
|
+
if (dataType === DataType.DATE) {
|
|
69
|
+
return (typeof value === 'object')
|
|
70
|
+
? DateUtils.formatDate(this.dataUnit.valueFromString(fieldName, value))
|
|
71
|
+
: value === null || value === void 0 ? void 0 : value.toString();
|
|
72
|
+
}
|
|
73
|
+
if (dataType === DataType.NUMBER && userInterface !== UserInterface.DECIMALNUMBER) {
|
|
74
|
+
return (_a = parseInt(this.dataUnit.getFormattedValue(fieldName, value))) === null || _a === void 0 ? void 0 : _a.toString();
|
|
75
|
+
}
|
|
76
|
+
return (_b = this.dataUnit.getFormattedValue(fieldName, value)) === null || _b === void 0 ? void 0 : _b.toString();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -14,6 +14,7 @@ export class EzMuiltiSelectionList {
|
|
|
14
14
|
this.dataSource = undefined;
|
|
15
15
|
this.useOptions = false;
|
|
16
16
|
this.options = undefined;
|
|
17
|
+
this.isTextSearch = false;
|
|
17
18
|
this.filteredOptions = undefined;
|
|
18
19
|
this.displayOptions = undefined;
|
|
19
20
|
this.viewScenario = undefined;
|
|
@@ -96,6 +97,7 @@ export class EzMuiltiSelectionList {
|
|
|
96
97
|
this.filteredOptions = this.ordenationByCheckStateAndAlphabetically([...optionsToSort, event.detail]);
|
|
97
98
|
}
|
|
98
99
|
this.viewScenario = ViewScenarios.DATASOURCE_RESULTS;
|
|
100
|
+
this.searchInput.value = "";
|
|
99
101
|
}
|
|
100
102
|
handleRemoveItemFromOptions(item) {
|
|
101
103
|
this.filteredOptions = this.ordenationByCheckStateAndAlphabetically(this.filteredOptions.filter(i => i.value !== item.value));
|
|
@@ -159,7 +161,7 @@ export class EzMuiltiSelectionList {
|
|
|
159
161
|
return scenarios[view];
|
|
160
162
|
}
|
|
161
163
|
render() {
|
|
162
|
-
return (h(Host, null, h("div", { class: "multi-selection" }, this.useOptions ? (h("ez-filter-input", { ref: (element) => (this.filterInput = element), label: `Buscar..`, onEzChange: this.handleSearchOnOption.bind(this) })) : (h("ez-search", { class: "multi-selection__input", label: `Buscar...`, ref: (element) => (this.searchInput = element), suppressEmptyOption: true, showOptionValue: false, showSelectedValue: false, optionLoader: (search) => this.searchWithDataSource(search, this.columnName), onEzChange: this.handleSearchOnDataSource.bind(this) })), h("ez-scroll", { class: "multi-selection__content-options" }, this.scenarioToDisplay(this.viewScenario)))));
|
|
164
|
+
return (h(Host, null, h("div", { class: "multi-selection" }, this.useOptions ? (h("ez-filter-input", { ref: (element) => (this.filterInput = element), label: `Buscar..`, onEzChange: this.handleSearchOnOption.bind(this) })) : (h("ez-search", { class: "multi-selection__input", label: `Buscar...`, ref: (element) => (this.searchInput = element), suppressEmptyOption: true, showOptionValue: false, showSelectedValue: false, optionLoader: (search) => this.searchWithDataSource(search, this.columnName), onEzChange: this.handleSearchOnDataSource.bind(this), isTextSearch: this.isTextSearch })), h("ez-scroll", { class: "multi-selection__content-options" }, this.scenarioToDisplay(this.viewScenario)))));
|
|
163
165
|
}
|
|
164
166
|
static get is() { return "ez-multi-selection-list"; }
|
|
165
167
|
static get encapsulation() { return "scoped"; }
|
|
@@ -249,6 +251,24 @@ export class EzMuiltiSelectionList {
|
|
|
249
251
|
"tags": [],
|
|
250
252
|
"text": "Op\u00E7\u00F5es de filtros a serem exibidas na listagem."
|
|
251
253
|
}
|
|
254
|
+
},
|
|
255
|
+
"isTextSearch": {
|
|
256
|
+
"type": "boolean",
|
|
257
|
+
"mutable": false,
|
|
258
|
+
"complexType": {
|
|
259
|
+
"original": "boolean",
|
|
260
|
+
"resolved": "boolean",
|
|
261
|
+
"references": {}
|
|
262
|
+
},
|
|
263
|
+
"required": false,
|
|
264
|
+
"optional": false,
|
|
265
|
+
"docs": {
|
|
266
|
+
"tags": [],
|
|
267
|
+
"text": "Informa se a pesquisa \u00E9 do tipo texto."
|
|
268
|
+
},
|
|
269
|
+
"attribute": "is-text-search",
|
|
270
|
+
"reflect": false,
|
|
271
|
+
"defaultValue": "false"
|
|
252
272
|
}
|
|
253
273
|
};
|
|
254
274
|
}
|