@sankhyalabs/sankhyablocks 4.8.1 → 4.8.3
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/pesquisa-fetcher-d9dda5c6.js +162 -0
- package/dist/cjs/snk-application.cjs.entry.js +2 -149
- package/dist/cjs/snk-crud.cjs.entry.js +1 -0
- package/dist/cjs/snk-detail-view.cjs.entry.js +2 -1
- package/dist/cjs/{snk-guides-viewer-cb02e675.js → snk-guides-viewer-19e24b86.js} +1 -0
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +3 -2
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +10 -2
- package/dist/components/pesquisa-fetcher.js +160 -0
- package/dist/components/snk-application2.js +2 -149
- package/dist/components/snk-crud.js +1 -0
- package/dist/components/snk-detail-view2.js +1 -0
- package/dist/components/snk-simple-crud.js +3 -2
- package/dist/esm/pesquisa-fetcher-b0c7f275.js +160 -0
- package/dist/esm/snk-application.entry.js +2 -149
- package/dist/esm/snk-crud.entry.js +1 -0
- package/dist/esm/snk-detail-view.entry.js +2 -1
- package/dist/esm/{snk-guides-viewer-b13cff0a.js → snk-guides-viewer-5284f800.js} +1 -0
- package/dist/esm/snk-guides-viewer.entry.js +2 -1
- package/dist/esm/snk-simple-crud.entry.js +3 -2
- package/dist/sankhyablocks/p-31dba496.js +1 -0
- package/dist/sankhyablocks/p-722f0e95.entry.js +83 -0
- package/dist/sankhyablocks/p-8e6681f8.entry.js +1 -0
- package/dist/sankhyablocks/{p-6181e6cb.entry.js → p-c7ca2118.entry.js} +1 -1
- package/dist/sankhyablocks/p-d3324c6c.js +6 -0
- package/dist/sankhyablocks/p-d9508a7f.entry.js +1 -0
- package/dist/sankhyablocks/p-f59bee89.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +4 -1
- package/package.json +1 -1
- package/dist/sankhyablocks/p-2eab10a4.entry.js +0 -88
- package/dist/sankhyablocks/p-5afa5b01.entry.js +0 -1
- package/dist/sankhyablocks/p-5b80ee28.entry.js +0 -1
- package/dist/sankhyablocks/p-64f21075.entry.js +0 -1
- package/dist/sankhyablocks/p-e1dbaecb.js +0 -1
@@ -0,0 +1,162 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
const core = require('@sankhyalabs/core');
|
4
|
+
const DataFetcher = require('./DataFetcher-6acfc3a8.js');
|
5
|
+
|
6
|
+
class PesquisaFetcher {
|
7
|
+
constructor() {
|
8
|
+
this._defaultPageSize = 100;
|
9
|
+
this._templateByQuery = new Map();
|
10
|
+
this._searchListenersByDataUnit = new Map();
|
11
|
+
this.buldTemplates();
|
12
|
+
}
|
13
|
+
buldTemplates() {
|
14
|
+
this._templateByQuery.set("search", DataFetcher.dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
15
|
+
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
16
|
+
value
|
17
|
+
label
|
18
|
+
}
|
19
|
+
}`);
|
20
|
+
}
|
21
|
+
loadSearchOptions(entityName, argument, criteria, options) {
|
22
|
+
var _a;
|
23
|
+
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
24
|
+
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
25
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
26
|
+
const values = {
|
27
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
28
|
+
entityName,
|
29
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
30
|
+
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
31
|
+
};
|
32
|
+
if (values.options) {
|
33
|
+
(_a = values.options) === null || _a === void 0 ? true : delete _a.dataUnitId;
|
34
|
+
}
|
35
|
+
return new Promise((resolve, reject) => {
|
36
|
+
DataFetcher.DataFetcher.get()
|
37
|
+
.callGraphQL({
|
38
|
+
values,
|
39
|
+
query: this._templateByQuery.get("search"),
|
40
|
+
})
|
41
|
+
.then((result) => {
|
42
|
+
resolve(result);
|
43
|
+
})
|
44
|
+
.catch((error) => {
|
45
|
+
reject(error);
|
46
|
+
});
|
47
|
+
});
|
48
|
+
}
|
49
|
+
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
50
|
+
var _a, _b, _c;
|
51
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
52
|
+
const values = {
|
53
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
54
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
55
|
+
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
56
|
+
};
|
57
|
+
const serviceName = "PesquisaSP.getSuggestion";
|
58
|
+
const externalCriteria = {
|
59
|
+
query: {
|
60
|
+
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
61
|
+
}
|
62
|
+
};
|
63
|
+
if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
|
64
|
+
externalCriteria.params = {
|
65
|
+
param: values.criteria.params.map(param => {
|
66
|
+
let value = param.value;
|
67
|
+
let type = param.dataType;
|
68
|
+
if (type === core.DataType.OBJECT) {
|
69
|
+
value = value.value;
|
70
|
+
type = "S";
|
71
|
+
}
|
72
|
+
else {
|
73
|
+
type = convertParamType(param.dataType);
|
74
|
+
}
|
75
|
+
return { $: value, type };
|
76
|
+
})
|
77
|
+
};
|
78
|
+
}
|
79
|
+
const options = searchOptions != undefined
|
80
|
+
? {
|
81
|
+
"pkFieldName": searchOptions.codeFieldName,
|
82
|
+
"label": searchOptions.descriptionFieldName,
|
83
|
+
"fieldName": searchOptions.codeFieldName,
|
84
|
+
"useDescriptionOptions": false,
|
85
|
+
"enableRowsCounter": true
|
86
|
+
}
|
87
|
+
: undefined;
|
88
|
+
const reqBody = {
|
89
|
+
"serviceName": serviceName,
|
90
|
+
"requestBody": {
|
91
|
+
"criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_c = values.searchOptions) === null || _c === void 0 ? void 0 : _c.rootEntity }, { options }),
|
92
|
+
"clientEventList": {
|
93
|
+
"clientEvent": []
|
94
|
+
}
|
95
|
+
}
|
96
|
+
};
|
97
|
+
return new Promise((resolve, reject) => {
|
98
|
+
DataFetcher.DataFetcher.get()
|
99
|
+
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
100
|
+
.then(result => resolve(result))
|
101
|
+
.catch(error => reject(error));
|
102
|
+
});
|
103
|
+
}
|
104
|
+
addSearchListener(entityName, dataUnitID, listener) {
|
105
|
+
var _a;
|
106
|
+
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
107
|
+
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
108
|
+
if (!entityListener) {
|
109
|
+
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
110
|
+
}
|
111
|
+
else {
|
112
|
+
for (const type of Object.keys(listener)) {
|
113
|
+
if (type in entityListener.listener) {
|
114
|
+
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
115
|
+
if (listenerFunctionIsEquals)
|
116
|
+
continue;
|
117
|
+
entityListener.listener[type] = listener[type];
|
118
|
+
}
|
119
|
+
}
|
120
|
+
}
|
121
|
+
return () => {
|
122
|
+
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
123
|
+
if (!newListeners.length) {
|
124
|
+
this._searchListenersByDataUnit.delete(dataUnitID);
|
125
|
+
return;
|
126
|
+
}
|
127
|
+
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
128
|
+
};
|
129
|
+
}
|
130
|
+
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
131
|
+
var _a;
|
132
|
+
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
133
|
+
if (!dataUnitId)
|
134
|
+
return;
|
135
|
+
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
136
|
+
if (!entityListener)
|
137
|
+
return;
|
138
|
+
const { listener } = entityListener;
|
139
|
+
if (!(listenerType in listener))
|
140
|
+
return;
|
141
|
+
return listener[listenerType]({ argument, criteria, searchOptions });
|
142
|
+
}
|
143
|
+
}
|
144
|
+
function convertParamType(dataType) {
|
145
|
+
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
146
|
+
//atual da pesquisa... em geral, somente inteiros,
|
147
|
+
//data (com ou sem hora) e string são realmente relevantes
|
148
|
+
switch (dataType) {
|
149
|
+
case core.DataType.NUMBER:
|
150
|
+
return "I";
|
151
|
+
case core.DataType.DATE:
|
152
|
+
return "D";
|
153
|
+
default:
|
154
|
+
return "S";
|
155
|
+
}
|
156
|
+
}
|
157
|
+
var SearchListenerType;
|
158
|
+
(function (SearchListenerType) {
|
159
|
+
SearchListenerType["beforeSearch"] = "beforeSearch";
|
160
|
+
})(SearchListenerType || (SearchListenerType = {}));
|
161
|
+
|
162
|
+
exports.PesquisaFetcher = PesquisaFetcher;
|
@@ -6,6 +6,7 @@ const index = require('./index-21bd01e1.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
7
7
|
const DataFetcher = require('./DataFetcher-6acfc3a8.js');
|
8
8
|
const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
9
|
+
const pesquisaFetcher = require('./pesquisa-fetcher-d9dda5c6.js');
|
9
10
|
const SnkMessageBuilder = require('./SnkMessageBuilder-47185d5d.js');
|
10
11
|
const ConfigStorage = require('./ConfigStorage-bc7d1d9b.js');
|
11
12
|
const formConfigFetcher = require('./form-config-fetcher-4a952a50.js');
|
@@ -71,154 +72,6 @@ class SnkErrorHandler {
|
|
71
72
|
}
|
72
73
|
}
|
73
74
|
|
74
|
-
class PesquisaFetcher {
|
75
|
-
constructor() {
|
76
|
-
this._defaultPageSize = 100;
|
77
|
-
this._templateByQuery = new Map();
|
78
|
-
this._searchListenersByDataUnit = new Map();
|
79
|
-
this.buldTemplates();
|
80
|
-
}
|
81
|
-
buldTemplates() {
|
82
|
-
this._templateByQuery.set("search", DataFetcher.dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
83
|
-
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
84
|
-
value
|
85
|
-
label
|
86
|
-
}
|
87
|
-
}`);
|
88
|
-
}
|
89
|
-
loadSearchOptions(entityName, argument, criteria, options) {
|
90
|
-
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
91
|
-
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
92
|
-
const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, options);
|
93
|
-
const values = {
|
94
|
-
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
95
|
-
entityName,
|
96
|
-
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
97
|
-
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
98
|
-
};
|
99
|
-
return new Promise((resolve, reject) => {
|
100
|
-
DataFetcher.DataFetcher.get()
|
101
|
-
.callGraphQL({
|
102
|
-
values,
|
103
|
-
query: this._templateByQuery.get("search"),
|
104
|
-
})
|
105
|
-
.then((result) => {
|
106
|
-
resolve(result);
|
107
|
-
})
|
108
|
-
.catch((error) => {
|
109
|
-
reject(error);
|
110
|
-
});
|
111
|
-
});
|
112
|
-
}
|
113
|
-
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
114
|
-
var _a, _b, _c;
|
115
|
-
const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, searchOptions);
|
116
|
-
const values = {
|
117
|
-
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
118
|
-
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
119
|
-
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
120
|
-
};
|
121
|
-
const serviceName = "PesquisaSP.getSuggestion";
|
122
|
-
const externalCriteria = {
|
123
|
-
query: {
|
124
|
-
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
125
|
-
}
|
126
|
-
};
|
127
|
-
if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
|
128
|
-
externalCriteria.params = {
|
129
|
-
param: values.criteria.params.map(param => {
|
130
|
-
let value = param.value;
|
131
|
-
let type = param.dataType;
|
132
|
-
if (type === core.DataType.OBJECT) {
|
133
|
-
value = value.value;
|
134
|
-
type = "S";
|
135
|
-
}
|
136
|
-
else {
|
137
|
-
type = convertParamType(param.dataType);
|
138
|
-
}
|
139
|
-
return { $: value, type };
|
140
|
-
})
|
141
|
-
};
|
142
|
-
}
|
143
|
-
const options = searchOptions != undefined
|
144
|
-
? {
|
145
|
-
"pkFieldName": searchOptions.codeFieldName,
|
146
|
-
"label": searchOptions.descriptionFieldName,
|
147
|
-
"fieldName": searchOptions.codeFieldName,
|
148
|
-
"useDescriptionOptions": false,
|
149
|
-
"enableRowsCounter": true
|
150
|
-
}
|
151
|
-
: undefined;
|
152
|
-
const reqBody = {
|
153
|
-
"serviceName": serviceName,
|
154
|
-
"requestBody": {
|
155
|
-
"criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_c = values.searchOptions) === null || _c === void 0 ? void 0 : _c.rootEntity }, { options }),
|
156
|
-
"clientEventList": {
|
157
|
-
"clientEvent": []
|
158
|
-
}
|
159
|
-
}
|
160
|
-
};
|
161
|
-
return new Promise((resolve, reject) => {
|
162
|
-
DataFetcher.DataFetcher.get()
|
163
|
-
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
164
|
-
.then(result => resolve(result))
|
165
|
-
.catch(error => reject(error));
|
166
|
-
});
|
167
|
-
}
|
168
|
-
addSearchListener(entityName, dataUnitID, listener) {
|
169
|
-
var _a;
|
170
|
-
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
171
|
-
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
172
|
-
if (!entityListener) {
|
173
|
-
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
174
|
-
}
|
175
|
-
else {
|
176
|
-
for (const type of Object.keys(listener)) {
|
177
|
-
if (type in entityListener.listener) {
|
178
|
-
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
179
|
-
if (listenerFunctionIsEquals)
|
180
|
-
continue;
|
181
|
-
entityListener.listener[type] = listener[type];
|
182
|
-
}
|
183
|
-
}
|
184
|
-
}
|
185
|
-
return () => {
|
186
|
-
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
187
|
-
if (!newListeners.length) {
|
188
|
-
this._searchListenersByDataUnit.delete(dataUnitID);
|
189
|
-
return;
|
190
|
-
}
|
191
|
-
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
192
|
-
};
|
193
|
-
}
|
194
|
-
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
195
|
-
var _a;
|
196
|
-
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
197
|
-
if (!dataUnitId)
|
198
|
-
return;
|
199
|
-
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
200
|
-
if (!entityListener)
|
201
|
-
return;
|
202
|
-
const { listener } = entityListener;
|
203
|
-
if (!(listenerType in listener))
|
204
|
-
return;
|
205
|
-
return listener[listenerType]({ argument, criteria, searchOptions });
|
206
|
-
}
|
207
|
-
}
|
208
|
-
function convertParamType(dataType) {
|
209
|
-
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
210
|
-
//atual da pesquisa... em geral, somente inteiros,
|
211
|
-
//data (com ou sem hora) e string são realmente relevantes
|
212
|
-
switch (dataType) {
|
213
|
-
case core.DataType.NUMBER:
|
214
|
-
return "I";
|
215
|
-
case core.DataType.DATE:
|
216
|
-
return "D";
|
217
|
-
default:
|
218
|
-
return "S";
|
219
|
-
}
|
220
|
-
}
|
221
|
-
|
222
75
|
function _0x53e1(){const _0x340df8=['2909523kXwted','CompanyName=Sankhya\x20Jiva\x20Tecnologia\x20e\x20Inovao\x20Ltda,LicensedApplication=Sankhya\x20Gestao,LicenseType=SingleApplication,LicensedConcurrentDeveloperCount=2,LicensedProductionInstancesCount=0,AssetReference=AG-019460,ExpiryDate=9_November_2022_[v2]_MTY2Nzk1MjAwMDAwMA==10487151e296ee4360f80961ca960869','1131048CARoeW','502909mLEPmu','447255iQEXuN','428UHbJwW','270AFTxAV','194369jhGqTI','1540nWuTrj','2044062GicUQI','30CkXPWg'];_0x53e1=function(){return _0x340df8;};return _0x53e1();}const _0xc7632f=_0x15c2;function _0x15c2(_0x353a9c,_0x3e4a5a){const _0x53e110=_0x53e1();return _0x15c2=function(_0x15c2aa,_0x219858){_0x15c2aa=_0x15c2aa-0x188;let _0x307231=_0x53e110[_0x15c2aa];return _0x307231;},_0x15c2(_0x353a9c,_0x3e4a5a);}(function(_0x42617e,_0x57debe){const _0x31061a=_0x15c2,_0x128d7d=_0x42617e();while(!![]){try{const _0x1c9bb1=-parseInt(_0x31061a(0x18e))/0x1+-parseInt(_0x31061a(0x189))/0x2+parseInt(_0x31061a(0x18b))/0x3+-parseInt(_0x31061a(0x190))/0x4*(parseInt(_0x31061a(0x188))/0x5)+-parseInt(_0x31061a(0x191))/0x6*(-parseInt(_0x31061a(0x192))/0x7)+parseInt(_0x31061a(0x18d))/0x8+-parseInt(_0x31061a(0x18f))/0x9*(-parseInt(_0x31061a(0x18a))/0xa);if(_0x1c9bb1===_0x57debe)break;else _0x128d7d['push'](_0x128d7d['shift']());}catch(_0x1bd816){_0x128d7d['push'](_0x128d7d['shift']());}}}(_0x53e1,0xe8676));const agGridLicense=_0xc7632f(0x18c);
|
223
76
|
|
224
77
|
class TotalsFetcher {
|
@@ -1136,7 +989,7 @@ const SnkApplication = class {
|
|
1136
989
|
}
|
1137
990
|
get pesquisaFetcher() {
|
1138
991
|
if (!this._pesquisaFetcher) {
|
1139
|
-
this._pesquisaFetcher = new PesquisaFetcher();
|
992
|
+
this._pesquisaFetcher = new pesquisaFetcher.PesquisaFetcher();
|
1140
993
|
}
|
1141
994
|
return this._pesquisaFetcher;
|
1142
995
|
}
|
@@ -6,6 +6,7 @@ const index = require('./index-21bd01e1.js');
|
|
6
6
|
const core = require('@sankhyalabs/core');
|
7
7
|
const taskbarElements = require('./taskbar-elements-5e87cf44.js');
|
8
8
|
require('./DataFetcher-6acfc3a8.js');
|
9
|
+
require('./pesquisa-fetcher-d9dda5c6.js');
|
9
10
|
const index$1 = require('./index-f400b1d6.js');
|
10
11
|
const constants = require('./constants-ae0ed870.js');
|
11
12
|
require('./index-fc7ca86c.js');
|
@@ -6,11 +6,12 @@ const index = require('./index-21bd01e1.js');
|
|
6
6
|
const SnkFormConfigManager = require('./SnkFormConfigManager-5230e010.js');
|
7
7
|
const form = require('@sankhyalabs/ezui/dist/collection/utils/form');
|
8
8
|
require('./DataFetcher-6acfc3a8.js');
|
9
|
+
require('./pesquisa-fetcher-d9dda5c6.js');
|
9
10
|
require('@sankhyalabs/core');
|
10
11
|
const index$1 = require('./index-f400b1d6.js');
|
11
12
|
const taskbarElements = require('./taskbar-elements-5e87cf44.js');
|
12
13
|
const constants = require('./constants-ae0ed870.js');
|
13
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
14
|
+
const snkGuidesViewer = require('./snk-guides-viewer-19e24b86.js');
|
14
15
|
require('./ConfigStorage-bc7d1d9b.js');
|
15
16
|
require('./form-config-fetcher-4a952a50.js');
|
16
17
|
require('./_commonjsHelpers-537d719a.js');
|
@@ -8,6 +8,7 @@ const taskbarProcessor = require('./taskbar-processor-bce3f499.js');
|
|
8
8
|
const taskbarElements = require('./taskbar-elements-5e87cf44.js');
|
9
9
|
const constants = require('./constants-ae0ed870.js');
|
10
10
|
require('./DataFetcher-6acfc3a8.js');
|
11
|
+
require('./pesquisa-fetcher-d9dda5c6.js');
|
11
12
|
const index$1 = require('./index-f400b1d6.js');
|
12
13
|
|
13
14
|
const snkGuidesViewerCss = ".sc-snk-guides-viewer-h{--snk-guides-viewer--space-large:var(--space--large, 24px);--snk-guides-viewer--space-medium:var(--space--medium, 12px);--snk-guides-viewer__header--min-height:94px;--snk-guides-viewer__header--z-index:var(--more-visible, 2);--snk-guides-viewer__header--background-color:var(--background--body, #fafcff);--snk-guides-viewer__guide-navigator--width:340px;display:block}snk-form-view.sc-snk-guides-viewer{width:100%}.snk-guides-viewer.sc-snk-guides-viewer{position:relative;padding-left:0px;padding-top:0px;padding-right:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__detail-container.sc-snk-guides-viewer{display:flex;row-gap:24px;flex-direction:column}.snk-guides-viewer__header.sc-snk-guides-viewer{position:sticky;align-items:center;top:0;z-index:var(--snk-guides-viewer__header--z-index);background-color:var(--snk-guides-viewer__header--background-color);min-height:var(--snk-guides-viewer__header--min-height);width:calc(100% + (var(--snk-guides-viewer--space-large) * 2));padding-left:var(--snk-guides-viewer--space-large);padding-right:var(--snk-guides-viewer--space-large);padding-top:var(--snk-guides-viewer--space-large);padding-bottom:var(--snk-guides-viewer--space-medium);margin-left:calc(var(--snk-guides-viewer--space-large) * -1);margin-right:calc(var(--snk-guides-viewer--space-large) * -1);margin-bottom:var(--snk-guides-viewer--space-medium)}.snk-guides-viewer__container.sc-snk-guides-viewer{display:grid;grid-template-columns:minmax(0, auto) minmax(0, 100%);height:100%;column-gap:var(--snk-guides-viewer--space-large)}.snk-guides-viewer__guide-navigator.sc-snk-guides-viewer{position:sticky;top:calc(var(--snk-guides-viewer__header--min-height) + var(--snk-guides-viewer--space-medium));height:calc(100vh - var(--snk-guides-viewer__header--min-height) - var(--snk-guides-viewer--space-large) - var(--snk-guides-viewer--space-medium))}.snk-guides-viewer__guide-navigator[open].sc-snk-guides-viewer{width:var(--snk-guides-viewer__guide-navigator--width);max-width:var(--snk-guides-viewer__guide-navigator--width);min-width:var(--snk-guides-viewer__guide-navigator--width)}.snk-guides-viewer__detail-content.sc-snk-guides-viewer{min-height:100%;align-items:flex-start;align-content:flex-start}";
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
const snkGuidesViewer = require('./snk-guides-viewer-
|
5
|
+
const snkGuidesViewer = require('./snk-guides-viewer-19e24b86.js');
|
6
6
|
require('./index-21bd01e1.js');
|
7
7
|
require('@sankhyalabs/core');
|
8
8
|
require('./SnkFormConfigManager-5230e010.js');
|
@@ -16,6 +16,7 @@ require('./taskbar-elements-5e87cf44.js');
|
|
16
16
|
require('./index-f400b1d6.js');
|
17
17
|
require('./index-fc7ca86c.js');
|
18
18
|
require('./constants-ae0ed870.js');
|
19
|
+
require('./pesquisa-fetcher-d9dda5c6.js');
|
19
20
|
|
20
21
|
|
21
22
|
|
@@ -7,6 +7,7 @@ const core = require('@sankhyalabs/core');
|
|
7
7
|
const constants = require('./constants-ae0ed870.js');
|
8
8
|
const taskbarElements = require('./taskbar-elements-5e87cf44.js');
|
9
9
|
require('./DataFetcher-6acfc3a8.js');
|
10
|
+
require('./pesquisa-fetcher-d9dda5c6.js');
|
10
11
|
const index$1 = require('./index-f400b1d6.js');
|
11
12
|
const taskbarProcessor = require('./taskbar-processor-bce3f499.js');
|
12
13
|
require('./index-fc7ca86c.js');
|
@@ -191,11 +192,11 @@ const SnkSimpleCrud = class {
|
|
191
192
|
this.onModeChange();
|
192
193
|
}
|
193
194
|
getTaskBarId() {
|
194
|
-
var _a, _b;
|
195
|
+
var _a, _b, _c;
|
195
196
|
if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
|
196
197
|
return "snkSimpleCrudTaskbar.finish_edition";
|
197
198
|
}
|
198
|
-
if (((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectedRecords.length) > 0) {
|
199
|
+
if (((_c = (_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectedRecords) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
199
200
|
return this._currentViewMode === constants.VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_selected" : "snkSimpleCrudTaskbar.form_selected";
|
200
201
|
}
|
201
202
|
return this._currentViewMode === constants.VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
|
@@ -67,11 +67,11 @@ export class SnkSimpleCrud {
|
|
67
67
|
this.onModeChange();
|
68
68
|
}
|
69
69
|
getTaskBarId() {
|
70
|
-
var _a, _b;
|
70
|
+
var _a, _b, _c;
|
71
71
|
if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
|
72
72
|
return "snkSimpleCrudTaskbar.finish_edition";
|
73
73
|
}
|
74
|
-
if (((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectedRecords.length) > 0) {
|
74
|
+
if (((_c = (_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectedRecords) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
75
75
|
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_selected" : "snkSimpleCrudTaskbar.form_selected";
|
76
76
|
}
|
77
77
|
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
|
@@ -17,15 +17,19 @@ export class PesquisaFetcher {
|
|
17
17
|
}`);
|
18
18
|
}
|
19
19
|
loadSearchOptions(entityName, argument, criteria, options) {
|
20
|
+
var _a;
|
20
21
|
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
21
22
|
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
22
|
-
const listenerResult = this.applySearchListener(
|
23
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
23
24
|
const values = {
|
24
25
|
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
25
26
|
entityName,
|
26
27
|
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
27
28
|
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
28
29
|
};
|
30
|
+
if (values.options) {
|
31
|
+
(_a = values.options) === null || _a === void 0 ? true : delete _a.dataUnitId;
|
32
|
+
}
|
29
33
|
return new Promise((resolve, reject) => {
|
30
34
|
DataFetcher.get()
|
31
35
|
.callGraphQL({
|
@@ -42,7 +46,7 @@ export class PesquisaFetcher {
|
|
42
46
|
}
|
43
47
|
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
44
48
|
var _a, _b, _c;
|
45
|
-
const listenerResult = this.applySearchListener(
|
49
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
46
50
|
const values = {
|
47
51
|
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
48
52
|
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
@@ -148,3 +152,7 @@ function convertParamType(dataType) {
|
|
148
152
|
return "S";
|
149
153
|
}
|
150
154
|
}
|
155
|
+
export var SearchListenerType;
|
156
|
+
(function (SearchListenerType) {
|
157
|
+
SearchListenerType["beforeSearch"] = "beforeSearch";
|
158
|
+
})(SearchListenerType || (SearchListenerType = {}));
|
@@ -0,0 +1,160 @@
|
|
1
|
+
import { DataType } from '@sankhyalabs/core';
|
2
|
+
import { d as dist, D as DataFetcher } from './DataFetcher.js';
|
3
|
+
|
4
|
+
class PesquisaFetcher {
|
5
|
+
constructor() {
|
6
|
+
this._defaultPageSize = 100;
|
7
|
+
this._templateByQuery = new Map();
|
8
|
+
this._searchListenersByDataUnit = new Map();
|
9
|
+
this.buldTemplates();
|
10
|
+
}
|
11
|
+
buldTemplates() {
|
12
|
+
this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
13
|
+
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
14
|
+
value
|
15
|
+
label
|
16
|
+
}
|
17
|
+
}`);
|
18
|
+
}
|
19
|
+
loadSearchOptions(entityName, argument, criteria, options) {
|
20
|
+
var _a;
|
21
|
+
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
22
|
+
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
23
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
24
|
+
const values = {
|
25
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
26
|
+
entityName,
|
27
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
28
|
+
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
29
|
+
};
|
30
|
+
if (values.options) {
|
31
|
+
(_a = values.options) === null || _a === void 0 ? true : delete _a.dataUnitId;
|
32
|
+
}
|
33
|
+
return new Promise((resolve, reject) => {
|
34
|
+
DataFetcher.get()
|
35
|
+
.callGraphQL({
|
36
|
+
values,
|
37
|
+
query: this._templateByQuery.get("search"),
|
38
|
+
})
|
39
|
+
.then((result) => {
|
40
|
+
resolve(result);
|
41
|
+
})
|
42
|
+
.catch((error) => {
|
43
|
+
reject(error);
|
44
|
+
});
|
45
|
+
});
|
46
|
+
}
|
47
|
+
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
48
|
+
var _a, _b, _c;
|
49
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
50
|
+
const values = {
|
51
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
52
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
53
|
+
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
54
|
+
};
|
55
|
+
const serviceName = "PesquisaSP.getSuggestion";
|
56
|
+
const externalCriteria = {
|
57
|
+
query: {
|
58
|
+
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
59
|
+
}
|
60
|
+
};
|
61
|
+
if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
|
62
|
+
externalCriteria.params = {
|
63
|
+
param: values.criteria.params.map(param => {
|
64
|
+
let value = param.value;
|
65
|
+
let type = param.dataType;
|
66
|
+
if (type === DataType.OBJECT) {
|
67
|
+
value = value.value;
|
68
|
+
type = "S";
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
type = convertParamType(param.dataType);
|
72
|
+
}
|
73
|
+
return { $: value, type };
|
74
|
+
})
|
75
|
+
};
|
76
|
+
}
|
77
|
+
const options = searchOptions != undefined
|
78
|
+
? {
|
79
|
+
"pkFieldName": searchOptions.codeFieldName,
|
80
|
+
"label": searchOptions.descriptionFieldName,
|
81
|
+
"fieldName": searchOptions.codeFieldName,
|
82
|
+
"useDescriptionOptions": false,
|
83
|
+
"enableRowsCounter": true
|
84
|
+
}
|
85
|
+
: undefined;
|
86
|
+
const reqBody = {
|
87
|
+
"serviceName": serviceName,
|
88
|
+
"requestBody": {
|
89
|
+
"criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_c = values.searchOptions) === null || _c === void 0 ? void 0 : _c.rootEntity }, { options }),
|
90
|
+
"clientEventList": {
|
91
|
+
"clientEvent": []
|
92
|
+
}
|
93
|
+
}
|
94
|
+
};
|
95
|
+
return new Promise((resolve, reject) => {
|
96
|
+
DataFetcher.get()
|
97
|
+
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
98
|
+
.then(result => resolve(result))
|
99
|
+
.catch(error => reject(error));
|
100
|
+
});
|
101
|
+
}
|
102
|
+
addSearchListener(entityName, dataUnitID, listener) {
|
103
|
+
var _a;
|
104
|
+
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
105
|
+
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
106
|
+
if (!entityListener) {
|
107
|
+
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
108
|
+
}
|
109
|
+
else {
|
110
|
+
for (const type of Object.keys(listener)) {
|
111
|
+
if (type in entityListener.listener) {
|
112
|
+
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
113
|
+
if (listenerFunctionIsEquals)
|
114
|
+
continue;
|
115
|
+
entityListener.listener[type] = listener[type];
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
return () => {
|
120
|
+
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
121
|
+
if (!newListeners.length) {
|
122
|
+
this._searchListenersByDataUnit.delete(dataUnitID);
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
126
|
+
};
|
127
|
+
}
|
128
|
+
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
129
|
+
var _a;
|
130
|
+
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
131
|
+
if (!dataUnitId)
|
132
|
+
return;
|
133
|
+
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
134
|
+
if (!entityListener)
|
135
|
+
return;
|
136
|
+
const { listener } = entityListener;
|
137
|
+
if (!(listenerType in listener))
|
138
|
+
return;
|
139
|
+
return listener[listenerType]({ argument, criteria, searchOptions });
|
140
|
+
}
|
141
|
+
}
|
142
|
+
function convertParamType(dataType) {
|
143
|
+
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
144
|
+
//atual da pesquisa... em geral, somente inteiros,
|
145
|
+
//data (com ou sem hora) e string são realmente relevantes
|
146
|
+
switch (dataType) {
|
147
|
+
case DataType.NUMBER:
|
148
|
+
return "I";
|
149
|
+
case DataType.DATE:
|
150
|
+
return "D";
|
151
|
+
default:
|
152
|
+
return "S";
|
153
|
+
}
|
154
|
+
}
|
155
|
+
var SearchListenerType;
|
156
|
+
(function (SearchListenerType) {
|
157
|
+
SearchListenerType["beforeSearch"] = "beforeSearch";
|
158
|
+
})(SearchListenerType || (SearchListenerType = {}));
|
159
|
+
|
160
|
+
export { PesquisaFetcher as P };
|