@sankhyalabs/sankhyablocks 4.6.3 → 4.8.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/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-fetcher-a3f0954f.js +158 -0
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +13 -96
- 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-ed5012ff.js} +1 -0
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +1 -0
- package/dist/collection/components/snk-application/snk-application.js +48 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +63 -5
- package/dist/components/pesquisa-fetcher.js +156 -0
- package/dist/components/snk-application2.js +15 -97
- package/dist/components/snk-crud.js +1 -0
- package/dist/components/snk-detail-view2.js +1 -0
- package/dist/components/snk-simple-crud.js +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-fetcher-e60477d1.js +156 -0
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +13 -96
- 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-3a29e72b.js} +1 -0
- package/dist/esm/snk-guides-viewer.entry.js +2 -1
- package/dist/esm/snk-simple-crud.entry.js +1 -0
- package/dist/sankhyablocks/p-1da34865.js +1 -0
- package/dist/sankhyablocks/p-3c18709f.entry.js +1 -0
- package/dist/sankhyablocks/p-5643a554.entry.js +1 -0
- package/dist/sankhyablocks/p-57c40d37.entry.js +83 -0
- package/dist/sankhyablocks/{p-6181e6cb.entry.js → p-6f8eb54b.entry.js} +1 -1
- package/dist/sankhyablocks/p-9b51be04.entry.js +1 -0
- package/dist/sankhyablocks/p-a81f0854.js +6 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +5 -1
- package/dist/types/components.d.ts +5 -1
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +18 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-0d9f624f.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
@@ -5,6 +5,7 @@ export class PesquisaFetcher {
|
|
5
5
|
constructor() {
|
6
6
|
this._defaultPageSize = 100;
|
7
7
|
this._templateByQuery = new Map();
|
8
|
+
this._searchListenersByDataUnit = new Map();
|
8
9
|
this.buldTemplates();
|
9
10
|
}
|
10
11
|
buldTemplates() {
|
@@ -18,10 +19,17 @@ export class PesquisaFetcher {
|
|
18
19
|
loadSearchOptions(entityName, argument, criteria, options) {
|
19
20
|
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
20
21
|
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
22
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
23
|
+
const values = {
|
24
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
25
|
+
entityName,
|
26
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
27
|
+
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
28
|
+
};
|
21
29
|
return new Promise((resolve, reject) => {
|
22
30
|
DataFetcher.get()
|
23
31
|
.callGraphQL({
|
24
|
-
values
|
32
|
+
values,
|
25
33
|
query: this._templateByQuery.get("search"),
|
26
34
|
})
|
27
35
|
.then((result) => {
|
@@ -33,15 +41,22 @@ export class PesquisaFetcher {
|
|
33
41
|
});
|
34
42
|
}
|
35
43
|
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
44
|
+
var _a, _b, _c;
|
45
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
46
|
+
const values = {
|
47
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
48
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
49
|
+
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
50
|
+
};
|
36
51
|
const serviceName = "PesquisaSP.getSuggestion";
|
37
52
|
const externalCriteria = {
|
38
53
|
query: {
|
39
|
-
$: criteria === null ||
|
54
|
+
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
40
55
|
}
|
41
56
|
};
|
42
|
-
if ((criteria === null ||
|
57
|
+
if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
|
43
58
|
externalCriteria.params = {
|
44
|
-
param: criteria.params.map(param => {
|
59
|
+
param: values.criteria.params.map(param => {
|
45
60
|
let value = param.value;
|
46
61
|
let type = param.dataType;
|
47
62
|
if (type === DataType.OBJECT) {
|
@@ -67,7 +82,7 @@ export class PesquisaFetcher {
|
|
67
82
|
const reqBody = {
|
68
83
|
"serviceName": serviceName,
|
69
84
|
"requestBody": {
|
70
|
-
"criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": searchOptions === null ||
|
85
|
+
"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 }),
|
71
86
|
"clientEventList": {
|
72
87
|
"clientEvent": []
|
73
88
|
}
|
@@ -80,6 +95,45 @@ export class PesquisaFetcher {
|
|
80
95
|
.catch(error => reject(error));
|
81
96
|
});
|
82
97
|
}
|
98
|
+
addSearchListener(entityName, dataUnitID, listener) {
|
99
|
+
var _a;
|
100
|
+
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
101
|
+
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
102
|
+
if (!entityListener) {
|
103
|
+
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
104
|
+
}
|
105
|
+
else {
|
106
|
+
for (const type of Object.keys(listener)) {
|
107
|
+
if (type in entityListener.listener) {
|
108
|
+
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
109
|
+
if (listenerFunctionIsEquals)
|
110
|
+
continue;
|
111
|
+
entityListener.listener[type] = listener[type];
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
return () => {
|
116
|
+
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
117
|
+
if (!newListeners.length) {
|
118
|
+
this._searchListenersByDataUnit.delete(dataUnitID);
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
122
|
+
};
|
123
|
+
}
|
124
|
+
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
125
|
+
var _a;
|
126
|
+
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
127
|
+
if (!dataUnitId)
|
128
|
+
return;
|
129
|
+
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
130
|
+
if (!entityListener)
|
131
|
+
return;
|
132
|
+
const { listener } = entityListener;
|
133
|
+
if (!(listenerType in listener))
|
134
|
+
return;
|
135
|
+
return listener[listenerType]({ argument, criteria, searchOptions });
|
136
|
+
}
|
83
137
|
}
|
84
138
|
function convertParamType(dataType) {
|
85
139
|
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
@@ -94,3 +148,7 @@ function convertParamType(dataType) {
|
|
94
148
|
return "S";
|
95
149
|
}
|
96
150
|
}
|
151
|
+
export var SearchListenerType;
|
152
|
+
(function (SearchListenerType) {
|
153
|
+
SearchListenerType["beforeSearch"] = "beforeSearch";
|
154
|
+
})(SearchListenerType || (SearchListenerType = {}));
|
@@ -0,0 +1,156 @@
|
|
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
|
+
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
21
|
+
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
22
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
23
|
+
const values = {
|
24
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
25
|
+
entityName,
|
26
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
27
|
+
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
28
|
+
};
|
29
|
+
return new Promise((resolve, reject) => {
|
30
|
+
DataFetcher.get()
|
31
|
+
.callGraphQL({
|
32
|
+
values,
|
33
|
+
query: this._templateByQuery.get("search"),
|
34
|
+
})
|
35
|
+
.then((result) => {
|
36
|
+
resolve(result);
|
37
|
+
})
|
38
|
+
.catch((error) => {
|
39
|
+
reject(error);
|
40
|
+
});
|
41
|
+
});
|
42
|
+
}
|
43
|
+
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
44
|
+
var _a, _b, _c;
|
45
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
46
|
+
const values = {
|
47
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
48
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
49
|
+
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
50
|
+
};
|
51
|
+
const serviceName = "PesquisaSP.getSuggestion";
|
52
|
+
const externalCriteria = {
|
53
|
+
query: {
|
54
|
+
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
55
|
+
}
|
56
|
+
};
|
57
|
+
if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
|
58
|
+
externalCriteria.params = {
|
59
|
+
param: values.criteria.params.map(param => {
|
60
|
+
let value = param.value;
|
61
|
+
let type = param.dataType;
|
62
|
+
if (type === DataType.OBJECT) {
|
63
|
+
value = value.value;
|
64
|
+
type = "S";
|
65
|
+
}
|
66
|
+
else {
|
67
|
+
type = convertParamType(param.dataType);
|
68
|
+
}
|
69
|
+
return { $: value, type };
|
70
|
+
})
|
71
|
+
};
|
72
|
+
}
|
73
|
+
const options = searchOptions != undefined
|
74
|
+
? {
|
75
|
+
"pkFieldName": searchOptions.codeFieldName,
|
76
|
+
"label": searchOptions.descriptionFieldName,
|
77
|
+
"fieldName": searchOptions.codeFieldName,
|
78
|
+
"useDescriptionOptions": false,
|
79
|
+
"enableRowsCounter": true
|
80
|
+
}
|
81
|
+
: undefined;
|
82
|
+
const reqBody = {
|
83
|
+
"serviceName": serviceName,
|
84
|
+
"requestBody": {
|
85
|
+
"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 }),
|
86
|
+
"clientEventList": {
|
87
|
+
"clientEvent": []
|
88
|
+
}
|
89
|
+
}
|
90
|
+
};
|
91
|
+
return new Promise((resolve, reject) => {
|
92
|
+
DataFetcher.get()
|
93
|
+
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
94
|
+
.then(result => resolve(result))
|
95
|
+
.catch(error => reject(error));
|
96
|
+
});
|
97
|
+
}
|
98
|
+
addSearchListener(entityName, dataUnitID, listener) {
|
99
|
+
var _a;
|
100
|
+
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
101
|
+
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
102
|
+
if (!entityListener) {
|
103
|
+
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
104
|
+
}
|
105
|
+
else {
|
106
|
+
for (const type of Object.keys(listener)) {
|
107
|
+
if (type in entityListener.listener) {
|
108
|
+
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
109
|
+
if (listenerFunctionIsEquals)
|
110
|
+
continue;
|
111
|
+
entityListener.listener[type] = listener[type];
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
return () => {
|
116
|
+
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
117
|
+
if (!newListeners.length) {
|
118
|
+
this._searchListenersByDataUnit.delete(dataUnitID);
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
122
|
+
};
|
123
|
+
}
|
124
|
+
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
125
|
+
var _a;
|
126
|
+
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
127
|
+
if (!dataUnitId)
|
128
|
+
return;
|
129
|
+
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
130
|
+
if (!entityListener)
|
131
|
+
return;
|
132
|
+
const { listener } = entityListener;
|
133
|
+
if (!(listenerType in listener))
|
134
|
+
return;
|
135
|
+
return listener[listenerType]({ argument, criteria, searchOptions });
|
136
|
+
}
|
137
|
+
}
|
138
|
+
function convertParamType(dataType) {
|
139
|
+
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
140
|
+
//atual da pesquisa... em geral, somente inteiros,
|
141
|
+
//data (com ou sem hora) e string são realmente relevantes
|
142
|
+
switch (dataType) {
|
143
|
+
case DataType.NUMBER:
|
144
|
+
return "I";
|
145
|
+
case DataType.DATE:
|
146
|
+
return "D";
|
147
|
+
default:
|
148
|
+
return "S";
|
149
|
+
}
|
150
|
+
}
|
151
|
+
var SearchListenerType;
|
152
|
+
(function (SearchListenerType) {
|
153
|
+
SearchListenerType["beforeSearch"] = "beforeSearch";
|
154
|
+
})(SearchListenerType || (SearchListenerType = {}));
|
155
|
+
|
156
|
+
export { PesquisaFetcher as P };
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
2
|
-
import { WaitingChangeException, WarningException, ErrorException, ObjectUtils,
|
2
|
+
import { WaitingChangeException, WarningException, ErrorException, ObjectUtils, DataUnit, StringUtils, DataType, DataUnitStorage, ChangeOperation, DateUtils, DependencyType, ElementIDUtils, ApplicationContext, ErrorTracking } from '@sankhyalabs/core';
|
3
3
|
import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher.js';
|
4
4
|
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
5
|
+
import { P as PesquisaFetcher } from './pesquisa-fetcher.js';
|
5
6
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder.js';
|
6
7
|
import { G as GridConfigFetcher, C as ConfigStorage } from './ConfigStorage.js';
|
7
8
|
import { R as ResourceFetcher } from './form-config-fetcher.js';
|
@@ -67,100 +68,6 @@ class SnkErrorHandler {
|
|
67
68
|
}
|
68
69
|
}
|
69
70
|
|
70
|
-
class PesquisaFetcher {
|
71
|
-
constructor() {
|
72
|
-
this._defaultPageSize = 100;
|
73
|
-
this._templateByQuery = new Map();
|
74
|
-
this.buldTemplates();
|
75
|
-
}
|
76
|
-
buldTemplates() {
|
77
|
-
this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
78
|
-
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
79
|
-
value
|
80
|
-
label
|
81
|
-
}
|
82
|
-
}`);
|
83
|
-
}
|
84
|
-
loadSearchOptions(entityName, argument, criteria, options) {
|
85
|
-
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
86
|
-
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
87
|
-
return new Promise((resolve, reject) => {
|
88
|
-
DataFetcher.get()
|
89
|
-
.callGraphQL({
|
90
|
-
values: { argument, entityName, criteria, options },
|
91
|
-
query: this._templateByQuery.get("search"),
|
92
|
-
})
|
93
|
-
.then((result) => {
|
94
|
-
resolve(result);
|
95
|
-
})
|
96
|
-
.catch((error) => {
|
97
|
-
reject(error);
|
98
|
-
});
|
99
|
-
});
|
100
|
-
}
|
101
|
-
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
102
|
-
const serviceName = "PesquisaSP.getSuggestion";
|
103
|
-
const externalCriteria = {
|
104
|
-
query: {
|
105
|
-
$: criteria === null || criteria === void 0 ? void 0 : criteria.expression
|
106
|
-
}
|
107
|
-
};
|
108
|
-
if ((criteria === null || criteria === void 0 ? void 0 : criteria.params.length) > 0) {
|
109
|
-
externalCriteria.params = {
|
110
|
-
param: criteria.params.map(param => {
|
111
|
-
let value = param.value;
|
112
|
-
let type = param.dataType;
|
113
|
-
if (type === DataType.OBJECT) {
|
114
|
-
value = value.value;
|
115
|
-
type = "S";
|
116
|
-
}
|
117
|
-
else {
|
118
|
-
type = convertParamType(param.dataType);
|
119
|
-
}
|
120
|
-
return { $: value, type };
|
121
|
-
})
|
122
|
-
};
|
123
|
-
}
|
124
|
-
const options = searchOptions != undefined
|
125
|
-
? {
|
126
|
-
"pkFieldName": searchOptions.codeFieldName,
|
127
|
-
"label": searchOptions.descriptionFieldName,
|
128
|
-
"fieldName": searchOptions.codeFieldName,
|
129
|
-
"useDescriptionOptions": false,
|
130
|
-
"enableRowsCounter": true
|
131
|
-
}
|
132
|
-
: undefined;
|
133
|
-
const reqBody = {
|
134
|
-
"serviceName": serviceName,
|
135
|
-
"requestBody": {
|
136
|
-
"criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.rootEntity }, { options }),
|
137
|
-
"clientEventList": {
|
138
|
-
"clientEvent": []
|
139
|
-
}
|
140
|
-
}
|
141
|
-
};
|
142
|
-
return new Promise((resolve, reject) => {
|
143
|
-
DataFetcher.get()
|
144
|
-
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
145
|
-
.then(result => resolve(result))
|
146
|
-
.catch(error => reject(error));
|
147
|
-
});
|
148
|
-
}
|
149
|
-
}
|
150
|
-
function convertParamType(dataType) {
|
151
|
-
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
152
|
-
//atual da pesquisa... em geral, somente inteiros,
|
153
|
-
//data (com ou sem hora) e string são realmente relevantes
|
154
|
-
switch (dataType) {
|
155
|
-
case DataType.NUMBER:
|
156
|
-
return "I";
|
157
|
-
case DataType.DATE:
|
158
|
-
return "D";
|
159
|
-
default:
|
160
|
-
return "S";
|
161
|
-
}
|
162
|
-
}
|
163
|
-
|
164
71
|
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);
|
165
72
|
|
166
73
|
class TotalsFetcher {
|
@@ -1105,7 +1012,8 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
1105
1012
|
rootEntity: ROOTENTITY,
|
1106
1013
|
descriptionFieldName: DESCRIPTIONFIELD,
|
1107
1014
|
codeFieldName: CODEFIELD,
|
1108
|
-
showInactives: false
|
1015
|
+
showInactives: false,
|
1016
|
+
dataUnitId: dataUnit.dataUnitId
|
1109
1017
|
};
|
1110
1018
|
dependencies === null || dependencies === void 0 ? void 0 : dependencies.filter(dep => dep.masterFields).forEach(dependency => {
|
1111
1019
|
var _a;
|
@@ -1169,6 +1077,15 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
1169
1077
|
async getAppLabel() {
|
1170
1078
|
return Workspace.getAppLabel(this._resourceID);
|
1171
1079
|
}
|
1080
|
+
/**
|
1081
|
+
* Adiciona um listener no fetcher de Pesquisa
|
1082
|
+
*/
|
1083
|
+
addSearchListener(entityName, dataUnit, listener) {
|
1084
|
+
return new Promise(resolve => {
|
1085
|
+
const removeListener = this.pesquisaFetcher.addSearchListener(entityName, dataUnit.dataUnitId, listener);
|
1086
|
+
resolve(removeListener);
|
1087
|
+
});
|
1088
|
+
}
|
1172
1089
|
clearContent(container) {
|
1173
1090
|
if (container) {
|
1174
1091
|
Array.from(container.children).forEach(child => {
|
@@ -1252,7 +1169,8 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
1252
1169
|
"executeSearch": [64],
|
1253
1170
|
"executePreparedSearch": [64],
|
1254
1171
|
"isDebugMode": [64],
|
1255
|
-
"getAppLabel": [64]
|
1172
|
+
"getAppLabel": [64],
|
1173
|
+
"addSearchListener": [64]
|
1256
1174
|
}]);
|
1257
1175
|
class RequestListenerLoadingBar {
|
1258
1176
|
constructor() {
|
@@ -2,6 +2,7 @@ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/i
|
|
2
2
|
import { ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
|
3
3
|
import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
|
4
4
|
import './DataFetcher.js';
|
5
|
+
import './pesquisa-fetcher.js';
|
5
6
|
import { P as PresentationMode } from './index2.js';
|
6
7
|
import { V as VIEW_MODE } from './constants.js';
|
7
8
|
import { d as defineCustomElement$m } from './snk-config-options2.js';
|
@@ -2,6 +2,7 @@ import { proxyCustomElement, HTMLElement, createEvent, h, Fragment, forceUpdate,
|
|
2
2
|
import { S as SnkFormConfigManager } from './SnkFormConfigManager.js';
|
3
3
|
import { buildFormMetadata, FormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
|
4
4
|
import './DataFetcher.js';
|
5
|
+
import './pesquisa-fetcher.js';
|
5
6
|
import { ApplicationContext, ElementIDUtils } from '@sankhyalabs/core';
|
6
7
|
import { P as PresentationMode } from './index2.js';
|
7
8
|
import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
|
@@ -3,6 +3,7 @@ import { DataUnit, StringUtils, SortMode, DataType, ChangeOperation, ObjectUtils
|
|
3
3
|
import { V as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants.js';
|
4
4
|
import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
|
5
5
|
import './DataFetcher.js';
|
6
|
+
import './pesquisa-fetcher.js';
|
6
7
|
import { P as PresentationMode } from './index2.js';
|
7
8
|
import { T as TaskbarProcessor } from './taskbar-processor.js';
|
8
9
|
import { d as defineCustomElement$5 } from './snk-data-exporter2.js';
|
package/dist/esm/loader.js
CHANGED
@@ -11,7 +11,7 @@ const patchEsm = () => {
|
|
11
11
|
const defineCustomElements = (win, options) => {
|
12
12
|
if (typeof window === 'undefined') return Promise.resolve();
|
13
13
|
return patchEsm().then(() => {
|
14
|
-
return bootstrapLazy([["snk-simple-crud",[[6,"snk-simple-crud",{"dataState":[16],"dataUnit":[16],"mode":[2],"taskbarManager":[16],"_currentViewMode":[32],"_config":[32],"goToView":[64],"setMetadata":[64],"setRecords":[64],"getRecords":[64]},[[0,"actionClick","actionClickListener"]]]]],["teste-pesquisa",[[1,"teste-pesquisa"]]],["snk-filter-binary-select",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-field-search",[[2,"snk-filter-field-search",{"searchable":[4],"breadcrumbItems":[32],"linkItems":[32],"fieldItems":[32],"setDataSource":[64],"filterDataSource":[64]}]]],["snk-filter-multi-select",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-number",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-param-config",[[2,"snk-filter-param-config",{"_opened":[32],"_configType":[32],"_expressionItem":[32],"_informedInstance":[32],"_canSave":[32],"open":[64],"close":[64]}]]],["snk-filter-period",[[0,"snk-filter-period",{"config":[16],"value":[8],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-personalized",[[0,"snk-filter-personalized",{"config":[16],"value":[1040],"fix":[16],"unfix":[16],"show":[64]}]]],["snk-filter-search",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-text",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["snk-detail-view",[[2,"snk-detail-view",{"formConfigManager":[1040],"dataUnitName":[1,"data-unit-name"],"guideItemPath":[16],"entityName":[1,"entity-name"],"label":[1],"dataUnit":[1040],"selectedForm":[1025,"selected-form"],"dataState":[1040],"_disabledButtons":[32],"changeViewMode":[64],"configGrid":[64],"showUp":[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["snk-configurator",[[2,"snk-configurator",{"configName":[1,"config-name"],"viewMode":[2,"view-mode"],"_opened":[32],"_permissions":[32],"open":[64],"close":[64]}]]],["snk-pesquisa",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-filter-bar",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"filterConfig":[1040],"allowDefault":[32],"scrollerLocked":[32]},[[0,"filterChange","filterChangeListener"]]]]],["snk-grid-config",[[2,"snk-grid-config",{"selectedIndex":[1026,"selected-index"],"application":[16],"columns":[1040],"config":[1040],"configName":[1,"config-name"]}]]],["snk-config-options",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"_defaultType":[32]}]]],["snk-data-unit",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"getDataUnit":[64],"getSelectedRecordsIDsInfo":[64]}]]],["snk-field-config",[[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16]}]]],["snk-tab-config",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["snk-form-config",[[2,"snk-form-config",{"dataUnit":[16],"configManager":[16],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["snk-taskbar",[[6,"snk-taskbar",{"configName":[1,"config-name"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"presentationMode":[1537,"presentation-mode"],"_permissions":[32]}]]],["snk-filter-item",[[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["snk-filter-list",[[4,"snk-filter-list",{"label":[1],"iconName":[1,"icon-name"],"items":[16],"getMessage":[16],"emptyText":[1,"empty-text"],"findFilterText":[1,"find-filter-text"],"buttonClass":[1,"button-class"],"_filterArgument":[32],"_showAll":[32],"hideDetail":[64]},[[2,"keydown","keyDownHandler"]]]]],["snk-select-box",[[1,"snk-select-box",{"selectedOption":[1,"selected-option"]}]]],["snk-exporter-email-sender",[[0,"snk-exporter-email-sender",{"getMessage":[16],"_config":[32],"_opened":[32],"_currentStep":[32],"open":[64],"close":[64]}]]],["snk-data-exporter",[[2,"snk-data-exporter",{"provider":[16],"_items":[32],"_showDropdown":[32],"_releasedToExport":[32]}]]],["snk-guides-viewer",[[2,"snk-guides-viewer",{"dataUnit":[16],"dataState":[16],"configName":[1,"config-name"],"entityPath":[1,"entity-path"],"actionsList":[16],"recordsValidator":[16],"masterFormConfig":[1040],"selectedGuide":[16],"taskbarManager":[16],"presentationMode":[1,"presentation-mode"],"_breadcrumbItems":[32],"_guides":[32],"_formEditorConfigManager":[32],"_formEditorDataUnit":[32],"showFormConfig":[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["snk-crud",[[6,"snk-crud",{"configName":[1025,"config-name"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"_dataUnit":[32],"_dataState":[32],"_currentViewMode":[32],"goToView":[64]}]]],["snk-form",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"_dataUnit":[32],"_dataState":[32],"_showFormConfig":[32],"_configManager":[32],"showConfig":[64],"hideConfig":[64]}]]],["snk-application",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"webConnection":[64],"createDataunit":[64],"updateDataunitCache":[64],"getDataUnit":[64],"addClientEvent":[64],"removeClientEvent":[64],"hasClientEvent":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadGridConfig":[64],"loadTotals":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64],"getAppLabel":[64]}]]],["snk-filter-detail",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["snk-grid",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"taskbarManager":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"_popUpGridConfig":[32],"showConfig":[64],"hideConfig":[64],"setConfig":[64]}]]],["snk-form-summary",[[2,"snk-form-summary",{"fixed":[1540],"contracted":[1540],"summary":[16]}]]],["snk-form-view",[[6,"snk-form-view",{"levelPath":[1,"level-path"],"label":[1],"name":[1],"fields":[16],"formMetadata":[8,"form-metadata"],"dataUnit":[16],"contracted":[4],"fixed":[1540],"summaryFields":[16],"canExpand":[4,"can-expand"],"canFix":[4,"can-fix"],"recordsValidator":[16],"showUp":[64]}]]],["snk-filter-modal",[[0,"snk-filter-modal",{"getMessage":[16],"items":[1040],"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"infoText":[1,"info-text"],"useSearch":[4,"use-search"],"processModalAction":[16],"_filterArgument":[32]}]]]], options);
|
14
|
+
return bootstrapLazy([["snk-simple-crud",[[6,"snk-simple-crud",{"dataState":[16],"dataUnit":[16],"mode":[2],"taskbarManager":[16],"_currentViewMode":[32],"_config":[32],"goToView":[64],"setMetadata":[64],"setRecords":[64],"getRecords":[64]},[[0,"actionClick","actionClickListener"]]]]],["teste-pesquisa",[[1,"teste-pesquisa"]]],["snk-filter-binary-select",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-field-search",[[2,"snk-filter-field-search",{"searchable":[4],"breadcrumbItems":[32],"linkItems":[32],"fieldItems":[32],"setDataSource":[64],"filterDataSource":[64]}]]],["snk-filter-multi-select",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-number",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-param-config",[[2,"snk-filter-param-config",{"_opened":[32],"_configType":[32],"_expressionItem":[32],"_informedInstance":[32],"_canSave":[32],"open":[64],"close":[64]}]]],["snk-filter-period",[[0,"snk-filter-period",{"config":[16],"value":[8],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-personalized",[[0,"snk-filter-personalized",{"config":[16],"value":[1040],"fix":[16],"unfix":[16],"show":[64]}]]],["snk-filter-search",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-text",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["snk-detail-view",[[2,"snk-detail-view",{"formConfigManager":[1040],"dataUnitName":[1,"data-unit-name"],"guideItemPath":[16],"entityName":[1,"entity-name"],"label":[1],"dataUnit":[1040],"selectedForm":[1025,"selected-form"],"dataState":[1040],"_disabledButtons":[32],"changeViewMode":[64],"configGrid":[64],"showUp":[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["snk-configurator",[[2,"snk-configurator",{"configName":[1,"config-name"],"viewMode":[2,"view-mode"],"_opened":[32],"_permissions":[32],"open":[64],"close":[64]}]]],["snk-pesquisa",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-filter-bar",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"filterConfig":[1040],"allowDefault":[32],"scrollerLocked":[32]},[[0,"filterChange","filterChangeListener"]]]]],["snk-grid-config",[[2,"snk-grid-config",{"selectedIndex":[1026,"selected-index"],"application":[16],"columns":[1040],"config":[1040],"configName":[1,"config-name"]}]]],["snk-config-options",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"_defaultType":[32]}]]],["snk-data-unit",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"getDataUnit":[64],"getSelectedRecordsIDsInfo":[64]}]]],["snk-field-config",[[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16]}]]],["snk-tab-config",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["snk-form-config",[[2,"snk-form-config",{"dataUnit":[16],"configManager":[16],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["snk-taskbar",[[6,"snk-taskbar",{"configName":[1,"config-name"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"presentationMode":[1537,"presentation-mode"],"_permissions":[32]}]]],["snk-filter-item",[[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["snk-filter-list",[[4,"snk-filter-list",{"label":[1],"iconName":[1,"icon-name"],"items":[16],"getMessage":[16],"emptyText":[1,"empty-text"],"findFilterText":[1,"find-filter-text"],"buttonClass":[1,"button-class"],"_filterArgument":[32],"_showAll":[32],"hideDetail":[64]},[[2,"keydown","keyDownHandler"]]]]],["snk-select-box",[[1,"snk-select-box",{"selectedOption":[1,"selected-option"]}]]],["snk-exporter-email-sender",[[0,"snk-exporter-email-sender",{"getMessage":[16],"_config":[32],"_opened":[32],"_currentStep":[32],"open":[64],"close":[64]}]]],["snk-data-exporter",[[2,"snk-data-exporter",{"provider":[16],"_items":[32],"_showDropdown":[32],"_releasedToExport":[32]}]]],["snk-guides-viewer",[[2,"snk-guides-viewer",{"dataUnit":[16],"dataState":[16],"configName":[1,"config-name"],"entityPath":[1,"entity-path"],"actionsList":[16],"recordsValidator":[16],"masterFormConfig":[1040],"selectedGuide":[16],"taskbarManager":[16],"presentationMode":[1,"presentation-mode"],"_breadcrumbItems":[32],"_guides":[32],"_formEditorConfigManager":[32],"_formEditorDataUnit":[32],"showFormConfig":[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["snk-crud",[[6,"snk-crud",{"configName":[1025,"config-name"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"_dataUnit":[32],"_dataState":[32],"_currentViewMode":[32],"goToView":[64]}]]],["snk-form",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"_dataUnit":[32],"_dataState":[32],"_showFormConfig":[32],"_configManager":[32],"showConfig":[64],"hideConfig":[64]}]]],["snk-application",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"webConnection":[64],"createDataunit":[64],"updateDataunitCache":[64],"getDataUnit":[64],"addClientEvent":[64],"removeClientEvent":[64],"hasClientEvent":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadGridConfig":[64],"loadTotals":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64],"getAppLabel":[64],"addSearchListener":[64]}]]],["snk-filter-detail",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["snk-grid",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"taskbarManager":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"_popUpGridConfig":[32],"showConfig":[64],"hideConfig":[64],"setConfig":[64]}]]],["snk-form-summary",[[2,"snk-form-summary",{"fixed":[1540],"contracted":[1540],"summary":[16]}]]],["snk-form-view",[[6,"snk-form-view",{"levelPath":[1,"level-path"],"label":[1],"name":[1],"fields":[16],"formMetadata":[8,"form-metadata"],"dataUnit":[16],"contracted":[4],"fixed":[1540],"summaryFields":[16],"canExpand":[4,"can-expand"],"canFix":[4,"can-fix"],"recordsValidator":[16],"showUp":[64]}]]],["snk-filter-modal",[[0,"snk-filter-modal",{"getMessage":[16],"items":[1040],"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"infoText":[1,"info-text"],"useSearch":[4,"use-search"],"processModalAction":[16],"_filterArgument":[32]}]]]], options);
|
15
15
|
});
|
16
16
|
};
|
17
17
|
|
@@ -0,0 +1,156 @@
|
|
1
|
+
import { DataType } from '@sankhyalabs/core';
|
2
|
+
import { d as dist, D as DataFetcher } from './DataFetcher-5e99fa75.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
|
+
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
21
|
+
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
22
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
23
|
+
const values = {
|
24
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
25
|
+
entityName,
|
26
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
27
|
+
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
28
|
+
};
|
29
|
+
return new Promise((resolve, reject) => {
|
30
|
+
DataFetcher.get()
|
31
|
+
.callGraphQL({
|
32
|
+
values,
|
33
|
+
query: this._templateByQuery.get("search"),
|
34
|
+
})
|
35
|
+
.then((result) => {
|
36
|
+
resolve(result);
|
37
|
+
})
|
38
|
+
.catch((error) => {
|
39
|
+
reject(error);
|
40
|
+
});
|
41
|
+
});
|
42
|
+
}
|
43
|
+
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
44
|
+
var _a, _b, _c;
|
45
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
46
|
+
const values = {
|
47
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
48
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
49
|
+
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
50
|
+
};
|
51
|
+
const serviceName = "PesquisaSP.getSuggestion";
|
52
|
+
const externalCriteria = {
|
53
|
+
query: {
|
54
|
+
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
55
|
+
}
|
56
|
+
};
|
57
|
+
if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
|
58
|
+
externalCriteria.params = {
|
59
|
+
param: values.criteria.params.map(param => {
|
60
|
+
let value = param.value;
|
61
|
+
let type = param.dataType;
|
62
|
+
if (type === DataType.OBJECT) {
|
63
|
+
value = value.value;
|
64
|
+
type = "S";
|
65
|
+
}
|
66
|
+
else {
|
67
|
+
type = convertParamType(param.dataType);
|
68
|
+
}
|
69
|
+
return { $: value, type };
|
70
|
+
})
|
71
|
+
};
|
72
|
+
}
|
73
|
+
const options = searchOptions != undefined
|
74
|
+
? {
|
75
|
+
"pkFieldName": searchOptions.codeFieldName,
|
76
|
+
"label": searchOptions.descriptionFieldName,
|
77
|
+
"fieldName": searchOptions.codeFieldName,
|
78
|
+
"useDescriptionOptions": false,
|
79
|
+
"enableRowsCounter": true
|
80
|
+
}
|
81
|
+
: undefined;
|
82
|
+
const reqBody = {
|
83
|
+
"serviceName": serviceName,
|
84
|
+
"requestBody": {
|
85
|
+
"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 }),
|
86
|
+
"clientEventList": {
|
87
|
+
"clientEvent": []
|
88
|
+
}
|
89
|
+
}
|
90
|
+
};
|
91
|
+
return new Promise((resolve, reject) => {
|
92
|
+
DataFetcher.get()
|
93
|
+
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
94
|
+
.then(result => resolve(result))
|
95
|
+
.catch(error => reject(error));
|
96
|
+
});
|
97
|
+
}
|
98
|
+
addSearchListener(entityName, dataUnitID, listener) {
|
99
|
+
var _a;
|
100
|
+
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
101
|
+
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
102
|
+
if (!entityListener) {
|
103
|
+
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
104
|
+
}
|
105
|
+
else {
|
106
|
+
for (const type of Object.keys(listener)) {
|
107
|
+
if (type in entityListener.listener) {
|
108
|
+
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
109
|
+
if (listenerFunctionIsEquals)
|
110
|
+
continue;
|
111
|
+
entityListener.listener[type] = listener[type];
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
return () => {
|
116
|
+
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
117
|
+
if (!newListeners.length) {
|
118
|
+
this._searchListenersByDataUnit.delete(dataUnitID);
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
122
|
+
};
|
123
|
+
}
|
124
|
+
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
125
|
+
var _a;
|
126
|
+
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
127
|
+
if (!dataUnitId)
|
128
|
+
return;
|
129
|
+
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
130
|
+
if (!entityListener)
|
131
|
+
return;
|
132
|
+
const { listener } = entityListener;
|
133
|
+
if (!(listenerType in listener))
|
134
|
+
return;
|
135
|
+
return listener[listenerType]({ argument, criteria, searchOptions });
|
136
|
+
}
|
137
|
+
}
|
138
|
+
function convertParamType(dataType) {
|
139
|
+
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
140
|
+
//atual da pesquisa... em geral, somente inteiros,
|
141
|
+
//data (com ou sem hora) e string são realmente relevantes
|
142
|
+
switch (dataType) {
|
143
|
+
case DataType.NUMBER:
|
144
|
+
return "I";
|
145
|
+
case DataType.DATE:
|
146
|
+
return "D";
|
147
|
+
default:
|
148
|
+
return "S";
|
149
|
+
}
|
150
|
+
}
|
151
|
+
var SearchListenerType;
|
152
|
+
(function (SearchListenerType) {
|
153
|
+
SearchListenerType["beforeSearch"] = "beforeSearch";
|
154
|
+
})(SearchListenerType || (SearchListenerType = {}));
|
155
|
+
|
156
|
+
export { PesquisaFetcher as P };
|