@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
@@ -1,185 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
-
|
5
|
-
const index = require('./index-21bd01e1.js');
|
6
|
-
const core = require('@sankhyalabs/core');
|
7
|
-
|
8
|
-
var SelectedItemType;
|
9
|
-
(function (SelectedItemType) {
|
10
|
-
SelectedItemType["LINK"] = "LINK";
|
11
|
-
SelectedItemType["FIELD"] = "FIELD";
|
12
|
-
})(SelectedItemType || (SelectedItemType = {}));
|
13
|
-
|
14
|
-
const ICON_MODES = {
|
15
|
-
[core.UserInterface.SHORTTEXT]: 'text',
|
16
|
-
[core.UserInterface.LONGTEXT]: 'text',
|
17
|
-
[core.UserInterface.INTEGERNUMBER]: 'number',
|
18
|
-
[core.UserInterface.DECIMALNUMBER]: 'number',
|
19
|
-
[core.UserInterface.DATE]: 'calendar',
|
20
|
-
[core.UserInterface.DATETIME]: 'calendar',
|
21
|
-
[core.UserInterface.SWITCH]: 'boolean',
|
22
|
-
[core.UserInterface.CHECKBOX]: 'check-circle-inverted',
|
23
|
-
[core.UserInterface.OPTIONSELECTOR]: 'list',
|
24
|
-
[core.UserInterface.SEARCH]: 'search',
|
25
|
-
[core.UserInterface.HTML]: 'tag_code',
|
26
|
-
[core.UserInterface.IMAGE]: 'png',
|
27
|
-
[core.UserInterface.FILE]: 'edit-file',
|
28
|
-
[core.UserInterface.TIME]: 'timer-outline',
|
29
|
-
[core.UserInterface.ELAPSEDTIME]: 'timer',
|
30
|
-
[core.UserInterface.MASKEDTEXT]: 'text',
|
31
|
-
[core.UserInterface.PASSWORD]: 'email',
|
32
|
-
};
|
33
|
-
const ListItem = ({ userInterface, description }) => {
|
34
|
-
return (index.h("ez-icon", { iconName: ICON_MODES[userInterface], className: "ez-padding-left--small", title: description }));
|
35
|
-
};
|
36
|
-
|
37
|
-
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}";
|
38
|
-
|
39
|
-
const SNK_CONTEXT_KEY = "__SNK__APPLICATION__";
|
40
|
-
const SnkFilterFieldSearch = class {
|
41
|
-
constructor(hostRef) {
|
42
|
-
index.registerInstance(this, hostRef);
|
43
|
-
this.ezSelectFilterItem = index.createEvent(this, "ezSelectFilterItem", 7);
|
44
|
-
this._filterMetadataStorage = new Map();
|
45
|
-
this._dataSource = null;
|
46
|
-
this._filterText = "";
|
47
|
-
this._isLoading = false;
|
48
|
-
this.searchable = true;
|
49
|
-
this.breadcrumbItems = [];
|
50
|
-
this.linkItems = [];
|
51
|
-
this.fieldItems = [];
|
52
|
-
}
|
53
|
-
/**
|
54
|
-
* Define a fonte de dados do componente.
|
55
|
-
* @param {IFilterLink} currentLink - Link atual da entidade.
|
56
|
-
* @param {IFilterMetadata} fetchData - callback que executa a busca de dados.
|
57
|
-
* @throws {Error} - Quando os metadados não forem válidos.
|
58
|
-
* @throws {Error} - Quando o link atual não for do tipo link.
|
59
|
-
*/
|
60
|
-
async setDataSource(currentLink, fetchData) {
|
61
|
-
var _a;
|
62
|
-
this._isLoading = true;
|
63
|
-
let metadata = this._filterMetadataStorage.get(currentLink.uri);
|
64
|
-
if (!metadata) {
|
65
|
-
metadata = await fetchData(currentLink);
|
66
|
-
this._filterMetadataStorage.set(currentLink.uri, metadata);
|
67
|
-
}
|
68
|
-
const { fields, links } = metadata || {};
|
69
|
-
if (!Array.isArray(fields) || !Array.isArray(links))
|
70
|
-
throw new Error('Invalid metadata');
|
71
|
-
if (currentLink.type !== SelectedItemType.LINK)
|
72
|
-
throw new Error('The current link must be a link type');
|
73
|
-
this._dataSource = metadata;
|
74
|
-
this._currentLink = currentLink;
|
75
|
-
this.mapDataSourceToLinkItems();
|
76
|
-
this.mapDataSourceToFieldItems();
|
77
|
-
this._isLoading = false;
|
78
|
-
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.show();
|
79
|
-
this._ezFieldList.scrollToTop();
|
80
|
-
this._ezLinkList.scrollToTop();
|
81
|
-
}
|
82
|
-
/**
|
83
|
-
* Filtra a fonte de dados do componente.
|
84
|
-
* @param {string} filterText - Texto para filtrar a fonte de dados.
|
85
|
-
* @throws {Error} - Quando o componente estiver com a propriedade searchable como true.
|
86
|
-
*/
|
87
|
-
async filterDataSource(filterText) {
|
88
|
-
if (this.searchable)
|
89
|
-
throw new Error('This method is not available when searchable is true');
|
90
|
-
this.handleFilterChange(filterText);
|
91
|
-
}
|
92
|
-
mapDataSourceToLinkItems() {
|
93
|
-
var _a;
|
94
|
-
const { links } = this._dataSource;
|
95
|
-
const filterLinkLabelMessage = this.getMessage('snkFilterFieldSearch.linkLabel', { link: (_a = this._currentLink) === null || _a === void 0 ? void 0 : _a.description });
|
96
|
-
const items = links.map(link => (Object.assign({ label: link.description }, link)));
|
97
|
-
this.linkItems = [{
|
98
|
-
group: filterLinkLabelMessage,
|
99
|
-
items
|
100
|
-
}];
|
101
|
-
if (this.breadcrumbItems.length === 0) {
|
102
|
-
this.breadcrumbItems = [Object.assign({ id: core.JSUtils.generateUUID(), label: this._currentLink.description }, this._currentLink)];
|
103
|
-
}
|
104
|
-
}
|
105
|
-
mapDataSourceToFieldItems() {
|
106
|
-
var _a;
|
107
|
-
const { fields } = this._dataSource;
|
108
|
-
const filterFieldLabelMessage = this.getMessage('snkFilterFieldSearch.fieldLabel', { link: (_a = this._currentLink) === null || _a === void 0 ? void 0 : _a.description });
|
109
|
-
const filteredFields = fields.filter(field => {
|
110
|
-
if (!this._currentLink)
|
111
|
-
return true;
|
112
|
-
const searchableByDescription = field.description.toLowerCase().includes(this._filterText.toLowerCase());
|
113
|
-
const searchableByName = field.name.toLowerCase().includes(this._filterText.toLowerCase());
|
114
|
-
return searchableByDescription || searchableByName;
|
115
|
-
});
|
116
|
-
const items = filteredFields.map(field => (Object.assign({ label: field.description }, field)));
|
117
|
-
this.fieldItems = [{
|
118
|
-
group: filterFieldLabelMessage,
|
119
|
-
items
|
120
|
-
}];
|
121
|
-
}
|
122
|
-
handleFilterChange(filterText) {
|
123
|
-
if (this._isLoading)
|
124
|
-
return;
|
125
|
-
this._filterText = filterText;
|
126
|
-
this.mapDataSourceToFieldItems();
|
127
|
-
}
|
128
|
-
handleSelectLink({ detail: item }) {
|
129
|
-
if (this._isLoading)
|
130
|
-
return;
|
131
|
-
const breadcrumbByIndex = this.breadcrumbItems.findIndex(breadcrumbItem => breadcrumbItem.id === item.id);
|
132
|
-
item.cache = this._filterMetadataStorage.has(item.uri);
|
133
|
-
if (breadcrumbByIndex > -1) {
|
134
|
-
this.breadcrumbItems = this.breadcrumbItems.slice(0, (breadcrumbByIndex + 1));
|
135
|
-
}
|
136
|
-
else {
|
137
|
-
this.breadcrumbItems = [...this.breadcrumbItems, Object.assign({ id: core.JSUtils.generateUUID(), label: item.description }, item)];
|
138
|
-
}
|
139
|
-
this.ezSelectFilterItem.emit(Object.assign(Object.assign({}, item), { type: SelectedItemType.LINK }));
|
140
|
-
}
|
141
|
-
handleSelectField({ detail: item }) {
|
142
|
-
var _a;
|
143
|
-
const breadcrumbPath = this.breadcrumbItems.map(breadcrumbItem => breadcrumbItem.label).join('>>');
|
144
|
-
const selectedField = Object.assign(Object.assign({}, item), { type: SelectedItemType.FIELD, path: `${breadcrumbPath} >> ${item.description}` });
|
145
|
-
this.ezSelectFilterItem.emit(selectedField);
|
146
|
-
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.hide();
|
147
|
-
}
|
148
|
-
getElementID(sufix) {
|
149
|
-
return {
|
150
|
-
[core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: core.ElementIDUtils.getInternalIDInfo(sufix)
|
151
|
-
};
|
152
|
-
}
|
153
|
-
/**
|
154
|
-
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
155
|
-
* através de um pequeno modulo na estrutura da aplicação:
|
156
|
-
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
157
|
-
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-field-search.msg.ts"
|
158
|
-
*/
|
159
|
-
getMessage(key, params) {
|
160
|
-
var _a, _b, _c;
|
161
|
-
if (!this._application)
|
162
|
-
this._application = core.ApplicationContext.getContextValue(SNK_CONTEXT_KEY);
|
163
|
-
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);
|
164
|
-
}
|
165
|
-
;
|
166
|
-
componentWillLoad() {
|
167
|
-
this._application = core.ApplicationContext.getContextValue(SNK_CONTEXT_KEY);
|
168
|
-
}
|
169
|
-
componentDidLoad() {
|
170
|
-
core.ElementIDUtils.addIDInfoIfNotExists(this._ezPopover, 'popover');
|
171
|
-
}
|
172
|
-
disconnectedCallback() {
|
173
|
-
var _a;
|
174
|
-
this._filterMetadataStorage.clear();
|
175
|
-
(_a = this._ezPopover) === null || _a === void 0 ? void 0 : _a.hide();
|
176
|
-
}
|
177
|
-
render() {
|
178
|
-
var _a;
|
179
|
-
const searchLabelMessage = this.getMessage('snkFilterFieldSearch.searchLabel');
|
180
|
-
return (index.h("ez-popover", Object.assign({ ref: (el) => this._ezPopover = el, role: "dialog", "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')))))));
|
181
|
-
}
|
182
|
-
};
|
183
|
-
SnkFilterFieldSearch.style = snkFilterFieldSearchCss;
|
184
|
-
|
185
|
-
exports.snk_filter_field_search = SnkFilterFieldSearch;
|
@@ -1,256 +0,0 @@
|
|
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 ezModalContainer = require('@sankhyalabs/ezui/dist/collection/components/ez-modal-container');
|
8
|
-
const index = require('./index-f400b1d6.js');
|
9
|
-
|
10
|
-
class PersonalizedFilterUtils {
|
11
|
-
/**
|
12
|
-
* Cria uma expressão de filtro a partir de um IExpressionItem.
|
13
|
-
* @param expressionItem - Objeto com os parâmetros necessários para montar a expressão.
|
14
|
-
* @returns Retorna a expressão de filtro.
|
15
|
-
*/
|
16
|
-
static buildFilterExpression(expressionItem) {
|
17
|
-
if (expressionItem == undefined) {
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
const value = this.buildVariableParameterValue(expressionItem);
|
21
|
-
let expression = expressionItem.expression || "";
|
22
|
-
switch (expressionItem.operand) {
|
23
|
-
case index.FilterOperand.IN:
|
24
|
-
expression += ` ${expressionItem.operand} (${value})`;
|
25
|
-
break;
|
26
|
-
case index.FilterOperand.NULL:
|
27
|
-
case index.FilterOperand.NOT_NULL:
|
28
|
-
expression += ` IS ${value}`;
|
29
|
-
break;
|
30
|
-
case index.FilterOperand.LIKE:
|
31
|
-
expression += ` LIKE '%${value}%'`;
|
32
|
-
break;
|
33
|
-
case index.FilterOperand.START_WITH:
|
34
|
-
expression += ` LIKE '${value}%'`;
|
35
|
-
break;
|
36
|
-
case index.FilterOperand.FINISHED_WITH:
|
37
|
-
expression += ` LIKE '%${value}'`;
|
38
|
-
break;
|
39
|
-
default:
|
40
|
-
expression += ` ${expressionItem.operand} ${value}`;
|
41
|
-
}
|
42
|
-
return expression;
|
43
|
-
}
|
44
|
-
/**
|
45
|
-
* Obtém o valor do parâmetro a partir de um IExpressionItem.
|
46
|
-
* @param expressionItem - Objeto com os parâmetros necessários para montar a expressão.
|
47
|
-
* @returns Retorna o valor do parâmetro.
|
48
|
-
*/
|
49
|
-
static buildVariableParameterValue(expressionItem) {
|
50
|
-
if (expressionItem == undefined) {
|
51
|
-
return;
|
52
|
-
}
|
53
|
-
if (expressionItem.systemConfig != undefined) {
|
54
|
-
const systemConfig = expressionItem.systemConfig;
|
55
|
-
return `?:{entidade=${systemConfig.entity || ""};campo=${systemConfig.fieldName || ""}}`;
|
56
|
-
}
|
57
|
-
if (expressionItem.userConfig != undefined) {
|
58
|
-
const userConfig = expressionItem.userConfig;
|
59
|
-
return `?:{desc=${userConfig.description || ""};tipo=${userConfig.type || ""}}`;
|
60
|
-
}
|
61
|
-
return `?:{entidade=${expressionItem.entityName || ""};campo=${expressionItem.fieldName || ""}}`;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
|
65
|
-
const snkFilterParamConfigCss = ".sc-snk-filter-param-config-h{--snk-filter-param-config__expression--color:var(--title--primary, #2b3a54);display:flex;position:relative}.snk-filter-param-config__expression.sc-snk-filter-param-config{--text-area__input--disabled--color:var(--snk-filter-param-config__expression--color)}";
|
66
|
-
|
67
|
-
const SnkFilterParamConfig = class {
|
68
|
-
constructor(hostRef) {
|
69
|
-
index$1.registerInstance(this, hostRef);
|
70
|
-
this._opened = false;
|
71
|
-
this._configType = index.FilterConfigType.SYSTEM_CONFIG;
|
72
|
-
this._expressionItem = undefined;
|
73
|
-
this._informedInstance = false;
|
74
|
-
this._canSave = false;
|
75
|
-
this.messagesBuilder = undefined;
|
76
|
-
}
|
77
|
-
open(expressionItem) {
|
78
|
-
this._opened = true;
|
79
|
-
this._expressionItem = expressionItem;
|
80
|
-
this.loadValues();
|
81
|
-
return new Promise(accept => {
|
82
|
-
this._promiseResolver = accept;
|
83
|
-
});
|
84
|
-
}
|
85
|
-
close() {
|
86
|
-
this._opened = false;
|
87
|
-
return new Promise(accept => {
|
88
|
-
this._promiseResolver = accept;
|
89
|
-
});
|
90
|
-
}
|
91
|
-
/**
|
92
|
-
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
93
|
-
* através de um pequeno modulo na estrutura da aplicação:
|
94
|
-
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
95
|
-
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-param-config.msg.ts"
|
96
|
-
*/
|
97
|
-
getMessage(key, params) {
|
98
|
-
return this.messagesBuilder.getMessage(key, params);
|
99
|
-
}
|
100
|
-
getConfigValue(configName, inputName, inputAlias = "") {
|
101
|
-
var _a, _b, _c;
|
102
|
-
return ((_b = (_a = this._expressionItem) === null || _a === void 0 ? void 0 : _a[configName]) === null || _b === void 0 ? void 0 : _b[inputName])
|
103
|
-
|| ((_c = this._expressionItem) === null || _c === void 0 ? void 0 : _c[inputAlias || inputName]);
|
104
|
-
}
|
105
|
-
loadValues() {
|
106
|
-
var _a;
|
107
|
-
const entityName = this.getConfigValue("systemConfig", "entity", "entityName");
|
108
|
-
const fieldName = this.getConfigValue("systemConfig", "fieldName");
|
109
|
-
const description = this.getConfigValue("userConfig", "description");
|
110
|
-
const type = this.getConfigValue("userConfig", "type");
|
111
|
-
if (((_a = this._expressionItem) === null || _a === void 0 ? void 0 : _a.userConfig) != undefined) {
|
112
|
-
this._configType = index.FilterConfigType.USER_CONFIG;
|
113
|
-
}
|
114
|
-
else {
|
115
|
-
this._configType = index.FilterConfigType.SYSTEM_CONFIG;
|
116
|
-
}
|
117
|
-
if (!core.StringUtils.isEmpty(entityName) && !core.StringUtils.isEmpty(fieldName)) {
|
118
|
-
this._instanceElement.value = { value: entityName, label: "" };
|
119
|
-
this._fieldElement.value = { value: fieldName, label: "" };
|
120
|
-
}
|
121
|
-
if (!core.StringUtils.isEmpty(description) && !core.StringUtils.isEmpty(type)) {
|
122
|
-
this._descriptionElement.value = description;
|
123
|
-
this._typeElement.value = type;
|
124
|
-
}
|
125
|
-
this.buildFilterExpression();
|
126
|
-
}
|
127
|
-
changeDefinitionUsed(option) {
|
128
|
-
this._configType = option !== null && option !== void 0 ? option : index.FilterConfigType.SYSTEM_CONFIG;
|
129
|
-
if (this._configType === index.FilterConfigType.SYSTEM_CONFIG) {
|
130
|
-
const entityName = this.getConfigValue("systemConfig", "entity", "entityName");
|
131
|
-
const fieldName = this.getConfigValue("systemConfig", "fieldName");
|
132
|
-
this._instanceElement.value = this._instanceElement.value || { value: entityName, label: "" };
|
133
|
-
this._fieldElement.value = this._fieldElement.value || { value: fieldName, label: "" };
|
134
|
-
}
|
135
|
-
else if (this._configType === index.FilterConfigType.USER_CONFIG) {
|
136
|
-
const description = this.getConfigValue("userConfig", "description");
|
137
|
-
const type = this.getConfigValue("userConfig", "type");
|
138
|
-
this._descriptionElement.value = this._descriptionElement.value || description;
|
139
|
-
this._typeElement.value = this._typeElement.value || type;
|
140
|
-
}
|
141
|
-
this.buildFilterExpression();
|
142
|
-
}
|
143
|
-
getTypeValue() {
|
144
|
-
var _a;
|
145
|
-
const value = (_a = this._typeElement) === null || _a === void 0 ? void 0 : _a.value;
|
146
|
-
return ((value === null || value === void 0 ? void 0 : value.value) || value);
|
147
|
-
}
|
148
|
-
getExpressionValues() {
|
149
|
-
var _a, _b, _c, _d, _e;
|
150
|
-
let systemConfig;
|
151
|
-
let userConfig;
|
152
|
-
if (this._configType === index.FilterConfigType.SYSTEM_CONFIG) {
|
153
|
-
const entity = (_b = (_a = this._instanceElement) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.value;
|
154
|
-
const fieldName = (_d = (_c = this._fieldElement) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.value;
|
155
|
-
systemConfig = { entity, fieldName };
|
156
|
-
}
|
157
|
-
else if (this._configType === index.FilterConfigType.USER_CONFIG) {
|
158
|
-
const description = (_e = this._descriptionElement) === null || _e === void 0 ? void 0 : _e.value;
|
159
|
-
const type = this.getTypeValue();
|
160
|
-
userConfig = { description, type };
|
161
|
-
}
|
162
|
-
return Object.assign(Object.assign(Object.assign({}, this._expressionItem), { systemConfig }), { userConfig });
|
163
|
-
}
|
164
|
-
isEnabled(value) {
|
165
|
-
return this._configType === value;
|
166
|
-
}
|
167
|
-
isInformedInstance() {
|
168
|
-
var _a, _b;
|
169
|
-
return !core.StringUtils.isEmpty((_b = (_a = this._instanceElement) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.value);
|
170
|
-
}
|
171
|
-
save() {
|
172
|
-
var _a;
|
173
|
-
this._expressionItem = Object.assign(Object.assign({}, this.getExpressionValues()), { expression: (_a = this._expressionElement) === null || _a === void 0 ? void 0 : _a.value });
|
174
|
-
this._promiseResolver(this._expressionItem);
|
175
|
-
this._opened = false;
|
176
|
-
}
|
177
|
-
buildFilterExpression() {
|
178
|
-
var _a;
|
179
|
-
this._informedInstance = this.isInformedInstance();
|
180
|
-
const expression = PersonalizedFilterUtils.buildFilterExpression(this.getExpressionValues());
|
181
|
-
this._expressionElement.value = expression || ((_a = this._expressionItem) === null || _a === void 0 ? void 0 : _a.expression);
|
182
|
-
this._canSave = this.getCanSave();
|
183
|
-
}
|
184
|
-
handleChangeInstance() {
|
185
|
-
this._informedInstance = this.isInformedInstance();
|
186
|
-
if (this._fieldElement != undefined && !core.StringUtils.isEmpty(this._fieldElement.value)) {
|
187
|
-
this._fieldElement.value = null;
|
188
|
-
}
|
189
|
-
this.buildFilterExpression();
|
190
|
-
}
|
191
|
-
getInstanceCriteria() {
|
192
|
-
var _a, _b;
|
193
|
-
const value = (_b = (_a = this._instanceElement) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.value;
|
194
|
-
return {
|
195
|
-
expression: "this.NOMETAB = (SELECT NOMETAB FROM TDDINS WHERE NOMEINSTANCIA = ?)",
|
196
|
-
params: [
|
197
|
-
{
|
198
|
-
name: "NOMEINSTANCIA",
|
199
|
-
dataType: core.DataType.TEXT,
|
200
|
-
value
|
201
|
-
}
|
202
|
-
]
|
203
|
-
};
|
204
|
-
}
|
205
|
-
onSearch({ mode, argument }, entity) {
|
206
|
-
if (this._application == undefined) {
|
207
|
-
return;
|
208
|
-
}
|
209
|
-
const isField = entity === index.FilterEntities.FIELD;
|
210
|
-
const criteria = isField ? this.getInstanceCriteria() : undefined;
|
211
|
-
const messageKey = `snkFilterParamConfig.label${isField ? "Field" : "Instance"}`;
|
212
|
-
const entityDescription = this.getMessage(messageKey);
|
213
|
-
const searchOptions = {
|
214
|
-
descriptionFieldName: isField ? "DESCRCAMPO" : "DESCRINSTANCIA",
|
215
|
-
codeFieldName: isField ? "NOMECAMPO" : "NOMEINSTANCIA",
|
216
|
-
showInactives: false
|
217
|
-
};
|
218
|
-
const options = {
|
219
|
-
entity,
|
220
|
-
entityDescription,
|
221
|
-
criteria,
|
222
|
-
searchOptions
|
223
|
-
};
|
224
|
-
return this._application.executePreparedSearch(mode, argument, options);
|
225
|
-
}
|
226
|
-
getElementID(sufix) {
|
227
|
-
return {
|
228
|
-
[core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME]: core.ElementIDUtils.getInternalIDInfo(sufix)
|
229
|
-
};
|
230
|
-
}
|
231
|
-
getCanSave() {
|
232
|
-
var _a;
|
233
|
-
if (this._configType === index.FilterConfigType.USER_CONFIG) {
|
234
|
-
const description = (_a = this._descriptionElement) === null || _a === void 0 ? void 0 : _a.value;
|
235
|
-
const type = this.getTypeValue();
|
236
|
-
return !core.StringUtils.isEmpty(description) && !core.StringUtils.isEmpty(type);
|
237
|
-
}
|
238
|
-
return true;
|
239
|
-
}
|
240
|
-
componentWillLoad() {
|
241
|
-
this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
242
|
-
}
|
243
|
-
render() {
|
244
|
-
core.ElementIDUtils.addIDInfoIfNotExists(this._element, 'snkFilterParamConfig');
|
245
|
-
return (index$1.h("ez-popup", Object.assign({ useHeader: false, size: "small", heightMode: "auto", opened: this._opened }, this.getElementID("popup")), index$1.h("ez-modal-container", Object.assign({ onEzModalAction: (evt) => {
|
246
|
-
if (evt.detail === ezModalContainer.ModalAction.CLOSE)
|
247
|
-
this.close();
|
248
|
-
}, modalTitle: this.getMessage("snkFilterParamConfig.modalTitle") }, this.getElementID("modalContainer")), index$1.h("div", { class: "ez-flex" }, index$1.h("div", { class: "ez-col ez-col--sd-6 ez-flex--column" }, index$1.h("ez-radio-button", Object.assign({ value: this._configType, onEzChange: (evt) => this.changeDefinitionUsed(evt.detail) }, this.getElementID("systemConfigOption")), index$1.h("ez-radio-button-option", { label: this.getMessage("snkFilterParamConfig.labelSystemConfig"), value: index.FilterConfigType.SYSTEM_CONFIG })), index$1.h("ez-search", Object.assign({ ref: (ref) => this._instanceElement = ref, label: this.getMessage("snkFilterParamConfig.labelInstance"), enabled: this.isEnabled(index.FilterConfigType.SYSTEM_CONFIG), suppressEmptyOption: true, showOptionValue: false, showSelectedValue: false, onEzChange: () => this.handleChangeInstance(), optionLoader: (searchArgument) => this.onSearch(searchArgument, index.FilterEntities.INSTANCE) }, this.getElementID("configFindEntity"))), index$1.h("ez-search", Object.assign({ ref: (ref) => this._fieldElement = ref, label: this.getMessage("snkFilterParamConfig.labelField"), enabled: this.isEnabled(index.FilterConfigType.SYSTEM_CONFIG) && this._informedInstance, suppressEmptyOption: true, showOptionValue: false, showSelectedValue: false, onEzChange: () => this.buildFilterExpression(), optionLoader: (searchArgument) => this.onSearch(searchArgument, index.FilterEntities.FIELD) }, this.getElementID("configFindField")))), index$1.h("div", { class: "ez-flex ez-padding--medium" }, index$1.h("hr", { class: "ez-divider-vertical" })), index$1.h("div", { class: "ez-col ez-col--sd-6 ez-flex--column" }, index$1.h("ez-radio-button", Object.assign({ value: this._configType, onEzChange: (evt) => this.changeDefinitionUsed(evt.detail) }, this.getElementID("userConfigOption")), index$1.h("ez-radio-button-option", { label: this.getMessage("snkFilterParamConfig.labelUserConfig"), value: index.FilterConfigType.USER_CONFIG })), index$1.h("ez-text-input", Object.assign({ ref: (ref) => this._descriptionElement = ref, label: this.getMessage("snkFilterParamConfig.labelDescription"), enabled: this.isEnabled(index.FilterConfigType.USER_CONFIG), onEzChange: () => this.buildFilterExpression() }, this.getElementID("configParamLabel"))), index$1.h("ez-combo-box", Object.assign({ ref: (ref) => this._typeElement = ref, label: this.getMessage("snkFilterParamConfig.labelType"), enabled: this.isEnabled(index.FilterConfigType.USER_CONFIG), suppressEmptyOption: true, onEzChange: () => this.buildFilterExpression() }, this.getElementID("configParamType")), Object.keys(index.FilterUserConfigTypes).map((configType) => {
|
249
|
-
return (index$1.h("option", { value: index.FilterUserConfigTypes[configType] }, this.getMessage(`snkFilterParamConfig.labelTypeValues.${configType.toLowerCase()}`)));
|
250
|
-
})))), index$1.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$1.h("div", { class: "ez-col ez-col--sd-12 ez-flex--justify-end ez-margin-vertical--small" }, index$1.h("ez-button", Object.assign({ class: "ez-padding-right--medium", label: this.getMessage("snkFilterParamConfig.labelCancel"), onClick: () => this.close() }, this.getElementID("cancelEditParam"))), index$1.h("ez-button", Object.assign({ class: "ez-button--primary", label: this.getMessage("snkFilterParamConfig.labelSave"), onClick: () => this.save(), enabled: this._canSave }, this.getElementID("saveEditParam")))))));
|
251
|
-
}
|
252
|
-
get _element() { return index$1.getElement(this); }
|
253
|
-
};
|
254
|
-
SnkFilterParamConfig.style = snkFilterParamConfigCss;
|
255
|
-
|
256
|
-
exports.snk_filter_param_config = SnkFilterParamConfig;
|