@sankhyalabs/sankhyablocks 5.5.0 → 5.6.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/{SnkMessageBuilder-26da04f7.js → SnkMessageBuilder-e64dce7f.js} +14 -0
- package/dist/cjs/index-8d94b7e0.js +7 -0
- package/dist/cjs/index-de79181a.js +201 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +2 -1
- package/dist/cjs/snk-crud.cjs.entry.js +2 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-c43df27b.js → snk-data-unit-85d6565e.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -3
- package/dist/cjs/snk-expression-item.cjs.entry.js +213 -0
- package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +435 -0
- package/dist/cjs/snk-grid.cjs.entry.js +3 -2
- package/dist/cjs/{snk-guides-viewer-e6a65393.js → snk-guides-viewer-9784c527.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +3 -2
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +126 -0
- package/dist/cjs/snk-simple-bar_2.cjs.entry.js +2 -1
- package/dist/cjs/snk-taskbar.cjs.entry.js +2 -1
- package/dist/cjs/taskbar-elements-bc2598f9.js +118 -0
- package/dist/collection/collection-manifest.json +2 -0
- package/dist/collection/components/snk-filter-field-search/snk-filter-field-search.js +62 -69
- package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.css +4 -0
- package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +87 -0
- package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/filter-operands/filter-operands.js +34 -0
- package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.css +97 -0
- package/dist/collection/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.js +298 -0
- package/dist/collection/components/snk-personalized-filter/subcomponents/snk-filter-param-config/snk-filter-param-config.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.js +63 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +2 -0
- package/dist/collection/lib/message/resources/snk-personalized-filter.msg.js +12 -0
- package/dist/collection/lib/store/index.js +2 -1
- package/dist/components/SnkMessageBuilder.js +14 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index2.js +1 -1
- package/dist/components/index3.js +199 -0
- package/dist/components/snk-data-exporter2.js +1 -1
- package/dist/components/snk-expression-item.d.ts +11 -0
- package/dist/components/snk-expression-item.js +6 -0
- package/dist/components/snk-expression-item2.js +241 -0
- package/dist/components/snk-filter-field-search.js +1 -200
- package/dist/{esm/snk-filter-field-search.entry.js → components/snk-filter-field-search2.js} +65 -38
- package/dist/components/snk-filter-param-config.js +1 -273
- package/dist/{esm/snk-filter-param-config.entry.js → components/snk-filter-param-config2.js} +35 -11
- package/dist/components/snk-grid2.js +2 -1
- package/dist/components/snk-personalized-filter.d.ts +11 -0
- package/dist/components/snk-personalized-filter.js +158 -0
- package/dist/components/snk-taskbar2.js +3 -197
- package/dist/esm/{SnkMessageBuilder-7a9392e6.js → SnkMessageBuilder-f3590f65.js} +14 -0
- package/dist/esm/{index-6519a79e.js → index-507e19ec.js} +1 -1
- package/dist/esm/index-620ac460.js +7 -0
- package/dist/esm/index-8efbf198.js +199 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +3 -2
- package/dist/esm/snk-crud.entry.js +3 -2
- package/dist/esm/snk-data-exporter.entry.js +3 -3
- package/dist/esm/{snk-data-unit-f9e4c694.js → snk-data-unit-50b1660c.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +5 -4
- package/dist/esm/snk-expression-item.entry.js +209 -0
- package/dist/esm/snk-filter-field-search_2.entry.js +430 -0
- package/dist/esm/snk-grid.entry.js +3 -2
- package/dist/esm/{snk-guides-viewer-62a9f74d.js → snk-guides-viewer-4d12f268.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +4 -3
- package/dist/esm/snk-personalized-filter.entry.js +122 -0
- package/dist/esm/snk-simple-bar_2.entry.js +3 -2
- package/dist/esm/snk-taskbar.entry.js +3 -2
- package/dist/esm/taskbar-elements-e6af3e93.js +115 -0
- package/dist/sankhyablocks/p-1dcfd32a.entry.js +1 -0
- package/dist/sankhyablocks/p-27e264d9.entry.js +1 -0
- package/dist/sankhyablocks/p-343699ad.entry.js +1 -0
- package/dist/sankhyablocks/{p-f2223502.js → p-3d3263b4.js} +1 -1
- package/dist/sankhyablocks/{p-b2523981.entry.js → p-3fbe2d69.entry.js} +1 -1
- package/dist/sankhyablocks/p-433dfa63.entry.js +1 -0
- package/dist/sankhyablocks/{p-f132e371.js → p-4c2015a9.js} +1 -1
- package/dist/sankhyablocks/p-4eefe631.entry.js +1 -0
- package/dist/sankhyablocks/p-6a02e236.js +1 -0
- package/dist/sankhyablocks/p-8bdf5e57.entry.js +1 -0
- package/dist/sankhyablocks/{p-a412992c.entry.js → p-c4417efb.entry.js} +1 -1
- package/dist/sankhyablocks/{p-92a0fca4.js → p-c9477950.js} +1 -1
- package/dist/sankhyablocks/{p-aeffd219.js → p-ccd26e3a.js} +1 -1
- package/dist/sankhyablocks/p-d410f45a.js +1 -0
- package/dist/sankhyablocks/p-df8f13b4.entry.js +1 -0
- package/dist/sankhyablocks/p-e9f42525.entry.js +1 -0
- package/dist/sankhyablocks/p-f344b811.entry.js +1 -0
- package/dist/sankhyablocks/p-f4184ce7.js +1 -0
- package/dist/sankhyablocks/p-fd4ed40a.entry.js +1 -0
- package/dist/sankhyablocks/p-ff96b509.entry.js +27 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-filter-field-search/interfaces/index.d.ts +14 -4
- package/dist/types/components/snk-filter-field-search/snk-filter-field-search.d.ts +13 -10
- package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +20 -0
- package/dist/types/components/snk-personalized-filter/subcomponents/snk-expression-item/filter-operands/filter-operands.d.ts +9 -0
- package/dist/types/components/snk-personalized-filter/subcomponents/snk-expression-item/snk-expression-item.d.ts +54 -0
- package/dist/types/components/snk-personalized-filter/subcomponents/snk-filter-param-config/interfaces/IExpressionItem.d.ts +4 -2
- package/dist/types/components.d.ts +83 -9
- package/dist/types/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.d.ts +7 -0
- package/dist/types/lib/message/resources/snk-personalized-filter.msg.d.ts +1 -0
- package/dist/types/lib/store/index.d.ts +1 -0
- package/package.json +1 -1
- package/react/components.d.ts +2 -0
- package/react/components.js +2 -0
- package/react/components.js.map +1 -1
- package/dist/cjs/snk-filter-field-search.cjs.entry.js +0 -185
- package/dist/cjs/snk-filter-param-config.cjs.entry.js +0 -256
- package/dist/cjs/taskbar-elements-80285601.js +0 -313
- package/dist/esm/taskbar-elements-055ba1ad.js +0 -309
- package/dist/sankhyablocks/p-4512cc6c.entry.js +0 -1
- package/dist/sankhyablocks/p-5cbbe1f7.entry.js +0 -1
- package/dist/sankhyablocks/p-63d01871.entry.js +0 -1
- package/dist/sankhyablocks/p-741b00ef.entry.js +0 -1
- package/dist/sankhyablocks/p-79d22df0.entry.js +0 -1
- package/dist/sankhyablocks/p-93d8fe00.entry.js +0 -1
- package/dist/sankhyablocks/p-999d1953.entry.js +0 -1
- package/dist/sankhyablocks/p-c3efd4eb.entry.js +0 -1
- package/dist/sankhyablocks/p-ebe876f5.entry.js +0 -1
- package/dist/sankhyablocks/p-ed438690.js +0 -1
- package/dist/sankhyablocks/p-f3d0c744.entry.js +0 -1
@@ -0,0 +1,213 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
const index$1 = require('./index-21bd01e1.js');
|
6
|
+
const core = require('@sankhyalabs/core');
|
7
|
+
const index$3 = require('./index-8d94b7e0.js');
|
8
|
+
const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
9
|
+
const FieldBuilder = require('@sankhyalabs/ezui/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder');
|
10
|
+
const index = require('./index-f400b1d6.js');
|
11
|
+
const index$2 = require('./index-de79181a.js');
|
12
|
+
|
13
|
+
const FilterOperandDefault = [
|
14
|
+
{ value: index.FilterOperand.EQUAL, label: "Igual (=)" },
|
15
|
+
{ value: index.FilterOperand.DIFFERENT, label: "Diferente (<>)" },
|
16
|
+
{ value: index.FilterOperand.LIKE, label: "Contendo (LIKE)" },
|
17
|
+
{ value: index.FilterOperand.IN, label: "Contido em (IN)" },
|
18
|
+
{ value: index.FilterOperand.START_WITH, label: "Iniciado com (%?)" },
|
19
|
+
{ value: index.FilterOperand.FINISHED_WITH, label: "Terminado com (?%)" },
|
20
|
+
{ value: index.FilterOperand.NULL, label: "Vazio (NULL)" },
|
21
|
+
{ value: index.FilterOperand.NOT_NULL, label: "Não Vazio (NOT NULL)" },
|
22
|
+
{ value: index.FilterOperand.LARGER, label: "Maior (>)" },
|
23
|
+
{ value: index.FilterOperand.LARGER_EQUAL, label: "Maior ou Igual (>=)" },
|
24
|
+
{ value: index.FilterOperand.SMALLER, label: "Menor (<)" },
|
25
|
+
{ value: index.FilterOperand.SMALLER_EQUAL, label: "Menor ou Igual (<=)" }
|
26
|
+
];
|
27
|
+
const FilterOperandTypeTextSearch = [
|
28
|
+
{ value: index.FilterOperand.EQUAL, label: "Igual (=)" },
|
29
|
+
{ value: index.FilterOperand.DIFFERENT, label: "Diferente (<>)" },
|
30
|
+
{ value: index.FilterOperand.LIKE, label: "Contendo (LIKE)" },
|
31
|
+
{ value: index.FilterOperand.IN, label: "Contido em (IN)" },
|
32
|
+
{ value: index.FilterOperand.START_WITH, label: "Iniciado com (%?)" },
|
33
|
+
{ value: index.FilterOperand.FINISHED_WITH, label: "Terminado com (?%)" },
|
34
|
+
{ value: index.FilterOperand.NULL, label: "Vazio (NULL)" },
|
35
|
+
{ value: index.FilterOperand.NOT_NULL, label: "Não Vazio (NOT NULL)" }
|
36
|
+
];
|
37
|
+
const FIELD_TYPE_SEARCH_AND_TEXT = [
|
38
|
+
core.UserInterface.SEARCH,
|
39
|
+
core.UserInterface.SHORTTEXT,
|
40
|
+
core.UserInterface.PASSWORD,
|
41
|
+
core.UserInterface.MASKEDTEXT,
|
42
|
+
core.UserInterface.LONGTEXT,
|
43
|
+
core.UserInterface.HTML
|
44
|
+
];
|
45
|
+
|
46
|
+
const snkExpressionItemCss = ".sc-snk-expression-item-h{display:flex;width:100%;--snk-expression-item--background-color:var(--background--xlight, #fff);--snk-expression-item__itens--padding:var(--space--small, 6px);--snk-expression-item__width--input-operator:220px;--snk-expression-item__width--input-value:240px;--snk-expression-item__width--input-value-variable:176px;--snk-expression-item--border-radius:var(--border--radius-medium, 12px);--snk-expression-item--border-color:var(--color--strokes, #DCE0E8);--snk-expression-item--border-style:var(--border--small, 1px solid)}.box.sc-snk-expression-item{width:100%;height:100%;background:var(--snk-expression-item--background-color);margin:var(--space--small, 6px);border:var(--snk-expression-item--border-color) var(--snk-expression-item--border-style);border-radius:var(--snk-expression-item--border-radius)}.box__container.sc-snk-expression-item{display:flex;align-items:center;justify-content:space-between;white-space:nowrap;margin:var(--space--small, 6px)}.box__container--input-filter.sc-snk-expression-item{width:100%}.box__container--input-operator.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-operator);min-width:var(--snk-expression-item__width--input-operator)}.box__container--input-value.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-value);min-width:var(--snk-expression-item__width--input-value)}.box__container--input-value-variable.sc-snk-expression-item{display:flex;width:var(--snk-expression-item__width--input-value-variable);min-width:var(--snk-expression-item__width--input-value-variable)}.box__container--button-delete.sc-snk-expression-item{display:flex}.box__container.sc-snk-expression-item>div.sc-snk-expression-item{padding-left:var(--snk-expression-item__itens--padding);padding-right:var(--snk-expression-item__itens--padding)}.box__container--button-delete--icon.sc-snk-expression-item{width:42px;min-width:42px}.box__container--input-value-variable--icon.sc-snk-expression-item{cursor:pointer}";
|
47
|
+
|
48
|
+
const SnkExpressionItem = class {
|
49
|
+
constructor(hostRef) {
|
50
|
+
index$1.registerInstance(this, hostRef);
|
51
|
+
this.ezFilterItemChange = index$1.createEvent(this, "ezFilterItemChange", 7);
|
52
|
+
this.ezFilterItemRemove = index$1.createEvent(this, "ezFilterItemRemove", 7);
|
53
|
+
this.application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
54
|
+
this.filterOperandDefault = FilterOperandDefault;
|
55
|
+
this.filterOperandTypeTextSearch = FilterOperandTypeTextSearch;
|
56
|
+
this._showValueVariable = false;
|
57
|
+
this._fieldSelected = undefined;
|
58
|
+
this._optionNotNull = false;
|
59
|
+
this.expression = undefined;
|
60
|
+
this.canRemove = true;
|
61
|
+
this.messagesBuilder = undefined;
|
62
|
+
}
|
63
|
+
expressionChanged(newValue, oldValue) {
|
64
|
+
if (newValue !== oldValue) {
|
65
|
+
this.ezFilterItemChange.emit(newValue);
|
66
|
+
}
|
67
|
+
}
|
68
|
+
componentWillLoad() {
|
69
|
+
this._dataSourceFetcher = index$2.store.get("filterFieldsDataSource");
|
70
|
+
index$2.store.onChange('filterFieldsDataSource', () => {
|
71
|
+
this._dataSourceFetcher = index$2.store.get("filterFieldsDataSource");
|
72
|
+
});
|
73
|
+
}
|
74
|
+
setValueExpression(key, value) {
|
75
|
+
this.expression[key] = value;
|
76
|
+
this.expressionChanged(this.expression);
|
77
|
+
}
|
78
|
+
getMessage(key, params) {
|
79
|
+
return this.application.messagesBuilder.getMessage(key, params);
|
80
|
+
}
|
81
|
+
handleSelectItem(filterField) {
|
82
|
+
if (filterField.type === index$3.SelectedItemType.FIELD) {
|
83
|
+
const field = filterField;
|
84
|
+
this._fieldSelected = field;
|
85
|
+
this.setValueExpression("fieldName", field.name);
|
86
|
+
}
|
87
|
+
}
|
88
|
+
handleFocus() {
|
89
|
+
if (this._elFilterFieldSearch)
|
90
|
+
this._elFilterFieldSearch.show();
|
91
|
+
}
|
92
|
+
handleChangeFilterInput(evt) {
|
93
|
+
this._elFilterFieldSearch.applyFilter(evt.detail);
|
94
|
+
}
|
95
|
+
handleChangeValueVariable(showValueVariable) {
|
96
|
+
this._showValueVariable = showValueVariable;
|
97
|
+
if (this._elFieldDynamic) {
|
98
|
+
this._elFieldDynamic.value = undefined;
|
99
|
+
this._elFieldDynamic.enabled = !showValueVariable;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
openSnkFilterParamConfig() {
|
103
|
+
var _a;
|
104
|
+
(_a = this._elFilterParamConfigRef) === null || _a === void 0 ? void 0 : _a.open(this.expression).then(this.onOpenPromiseReady.bind(this)).catch(error => {
|
105
|
+
console.error(error);
|
106
|
+
});
|
107
|
+
}
|
108
|
+
onOpenPromiseReady(changes) {
|
109
|
+
this.expression = changes;
|
110
|
+
}
|
111
|
+
buildOptionsOperator() {
|
112
|
+
var _a;
|
113
|
+
if (FIELD_TYPE_SEARCH_AND_TEXT.includes((_a = this._fieldSelected) === null || _a === void 0 ? void 0 : _a.userInterface)) {
|
114
|
+
return this.filterOperandTypeTextSearch;
|
115
|
+
}
|
116
|
+
else {
|
117
|
+
return this.filterOperandDefault;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
handleChangeOperator(optionSelected) {
|
121
|
+
this.checkOptionIsNull(optionSelected);
|
122
|
+
this.setValueExpression("operand", optionSelected);
|
123
|
+
}
|
124
|
+
checkOptionIsNull(optionSelected) {
|
125
|
+
if (optionSelected === index.FilterOperand.NULL || optionSelected === index.FilterOperand.NOT_NULL) {
|
126
|
+
this._optionNotNull = true;
|
127
|
+
if (this._elFieldDynamic) {
|
128
|
+
this._elFieldDynamic.enabled = false;
|
129
|
+
this._elFieldDynamic.value = undefined;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
else {
|
133
|
+
this._optionNotNull = false;
|
134
|
+
if (this._elFieldDynamic) {
|
135
|
+
this._elFieldDynamic.enabled = this._showValueVariable ? false : true;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
confirmRemove(evt) {
|
140
|
+
evt.preventDefault();
|
141
|
+
evt.stopPropagation();
|
142
|
+
utils.ApplicationUtils.confirm(this.getMessage("snkPersonalizedFilter.confirm.title"), this.getMessage("snkPersonalizedFilter.confirm.description"))
|
143
|
+
.then((canRemove) => {
|
144
|
+
if (canRemove) {
|
145
|
+
this.ezFilterItemRemove.emit(this.expression);
|
146
|
+
}
|
147
|
+
});
|
148
|
+
}
|
149
|
+
buildFieldByType() {
|
150
|
+
var _a, _b;
|
151
|
+
if (!this._fieldSelected)
|
152
|
+
return;
|
153
|
+
const inputFieldData = (_a = FieldBuilder.fieldBuilder(this.configureFieldByType())) === null || _a === void 0 ? void 0 : _a.$children$.shift();
|
154
|
+
if (this._optionNotNull && inputFieldData || ((_b = this._elValueVariable) === null || _b === void 0 ? void 0 : _b.value) && inputFieldData) {
|
155
|
+
inputFieldData.$attrs$.enabled = false;
|
156
|
+
}
|
157
|
+
return index$1.h(inputFieldData.$tag$, Object.assign(Object.assign({}, inputFieldData.$attrs$), { ref: (el) => {
|
158
|
+
this._elFieldDynamic = el;
|
159
|
+
} }));
|
160
|
+
}
|
161
|
+
configureFieldByType() {
|
162
|
+
const field = {
|
163
|
+
userInterface: this._fieldSelected.userInterface,
|
164
|
+
name: this._fieldSelected.name,
|
165
|
+
label: this._fieldSelected.label,
|
166
|
+
canShowError: false
|
167
|
+
};
|
168
|
+
switch (field.userInterface) {
|
169
|
+
case core.UserInterface.OPTIONSELECTOR:
|
170
|
+
field.props = {
|
171
|
+
options: this._fieldSelected.properties.map(option => ({
|
172
|
+
value: option.value,
|
173
|
+
label: option.name,
|
174
|
+
})),
|
175
|
+
};
|
176
|
+
break;
|
177
|
+
case core.UserInterface.LONGTEXT:
|
178
|
+
field.rows = 1;
|
179
|
+
break;
|
180
|
+
case core.UserInterface.SEARCH:
|
181
|
+
field.optionLoader = searchArgument => this.setCriteriaSearch(searchArgument, this.application);
|
182
|
+
break;
|
183
|
+
}
|
184
|
+
return field;
|
185
|
+
}
|
186
|
+
setCriteriaSearch({ mode, argument }, application) {
|
187
|
+
if (application == undefined)
|
188
|
+
return;
|
189
|
+
const searchOptions = {
|
190
|
+
showInactives: false
|
191
|
+
};
|
192
|
+
const options = {
|
193
|
+
entity: this._fieldSelected.properties.ENTITYNAME,
|
194
|
+
searchOptions: searchOptions,
|
195
|
+
entityDescription: this._fieldSelected.label
|
196
|
+
};
|
197
|
+
return application.executePreparedSearch(mode, argument, options);
|
198
|
+
}
|
199
|
+
render() {
|
200
|
+
var _a;
|
201
|
+
return (index$1.h(index$1.Host, null, index$1.h("div", { class: "box" }, index$1.h("div", { class: "box__container" }, index$1.h("div", { class: "box__container--input-filter" }, index$1.h("ez-filter-input", { value: (_a = this._fieldSelected) === null || _a === void 0 ? void 0 : _a.path, label: this.getMessage("snkPersonalizedFilter.info.labelSearchField"), canShowError: false, onEzChange: (evt) => this.handleChangeFilterInput(evt), onFocus: () => this.handleFocus() }), index$1.h("snk-filter-field-search", { ref: ref => this._elFilterFieldSearch = ref, searchable: false, onEzSelectFilterItem: (ev) => this.handleSelectItem(ev.detail), fieldsDataSource: this._dataSourceFetcher })), index$1.h("div", { class: "box__container--input-operator" }, index$1.h("ez-combo-box", { label: this.getMessage("snkPersonalizedFilter.info.labelOperator"), canShowError: false, options: this.buildOptionsOperator(), onEzChange: (evt) => this.handleChangeOperator(evt.detail.value), suppressEmptyOption: true })), index$1.h("div", { class: "box__container--input-value" }, !this._fieldSelected ?
|
202
|
+
index$1.h("ez-number-input", { label: "Valor", canShowError: false, enabled: (!this._showValueVariable && !this._optionNotNull) }) :
|
203
|
+
this.buildFieldByType()), index$1.h("div", { class: "box__container--input-value-variable", title: this.getMessage("snkPersonalizedFilter.info.titleTooltip") }, !this._optionNotNull &&
|
204
|
+
index$1.h("ez-check", { ref: ref => this._elValueVariable = ref, label: this.getMessage("snkPersonalizedFilter.info.labelValueVarible"), mode: utils.CheckMode.SWITCH, onEzChange: (evt) => this.handleChangeValueVariable(evt.detail) }), (this._showValueVariable && !this._optionNotNull) &&
|
205
|
+
index$1.h("ez-icon", { class: "box__container--input-value-variable--icon", size: "large", iconName: "settings-inverted", onClick: () => this.openSnkFilterParamConfig() }), index$1.h("snk-filter-param-config", { ref: (el) => this._elFilterParamConfigRef = el, messagesBuilder: this.messagesBuilder })), index$1.h("div", { class: "box__container--button-delete" }, index$1.h("div", { class: "box__container--button-delete--icon" }, this.canRemove && index$1.h("ez-button", { mode: "icon", iconName: "delete", onClick: (evt) => this.confirmRemove(evt) })))))));
|
206
|
+
}
|
207
|
+
static get watchers() { return {
|
208
|
+
"expression": ["expressionChanged"]
|
209
|
+
}; }
|
210
|
+
};
|
211
|
+
SnkExpressionItem.style = snkExpressionItemCss;
|
212
|
+
|
213
|
+
exports.snk_expression_item = SnkExpressionItem;
|
@@ -0,0 +1,435 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
const index = require('./index-21bd01e1.js');
|
6
|
+
const index$1 = require('./index-8d94b7e0.js');
|
7
|
+
const core = require('@sankhyalabs/core');
|
8
|
+
const ezModalContainer = require('@sankhyalabs/ezui/dist/collection/components/ez-modal-container');
|
9
|
+
const index$2 = require('./index-f400b1d6.js');
|
10
|
+
|
11
|
+
const ICON_MODES = {
|
12
|
+
[core.UserInterface.SHORTTEXT]: 'text',
|
13
|
+
[core.UserInterface.LONGTEXT]: 'text',
|
14
|
+
[core.UserInterface.INTEGERNUMBER]: 'number',
|
15
|
+
[core.UserInterface.DECIMALNUMBER]: 'number',
|
16
|
+
[core.UserInterface.DATE]: 'calendar',
|
17
|
+
[core.UserInterface.DATETIME]: 'calendar',
|
18
|
+
[core.UserInterface.SWITCH]: 'boolean',
|
19
|
+
[core.UserInterface.CHECKBOX]: 'check-circle-inverted',
|
20
|
+
[core.UserInterface.OPTIONSELECTOR]: 'list',
|
21
|
+
[core.UserInterface.SEARCH]: 'search',
|
22
|
+
[core.UserInterface.HTML]: 'tag_code',
|
23
|
+
[core.UserInterface.IMAGE]: 'png',
|
24
|
+
[core.UserInterface.FILE]: 'edit-file',
|
25
|
+
[core.UserInterface.TIME]: 'timer-outline',
|
26
|
+
[core.UserInterface.ELAPSEDTIME]: 'timer',
|
27
|
+
[core.UserInterface.MASKEDTEXT]: 'text',
|
28
|
+
[core.UserInterface.PASSWORD]: 'email',
|
29
|
+
};
|
30
|
+
const ListItem = ({ userInterface, description }) => {
|
31
|
+
return (index.h("ez-icon", { iconName: ICON_MODES[userInterface], className: "ez-padding-left--small", title: description }));
|
32
|
+
};
|
33
|
+
|
34
|
+
const snkFilterFieldSearchCss = ".sc-snk-filter-field-search-h{--snk-filter-field-search--container-width:468px;--snk-filter-field-search--container-height:322px}.snk-filter-field-search__container.sc-snk-filter-field-search{display:flex;flex-direction:column;padding:var(--space--medium);width:var(--snk-filter-field-search--container-width);height:var(--snk-filter-field-search--container-height)}.snk-filter-field-search__section.sc-snk-filter-field-search{display:grid;grid-template-columns:1fr 1fr;place-items:flex-start;overflow:hidden;gap:var(--space--small)}.snk-filter-field-search__input.sc-snk-filter-field-search{margin-bottom:var(--space--medium)}.snk-filter-field-search__list_container.sc-snk-filter-field-search{display:flex;flex-direction:column}.snk-filter-field-search__list.sc-snk-filter-field-search{overflow-y:auto}";
|
35
|
+
|
36
|
+
const SNK_CONTEXT_KEY = "__SNK__APPLICATION__";
|
37
|
+
const SnkFilterFieldSearch = class {
|
38
|
+
constructor(hostRef) {
|
39
|
+
index.registerInstance(this, hostRef);
|
40
|
+
this.ezSelectFilterItem = index.createEvent(this, "ezSelectFilterItem", 7);
|
41
|
+
this._filterMetadataStorage = new Map();
|
42
|
+
this._currentMetadata = null;
|
43
|
+
this._filterText = "";
|
44
|
+
this._isLoading = false;
|
45
|
+
this.searchable = true;
|
46
|
+
this.fieldsDataSource = undefined;
|
47
|
+
this.breadcrumbItems = [];
|
48
|
+
this.linkItems = [];
|
49
|
+
this.fieldItems = [];
|
50
|
+
}
|
51
|
+
/**
|
52
|
+
* Realiza a abertura do componente e faz a primeira carga
|
53
|
+
* de dados.
|
54
|
+
* */
|
55
|
+
async show() {
|
56
|
+
var _a;
|
57
|
+
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.show();
|
58
|
+
return this.loadData();
|
59
|
+
}
|
60
|
+
/**
|
61
|
+
* Filtra a fonte de dados do componente.
|
62
|
+
* @param {string} filterText - Texto para filtrar a fonte de dados.
|
63
|
+
* @throws {Error} - Quando o componente estiver com a propriedade searchable como true.
|
64
|
+
*/
|
65
|
+
async applyFilter(filterText) {
|
66
|
+
if (this.searchable)
|
67
|
+
throw new Error('This method is not available when searchable is true');
|
68
|
+
this.handleFilterChange(filterText);
|
69
|
+
}
|
70
|
+
async loadData() {
|
71
|
+
this._isLoading = true;
|
72
|
+
let metadata;
|
73
|
+
if (this._currentLink != undefined) {
|
74
|
+
metadata = this._filterMetadataStorage.get(this._currentLink.uri);
|
75
|
+
}
|
76
|
+
if (!metadata) {
|
77
|
+
metadata = await this.fieldsDataSource.fetchData(this._currentLink);
|
78
|
+
this._currentLink = metadata.currentLink;
|
79
|
+
this._filterMetadataStorage.set(this._currentLink.uri, metadata);
|
80
|
+
}
|
81
|
+
const { fields, links } = metadata || {};
|
82
|
+
if (!Array.isArray(fields) || !Array.isArray(links))
|
83
|
+
throw new Error('Invalid metadata');
|
84
|
+
this._currentMetadata = metadata;
|
85
|
+
this.mapDataSourceToLinkItems();
|
86
|
+
this.mapDataSourceToFieldItems();
|
87
|
+
this._isLoading = false;
|
88
|
+
this._ezFieldList.scrollToTop();
|
89
|
+
this._ezLinkList.scrollToTop();
|
90
|
+
}
|
91
|
+
mapDataSourceToLinkItems() {
|
92
|
+
var _a;
|
93
|
+
const { links } = this._currentMetadata;
|
94
|
+
const filterLinkLabelMessage = this.getMessage('snkFilterFieldSearch.linkLabel', { link: (_a = this._currentLink) === null || _a === void 0 ? void 0 : _a.description });
|
95
|
+
const items = links.map(link => (Object.assign({ label: link.description }, link)));
|
96
|
+
this.linkItems = [{
|
97
|
+
group: filterLinkLabelMessage,
|
98
|
+
items,
|
99
|
+
}];
|
100
|
+
if (this.breadcrumbItems.length === 0) {
|
101
|
+
this.breadcrumbItems = [Object.assign({ id: core.JSUtils.generateUUID(), label: this._currentLink.description }, this._currentLink)];
|
102
|
+
}
|
103
|
+
}
|
104
|
+
mapDataSourceToFieldItems() {
|
105
|
+
var _a;
|
106
|
+
const { fields } = this._currentMetadata;
|
107
|
+
const filterFieldLabelMessage = this.getMessage('snkFilterFieldSearch.fieldLabel', { link: (_a = this._currentLink) === null || _a === void 0 ? void 0 : _a.description });
|
108
|
+
const filteredFields = fields.filter(field => {
|
109
|
+
if (!this._currentLink)
|
110
|
+
return true;
|
111
|
+
const searchableByDescription = field.description.toLowerCase().includes(this._filterText.toLowerCase());
|
112
|
+
const searchableByName = field.name.toLowerCase().includes(this._filterText.toLowerCase());
|
113
|
+
return searchableByDescription || searchableByName;
|
114
|
+
});
|
115
|
+
const items = filteredFields.map(field => (Object.assign({ label: field.description }, field)));
|
116
|
+
this.fieldItems = [{
|
117
|
+
group: filterFieldLabelMessage,
|
118
|
+
items
|
119
|
+
}];
|
120
|
+
}
|
121
|
+
handleFilterChange(filterText) {
|
122
|
+
if (this._isLoading)
|
123
|
+
return;
|
124
|
+
this._filterText = filterText;
|
125
|
+
this.mapDataSourceToFieldItems();
|
126
|
+
}
|
127
|
+
handleSelectLink({ detail: item }) {
|
128
|
+
if (this._isLoading)
|
129
|
+
return;
|
130
|
+
const breadcrumbByIndex = this.breadcrumbItems.findIndex(breadcrumbItem => breadcrumbItem.id === item.id);
|
131
|
+
item.cache = this._filterMetadataStorage.has(item.uri);
|
132
|
+
if (breadcrumbByIndex > -1) {
|
133
|
+
this.breadcrumbItems = this.breadcrumbItems.slice(0, (breadcrumbByIndex + 1));
|
134
|
+
}
|
135
|
+
else {
|
136
|
+
this.breadcrumbItems = [...this.breadcrumbItems, Object.assign({ id: core.JSUtils.generateUUID(), label: item.description }, item)];
|
137
|
+
}
|
138
|
+
const selectedItem = Object.assign(Object.assign({}, item), { type: index$1.SelectedItemType.LINK });
|
139
|
+
this._currentLink = selectedItem;
|
140
|
+
this.ezSelectFilterItem.emit(selectedItem);
|
141
|
+
this.loadData();
|
142
|
+
}
|
143
|
+
handleSelectField({ detail: item }) {
|
144
|
+
var _a;
|
145
|
+
const breadcrumbPath = this.breadcrumbItems.map(breadcrumbItem => breadcrumbItem.label).join('>>');
|
146
|
+
const selectedField = Object.assign(Object.assign({}, item), { type: index$1.SelectedItemType.FIELD, path: `${breadcrumbPath} >> ${item.description}` });
|
147
|
+
this.ezSelectFilterItem.emit(selectedField);
|
148
|
+
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.hide();
|
149
|
+
}
|
150
|
+
getElementID(sufix) {
|
151
|
+
return {
|
152
|
+
[core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: core.ElementIDUtils.getInternalIDInfo(sufix)
|
153
|
+
};
|
154
|
+
}
|
155
|
+
/**
|
156
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
157
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
158
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
159
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-field-search.msg.ts"
|
160
|
+
*/
|
161
|
+
getMessage(key, params) {
|
162
|
+
var _a, _b, _c;
|
163
|
+
if (!this._application)
|
164
|
+
this._application = core.ApplicationContext.getContextValue(SNK_CONTEXT_KEY);
|
165
|
+
return (_c = (_b = (_a = this._application) === null || _a === void 0 ? void 0 : _a.messagesBuilder) === null || _b === void 0 ? void 0 : _b.getMessage) === null || _c === void 0 ? void 0 : _c.call(_b, key, params);
|
166
|
+
}
|
167
|
+
;
|
168
|
+
componentWillLoad() {
|
169
|
+
this._application = core.ApplicationContext.getContextValue(SNK_CONTEXT_KEY);
|
170
|
+
}
|
171
|
+
componentDidLoad() {
|
172
|
+
core.ElementIDUtils.addIDInfoIfNotExists(this._ezPopover, 'popover');
|
173
|
+
}
|
174
|
+
disconnectedCallback() {
|
175
|
+
var _a;
|
176
|
+
this._filterMetadataStorage.clear();
|
177
|
+
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.hide();
|
178
|
+
}
|
179
|
+
render() {
|
180
|
+
var _a;
|
181
|
+
const searchLabelMessage = this.getMessage('snkFilterFieldSearch.searchLabel');
|
182
|
+
return (index.h("ez-popover", Object.assign({ ref: (el) => this._ezPopover = el, role: "dialog", overlayType: "none", "aria-hidden": !((_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.opened) }, this.getElementID('EzPopover')), index.h("div", { class: "snk-filter-field-search__container" }, index.h("header", { class: "snk-filter-field-search__header" }, this.searchable && !!searchLabelMessage && (index.h("ez-filter-input", Object.assign({ class: "snk-filter-field-search__input", label: searchLabelMessage, asyncSearch: true, canShowError: false, onEzSearching: (event) => this.handleFilterChange.bind(this)(event.detail), "aria-label": searchLabelMessage, "aria-required": "false", "aria-invalid": "false" }, this.getElementID('EzFilterInput')))), this.breadcrumbItems.length > 0 && (index.h("ez-breadcrumb", Object.assign({ items: this.breadcrumbItems, onSelectedItem: this.handleSelectLink.bind(this), role: "navigation", "aria-current": "step" }, this.getElementID('EzBreadcrumb')))), index.h("hr", { class: "ez-divider-horizontal ez-margin-vertical--medium" })), index.h("section", { class: "snk-filter-field-search__section" }, index.h("ez-list", Object.assign({ ref: (el) => this._ezLinkList = el, class: "snk-filter-field-search__list", id: "filterLinkList", useGroups: true, dataSource: this.linkItems, onEzSelectItem: this.handleSelectLink.bind(this), hoverFeedback: true, ezSelectable: true, itemSlotBuilder: ({ fieldCount }) => index.h("ez-badge", { label: fieldCount }), "aria-describedby": "filterLinkLabel" }, this.getElementID('EzListLinks'))), index.h("ez-list", Object.assign({ ref: (el) => this._ezFieldList = el, class: "snk-filter-field-search__list", id: "filterFieldList", useGroups: true, dataSource: this.fieldItems, onEzSelectItem: this.handleSelectField.bind(this), hoverFeedback: true, ezSelectable: true, itemSlotBuilder: ListItem, "aria-describedby": "filterFieldLabel" }, this.getElementID('EzListFields')))))));
|
183
|
+
}
|
184
|
+
};
|
185
|
+
SnkFilterFieldSearch.style = snkFilterFieldSearchCss;
|
186
|
+
|
187
|
+
class PersonalizedFilterUtils {
|
188
|
+
/**
|
189
|
+
* Cria uma expressão de filtro a partir de um IExpressionItem.
|
190
|
+
* @param expressionItem - Objeto com os parâmetros necessários para montar a expressão.
|
191
|
+
* @returns Retorna a expressão de filtro.
|
192
|
+
*/
|
193
|
+
static buildFilterExpression(expressionItem) {
|
194
|
+
if (expressionItem == undefined) {
|
195
|
+
return;
|
196
|
+
}
|
197
|
+
const value = this.buildVariableParameterValue(expressionItem);
|
198
|
+
let expression = expressionItem.expression || "";
|
199
|
+
switch (expressionItem.operand) {
|
200
|
+
case index$2.FilterOperand.IN:
|
201
|
+
expression += ` ${expressionItem.operand} (${value})`;
|
202
|
+
break;
|
203
|
+
case index$2.FilterOperand.NULL:
|
204
|
+
case index$2.FilterOperand.NOT_NULL:
|
205
|
+
expression += ` IS ${value}`;
|
206
|
+
break;
|
207
|
+
case index$2.FilterOperand.LIKE:
|
208
|
+
expression += ` LIKE '%${value}%'`;
|
209
|
+
break;
|
210
|
+
case index$2.FilterOperand.START_WITH:
|
211
|
+
expression += ` LIKE '${value}%'`;
|
212
|
+
break;
|
213
|
+
case index$2.FilterOperand.FINISHED_WITH:
|
214
|
+
expression += ` LIKE '%${value}'`;
|
215
|
+
break;
|
216
|
+
default:
|
217
|
+
expression += ` ${expressionItem.operand} ${value}`;
|
218
|
+
}
|
219
|
+
return expression;
|
220
|
+
}
|
221
|
+
/**
|
222
|
+
* Obtém o valor do parâmetro a partir de um IExpressionItem.
|
223
|
+
* @param expressionItem - Objeto com os parâmetros necessários para montar a expressão.
|
224
|
+
* @returns Retorna o valor do parâmetro.
|
225
|
+
*/
|
226
|
+
static buildVariableParameterValue(expressionItem) {
|
227
|
+
if (expressionItem == undefined) {
|
228
|
+
return;
|
229
|
+
}
|
230
|
+
if (expressionItem.systemConfig != undefined) {
|
231
|
+
const systemConfig = expressionItem.systemConfig;
|
232
|
+
return `?:{entidade=${systemConfig.entity || ""};campo=${systemConfig.fieldName || ""}}`;
|
233
|
+
}
|
234
|
+
if (expressionItem.userConfig != undefined) {
|
235
|
+
const userConfig = expressionItem.userConfig;
|
236
|
+
return `?:{desc=${userConfig.description || ""};tipo=${userConfig.type || ""}}`;
|
237
|
+
}
|
238
|
+
return `?:{entidade=${expressionItem.entityName || ""};campo=${expressionItem.fieldName || ""}}`;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
const snkFilterParamConfigCss = ":host{--snk-filter-param-config__expression--color:var(--title--primary, #2b3a54);display:flex;position:relative}.snk-filter-param-config__expression{--text-area__input--disabled--color:var(--snk-filter-param-config__expression--color)}";
|
243
|
+
|
244
|
+
const SnkFilterParamConfig = class {
|
245
|
+
constructor(hostRef) {
|
246
|
+
index.registerInstance(this, hostRef);
|
247
|
+
this._opened = false;
|
248
|
+
this._configType = index$2.FilterConfigType.SYSTEM_CONFIG;
|
249
|
+
this._expressionItem = undefined;
|
250
|
+
this._informedInstance = false;
|
251
|
+
this._canSave = false;
|
252
|
+
this.messagesBuilder = undefined;
|
253
|
+
}
|
254
|
+
open(expressionItem) {
|
255
|
+
this._opened = true;
|
256
|
+
this._expressionItem = expressionItem;
|
257
|
+
this.loadValues();
|
258
|
+
return new Promise(accept => {
|
259
|
+
this._promiseResolver = accept;
|
260
|
+
});
|
261
|
+
}
|
262
|
+
close() {
|
263
|
+
this._opened = false;
|
264
|
+
return new Promise(accept => {
|
265
|
+
this._promiseResolver = accept;
|
266
|
+
});
|
267
|
+
}
|
268
|
+
/**
|
269
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
270
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
271
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
272
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-param-config.msg.ts"
|
273
|
+
*/
|
274
|
+
getMessage(key, params) {
|
275
|
+
var _a;
|
276
|
+
return (_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, params);
|
277
|
+
}
|
278
|
+
getConfigValue(configName, inputName, inputAlias = "") {
|
279
|
+
var _a, _b, _c;
|
280
|
+
return ((_b = (_a = this._expressionItem) === null || _a === void 0 ? void 0 : _a[configName]) === null || _b === void 0 ? void 0 : _b[inputName])
|
281
|
+
|| ((_c = this._expressionItem) === null || _c === void 0 ? void 0 : _c[inputAlias || inputName]);
|
282
|
+
}
|
283
|
+
loadValues() {
|
284
|
+
var _a;
|
285
|
+
const entityName = this.getConfigValue("systemConfig", "entity", "entityName");
|
286
|
+
const fieldName = this.getConfigValue("systemConfig", "fieldName");
|
287
|
+
const description = this.getConfigValue("userConfig", "description");
|
288
|
+
const type = this.getConfigValue("userConfig", "type");
|
289
|
+
if (((_a = this._expressionItem) === null || _a === void 0 ? void 0 : _a.userConfig) != undefined) {
|
290
|
+
this._configType = index$2.FilterConfigType.USER_CONFIG;
|
291
|
+
}
|
292
|
+
else {
|
293
|
+
this._configType = index$2.FilterConfigType.SYSTEM_CONFIG;
|
294
|
+
}
|
295
|
+
if (!core.StringUtils.isEmpty(entityName) && !core.StringUtils.isEmpty(fieldName)) {
|
296
|
+
this._instanceElement.value = { value: entityName, label: "" };
|
297
|
+
this._fieldElement.value = { value: fieldName, label: "" };
|
298
|
+
}
|
299
|
+
if (!core.StringUtils.isEmpty(description) && !core.StringUtils.isEmpty(type)) {
|
300
|
+
this._descriptionElement.value = description;
|
301
|
+
this._typeElement.value = type;
|
302
|
+
}
|
303
|
+
this.buildFilterExpression();
|
304
|
+
}
|
305
|
+
changeDefinitionUsed(option) {
|
306
|
+
this._configType = option !== null && option !== void 0 ? option : index$2.FilterConfigType.SYSTEM_CONFIG;
|
307
|
+
if (this._configType === index$2.FilterConfigType.SYSTEM_CONFIG) {
|
308
|
+
const entityName = this.getConfigValue("systemConfig", "entity", "entityName");
|
309
|
+
const fieldName = this.getConfigValue("systemConfig", "fieldName");
|
310
|
+
this._instanceElement.value = this._instanceElement.value || { value: entityName, label: "" };
|
311
|
+
this._fieldElement.value = this._fieldElement.value || { value: fieldName, label: "" };
|
312
|
+
}
|
313
|
+
else if (this._configType === index$2.FilterConfigType.USER_CONFIG) {
|
314
|
+
const description = this.getConfigValue("userConfig", "description");
|
315
|
+
const type = this.getConfigValue("userConfig", "type");
|
316
|
+
this._descriptionElement.value = this._descriptionElement.value || description;
|
317
|
+
this._typeElement.value = this._typeElement.value || type;
|
318
|
+
}
|
319
|
+
this.buildFilterExpression();
|
320
|
+
}
|
321
|
+
getTypeValue() {
|
322
|
+
var _a;
|
323
|
+
const value = (_a = this._typeElement) === null || _a === void 0 ? void 0 : _a.value;
|
324
|
+
return ((value === null || value === void 0 ? void 0 : value.value) || value);
|
325
|
+
}
|
326
|
+
getExpressionValues() {
|
327
|
+
var _a, _b, _c, _d, _e;
|
328
|
+
let systemConfig;
|
329
|
+
let userConfig;
|
330
|
+
if (this._configType === index$2.FilterConfigType.SYSTEM_CONFIG) {
|
331
|
+
const entity = (_b = (_a = this._instanceElement) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.value;
|
332
|
+
const fieldName = (_d = (_c = this._fieldElement) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.value;
|
333
|
+
systemConfig = { entity, fieldName };
|
334
|
+
}
|
335
|
+
else if (this._configType === index$2.FilterConfigType.USER_CONFIG) {
|
336
|
+
const description = (_e = this._descriptionElement) === null || _e === void 0 ? void 0 : _e.value;
|
337
|
+
const type = this.getTypeValue();
|
338
|
+
userConfig = { description, type };
|
339
|
+
}
|
340
|
+
return Object.assign(Object.assign(Object.assign({}, this._expressionItem), { systemConfig }), { userConfig });
|
341
|
+
}
|
342
|
+
isEnabled(value) {
|
343
|
+
return this._configType === value;
|
344
|
+
}
|
345
|
+
isInformedInstance() {
|
346
|
+
var _a, _b;
|
347
|
+
return !core.StringUtils.isEmpty((_b = (_a = this._instanceElement) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.value);
|
348
|
+
}
|
349
|
+
save() {
|
350
|
+
var _a;
|
351
|
+
this._expressionItem = Object.assign(Object.assign({}, this.getExpressionValues()), { expression: (_a = this._expressionElement) === null || _a === void 0 ? void 0 : _a.value });
|
352
|
+
this._promiseResolver(this._expressionItem);
|
353
|
+
this._opened = false;
|
354
|
+
}
|
355
|
+
buildFilterExpression() {
|
356
|
+
var _a;
|
357
|
+
this._informedInstance = this.isInformedInstance();
|
358
|
+
const expression = PersonalizedFilterUtils.buildFilterExpression(this.getExpressionValues());
|
359
|
+
this._expressionElement.value = expression || ((_a = this._expressionItem) === null || _a === void 0 ? void 0 : _a.expression);
|
360
|
+
this._canSave = this.getCanSave();
|
361
|
+
}
|
362
|
+
handleChangeInstance() {
|
363
|
+
this._informedInstance = this.isInformedInstance();
|
364
|
+
if (this._fieldElement != undefined && !core.StringUtils.isEmpty(this._fieldElement.value)) {
|
365
|
+
this._fieldElement.value = null;
|
366
|
+
}
|
367
|
+
this.buildFilterExpression();
|
368
|
+
}
|
369
|
+
getInstanceCriteria() {
|
370
|
+
var _a, _b;
|
371
|
+
const value = (_b = (_a = this._instanceElement) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.value;
|
372
|
+
return {
|
373
|
+
expression: "this.NOMETAB = (SELECT NOMETAB FROM TDDINS WHERE NOMEINSTANCIA = ?)",
|
374
|
+
params: [
|
375
|
+
{
|
376
|
+
name: "NOMEINSTANCIA",
|
377
|
+
dataType: core.DataType.TEXT,
|
378
|
+
value
|
379
|
+
}
|
380
|
+
]
|
381
|
+
};
|
382
|
+
}
|
383
|
+
onSearch({ mode, argument }, entity) {
|
384
|
+
if (this._application == undefined) {
|
385
|
+
return;
|
386
|
+
}
|
387
|
+
const isField = entity === index$2.FilterEntities.FIELD;
|
388
|
+
const criteria = isField ? this.getInstanceCriteria() : undefined;
|
389
|
+
const messageKey = `snkFilterParamConfig.label${isField ? "Field" : "Instance"}`;
|
390
|
+
const entityDescription = this.getMessage(messageKey);
|
391
|
+
const searchOptions = {
|
392
|
+
descriptionFieldName: isField ? "DESCRCAMPO" : "DESCRINSTANCIA",
|
393
|
+
codeFieldName: isField ? "NOMECAMPO" : "NOMEINSTANCIA",
|
394
|
+
showInactives: false
|
395
|
+
};
|
396
|
+
const options = {
|
397
|
+
entity,
|
398
|
+
entityDescription,
|
399
|
+
criteria,
|
400
|
+
searchOptions
|
401
|
+
};
|
402
|
+
return this._application.executePreparedSearch(mode, argument, options);
|
403
|
+
}
|
404
|
+
getElementID(sufix) {
|
405
|
+
return {
|
406
|
+
[core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: core.ElementIDUtils.getInternalIDInfo(sufix)
|
407
|
+
};
|
408
|
+
}
|
409
|
+
getCanSave() {
|
410
|
+
var _a;
|
411
|
+
if (this._configType === index$2.FilterConfigType.USER_CONFIG) {
|
412
|
+
const description = (_a = this._descriptionElement) === null || _a === void 0 ? void 0 : _a.value;
|
413
|
+
const type = this.getTypeValue();
|
414
|
+
return !core.StringUtils.isEmpty(description) && !core.StringUtils.isEmpty(type);
|
415
|
+
}
|
416
|
+
return true;
|
417
|
+
}
|
418
|
+
componentWillLoad() {
|
419
|
+
this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
420
|
+
}
|
421
|
+
render() {
|
422
|
+
core.ElementIDUtils.addIDInfoIfNotExists(this._element, 'snkFilterParamConfig');
|
423
|
+
return (index.h("ez-popup", Object.assign({ useHeader: false, size: "small", heightMode: "auto", opened: this._opened }, this.getElementID("popup")), index.h("ez-modal-container", Object.assign({ onEzModalAction: (evt) => {
|
424
|
+
if (evt.detail === ezModalContainer.ModalAction.CLOSE)
|
425
|
+
this.close();
|
426
|
+
}, modalTitle: this.getMessage("snkFilterParamConfig.modalTitle") }, this.getElementID("modalContainer")), index.h("div", { class: "ez-flex" }, index.h("div", { class: "ez-col ez-col--sd-6 ez-flex--column" }, index.h("ez-radio-button", Object.assign({ value: this._configType, onEzChange: (evt) => this.changeDefinitionUsed(evt.detail) }, this.getElementID("systemConfigOption")), index.h("ez-radio-button-option", { label: this.getMessage("snkFilterParamConfig.labelSystemConfig"), value: index$2.FilterConfigType.SYSTEM_CONFIG })), index.h("ez-search", Object.assign({ ref: (ref) => this._instanceElement = ref, label: this.getMessage("snkFilterParamConfig.labelInstance"), enabled: this.isEnabled(index$2.FilterConfigType.SYSTEM_CONFIG), suppressEmptyOption: true, showOptionValue: false, showSelectedValue: false, onEzChange: () => this.handleChangeInstance(), optionLoader: (searchArgument) => this.onSearch(searchArgument, index$2.FilterEntities.INSTANCE) }, this.getElementID("configFindEntity"))), index.h("ez-search", Object.assign({ ref: (ref) => this._fieldElement = ref, label: this.getMessage("snkFilterParamConfig.labelField"), enabled: this.isEnabled(index$2.FilterConfigType.SYSTEM_CONFIG) && this._informedInstance, suppressEmptyOption: true, showOptionValue: false, showSelectedValue: false, onEzChange: () => this.buildFilterExpression(), optionLoader: (searchArgument) => this.onSearch(searchArgument, index$2.FilterEntities.FIELD) }, this.getElementID("configFindField")))), index.h("div", { class: "ez-flex ez-padding--medium" }, index.h("hr", { class: "ez-divider-vertical" })), index.h("div", { class: "ez-col ez-col--sd-6 ez-flex--column" }, index.h("ez-radio-button", Object.assign({ value: this._configType, onEzChange: (evt) => this.changeDefinitionUsed(evt.detail) }, this.getElementID("userConfigOption")), index.h("ez-radio-button-option", { label: this.getMessage("snkFilterParamConfig.labelUserConfig"), value: index$2.FilterConfigType.USER_CONFIG })), index.h("ez-text-input", Object.assign({ ref: (ref) => this._descriptionElement = ref, label: this.getMessage("snkFilterParamConfig.labelDescription"), enabled: this.isEnabled(index$2.FilterConfigType.USER_CONFIG), onEzChange: () => this.buildFilterExpression() }, this.getElementID("configParamLabel"))), index.h("ez-combo-box", Object.assign({ ref: (ref) => this._typeElement = ref, label: this.getMessage("snkFilterParamConfig.labelType"), enabled: this.isEnabled(index$2.FilterConfigType.USER_CONFIG), suppressEmptyOption: true, onEzChange: () => this.buildFilterExpression() }, this.getElementID("configParamType")), Object.keys(index$2.FilterUserConfigTypes).map((configType) => {
|
427
|
+
return (index.h("option", { value: index$2.FilterUserConfigTypes[configType] }, this.getMessage(`snkFilterParamConfig.labelTypeValues.${configType.toLowerCase()}`)));
|
428
|
+
})))), index.h("ez-text-area", Object.assign({ ref: (ref) => this._expressionElement = ref, class: "snk-filter-param-config__expression", label: this.getMessage("snkFilterParamConfig.labelExpression"), enabled: false }, this.getElementID("presentationExpression"))), index.h("div", { class: "ez-col ez-col--sd-12 ez-flex--justify-end ez-margin-vertical--small" }, index.h("ez-button", Object.assign({ class: "ez-padding-right--medium", label: this.getMessage("snkFilterParamConfig.labelCancel"), onClick: () => this.close() }, this.getElementID("cancelEditParam"))), index.h("ez-button", Object.assign({ class: "ez-button--primary", label: this.getMessage("snkFilterParamConfig.labelSave"), onClick: () => this.save(), enabled: this._canSave }, this.getElementID("saveEditParam")))))));
|
429
|
+
}
|
430
|
+
get _element() { return index.getElement(this); }
|
431
|
+
};
|
432
|
+
SnkFilterParamConfig.style = snkFilterParamConfigCss;
|
433
|
+
|
434
|
+
exports.snk_filter_field_search = SnkFilterFieldSearch;
|
435
|
+
exports.snk_filter_param_config = SnkFilterParamConfig;
|