@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-74224.1 → 0.0.0-bugfix-dev-KB-75070.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{ConfigStorage-ecc0ed20.js → ConfigStorage-f079f5fd.js} +2 -2
- package/dist/cjs/{ContinuousInsertUtils-29b65619.js → ContinuousInsertUtils-64e47516.js} +29 -20
- package/dist/cjs/{DataFetcher-cadeef8e.js → DataFetcher-e059eb72.js} +7 -5
- package/dist/cjs/{SnkFormConfigManager-f1c92f79.js → SnkFormConfigManager-63369164.js} +2 -2
- package/dist/cjs/{auth-fetcher-d68841bc.js → auth-fetcher-4f853233.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-f89461c1.js → dataunit-fetcher-228016f4.js} +3 -3
- package/dist/cjs/{form-config-fetcher-ed497282.js → form-config-fetcher-39397ac5.js} +1 -1
- package/dist/cjs/index-f9e81701.js +8 -28
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-ca89181c.js → pesquisa-fetcher-a9bfeb22.js} +7 -2
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -5
- package/dist/cjs/snk-application.cjs.entry.js +111 -59
- package/dist/cjs/snk-attach.cjs.entry.js +5 -5
- package/dist/cjs/{snk-form-config.cjs.entry.js → snk-config-options_3.cjs.entry.js} +365 -3
- package/dist/cjs/snk-crud.cjs.entry.js +13 -7
- package/dist/cjs/snk-data-exporter.cjs.entry.js +5 -5
- package/dist/cjs/{snk-data-unit-668dc5e8.js → snk-data-unit-3d9b6ed4.js} +26 -14
- package/dist/cjs/snk-data-unit.cjs.entry.js +3 -3
- package/dist/cjs/snk-detail-view.cjs.entry.js +7 -7
- package/dist/cjs/{snk-filter-bar.cjs.entry.js → snk-filter-bar_4.cjs.entry.js} +691 -3
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
- package/dist/cjs/snk-grid.cjs.entry.js +16 -8
- package/dist/cjs/{snk-guides-viewer-4236cb9d.js → snk-guides-viewer-eee43c8b.js} +8 -5
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -7
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
- package/dist/cjs/snk-simple-crud.cjs.entry.js +45 -10
- package/dist/cjs/snk-taskbar.cjs.entry.js +37 -35
- package/dist/collection/collection-manifest.json +11 -31
- package/dist/collection/components/snk-application/request-listener/DebouncedRequestListener.js +28 -0
- package/dist/collection/components/snk-application/request-listener/RequestListenerFactory.js +16 -0
- package/dist/collection/components/snk-application/request-listener/RequestListenerLoadingBar.js +52 -0
- package/dist/collection/components/snk-application/snk-application.js +44 -54
- package/dist/collection/components/snk-crud/snk-crud.js +26 -2
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +3 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +25 -13
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +18 -0
- package/dist/collection/components/snk-grid/snk-grid.js +28 -2
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +57 -4
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +38 -36
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -6
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +6 -1
- package/dist/collection/lib/utils/CrudUtils.js +25 -16
- package/dist/collection/sw.js +46 -0
- package/dist/components/ContinuousInsertUtils.js +25 -16
- package/dist/components/DataFetcher.js +7 -5
- package/dist/components/dataunit-fetcher.js +2 -2
- package/dist/components/pesquisa-fetcher.js +6 -1
- package/dist/components/snk-application2.js +107 -54
- package/dist/components/snk-crud.js +9 -2
- package/dist/components/snk-data-unit2.js +25 -13
- package/dist/components/snk-detail-view2.js +3 -0
- package/dist/components/snk-filter-bar2.js +4 -0
- package/dist/components/snk-grid2.js +11 -2
- package/dist/components/snk-simple-crud2.js +40 -4
- package/dist/components/snk-taskbar2.js +38 -36
- package/dist/esm/{ConfigStorage-7b36d041.js → ConfigStorage-6514d66e.js} +2 -2
- package/dist/esm/{ContinuousInsertUtils-30caa626.js → ContinuousInsertUtils-b62906f9.js} +29 -20
- package/dist/esm/{DataFetcher-a9c598f2.js → DataFetcher-5034df59.js} +7 -5
- package/dist/esm/{SnkFormConfigManager-139f09fa.js → SnkFormConfigManager-b409c745.js} +3 -3
- package/dist/esm/{auth-fetcher-749d880f.js → auth-fetcher-ca5d3a49.js} +1 -1
- package/dist/esm/{constants-8457af36.js → constants-7302ee87.js} +1 -1
- package/dist/esm/{dataunit-fetcher-c24c76c6.js → dataunit-fetcher-56cb648b.js} +3 -3
- package/dist/esm/{form-config-fetcher-adbe5d34.js → form-config-fetcher-a7d3e277.js} +1 -1
- package/dist/esm/index-a7d3d3f1.js +8 -28
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{pesquisa-fetcher-8edaa8cd.js → pesquisa-fetcher-6bc2e41a.js} +7 -2
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +6 -6
- package/dist/esm/snk-application.entry.js +111 -59
- package/dist/esm/snk-attach.entry.js +6 -6
- package/dist/esm/{snk-form-config.entry.js → snk-config-options_3.entry.js} +366 -6
- package/dist/esm/snk-configurator.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +14 -8
- package/dist/esm/snk-data-exporter.entry.js +6 -6
- package/dist/esm/{snk-data-unit-0fdfb6c2.js → snk-data-unit-9fa7d2b9.js} +26 -14
- package/dist/esm/snk-data-unit.entry.js +3 -3
- package/dist/esm/snk-detail-view.entry.js +8 -8
- package/dist/esm/snk-field-config.entry.js +1 -1
- package/dist/esm/{snk-filter-bar.entry.js → snk-filter-bar_4.entry.js} +690 -5
- package/dist/esm/snk-filter-modal-item.entry.js +3 -3
- package/dist/esm/snk-grid.entry.js +16 -8
- package/dist/esm/{snk-guides-viewer-8934c537.js → snk-guides-viewer-e8ca764a.js} +9 -6
- package/dist/esm/snk-guides-viewer.entry.js +8 -8
- package/dist/esm/snk-personalized-filter.entry.js +3 -3
- package/dist/esm/snk-simple-crud.entry.js +47 -12
- package/dist/esm/snk-tab-config.entry.js +1 -1
- package/dist/esm/snk-taskbar.entry.js +38 -36
- package/dist/sankhyablocks/{p-f3434fc4.js → p-00278e07.js} +1 -1
- package/dist/sankhyablocks/{p-b9c67e45.entry.js → p-0d2a2e9e.entry.js} +1 -1
- package/dist/sankhyablocks/{p-afbb070d.js → p-0e206e62.js} +1 -1
- package/dist/sankhyablocks/{p-06421fdb.js → p-126c58ea.js} +1 -1
- package/dist/sankhyablocks/p-200a5481.entry.js +11 -0
- package/dist/sankhyablocks/{p-8eb67fa4.entry.js → p-2d3f9482.entry.js} +1 -1
- package/dist/sankhyablocks/p-30ebcbe0.entry.js +1 -0
- package/dist/sankhyablocks/{p-1bf06cd3.js → p-341465ce.js} +2 -2
- package/dist/sankhyablocks/p-342eeb3b.js +1 -0
- package/dist/sankhyablocks/{p-7663f597.entry.js → p-41793e17.entry.js} +1 -1
- package/dist/sankhyablocks/p-42130213.entry.js +1 -0
- package/dist/sankhyablocks/{p-be5d8fcb.entry.js → p-43353d86.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7ac7932c.js → p-47d24ac8.js} +2 -2
- package/dist/sankhyablocks/p-520c7c38.entry.js +1 -0
- package/dist/sankhyablocks/{p-430e4d3c.entry.js → p-7075b789.entry.js} +1 -1
- package/dist/sankhyablocks/p-83e71703.entry.js +1 -0
- package/dist/sankhyablocks/{p-95df461f.entry.js → p-8b4fc28f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b0ef4383.js → p-95ce311a.js} +1 -1
- package/dist/sankhyablocks/{p-4d9549cf.js → p-9ffd9fc7.js} +1 -1
- package/dist/sankhyablocks/{p-dcead955.entry.js → p-a2c790ac.entry.js} +1 -1
- package/dist/sankhyablocks/p-a3fadd0b.entry.js +1 -0
- package/dist/sankhyablocks/{p-212213d9.entry.js → p-aa003d4e.entry.js} +1 -1
- package/dist/sankhyablocks/p-aaf94476.js +1 -0
- package/dist/sankhyablocks/p-ac26df7a.entry.js +1 -0
- package/dist/sankhyablocks/{p-fd8e631c.entry.js → p-af7f7b3e.entry.js} +1 -1
- package/dist/sankhyablocks/p-c51ad0e7.entry.js +1 -0
- package/dist/sankhyablocks/{p-16869f77.js → p-e3a285a2.js} +1 -1
- package/dist/sankhyablocks/p-e4391e16.js +1 -0
- package/dist/sankhyablocks/{p-fb34e0cf.entry.js → p-fca0e5cc.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/request-listener/DebouncedRequestListener.d.ts +11 -0
- package/dist/types/components/snk-application/request-listener/RequestListenerFactory.d.ts +12 -0
- package/dist/types/components/snk-application/request-listener/RequestListenerLoadingBar.d.ts +13 -0
- package/dist/types/components/snk-application/snk-application.d.ts +9 -13
- package/dist/types/components/snk-crud/snk-crud.d.ts +4 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +4 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +2 -0
- package/dist/types/components.d.ts +30 -0
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +1 -0
- package/dist/types/lib/utils/CrudUtils.d.ts +1 -0
- package/package.json +3 -2
- package/dist/cjs/snk-config-options.cjs.entry.js +0 -239
- package/dist/cjs/snk-filter-item.cjs.entry.js +0 -312
- package/dist/cjs/snk-filter-list.cjs.entry.js +0 -152
- package/dist/cjs/snk-filter-modal.cjs.entry.js +0 -249
- package/dist/cjs/snk-form.cjs.entry.js +0 -144
- package/dist/esm/snk-config-options.entry.js +0 -235
- package/dist/esm/snk-filter-item.entry.js +0 -308
- package/dist/esm/snk-filter-list.entry.js +0 -148
- package/dist/esm/snk-filter-modal.entry.js +0 -245
- package/dist/esm/snk-form.entry.js +0 -140
- package/dist/sankhyablocks/p-01086ff7.entry.js +0 -1
- package/dist/sankhyablocks/p-2923c1b5.js +0 -1
- package/dist/sankhyablocks/p-2aae03a1.entry.js +0 -1
- package/dist/sankhyablocks/p-3b60db06.entry.js +0 -1
- package/dist/sankhyablocks/p-5dd8cf4f.js +0 -1
- package/dist/sankhyablocks/p-60b29483.entry.js +0 -1
- package/dist/sankhyablocks/p-70a4af56.entry.js +0 -1
- package/dist/sankhyablocks/p-92eadb1c.entry.js +0 -1
- package/dist/sankhyablocks/p-a42e7a1e.entry.js +0 -11
- package/dist/sankhyablocks/p-a724e798.entry.js +0 -1
- package/dist/sankhyablocks/p-a75d242d.entry.js +0 -1
- package/dist/sankhyablocks/p-b9679243.entry.js +0 -1
- package/dist/sankhyablocks/p-ca5ec380.js +0 -1
- package/dist/sankhyablocks/p-d3f53df2.entry.js +0 -1
- package/dist/sankhyablocks/p-e8763234.entry.js +0 -1
- package/dist/sankhyablocks/p-feba9d4b.entry.js +0 -1
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a7d3d3f1.js';
|
|
2
|
-
import { FloatingManager, ElementIDUtils, ArrayUtils } from '@sankhyalabs/core';
|
|
3
|
-
|
|
4
|
-
const SHOW_MORE_ITEM_NAME = "__SHOWMORE__";
|
|
5
|
-
const MAX_FILTERS = 5;
|
|
6
|
-
const SnkFilterList = class {
|
|
7
|
-
constructor(hostRef) {
|
|
8
|
-
registerInstance(this, hostRef);
|
|
9
|
-
this.snkItemSelected = createEvent(this, "snkItemSelected", 7);
|
|
10
|
-
this._preselection = -1;
|
|
11
|
-
this.innerClickCheck = (_floatingContainer, node) => {
|
|
12
|
-
if (node.id != FloatingManager.MODAL_ELEMENT_ID) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
this._detailIsVisible = false;
|
|
16
|
-
return false;
|
|
17
|
-
};
|
|
18
|
-
this._filterArgument = undefined;
|
|
19
|
-
this._showAll = undefined;
|
|
20
|
-
this.label = undefined;
|
|
21
|
-
this.iconName = undefined;
|
|
22
|
-
this.items = undefined;
|
|
23
|
-
this.getMessage = undefined;
|
|
24
|
-
this.emptyText = undefined;
|
|
25
|
-
this.findFilterText = undefined;
|
|
26
|
-
this.buttonClass = undefined;
|
|
27
|
-
}
|
|
28
|
-
showDetail() {
|
|
29
|
-
this._preselection = -1;
|
|
30
|
-
this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, {
|
|
31
|
-
autoClose: true,
|
|
32
|
-
innerClickTest: this.innerClickCheck,
|
|
33
|
-
backClickListener: () => this.onListCloseCallback(),
|
|
34
|
-
useOverlay: true
|
|
35
|
-
});
|
|
36
|
-
this._detailIsVisible = true;
|
|
37
|
-
this._showAll = false;
|
|
38
|
-
this._filterArgument = "";
|
|
39
|
-
this._filterInput.setFocus();
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Oculta os detalhes do componente snk-filter-list.
|
|
43
|
-
*/
|
|
44
|
-
async hideDetail() {
|
|
45
|
-
if (this._floatingID != undefined) {
|
|
46
|
-
FloatingManager.close(this._floatingID);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
onListCloseCallback() {
|
|
50
|
-
this._floatingID = undefined;
|
|
51
|
-
this._detailIsVisible = false;
|
|
52
|
-
}
|
|
53
|
-
buttonClick() {
|
|
54
|
-
if (this._detailIsVisible) {
|
|
55
|
-
this.hideDetail();
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
this.showDetail();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
componentDidLoad() {
|
|
62
|
-
if (this._element) {
|
|
63
|
-
ElementIDUtils.addIDInfo(this._element);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
componentDidRender() {
|
|
67
|
-
if (this._floatingID == undefined) {
|
|
68
|
-
if (this._popover) {
|
|
69
|
-
this._popover.remove();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
buildIdElement(buttonElement, name) {
|
|
74
|
-
if (!buttonElement)
|
|
75
|
-
return;
|
|
76
|
-
const dataElement = { id: name };
|
|
77
|
-
buttonElement.removeAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
|
|
78
|
-
ElementIDUtils.addIDInfoIfNotExists(buttonElement, "filterItemList", dataElement);
|
|
79
|
-
}
|
|
80
|
-
buildItemElement(item) {
|
|
81
|
-
const itemId = ++this._selectableItemsCount;
|
|
82
|
-
return (h("button", { ref: elem => elem && this.buildIdElement(elem, item.label), id: `filter-item${itemId}`, onFocusin: () => this._preselection = itemId, class: `ez-col ez-col--sd-12 ez-align--middle ez-padding--small sc-snk-filter-bar snk-filter-bar__filter-list-item`, onClick: () => this.itemSelected(item.name), name: item.label, key: itemId }, item.iconName ? h("ez-icon", { iconName: item.iconName, size: "small", class: `ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${item.iconClass || ""}` }) : undefined, h("div", { class: `ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${item.labelClass || ""}` }, item.label)));
|
|
83
|
-
}
|
|
84
|
-
itemSelected(itemName) {
|
|
85
|
-
if (itemName === SHOW_MORE_ITEM_NAME) {
|
|
86
|
-
this._showAll = true;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
this.hideDetail();
|
|
90
|
-
this.snkItemSelected.emit(itemName);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
getFilterItems() {
|
|
94
|
-
const items = this.items ? ArrayUtils.applyStringFilter(this._filterArgument, this.items.filter(item => item.kind === "FILTER")) : [];
|
|
95
|
-
if (items.length === 0) {
|
|
96
|
-
return h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-items-container--empty" }, this.emptyText);
|
|
97
|
-
}
|
|
98
|
-
const hideItems = !this._filterArgument && !this._showAll && (items.length > MAX_FILTERS + 1);
|
|
99
|
-
if (hideItems) {
|
|
100
|
-
items.splice(MAX_FILTERS);
|
|
101
|
-
items.push({ kind: "INTERNAL", label: "Mostrar mais", iconName: "dots-horizontal", name: SHOW_MORE_ITEM_NAME, iconClass: "snk-filter-bar__filter-list-item__icon--secondary", labelClass: "snk-filter-bar__filter-list-item__label--secondary" });
|
|
102
|
-
}
|
|
103
|
-
this._selectableItemsCount = 0;
|
|
104
|
-
return h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-list-items-container" }, items.map(item => this.buildItemElement(item)));
|
|
105
|
-
}
|
|
106
|
-
getFooterItems() {
|
|
107
|
-
return this.items.filter(item => item.kind === "FOOTER");
|
|
108
|
-
}
|
|
109
|
-
keyDownHandler(event) {
|
|
110
|
-
switch (event.key) {
|
|
111
|
-
case "ArrowDown":
|
|
112
|
-
this.changePreselection(this._preselection + 1);
|
|
113
|
-
//Paramos a propagação do evento para evitar scroll indesejado
|
|
114
|
-
event.stopImmediatePropagation();
|
|
115
|
-
event.stopPropagation();
|
|
116
|
-
event.preventDefault();
|
|
117
|
-
break;
|
|
118
|
-
case "ArrowUp":
|
|
119
|
-
this.changePreselection(this._preselection - 1);
|
|
120
|
-
//Paramos a propagação do evento para evitar scroll indesejado
|
|
121
|
-
event.stopImmediatePropagation();
|
|
122
|
-
event.stopPropagation();
|
|
123
|
-
event.preventDefault();
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
changePreselection(newSelection) {
|
|
128
|
-
if (newSelection < 0) {
|
|
129
|
-
newSelection = this._selectableItemsCount;
|
|
130
|
-
}
|
|
131
|
-
this._preselection = newSelection > this._selectableItemsCount ? 0 : newSelection;
|
|
132
|
-
if (this._preselection === 0) {
|
|
133
|
-
this._filterInput.setFocus();
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
const item = this._element.querySelector(`#filter-item${this._preselection}`);
|
|
137
|
-
if (item) {
|
|
138
|
-
item.focus();
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
render() {
|
|
143
|
-
return (h(Host, { class: "ez-flex ez-flex--column" }, h("ez-button", { class: this.buttonClass, label: this.label, onClick: () => this.buttonClick(), mode: this.iconName ? "icon" : undefined, iconName: this.iconName, size: "small" }, h("slot", { name: "leftIcon" })), h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, h("div", { class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--4", ref: elem => this._popover = elem }, h("ez-filter-input", { ref: ref => this._filterInput = ref, "data-element-id": "serachFilters", mode: "slim", label: this.findFilterText, value: this._filterArgument, onEzChange: (evt) => this._filterArgument = evt.detail, onFocus: () => this._preselection = 0 }), this.getFilterItems(), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), this.items ? this.getFooterItems().map(item => this.buildItemElement(item)) : undefined))));
|
|
144
|
-
}
|
|
145
|
-
get _element() { return getElement(this); }
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export { SnkFilterList as snk_filter_list };
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, h } from './index-a7d3d3f1.js';
|
|
2
|
-
import { ModalAction } from '@sankhyalabs/ezui/dist/collection/components/ez-modal-container';
|
|
3
|
-
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
|
-
import { F as FilterType } from './filter-type.enum-a80c1b6b.js';
|
|
5
|
-
import { F as FilterItemType } from './filter-item-type.enum-d45e026f.js';
|
|
6
|
-
import { ObjectUtils } from '@sankhyalabs/core';
|
|
7
|
-
import { P as PersonalizedFilterUtils } from './PersonalizedFilterUtils-e2b38ef7.js';
|
|
8
|
-
import { F as FilterNumberVariation } from './filterNumberVariation-8cee02ea.js';
|
|
9
|
-
import './index-ae591a44.js';
|
|
10
|
-
|
|
11
|
-
const snkFilterModalCss = "ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter-modal__container{width:344px;max-width:344px;min-width:344px;overflow:hidden}.snk-filter-modal__content{display:flex;flex-direction:column;gap:var(--space--medium, 12px);padding-right:var(--space--3xs, 4px)}.snk-filter-modal__collapsible-box{border:var(--border--small, 1px solid) var(--color--strokes, #DCE0E8);border-radius:var(--border--radius-medium);padding:var(--space--medium, 12px) var(--space--small, 6px)}.snk-filter-modal__rendered-items{max-height:760px;overflow-x:clip;overflow-y:auto}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";
|
|
12
|
-
|
|
13
|
-
const SnkFilterModal = class {
|
|
14
|
-
constructor(hostRef) {
|
|
15
|
-
registerInstance(this, hostRef);
|
|
16
|
-
this.getMessage = undefined;
|
|
17
|
-
this.configName = undefined;
|
|
18
|
-
this.filters = undefined;
|
|
19
|
-
this.applyFilters = undefined;
|
|
20
|
-
this.closeModal = undefined;
|
|
21
|
-
this.addPersonalizedFilter = undefined;
|
|
22
|
-
this.editPersonalizedFilter = undefined;
|
|
23
|
-
this.deletePersonalizedFilter = undefined;
|
|
24
|
-
this.filtersToDelete = [];
|
|
25
|
-
this.disablePersonalizedFilter = undefined;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Emitido quando um filtro personalizado é deletado.
|
|
29
|
-
*/
|
|
30
|
-
deletePersonalizedFilterListener(event) {
|
|
31
|
-
this.filtersToDelete.push(event.detail);
|
|
32
|
-
}
|
|
33
|
-
getCustomMessage(key, params) {
|
|
34
|
-
var _a;
|
|
35
|
-
return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
|
|
36
|
-
}
|
|
37
|
-
//TODO: tratar clear all dos filtros personalizados
|
|
38
|
-
handleClearAll() {
|
|
39
|
-
const { customFilters, quickFilters, otherFilters, multiListFilters } = this.filters.reduce((acc, filter) => {
|
|
40
|
-
if (filter.type === FilterItemType.MULTI_LIST) {
|
|
41
|
-
acc.multiListFilters.push(filter);
|
|
42
|
-
return acc;
|
|
43
|
-
}
|
|
44
|
-
if (filter.filterType === FilterType.QUICK_FILTER) {
|
|
45
|
-
acc.quickFilters.push(filter);
|
|
46
|
-
return acc;
|
|
47
|
-
}
|
|
48
|
-
if (filter.filterType === FilterType.CUSTOM_FILTER) {
|
|
49
|
-
acc.customFilters.push(filter);
|
|
50
|
-
return acc;
|
|
51
|
-
}
|
|
52
|
-
if (filter.filterType === FilterType.OTHER_FILTERS) {
|
|
53
|
-
acc.otherFilters.push(filter);
|
|
54
|
-
return acc;
|
|
55
|
-
}
|
|
56
|
-
return acc;
|
|
57
|
-
}, { quickFilters: [], customFilters: [], otherFilters: [], multiListFilters: [] });
|
|
58
|
-
this.handleClearFilterList(quickFilters);
|
|
59
|
-
this.handleClearCustomFilters(customFilters);
|
|
60
|
-
this.handleClearOthersFilters(otherFilters);
|
|
61
|
-
multiListFilters.forEach(multiListFilter => this.handleClearSigleFilter(multiListFilter));
|
|
62
|
-
}
|
|
63
|
-
handleClearOthersFilters(otherFilters) {
|
|
64
|
-
this.filters = this.filters.map(filter => otherFilters.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
|
|
65
|
-
}
|
|
66
|
-
handleClearCustomFilters(customFilters) {
|
|
67
|
-
this.filters.forEach((filter, index) => {
|
|
68
|
-
if (filter.filterType === FilterType.CUSTOM_FILTER)
|
|
69
|
-
this.filters[index] = this.clearAllCustomFilter(customFilters).shift();
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
clearAllCustomFilter(filterConfigSnapshot) {
|
|
73
|
-
return filterConfigSnapshot.map(filterItem => {
|
|
74
|
-
const copy = Object.assign({}, filterItem);
|
|
75
|
-
delete copy.value;
|
|
76
|
-
copy.visible = false;
|
|
77
|
-
if (copy.groupedItems) {
|
|
78
|
-
copy.groupedItems = this.clearAllCustomFilter(copy.groupedItems);
|
|
79
|
-
}
|
|
80
|
-
return copy;
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
handleClose() {
|
|
84
|
-
const hasChangesToSave = ObjectUtils.objectToString(this.filters) !== ObjectUtils.objectToString(this._originalFilterConfig);
|
|
85
|
-
if (!hasChangesToSave) {
|
|
86
|
-
this.closeModal();
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
return ApplicationUtils.confirm(this.getCustomMessage('validations.notSaved.title'), this.getCustomMessage('validations.notSaved.message')).then((cancelAction) => {
|
|
90
|
-
if (cancelAction)
|
|
91
|
-
this.closeModal();
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
handleApplyFilters() {
|
|
95
|
-
const filterPersonalized = this.filters.find(filter => filter.filterType === FilterType.CUSTOM_FILTER);
|
|
96
|
-
if (this.isValidCustomFilter(filterPersonalized)) {
|
|
97
|
-
this.applyFilters(this.filters);
|
|
98
|
-
}
|
|
99
|
-
if (this.filtersToDelete.length > 0) {
|
|
100
|
-
this.filtersToDelete.forEach(filter => {
|
|
101
|
-
this.deletePersonalizedFilter(filter, this.configName);
|
|
102
|
-
});
|
|
103
|
-
this.filtersToDelete = [];
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
isValidCustomFilter(filterPersonalized) {
|
|
107
|
-
const isValid = PersonalizedFilterUtils.validateVariableValues(filterPersonalized);
|
|
108
|
-
if (!isValid) {
|
|
109
|
-
ApplicationUtils.alert(this.getCustomMessage('validations.notFullFilled.title'), this.getCustomMessage('validations.notFullFilled.message'));
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
modalActionListener(evt) {
|
|
115
|
-
const modalAction = evt.detail;
|
|
116
|
-
switch (modalAction) {
|
|
117
|
-
case ModalAction.CANCEL:
|
|
118
|
-
this.handleClearAll();
|
|
119
|
-
break;
|
|
120
|
-
case ModalAction.OK:
|
|
121
|
-
this.handleApplyFilters();
|
|
122
|
-
break;
|
|
123
|
-
case ModalAction.CLOSE:
|
|
124
|
-
this.handleClose();
|
|
125
|
-
break;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
handleFilterChange(filterConfig) {
|
|
129
|
-
this.filters = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
|
|
130
|
-
}
|
|
131
|
-
handleClearFilterList(filterList) {
|
|
132
|
-
this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
|
|
133
|
-
}
|
|
134
|
-
handleClearSigleFilter(filterItem) {
|
|
135
|
-
if (FilterItemType.MULTI_LIST === filterItem.type) {
|
|
136
|
-
let filterItemCopy = ObjectUtils.copy(filterItem);
|
|
137
|
-
this.uncheckFilterValues(filterItemCopy.value);
|
|
138
|
-
const filterListCopy = ObjectUtils.copy(this.filters);
|
|
139
|
-
const index = filterListCopy.findIndex(item => item.id === filterItem.id);
|
|
140
|
-
filterListCopy.splice(index, 1, filterItemCopy);
|
|
141
|
-
this.filters = ObjectUtils.copy(filterListCopy);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
if (FilterItemType.CHECK_BOX_LIST === filterItem.type) {
|
|
145
|
-
const filterListCopy = ObjectUtils.copy(this.filters);
|
|
146
|
-
filterListCopy.find(filter => filter.id === filterItem.id).value = undefined;
|
|
147
|
-
this.filters = ObjectUtils.copy(filterListCopy);
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
this.filters.find(filter => filter.id === filterItem.id).value = undefined;
|
|
151
|
-
}
|
|
152
|
-
uncheckFilterValues(valueList) {
|
|
153
|
-
valueList.forEach(value => {
|
|
154
|
-
if (!!value) {
|
|
155
|
-
value.check = false;
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
return valueList;
|
|
159
|
-
}
|
|
160
|
-
renderFilterItem(filterItem, fullRow) {
|
|
161
|
-
return (h("snk-filter-modal-item", { class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, configName: this.configName, onFilterChange: (event) => this.handleFilterChange(event.detail), onEditPersonalizedFilter: evt => this.editPersonalizedFilter(evt.detail), onAddPersonalizedFilter: () => this.addPersonalizedFilter() }));
|
|
162
|
-
}
|
|
163
|
-
isDefaultFilterNumberVariation(filter) {
|
|
164
|
-
var _a;
|
|
165
|
-
return filter.type === FilterItemType.NUMBER
|
|
166
|
-
&& (!filter.props.variation || ((_a = filter.props) === null || _a === void 0 ? void 0 : _a.variation) === FilterNumberVariation.DEFAULT);
|
|
167
|
-
}
|
|
168
|
-
mountFiltersLines(filters) {
|
|
169
|
-
const MAX_LINE_LENGTH = 2;
|
|
170
|
-
let currentLine = 0;
|
|
171
|
-
let forceAddCurrent = false;
|
|
172
|
-
const filtersLines = {};
|
|
173
|
-
for (let curr = 0; curr < filters.length; curr++) {
|
|
174
|
-
filtersLines[currentLine] = filtersLines[currentLine] || [];
|
|
175
|
-
const item = filters[curr];
|
|
176
|
-
const isLast = curr === filters.length - 1;
|
|
177
|
-
const currentItemMatch = item.type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(item);
|
|
178
|
-
const nextItemMatch = isLast ? false : filters[curr + 1].type === FilterItemType.TEXT || this.isDefaultFilterNumberVariation(filters[curr + 1]);
|
|
179
|
-
if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
|
|
180
|
-
filtersLines[currentLine].push(item);
|
|
181
|
-
forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
|
|
182
|
-
if (filtersLines[currentLine].length === MAX_LINE_LENGTH)
|
|
183
|
-
++currentLine;
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
filtersLines[currentLine] = filtersLines[currentLine] || [];
|
|
187
|
-
filtersLines[currentLine].push(item);
|
|
188
|
-
++currentLine;
|
|
189
|
-
}
|
|
190
|
-
return Object.values(filtersLines);
|
|
191
|
-
}
|
|
192
|
-
renderFilterLine(filters) {
|
|
193
|
-
const fullLine = filters.length === 1;
|
|
194
|
-
return filters.map((filter) => this.renderFilterItem(filter, fullLine));
|
|
195
|
-
}
|
|
196
|
-
getIformedFiltersCount(listItems) {
|
|
197
|
-
let countInformedItens = 0;
|
|
198
|
-
listItems.forEach(item => {
|
|
199
|
-
var _a, _b, _c, _d, _e, _f;
|
|
200
|
-
if (FilterItemType.MULTI_LIST === item.type) {
|
|
201
|
-
countInformedItens += (_e = (_d = (_c = ((_b = (_a = item.value) === null || _a === void 0 ? void 0 : _a.elements) !== null && _b !== void 0 ? _b : item.value)) === null || _c === void 0 ? void 0 : _c.filter(value => value === null || value === void 0 ? void 0 : value.check)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0;
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
if (FilterItemType.CHECK_BOX_LIST === item.type) {
|
|
205
|
-
countInformedItens += Object.entries((_f = item.value) !== null && _f !== void 0 ? _f : {})
|
|
206
|
-
.filter(([_, value]) => value === true)
|
|
207
|
-
.map(([key, _]) => key).length;
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
if (item.groupedItems != undefined) {
|
|
211
|
-
countInformedItens = item.groupedItems.filter(item => item.visible).length;
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
if (!!item.value) {
|
|
215
|
-
countInformedItens++;
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
return countInformedItens;
|
|
219
|
-
}
|
|
220
|
-
renderCollapsibleFilterBox(label, listItems, isSingleItem, shouldRenderFooter = true) {
|
|
221
|
-
if (!listItems.length)
|
|
222
|
-
return null;
|
|
223
|
-
const appliedFilters = this.getIformedFiltersCount(listItems);
|
|
224
|
-
const lines = this.mountFiltersLines(listItems);
|
|
225
|
-
return (h("ez-collapsible-box", { class: "snk-filter-modal__collapsible-box", headerSize: "medium", value: true, label: label }, !!appliedFilters && (h("ez-badge", { class: "ez-badge--primary-subtle", slot: "rightSlot", label: appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.toString() })), h("div", { class: "ez-row snk-filter-modal__rendered-items" }, lines.map(this.renderFilterLine.bind(this))), shouldRenderFooter && (h("div", { class: "ez-flex ez-flex--justify-end grow" }, h("ez-button", { class: "ez-button--tertiary", size: "medium", label: "Limpar", onClick: () => isSingleItem ? this.handleClearSigleFilter(listItems[0]) : this.handleClearFilterList(listItems) })))));
|
|
226
|
-
}
|
|
227
|
-
componentWillRender() {
|
|
228
|
-
this._modalTitle = this.getCustomMessage('title');
|
|
229
|
-
this._okButtonLabel = this.getCustomMessage('okButtonLabel');
|
|
230
|
-
this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
|
|
231
|
-
}
|
|
232
|
-
componentDidLoad() {
|
|
233
|
-
if (!this._originalFilterConfig)
|
|
234
|
-
this._originalFilterConfig = this.filters;
|
|
235
|
-
}
|
|
236
|
-
render() {
|
|
237
|
-
const customFilters = this.filters.filter(filter => filter.filterType === FilterType.CUSTOM_FILTER);
|
|
238
|
-
const quickFilters = this.filters.filter(filter => filter.filterType === FilterType.QUICK_FILTER);
|
|
239
|
-
const otherFilters = this.filters.filter(filter => filter.filterType === FilterType.OTHER_FILTERS);
|
|
240
|
-
return (h("ez-modal-container", { class: "snk-filter-modal__container", modalTitle: this._modalTitle, cancelButtonLabel: this._cancelButtonLabel, okButtonLabel: this._okButtonLabel, onEzModalAction: this.modalActionListener.bind(this) }, h("div", { class: "snk-filter-modal__content ez-col--sd-12" }, !this.disablePersonalizedFilter && this.renderCollapsibleFilterBox(this.getCustomMessage('customFilters'), customFilters, false, false), this.renderCollapsibleFilterBox(this.getCustomMessage('quickFilters'), quickFilters, false), otherFilters.map(filter => this.renderCollapsibleFilterBox(filter.label, [filter], true)))));
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
SnkFilterModal.style = snkFilterModalCss;
|
|
244
|
-
|
|
245
|
-
export { SnkFilterModal as snk_filter_modal };
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-a7d3d3f1.js';
|
|
2
|
-
import { ElementIDUtils } from '@sankhyalabs/core';
|
|
3
|
-
import { S as SnkFormConfigManager } from './SnkFormConfigManager-139f09fa.js';
|
|
4
|
-
import { R as ResourceIDUtils } from './ResourceIDUtils-a114189a.js';
|
|
5
|
-
import './ConfigStorage-7b36d041.js';
|
|
6
|
-
import './form-config-fetcher-adbe5d34.js';
|
|
7
|
-
import './DataFetcher-a9c598f2.js';
|
|
8
|
-
import './PrintUtils-3e4ff0f5.js';
|
|
9
|
-
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
10
|
-
import './filter-item-type.enum-d45e026f.js';
|
|
11
|
-
import './constants-8457af36.js';
|
|
12
|
-
|
|
13
|
-
const snkFormCss = ".sc-snk-form-h{--snk-form__header--min-height:94px;display:block}.snk-form__form--hidden.sc-snk-form{display:none}";
|
|
14
|
-
|
|
15
|
-
const SnkForm = class {
|
|
16
|
-
constructor(hostRef) {
|
|
17
|
-
registerInstance(this, hostRef);
|
|
18
|
-
this.exit = createEvent(this, "exit", 7);
|
|
19
|
-
this.actionClick = createEvent(this, "actionClick", 7);
|
|
20
|
-
this.formItemsReady = createEvent(this, "formItemsReady", 7);
|
|
21
|
-
this._customEditors = new Map();
|
|
22
|
-
this._dataUnit = undefined;
|
|
23
|
-
this._dataState = undefined;
|
|
24
|
-
this._showFormConfig = false;
|
|
25
|
-
this._configManager = undefined;
|
|
26
|
-
this.configName = undefined;
|
|
27
|
-
this.recordsValidator = undefined;
|
|
28
|
-
this.messagesBuilder = undefined;
|
|
29
|
-
this.formLegacyConfigName = undefined;
|
|
30
|
-
this.resourceID = undefined;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Exibe a janela de configurações do formulário.
|
|
34
|
-
*/
|
|
35
|
-
async showConfig() {
|
|
36
|
-
this._showFormConfig = true;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Fecha a janela de configurações do formulário.
|
|
40
|
-
*/
|
|
41
|
-
async hideConfig() {
|
|
42
|
-
this._showFormConfig = false;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Registra um editor customizado para campos da grade e formulário.
|
|
46
|
-
*/
|
|
47
|
-
async addCustomEditor(fieldName, customEditor) {
|
|
48
|
-
if (this._form) {
|
|
49
|
-
this._form.addCustomEditor(fieldName, customEditor);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const newCustomEditors = new Map(this._customEditors);
|
|
53
|
-
newCustomEditors.set(fieldName, customEditor);
|
|
54
|
-
this._customEditors = newCustomEditors;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Altera/adiciona uma propriedade nos metadados do campo.
|
|
58
|
-
*/
|
|
59
|
-
async setFieldProp(fieldName, propName, value) {
|
|
60
|
-
await this._form.setFieldProp(fieldName, propName, value);
|
|
61
|
-
}
|
|
62
|
-
closeConfig() {
|
|
63
|
-
this.hideConfig();
|
|
64
|
-
}
|
|
65
|
-
dataunitReady() {
|
|
66
|
-
const dataInfo = { dataUnit: this._dataUnit };
|
|
67
|
-
ElementIDUtils.addIDInfo(this._element, null, dataInfo);
|
|
68
|
-
}
|
|
69
|
-
setCustomEditors() {
|
|
70
|
-
if (!this._form) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
for (const [fieldName, customEditor] of this._customEditors) {
|
|
74
|
-
this._form.addCustomEditor(fieldName, customEditor);
|
|
75
|
-
this._customEditors.delete(fieldName);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async componentDidRender() {
|
|
79
|
-
this.setCustomEditors();
|
|
80
|
-
}
|
|
81
|
-
async componentWillLoad() {
|
|
82
|
-
let parent = this._element.parentElement;
|
|
83
|
-
while (parent) {
|
|
84
|
-
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
|
85
|
-
this._snkDataUnit = parent;
|
|
86
|
-
this._dataUnit = this._snkDataUnit.dataUnit;
|
|
87
|
-
this._dataState = this._snkDataUnit.dataState;
|
|
88
|
-
if (this._dataUnit) {
|
|
89
|
-
this.dataunitReady();
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
|
93
|
-
this._dataUnit = evt.detail;
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
parent = parent.parentElement;
|
|
100
|
-
}
|
|
101
|
-
if (this.resourceID == undefined) {
|
|
102
|
-
this.resourceID = await ResourceIDUtils.getResourceID();
|
|
103
|
-
}
|
|
104
|
-
this._configManager = new SnkFormConfigManager(this.configName, this.resourceID, undefined, this._dataUnit);
|
|
105
|
-
this.addFormLegacyConfig();
|
|
106
|
-
await this._configManager.loadConfig();
|
|
107
|
-
}
|
|
108
|
-
async handleDataStateChange(evt) {
|
|
109
|
-
var _a;
|
|
110
|
-
this._dataState = evt.detail;
|
|
111
|
-
const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
|
|
112
|
-
for (const field of fieldsWithRmPrecision || []) {
|
|
113
|
-
if (!field) {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
const rmPrecision = (_a = this._dataState.rowMetadata) === null || _a === void 0 ? void 0 : _a.getProp('rm_precision', field);
|
|
117
|
-
if (!rmPrecision && rmPrecision !== 0) {
|
|
118
|
-
continue;
|
|
119
|
-
}
|
|
120
|
-
await this.setFieldProp(field, 'precision', rmPrecision);
|
|
121
|
-
await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
addFormLegacyConfig() {
|
|
125
|
-
if (this.formLegacyConfigName) {
|
|
126
|
-
this._configManager.addFormLegacyConfig(this.formLegacyConfigName);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
render() {
|
|
130
|
-
if (!this._dataUnit || !this._dataState) {
|
|
131
|
-
return undefined;
|
|
132
|
-
}
|
|
133
|
-
return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { ref: (ref) => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
|
|
134
|
-
h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
|
|
135
|
-
}
|
|
136
|
-
get _element() { return getElement(this); }
|
|
137
|
-
};
|
|
138
|
-
SnkForm.style = snkFormCss;
|
|
139
|
-
|
|
140
|
-
export { SnkForm as snk_form };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export{S as snk_guides_viewer}from"./p-16869f77.js";import"./p-d2d301a6.js";import"@sankhyalabs/core";import"./p-afbb070d.js";import"./p-4d9549cf.js";import"./p-06421fdb.js";import"./p-f3434fc4.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-b0ef4383.js";import"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-23736d75.js";import"./p-7e7a7473.js";import"./p-30cf616e.js";import"./p-6dc031de.js";import"./p-1bf06cd3.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-7ac7932c.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";import"@sankhyalabs/core/dist/dataunit/DataUnit";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{D as t}from"./p-f3434fc4.js";import"./p-1bf06cd3.js";import{SortMode as i,ApplicationContext as s,UserInterface as e,DateUtils as r,ObjectUtils as a,StringUtils as n,NumberUtils as o,DataType as l}from"@sankhyalabs/core";import"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import{UserInterface as c}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{P as u}from"./p-7ac7932c.js";import"./p-ff1990ad.js";import"./p-06421fdb.js";import d from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import{h}from"./p-d2d301a6.js";class m{static assertDefaultSorting(t,s){t&&s&&(s.defaultSorting=t.columns.filter((t=>null!=t.ascending)).sort(((t,i)=>t.orderIndex-i.orderIndex)).map((({name:t,ascending:e})=>{const{dataType:r}=s.getField(t);return{field:t,dataType:r,mode:e?i.ASC:i.DESC}})))}static find(i,e,r,a=!0,n,o){let l=[],c=[],u={},d=s.getContextValue("__SNK__APPLICATION__");if(e){if(!Array.isArray(e))throw new Error(d.messagesBuilder.getMessage("crudUtils.errorArray",null));e.forEach((t=>{l.push({name:t})}))}if(r)for(const t in r)r.hasOwnProperty(t)&&c.push({nome:t,valor:r[t]});n&&(u={expression:{$:n}});let h={requestBody:{entity:{name:i,criterio:c,fields:{field:l},literalCriteria:u,orderby:o}}};return new Promise((i=>{t.get().callServiceBroker("mge@crud.find",JSON.stringify(h)).then((t=>{var s;let e=null===(s=t.entidades)||void 0===s?void 0:s.entidade;if(null!=e){let t={fields:new Map};for(let i in e){let s=e[i];if(s.hasOwnProperty("$")&&t.fields.set(i,s.$),a)break}i(t)}else i(null)}))}))}}class f{setDataUnit(t){this._dataUnit=t}setApplication(t){this._application=t}formatLabel(t,i){const{userInterface:s}=this._dataUnit.getField(t);return s===e.DATETIME?r.formatDate(this._dataUnit.valueFromString(t,i)):String(this._dataUnit.getFormattedValue(t,i))}async getStaticOptions(t){return Promise.resolve(null==t?void 0:await u.getDistinct(this._dataUnit,t))}fetchData(t,i){return new Promise((s=>{this._application.executeSelectDistinct(this._dataUnit,i,t).then((t=>{s(t.map((t=>this._dataUnit.getField(i).userInterface===e.SEARCH?Object.assign(Object.assign({},JSON.parse(t)),{check:!0}):{value:t,label:this.formatLabel(i,t),check:!0})))}))}))}sortItems(t,i){return d.defaultSorterMultSelectionOption(this._dataUnit,t,i)}}class p{setGrid(t){this._grid||(this._grid=t,this.refreshSelectedRows())}setDataState(t){this._dataState&&a.equals(null==t?void 0:t.metadataByRow,this._dataState.metadataByRow)||(this._dataState=t,this.refreshSelectedRows())}format(t,i,s){var e;if(n.isEmpty(t))return t;const r=null===(e=this._dataState)||void 0===e?void 0:e.metadataByRow.get(s),a=null==r?void 0:r.getProp("rm_precision",i.name);return a||0===a?o.format(t,a,a):t}refreshSelectedRows(){var t;null===(t=this._grid)||void 0===t||t.refreshSelectedRows()}}class v{constructor(t,i){this.dataUnit=t,this.grid=i}async getColumnsMetadata(){var t;return this.columnsState=await(null===(t=this.grid)||void 0===t?void 0:t.getColumnsState())||[],await this.buildColumnsMetadata(this.columnsState)}getColumnsState(){return this.columnsState}async buildColumnsMetadata(t){var i,s;const e=[];for(const r of t){if(r.hidden&&"RECDESP"!==r.name)continue;const t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(r.name),a=await this.grid.getCustomValueFormatter(r.name);if(e.push({label:r.label,id:r.name,width:r.width,type:null==t?void 0:t.dataType,userInterface:null==t?void 0:t.userInterface,customFormatter:a}),null!=(null===(s=null==t?void 0:t.properties)||void 0===s?void 0:s.DESCRIPTIONFIELD)){const i=t.properties.mergedFrom;e.push({label:t.properties.DESCRIPTIONENTITY,id:`${i?i+".":""}${t.properties.ENTITYNAME}.${t.properties.DESCRIPTIONFIELD}`,width:r.width,type:l.TEXT,userInterface:c.LONGTEXT,descriptionFrom:t.name})}}return e||[]}}class b{constructor(t,i,s){this.snkApplication=t,this.keyConfigEnableContinuousInsert=`${i}enableContinuousInsert${s||""}`}handleSaveConfig(t){return this.snkApplication.saveConfig(this.keyConfigEnableContinuousInsert,t)}getConfig(){return this.snkApplication.getConfig(this.keyConfigEnableContinuousInsert).then((t=>!!t&&"true"==t)).catch((()=>!1))}actionContinuousInsert(t,i){return{value:n.generateUUID(),label:t?"Desativar inclusão contínua":"Ativar inclusão contínua",enabled:!0,itemBuilder:()=>h("div",{class:"ez-dropdown__item-wrapper",onClick:i},h("span",{class:"ez-dropdown__item-label"},t?"Desativar inclusão contínua":"Ativar inclusão contínua"))}}}export{v as C,p as R,f as S,m as a,b}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as s,h as i,H as e,g as a}from"./p-d2d301a6.js";import{Action as h,StringUtils as n,ApplicationContext as r,OVERFLOWED_CLASS_NAME as o,OverflowWatcher as l,OverflowDirection as d,ElementIDUtils as v}from"@sankhyalabs/core";import{A as u}from"./p-dc36cfbf.js";import{T as c,V as k,A as m,b,a as p}from"./p-7e7a7473.js";import{P as T}from"./p-30cf616e.js";import"./p-6dc031de.js";const f=class{constructor(i){t(this,i),this.actionClick=s(this,"actionClick",7),this.taskbarSaveLocker=s(this,"taskbarSaveLocker",7),this.taskbarSaveUnlocker=s(this,"taskbarSaveUnlocker",7),this.TASKBAR_ITEM_ID_PREFIX="TASKBAR_ITEM_",this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME="taskbar-custom-elements-container",this.ACTIONS_BUTTON_TAG="TASKBAR-ACTIONS-BUTTON",this.NOT_OVERFLOW_ELEMENTS=["moreOptions","dataExporter_snkDataExporter","actionsButton_snkActionsButton"],this._titleKeyByElement={[c.UPDATE]:"snkTaskbar.titleUpdate",[c.PREVIOUS]:"snkTaskbar.titlePrevious",[c.NEXT]:"snkTaskbar.titleNext",[c.REFRESH]:"snkTaskbar.titleRefresh",[c.CLONE]:"snkTaskbar.titleClone",[c.REMOVE]:"snkTaskbar.titleRemove",[c.MORE_OPTIONS]:"snkTaskbar.titleMoreOptions",[c.INSERT]:"snkTaskbar.titleInsert",[c.CANCEL]:"snkTaskbar.titleCancel",[c.SAVE]:"snkTaskbar.titleSave",[c.GRID_MODE]:"snkTaskbar.titleGridMode",[c.FORM_MODE]:"snkTaskbar.titleFormMode",[c.CONFIGURATOR]:"snkTaskbar.titleConfigurator",[c.ATTACH]:"snkTaskbar.titleAttach"},this.onSaveEvent=t=>{switch(t.type){case h.FIELD_INVALIDATED:case h.INVALIDATE_CLEAN:case h.DATA_SAVED:case h.SAVING_ERROR:case h.SAVING_CANCELED:this._isWaitingForSave=!1;break;case h.SAVING_DATA:this._isWaitingForSave=!0}},this._permissions=void 0,this._overFlowedElements=[],this._customElements=void 0,this._customElementsId=void 0,this._slotContainer=void 0,this._hiddenActionsList=[],this._lastWidth=void 0,this._hasToUpdateOverFlow=!1,this._isWaitingForSave=!1,this.alignRigth=!1,this.customSlotId="TASKBAR_CUSTOM_ELEMENTS",this.customContainerId=void 0,this.overflowStrategy="hiddenItems",this.configName=void 0,this.resourceID=void 0,this.buttons=void 0,this.customButtons=void 0,this.actionsList=void 0,this.primaryButton=void 0,this.disabledButtons=void 0,this.dataUnit=void 0,this.presentationMode=T.PRIMARY,this.messagesBuilder=void 0}handleCustomSlotElementsLoaded(t){this.hasToSearchCustomElements(t)&&this.getCustomElements(!0)}handleTaskbarSaveLocker(){!0!==this._isWaitingForSave&&(this._isWaitingForSave=!0)}handleTaskbarSaveUnlocker(){!0===this._isWaitingForSave&&(this._isWaitingForSave=!1)}hasToSearchCustomElements(t){return this.customSlotId===t.detail&&!this._slotContainer}observeButtons(){this._definitions=void 0,requestAnimationFrame((()=>{requestAnimationFrame((()=>{var t;return null===(t=this._overFlowWatcher)||void 0===t?void 0:t.forceUpdate()}))}))}observeDisabledButtons(){var t;null===(t=this._overFlowWatcher)||void 0===t||t.forceUpdate()}observeLastWidth(t,s){0===s&&0!==t&&(this._hasToUpdateOverFlow=!0)}observeIsWaitingForSave(t,s){1==t&&0==s&&this.taskbarSaveLocker.emit(),0==t&&1==s&&this.taskbarSaveUnlocker.emit()}elementsFromString(t){const s=[];return null==t||t.split(",").forEach((t=>{t=t.trim(),(k[t]||this.isAllowed(t))&&s.push(t.trim())})),s}isAllowed(t){return t===m.CONFIGURATOR?!!this._permissions&&(this._permissions.isSup||this._permissions[u.CONFIG_GRID]||this._permissions[u.CONFIG]):!m[t]||!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getTitle(t){var s;let i;return i=this.isAllowed(t)?this._titleKeyByElement[t]:"snkTaskbar.forbidden",i?null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(i,{}):""}elementClick(t){if(this.dataUnit)switch(t){case c.PREVIOUS:this.dataUnit.previousRecord();break;case c.NEXT:this.dataUnit.nextRecord();break;case c.REFRESH:this.dataUnit.loadData();break;case c.CLONE:this.dataUnit.copySelected();break;case c.REMOVE:this.dataUnit.removeSelectedRecords();break;case c.INSERT:this.dataUnit.addRecord();break;case c.CANCEL:this.dataUnit.cancelEdition();break;case c.SAVE:this._isWaitingForSave||(this._isWaitingForSave=!0,this.dataUnit.saveData().finally((()=>{this._isWaitingForSave=!1})))}this.isEnabled(t)&&this.actionClick.emit(t)}isEnabled(t){return!(!this.isAllowed(t)||this.disabledButtons&&this.disabledButtons.includes(t))}validatePresentationMode(){Object.values(T).includes(this.presentationMode)||(this.presentationMode=T.PRIMARY)}getElement(t,s){let i=s===this.primaryButton?"ez-button--primary ":"";t>1&&(i+="ez-padding-left--medium");const e=c[s.toString()],a=this._element.dataset.exporterStoreKey||this.configName;return e?b(s,i,this.getIdElemBtnNative(s),(t=>this.getTitle(t)),(t=>this.elementClick(t)),(t=>this.isEnabled(t)),this.buildDynamicActionsList(),a,this.presentationMode):p(s,i,this.getIdElemBtnCustom(s),(t=>this.elementClick(t)),(t=>this.isEnabled(t)))}buildDynamicActionsList(){var t;return this._hiddenActionsList.length?[...null!==(t=this.actionsList)&&void 0!==t?t:[],{type:"divider",label:"",value:""},...this._hiddenActionsList]:this.actionsList}getIdElemBtnNative(t){return n.toCamelCase(t)}getIdElemBtnCustom(t){return n.toCamelCase(t.name)}isDivider(t){var s;return void 0!==t&&(null===(s=t.t)||void 0===s?void 0:s["data-taskbar-divider"])}removeEmpty(t){let s;return t.filter((t=>!(null==t||this.isDivider(s)&&this.isDivider(t)||(s=t,0))))}appendCustomElementsInTaskbar(){this._customElementsId.forEach((t=>{const s=t.replace(this.TASKBAR_ITEM_ID_PREFIX,""),i=this._customElements.get(s),e=this._element.querySelector(`#${t}`);e?null==e||e.appendChild(i):this.unlinkCustomElementFromTaskbar(i)}))}addCustomElementContainer(t){var s;const e=`${this.TASKBAR_ITEM_ID_PREFIX}${t}`;return this._customElementsId.includes(e)||(this._customElementsId.push(e),null===(s=this._overFlowWatcher)||void 0===s||s.addNotOverFlowElement(e)),i("span",{class:"ez-padding-left--medium",key:e,id:e})}getCustomElements(t){var s,i;this._customElementsId=[],this._customElements=new Map,this._slotContainer=this.buildSlotContainer(t),Array.from(null!==(i=null===(s=this._slotContainer)||void 0===s?void 0:s.children)&&void 0!==i?i:[]).forEach((t=>this._customElements.set(t.id,t)))}buildSlotContainer(t){let s;if(this.customContainerId){const t=document.querySelector(`#${this.customContainerId}`);s=null==t?void 0:t.querySelector(`#${this.customSlotId}`)}else s=this._element.querySelector(`#${this.customSlotId}`);return t&&!s&&(s=document.querySelector(`#${this.customSlotId}`)),s}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)):this._permissions={},this.getCustomElements()}componentWillRender(){this.handleDefinitions(),this.validatePresentationMode(),this.updateOverFlowIfNeeded()}handleDefinitions(){null==this._definitions&&this._permissions&&(this._definitions=this.elementsFromString(this.buttons))}updateOverFlowIfNeeded(){this._hasToUpdateOverFlow&&(requestAnimationFrame((()=>{var t;return null===(t=this._overFlowWatcher)||void 0===t?void 0:t.forceUpdate()})),this._hasToUpdateOverFlow=!1)}handleOverFlow(t){const s=t.filter((t=>!this.hasToIgnoreOverFlow(t)));this.resetOverFlowedElements(),this.doOverFlowElements(s)}resetOverFlowedElements(){this._overFlowedElements.forEach((t=>{t.classList.remove(o)})),this._hiddenActionsList=[],this._overFlowedElements=[]}doOverFlowElements(t){t.forEach((t=>{t.classList.add(o),this._overFlowedElements.push(t),this.addItemToActionList(t)}))}addItemToActionList(t){const s=this.getTaskbarElementName(t);if(s&&this.isEnabled(s)&&this.isAllowed(s)){const i={value:s,label:this.getTaskbarElementLabel(t),iconName:this.getTaskbarElementIcon(t)};this._hiddenActionsList.push(i)}}getTaskbarElementName(t){var s;return null!==(s=t.getAttribute("data-taskbar-element"))&&void 0!==s?s:""}getTaskbarElementIcon(t){var s;return null!==(s=t.getAttribute("data-taskbar-icon"))&&void 0!==s?s:""}getTaskbarElementLabel(t){var s;return null!==(s=t.getAttribute("data-taskbar-label"))&&void 0!==s?s:""}hasToIgnoreOverFlow(t){return t.classList.contains(this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME)}handleOverFlowStrategy(){"hiddenItems"===this.overflowStrategy&&(this._overFlowWatcher=new l(this.buildOverFlowWatcherParams()))}buildOverFlowWatcherParams(){return{element:this._element,callback:this.handleOverFlow.bind(this),overFlowDirection:d.HORIZONTAL,notOverFlow:this.NOT_OVERFLOW_ELEMENTS}}componentDidLoad(){v.addIDInfo(this._element,null,{dataUnit:this.dataUnit}),this.handleOverFlowStrategy(),this.dataUnit.subscribe(this.onSaveEvent)}componentDidRender(){this.appendCustomElementsInTaskbar(),this.updateLastWidth()}updateLastWidth(){this._lastWidth=this._element.getBoundingClientRect().width}disconnectedCallback(){var t;this.unlinkAllCustomElements(),null===(t=this._overFlowWatcher)||void 0===t||t.destroy()}unlinkAllCustomElements(){var t;null===(t=this._customElementsId)||void 0===t||t.forEach((t=>{const s=t.replace(this.TASKBAR_ITEM_ID_PREFIX,""),i=this._customElements.get(s);this.unlinkCustomElementFromTaskbar(i)}))}unlinkCustomElementFromTaskbar(t){this._slotContainer.appendChild(t)}render(){if(void 0===this._definitions)return;let t=0;return i(e,{class:this.getHostClasses()},this.removeEmpty(this._definitions.map((s=>{var e,a;return t++,c[s]?this.getElement(t,c[s]):(null===(e=this.customButtons)||void 0===e?void 0:e.has(s))?this.getElement(t,this.customButtons.get(s)):this._customElements.has(s)?this.addCustomElementContainer(s):(null===(a=this._overFlowWatcher)||void 0===a||a.addNotOverFlowElement(s),i("slot",{name:s}))}))),i("div",{class:this.TASKBAR_CUSTOM_ELEMENTS_CONTAINER_CLASS_NAME},i("slot",{name:this.customSlotId})))}getHostClasses(){return"hiddenItems"!==this.overflowStrategy?"no-wrap":"full-width "+(this.alignRigth?"align-right":"")}get _element(){return a(this)}static get watchers(){return{buttons:["observeButtons"],disabledButtons:["observeDisabledButtons"],_lastWidth:["observeLastWidth"],_isWaitingForSave:["observeIsWaitingForSave"]}}};f.style=".sc-snk-taskbar-h{display:flex;flex-wrap:wrap}.no-wrap.sc-snk-taskbar-h{flex-wrap:nowrap}.full-width.sc-snk-taskbar-h{width:100%}.align-right.sc-snk-taskbar-h{justify-content:flex-end}.overflowed.sc-snk-taskbar{display:none}";export{f as snk_taskbar}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as i,c as e,h as t,H as l,g as s}from"./p-d2d301a6.js";import{UserInterface as n,ObjectUtils as o,StringUtils as a,ApplicationContext as d,ElementIDUtils as r}from"@sankhyalabs/core";import{DataType as u,getConvertedValue as h}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{CheckMode as c}from"@sankhyalabs/ezui/dist/collection/utils";import{V as v,D as p,b}from"./p-b0ef4383.js";const f=class{constructor(t){i(this,t),this.configOptionsChanged=e(this,"configOptionsChanged",7),this._defaultType=void 0,this.fieldConfig={},this.idConfig=void 0,this.dataUnit=void 0,this.messagesBuilder=void 0}onConfigDefault(i){null!=i&&(this._defaultType=i,this.fieldConfig.defaultValue={type:this._defaultType},this.configOptionsChanged.emit(this.fieldConfig))}buildOptions(){var i,e,t;let l=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(null===(e=this.fieldConfig)||void 0===e?void 0:e.name))||void 0===t?void 0:t.userInterface;return l===n.SEARCH&&(l=n.INTEGERNUMBER),v.UserInterface[l]}enabledValueDefault(){var i,e,t;const l=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(null===(e=this.fieldConfig)||void 0===e?void 0:e.name),s=null===(t=null==l?void 0:l.properties)||void 0===t?void 0:t.allowDefault,o=v.UserInterface.hasOwnProperty(null==l?void 0:l.userInterface)||(null==l?void 0:l.userInterface)===n.SEARCH;return!(null!=s&&"true"!==s||!o)}isAllowDefault(){var i,e;const t=null===(e=null===(i=this._fieldProperties)||void 0===i?void 0:i.properties)||void 0===e?void 0:e.allowDefault;return null==t||"true"===t}loadDefaultValue(){var i;null==this.fieldConfig?(this._defaultType=p.fixed,this.fieldConfig={defaultValue:{type:this._defaultType}}):null==(null===(i=this.fieldConfig.defaultValue)||void 0===i?void 0:i.type)?(this._defaultType=p.fixed,this.fieldConfig.defaultValue={type:this._defaultType}):this._defaultType=this.fieldConfig.defaultValue.type}getFieldProperties(i){var e;if(null!=i)return null===(e=this.dataUnit)||void 0===e?void 0:e.getField(i)}getMessage(i,e){return this.messagesBuilder.getMessage(i,e)}getDefaultType(){var i;return null!==(i=this.fieldConfig.defaultValue.type)&&void 0!==i?i:p.fixed}getEnabledByProperty(i,e){const t=this._fieldProperties;if(null==t)return!0;const l=t.properties||{};return l.hasOwnProperty(e)?"S"!==l[e]:!0!==t[i]}getValueByProperty(i){const e=this._fieldProperties;return null!=e&&!0===e[i]||this.fieldConfig[i]}getValidatedValue(i){var e,t;if(null==i)return;const l=null===(e=this.dataUnit)||void 0===e?void 0:e.getField(null===(t=this.fieldConfig)||void 0===t?void 0:t.name),s=null==l?void 0:l.dataType;if(null==s)return;const n=null!=(null==i?void 0:i.waitmessage)?void 0:s!==u.OBJECT&&s!==u.DATE&&"object"==typeof i?i.value:i;return s===u.OBJECT?JSON.stringify(n):n}buildInputDefault({value:i,enabled:e,label:l,name:s,required:a,userInterface:d},r,u){let h,c=0,v=0;const p=null==d||null==b[d]?b.DEFAULT:b[d];if(d===n.OPTIONSELECTOR){const i=null==r?void 0:r.options;if("string"==typeof i){const e=o.stringToObject(i);h=Object.keys(e).map((i=>({value:i,label:e[i]})))}else h=i}else d===n.DECIMALNUMBER&&(c=Number((null==r?void 0:r.precision)||2),v=Number((null==r?void 0:r.prettyPrecision)||c));return t(p,Object.assign({value:i,enabled:e,label:l,"data-field-name":s,key:s,onEzChange:i=>this.onChange(null==i?void 0:i.detail)},this.getConditionalAttributes(d,a,h,c,v,u)))}getConditionalAttributes(i,e,t,l,s,o){switch(i){case n.SEARCH:return{suppressEmptyOption:e,optionLoader:i=>this.onSearch(i)};case n.OPTIONSELECTOR:return{suppressEmptyOption:e,options:t};case n.CHECKBOX:case n.SWITCH:return{mode:o};case n.INTEGERNUMBER:case n.DECIMALNUMBER:return{precision:l,prettyPrecision:s,onEzStartChange:i=>this.onChange(null==i?void 0:i.detail)};case n.DATE:case n.DATETIME:case n.TIME:return{onEzStartChange:i=>this.onChange(null==i?void 0:i.detail)};default:return{}}}onChange(i){this.fieldConfig.defaultValue.value=this.getValidatedValue(i),this.configOptionsChanged.emit(this.fieldConfig)}onSearch(i){if(null!=this._application&&null!=this.fieldConfig)return this._application.executeSearch(i,this.fieldConfig.name,this.dataUnit)}buildField(i,e){const{name:t,label:l,readOnly:s,required:o,defaultValue:d}=e,{userInterface:r,properties:u}=i;let v,p=a.getBooleanValue(null==u?void 0:u.allowDefault,!s);r===n.FILE&&(p=!1),p&&(v=null==d?void 0:d.value,null!=v&&(v=h(null==i?void 0:i.dataType,v)));const b={value:v,enabled:p,label:l,name:t,required:o,userInterface:r};switch(r){case n.SWITCH:return this.buildInputDefault(b,void 0,c.SWITCH);case n.CHECKBOX:return this.buildInputDefault(b,void 0,c.REGULAR);case n.OPTIONSELECTOR:case n.DECIMALNUMBER:return this.buildInputDefault(b,u);default:return this.buildInputDefault(b)}}componentWillLoad(){var i;this.loadDefaultValue(),this._application=d.getContextValue("__SNK__APPLICATION__"),this._fieldProperties=this.getFieldProperties(null===(i=this.fieldConfig)||void 0===i?void 0:i.name)}componentDidLoad(){r.addIDInfo(this._element,this.fieldConfig.name)}render(){var i,e;return t(l,null,t("div",{id:this.idConfig},t("div",{class:"ez-row ez-padding--medium"},t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-text-input",{label:this.getMessage("snkConfigOptions.label.nameField"),value:null===(i=this.fieldConfig)||void 0===i?void 0:i.label,onEzChange:i=>{this.fieldConfig.label=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.typeValueDefault"),suppressEmptyOption:!0,enabled:this.enabledValueDefault(),onEzChange:i=>{var e;return this.onConfigDefault(null===(e=i.detail)||void 0===e?void 0:e.value)},value:this.getDefaultType()},t("option",{value:p.fixed},this.getMessage("snkConfigOptions.options.valueFixed")),t("option",{value:p.variable},this.getMessage("snkConfigOptions.options.variable")))),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},this._defaultType===p.variable?t("ez-combo-box",{label:this.getMessage("snkConfigOptions.label.valueDefault"),enabled:this.isAllowDefault(),onEzChange:i=>{var e;this.fieldConfig.defaultValue.value=null===(e=i.detail)||void 0===e?void 0:e.value,this.configOptionsChanged.emit(this.fieldConfig)},value:this.fieldConfig.defaultValue.value,options:this.buildOptions()}):(null===(e=this._fieldProperties)||void 0===e?void 0:e.userInterface)&&this.buildField(this._fieldProperties,this.fieldConfig))),t("div",{class:"ez-row ez-padding--medium config-options__switch-row"},t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:c.SWITCH,label:this.getMessage("snkConfigOptions.label.clearDuplicate"),value:this.fieldConfig.cleanOnCopy,onEzChange:i=>{this.fieldConfig.cleanOnCopy=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:c.SWITCH,label:this.getMessage("snkConfigOptions.label.requiredField"),enabled:this.getEnabledByProperty("required","systemRequired"),value:this.getValueByProperty("required"),onEzChange:i=>{this.fieldConfig.required=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})),t("div",{class:"ez-col ez-col--sd-12 ez-col--tb-4 ez-padding--small"},t("ez-check",{mode:c.SWITCH,label:this.getMessage("snkConfigOptions.label.protectedField"),enabled:this.getEnabledByProperty("readOnly","systemReadOnly"),value:this.getValueByProperty("readOnly"),onEzChange:i=>{this.fieldConfig.readOnly=i.detail,this.configOptionsChanged.emit(this.fieldConfig)}})))))}get _element(){return s(this)}};f.style=".sc-snk-config-options-h{--snk-config-options--border:2px solid var(--color--secondary-200, #D2D3DA);width:100%;border-radius:15px;border:var(--snk-config-options--border)}.config-options__switch-row.sc-snk-config-options{margin-top:-30px}";export{f as snk_config_options}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as i,h as s,g as e,H as a}from"./p-d2d301a6.js";import{Action as n,ObjectUtils as h,DataUnitAction as r,StringUtils as o,ApplicationContext as d}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as u,S as v}from"./p-17425c72.js";import{g as f,a as m}from"./p-7ac7932c.js";import{convertType as b}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{g as p}from"./p-7dd49d15.js";const D=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.messagesBuilderUpdated=i(this,"messagesBuilderUpdated",3),this.dataUnitFieldsHidded=i(this,"dataUnitFieldsHidded",7),this.insertionMode=i(this,"insertionMode",3),this.cancelEdition=i(this,"cancelEdition",3),this._onDataUnitResolve=[],this._openedAlert=!1,this._fieldsWithRmp=[],this._fieldsWithRmPrecision=[],this._metadataByRow=new Map,this._rowMetadataCache=new Map,this.REGEX_DATAUNIT_NAME=/dd:\/\/(.+?)\//,this._dataUnitObserver=async t=>{const i=this.buildDataState(t.type);switch(this.dataState=i,this.messagesBuilder.currentOperation=this.getMessageOperation(),t.type){case n.DATA_SAVED:await this.handleDataSaved(t);break;case n.RECORDS_ADDED:case n.RECORDS_COPIED:this.insertionMode.emit();break;case n.EDITION_CANCELED:this.cancelEdition.emit();break;case n.RECORDS_REMOVED:this.handleRecordsRemoved(t);break;case n.METADATA_LOADED:this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata)}},this.fieldsToLink=[],this.dataState=void 0,this.messagesBuilder=void 0,this.dataUnitName=void 0,this.entityName=void 0,this.pageSize=150,this.dataUnit=void 0,this.beforeSave=void 0,this.afterSave=void 0,this.useCancelConfirm=!0,this.ignoreSaveMessage=void 0,this.configName=void 0,this.resourceID=void 0,this.domainMessagesBuilder=void 0}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,i){i!=t&&(this.dataUnit?this._application.updateDataunitCache(i,this.dataUnitName,this.dataUnit):this.loadDataUnit())}observeEntityName(t,i){i!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,i){h.objectToString(i)!=h.objectToString(t)&&this.dataStateChange.emit(t)}observeDataUnit(){this.handlerLinkFields(),this.dataUnitReady.emit(this.dataUnit)}observeMessagesBuilder(t){t&&this.messagesBuilderUpdated.emit(t)}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async getSelectedRecordsIDsInfo(){return p(this.dataUnit)}async getFieldsWithRmp(){return this._fieldsWithRmp}async getFieldsWithRmPrecision(){return this._fieldsWithRmPrecision}async getRowMetadata(t){return this.doGetRowMetadata(t)}doGetRowMetadata(t){const i=this.dataUnit.getSelectedRecord();if(!t&&!i)return;const s=t||i,e=this._metadataByRow.get("string"==typeof s?s:s.__record__id__);return e?(e.getProp=this.buildGetPropRowMetadata(e),Object.assign({},e)):void 0}buildGetPropRowMetadata(t){return(i,s)=>("rm_precision"===i&&(i=this.resolvePrecisionFromMetadata(s)),h.getProp(t,i))}resolvePrecisionFromMetadata(t){var i,s;if(!t)return void l.error(this.getMessage("snkDataUnit.fieldNameRequired"));const e=null===(s=null===(i=this.dataUnit.getField(t))||void 0===i?void 0:i.properties)||void 0===s?void 0:s.rm_precision;return e?e.split(".").filter(((t,i)=>1!==i)).join("."):""}getCleanOnCopyFields(){var t;return null===(t=this.dataUnit.metadata)||void 0===t?void 0:t.fields.filter((t=>{var i;return null===(i=t.properties)||void 0===i?void 0:i.cleanOnCopy})).map((t=>t.name))}fillFieldsWithRmp(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rmp)&&!this._fieldsWithRmp.includes(t.name)&&this._fieldsWithRmp.push(t.name)}))}fillFieldsWithRmPrecision(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rm_precision)&&!this._fieldsWithRmPrecision.includes(t.name)&&this._fieldsWithRmPrecision.push(t.name)}))}getCacheName(t,i,s){return[t,i,s].join("_")}updateDataStateRmp(t){const i=Object.assign({},t);this.dataState.rowMetadata=i}saveCacheRmd(t){const i=t.__record__metadata__,s=Object.keys(i);s.shift(),s.forEach((s=>{const e=f(t,s),a=this.getCacheName(s,i.provider,e);this._rowMetadataCache.set(a,Object.assign({},i))}))}getMetadataByRow(t){var i;if(!(null===(i=t.records)||void 0===i?void 0:i.length))return t;if(!this._fieldsWithRmp.length){const i=t.records.map((t=>(delete t.__record__metadata__,t)));return Object.assign(Object.assign({},t),{records:i})}const s=t.records.map((t=>{if(!t.__record__metadata__)return t;this.saveCacheRmd(t);const i=Object.assign({},t.__record__metadata__);return i.getProp=this.buildGetPropRowMetadata(i),this._metadataByRow.set(t.__record__id__,i),delete t.__record__metadata__,t}));return Object.assign(Object.assign({},t),{records:s})}interceptRecordsAdded(t){if(this.isAllowed("INSERT"))return new r(n.RECORDS_ADDED,this.handleLinksWithParent(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenInsert"))}interceptRecordsCopied(t){if(this.isAllowed("CLONE"))return new r(n.RECORDS_COPIED,this.handleRecordsCopied(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenClone"))}async interceptDataChange(t){if(this.isAllowed("UPDATE"))return t;this._openedAlert?await this.dataUnit.cancelEdition():(this._openedAlert=!0,await this.dataUnit.cancelEdition(),await l.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")),this._openedAlert=!1)}async interceptSavingData(t){if(!this.beforeSave)return t;const i=this.beforeSave(this.dataUnit);return i instanceof Promise?await i?t:void 0:i?t:void 0}interceptDataSaved(t){if(!this.afterSave)return t;this.afterSave(this.dataUnit)}async interceptEditionCanceled(t){var i,s;if(!this.useCancelConfirm||!this.dataState.hasDirtyRecords||(null===(i=t.payload)||void 0===i?void 0:i.fromParent)||(null===(s=t.payload)||void 0===s?void 0:s.silent))return t;const e=this.getMessage("snkDataUnit.cancelConfirmation");if(null==e)return this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),t;const a=this.getMessage("snkDataUnit.cancelConfirmationTitle"),n=await l.confirm(a,e);return n&&this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),n?t:void 0}async interceptRemovingRecords(t){var i,s,e;if(!this.isAllowed("REMOVE"))return void l.info(this.getMessage("snkDataUnit.forbiddenRemove"));let a=!1,n=!(null===(i=t.payload)||void 0===i?void 0:i.silent)&&this.getMessage("snkDataUnit.removeConfirmation");const h=null===(s=this.dataUnit)||void 0===s?void 0:s.getSelectionInfo();if(!(null===(e=t.payload)||void 0===e?void 0:e.silent)&&(null==h?void 0:h.length)>1&&(n=this.getMessage("snkDataUnit.removeAllConfirmation",{size:h.length}),a=!0),!n)return t;const r={canClose:!1,labelCancel:this.getMessage("snkDataUnit.confirm."+(a?"no":"cancel")),labelConfirm:this.getMessage("snkDataUnit.confirm."+(a?"yes":"delete")),btnConfirmDanger:!1},o=this.getMessage("snkDataUnit.removeConfirmationTitle");return await l.confirm(o,n,null,c.WARN,r)?t:void 0}interceptDataLoaded(t){const i=this.getMetadataByRow(t.payload);return new r(n.DATA_LOADED,i)}interceptMetadataLoaded(t){return this.fillFieldsWithRmp(t.payload),this.fillFieldsWithRmPrecision(t.payload),new r(n.METADATA_LOADED,this.handleDULinksOnMetadataLoaded(t.payload))}async interceptAction(t){switch(t.type){case n.RECORDS_ADDED:return this.interceptRecordsAdded(t);case n.RECORDS_COPIED:return this.interceptRecordsCopied(t);case n.DATA_CHANGED:return await this.handleLoadRowMetadata(t),await this.interceptDataChange(t);case n.CHANGING_DATA:return await this.interceptDataChange(t);case n.SAVING_DATA:return await this.interceptSavingData(t);case n.DATA_SAVED:return this.interceptDataSaved(t);case n.EDITION_CANCELED:return await this.interceptEditionCanceled(t);case n.REMOVING_RECORDS:return await this.interceptRemovingRecords(t);case n.DATA_LOADED:return this.interceptDataLoaded(t);case n.METADATA_LOADED:return this.interceptMetadataLoaded(t);default:return t}}async handleLoadRowMetadata(t){const i=t.type===n.DATA_CHANGED?t.payload:t.payload.changes[0].record,s=Object.keys(i).find((t=>this._fieldsWithRmp.includes(t)));if(s){const t=this.dataUnit.getField(s).properties.rmp,e=f(i,s);return await this.updateRowMetadata({fieldName:s,fieldValue:e,metadataName:t,updatedFields:i})}}async updateRowMetadata({fieldName:t,fieldValue:i,metadataName:s,updatedFields:e}){const a=this.getCacheName(t,s,i),n=this._rowMetadataCache.get(a);if(n)return this.updateDataStateRmp(n),n;{const i=new m,n=await i.loadRowMetadata(this,t,s,e);return this.updateDataStateRmp(n._rmd),this._rowMetadataCache.set(a,Object.assign({},n._rmd)),Object.assign({},n._rmd)}}handleDULinksOnMetadataLoaded(t){const i=Object.assign({},t);return this.processLinks(i),i}handleRecordsCopied(t){let i=[...t];return i=this.handleCleanOnCopy(i),this.handleLinksWithParent(i)}handleLinksWithParent(t){var i,s;const e=null!==(i=this._parentDataUnit)&&void 0!==i?i:null===(s=this.dataUnit)||void 0===s?void 0:s.getParentDataUnit();if(!e)return t;const a=e.getSelectedRecord(),n=null==e?void 0:e.getChildInfo(this.getCleanDataUnitName()),{links:h}=n;return h&&0!==h.length?t.map((t=>this.buildRecordWithLinkedFields(t,h,a))):t}buildRecordWithLinkedFields(t,i,s){const e=Object.assign({},t);return i.forEach((t=>{const i=b(this.dataUnit.getField(t.target).dataType,s[t.source]);e[t.target]=i})),e}handleCleanOnCopy(t){const i=this.getCleanOnCopyFields();return i.length>0&&(t=t.map((t=>this.buildCopyWithCleanedFields(t,i)))),t}buildCopyWithCleanedFields(t,i){const s=Object.assign({},t);return i.forEach((t=>delete s[t])),s}showSuccessMessage(t){l.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}buildDataState(t){var i;const s=this.dataUnit.getSelectionInfo(),e=(this.dataUnit.hasDirtyRecords()||this.dataUnit.hasWaitingChanges())&&(null==s?void 0:s.isEmpty()),a=this.dataUnit.getSelectedRecord();let h=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata;return!a||h&&![n.SELECTION_CHANGED,n.EDITION_CANCELED,n.NEXT_SELECTED,n.PREVIOUS_SELECTED].includes(t)?h&&(h.getProp=this.buildGetPropRowMetadata(h)):h=this.doGetRowMetadata(a),new w({insertionMode:this.dataUnit.hasNewRecord(),isStartingInsertionMode:e,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:this.dataUnit.hasCopiedRecord(),isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:void 0,selectionInfo:s,selectedRecord:a,recordsIsEmpty:0===this.dataUnit.records.length,metadataByRow:this._metadataByRow,rowMetadata:h})}async handleDataSaved(t){const i=await this.handleLoadRowMetadata(t);if(i&&(i.getProp=this.buildGetPropRowMetadata(i)),this._metadataByRow.set(t.payload.records[0].__record__id__,i),this.dataState=this.buildDataState(),this.ignoreSaveMessage)return;const s=t.payload.changes[0]._operation.toLowerCase(),e=this.getMessage("snkDataUnit.saveInfo",t.payload.records[0],s);null!=e&&this.showSuccessMessage(e)}handleRecordsRemoved(t){var i,s;let e=this.buildRemoveFinishMessage(t);null!=e&&this.showSuccessMessage(e);const a=null!==(s=null===(i=this.dataUnit.records)||void 0===i?void 0:i.length)&&void 0!==s?s:0,n=this.dataUnit.getPaginationInfo();n&&this.dataUnit.gotoPage(a>0||n.hasMore?n.currentPage:0)}buildRemoveFinishMessage(t){const i=t.payload.records;if(i&&i.length)return(null==i?void 0:i.length)>1?this.getMessage("snkDataUnit.removeAllInfo",{size:i.length}):this.getMessage("snkDataUnit.removeInfo",i)}getMessage(t,i,s){return i||(i=this.getMessageParams()),s&&(this.messagesBuilder.currentOperation=s),this.messagesBuilder.getMessage(t,i)}getMessageParams(){return this.dataState.selectedRecord}getMessageOperation(){return this.dataState.copyMode?u.CLONE:this.dataState.insertionMode||this.dataState.isStartingInsertionMode?u.INSERT:this.dataState.isDirty?u.UPDATE:u.CLEAN}async getDataUnitParentOrChild(){var t;const i=this.dataUnitName?this.dataUnitName:this.entityName;return this._parentSnkDataUnit?(this._parentDataUnit=await(null===(t=this._parentSnkDataUnit)||void 0===t?void 0:t.getDataUnit()),await this._application.getDataUnit(this.entityName,i,this._parentDataUnit,this.configName,this.resourceID)):await this._application.getDataUnit(this.entityName,i,null,this.configName,this.resourceID)}updateMetadataWithRMP(){this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata);const t=this.handleDULinksOnMetadataLoaded(this.dataUnit.metadata);this.dataUnit.metadata=t}async loadDataUnit(){var t,i;if(null==this.dataUnit&&this._application&&this.entityName&&(this.dataUnit=await this.getDataUnitParentOrChild()),this.dataUnit){if(this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.subscribe(this._dataUnitObserver),(null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)&&this.updateMetadataWithRMP(),this.dataUnit.addInterceptor(this),null===(i=this.dataUnit.records)||void 0===i?void 0:i.length){const{records:t}=this.getMetadataByRow(this.dataUnit);this.dataUnit.records=t}let s;for(this.dataState=this.buildDataState();s=this._onDataUnitResolve.pop();)s(this.dataUnit)}}getParentSnkDataUnit(){let t=this.element;for(;t.parentNode;){if("SNK-DATA-UNIT"===t.parentNode.nodeName)return t.parentNode;t=t.parentNode}}handlerLinkFields(){var t,i,s,e;const a=null!==(t=this._parentDataUnit)&&void 0!==t?t:null===(i=this.dataUnit)||void 0===i?void 0:i.getParentDataUnit();if(!a)return;const n=null!==(s=this.entityName)&&void 0!==s?s:this.getCleanDataUnitName(),h=a.getChildInfo(n);if(!h)return;const r=null===(e=null==h?void 0:h.links)||void 0===e?void 0:e.map((t=>t.target));this.handleDUWithLinks(r)}handleDUWithLinks(t){this.fieldsToLink=t;const i=Object.assign({},this.dataUnit.metadata);this.processLinks(i),this.dataUnit.metadata=i,this.dataUnitFieldsHidded.emit()}processLinks(t){var i;null===(i=null==t?void 0:t.fields)||void 0===i||i.forEach((t=>{var i;(null===(i=this.fieldsToLink)||void 0===i?void 0:i.includes(t.name))&&(t.visible=!1)}))}getCleanDataUnitName(){var t;const i=this.dataUnit.name;if(o.isEmpty(i))return i;const s=this.REGEX_DATAUNIT_NAME.exec(i);return null!==(t=null==s?void 0:s[1])&&void 0!==t?t:i}static getNearestInstance(t){let i=t.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase())return i;i=i.parentElement}}instanceMessagesBuilder(){var t;this.messagesBuilder||(this.messagesBuilder=new v(null!==(t=this.domainMessagesBuilder)&&void 0!==t?t:this.entityName))}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)),this._parentSnkDataUnit=this.getParentSnkDataUnit(),this.instanceMessagesBuilder()}disconnectedCallback(){this.dataUnit&&this.dataUnit.releaseCallbacks()}async componentDidLoad(){await this.loadDataUnit(),this.handlerLinkFields()}render(){return s(a,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"],messagesBuilder:["observeMessagesBuilder"]}}};class w{constructor(t){this.copyMode=t.copyMode,this.insertionMode=t.insertionMode,this.isStartingInsertionMode=t.isStartingInsertionMode,this.isDirty=t.isDirty,this.hasDirtyRecords=t.hasDirtyRecords,this.hasNext=t.hasNext,this.hasPrevious=t.hasPrevious,this.selectionInfo=t.selectionInfo,this.selectedRecord=t.selectedRecord,this.recordsIsEmpty=t.recordsIsEmpty,this.metadataByRow=t.metadataByRow,this.rowMetadata=t.rowMetadata}get selectedRecords(){var t;if(console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`."),null===(t=this.selectionInfo)||void 0===t?void 0:t.isAllRecords())throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");return this.selectionInfo.records}}export{D as S}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as i,c as t,h as s,g as o}from"./p-d2d301a6.js";import{ElementIDUtils as h}from"@sankhyalabs/core";import{S as a}from"./p-afbb070d.js";import{R as n}from"./p-688dcb4c.js";import"./p-4d9549cf.js";import"./p-06421fdb.js";import"./p-f3434fc4.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-b0ef4383.js";const e=class{constructor(s){i(this,s),this.exit=t(this,"exit",7),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this._customEditors=new Map,this._dataUnit=void 0,this._dataState=void 0,this._showFormConfig=!1,this._configManager=void 0,this.configName=void 0,this.recordsValidator=void 0,this.messagesBuilder=void 0,this.formLegacyConfigName=void 0,this.resourceID=void 0}async showConfig(){this._showFormConfig=!0}async hideConfig(){this._showFormConfig=!1}async addCustomEditor(i,t){if(this._form)return void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async setFieldProp(i,t,s){await this._form.setFieldProp(i,t,s)}closeConfig(){this.hideConfig()}dataunitReady(){h.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}setCustomEditors(){if(this._form)for(const[i,t]of this._customEditors)this._form.addCustomEditor(i,t),this._customEditors.delete(i)}async componentDidRender(){this.setCustomEditors()}async componentWillLoad(){let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.dataunitReady():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail})),this._snkDataUnit.addEventListener("dataStateChange",this.handleDataStateChange.bind(this));break}i=i.parentElement}null==this.resourceID&&(this.resourceID=await n.getResourceID()),this._configManager=new a(this.configName,this.resourceID,void 0,this._dataUnit),this.addFormLegacyConfig(),await this._configManager.loadConfig()}async handleDataStateChange(i){var t;this._dataState=i.detail;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const i of s||[]){if(!i)continue;const s=null===(t=this._dataState.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",i);(s||0===s)&&(await this.setFieldProp(i,"precision",s),await this.setFieldProp(i,"prettyPrecision",s))}}addFormLegacyConfig(){this.formLegacyConfigName&&this._configManager.addFormLegacyConfig(this.formLegacyConfigName)}render(){if(this._dataUnit&&this._dataState)return s("section",null,s("div",{class:"ez-row"},s("div",{class:"ez-col ez-col--sd-12"},s("ez-form",{ref:i=>this._form=i,key:"ezForm"+this._snkDataUnit.entityName,"data-element-id":"embedded",dataUnit:this._dataUnit,config:this._configManager.getConfig(this._dataUnit),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&s("snk-form-config",{messagesBuilder:this.messagesBuilder,dataUnit:this._dataUnit,configManager:this._configManager,onConfigClose:()=>this.closeConfig()}))))}get _element(){return o(this)}};e.style=".sc-snk-form-h{--snk-form__header--min-height:94px;display:block}.snk-form__form--hidden.sc-snk-form{display:none}";export{e as snk_form}
|