@sankhyalabs/sankhyablocks 4.7.0 → 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/pesquisa-fetcher-a3f0954f.js +158 -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-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/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +6 -2
- package/dist/components/pesquisa-fetcher.js +156 -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 +1 -0
- package/dist/esm/pesquisa-fetcher-e60477d1.js +156 -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-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/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
@@ -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,154 +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._searchListenersByDataUnit = new Map();
|
75
|
-
this.buldTemplates();
|
76
|
-
}
|
77
|
-
buldTemplates() {
|
78
|
-
this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
79
|
-
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
80
|
-
value
|
81
|
-
label
|
82
|
-
}
|
83
|
-
}`);
|
84
|
-
}
|
85
|
-
loadSearchOptions(entityName, argument, criteria, options) {
|
86
|
-
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
87
|
-
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
88
|
-
const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, options);
|
89
|
-
const values = {
|
90
|
-
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
91
|
-
entityName,
|
92
|
-
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
93
|
-
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
94
|
-
};
|
95
|
-
return new Promise((resolve, reject) => {
|
96
|
-
DataFetcher.get()
|
97
|
-
.callGraphQL({
|
98
|
-
values,
|
99
|
-
query: this._templateByQuery.get("search"),
|
100
|
-
})
|
101
|
-
.then((result) => {
|
102
|
-
resolve(result);
|
103
|
-
})
|
104
|
-
.catch((error) => {
|
105
|
-
reject(error);
|
106
|
-
});
|
107
|
-
});
|
108
|
-
}
|
109
|
-
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
110
|
-
var _a, _b, _c;
|
111
|
-
const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, searchOptions);
|
112
|
-
const values = {
|
113
|
-
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
114
|
-
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
115
|
-
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
116
|
-
};
|
117
|
-
const serviceName = "PesquisaSP.getSuggestion";
|
118
|
-
const externalCriteria = {
|
119
|
-
query: {
|
120
|
-
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
121
|
-
}
|
122
|
-
};
|
123
|
-
if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
|
124
|
-
externalCriteria.params = {
|
125
|
-
param: values.criteria.params.map(param => {
|
126
|
-
let value = param.value;
|
127
|
-
let type = param.dataType;
|
128
|
-
if (type === DataType.OBJECT) {
|
129
|
-
value = value.value;
|
130
|
-
type = "S";
|
131
|
-
}
|
132
|
-
else {
|
133
|
-
type = convertParamType(param.dataType);
|
134
|
-
}
|
135
|
-
return { $: value, type };
|
136
|
-
})
|
137
|
-
};
|
138
|
-
}
|
139
|
-
const options = searchOptions != undefined
|
140
|
-
? {
|
141
|
-
"pkFieldName": searchOptions.codeFieldName,
|
142
|
-
"label": searchOptions.descriptionFieldName,
|
143
|
-
"fieldName": searchOptions.codeFieldName,
|
144
|
-
"useDescriptionOptions": false,
|
145
|
-
"enableRowsCounter": true
|
146
|
-
}
|
147
|
-
: undefined;
|
148
|
-
const reqBody = {
|
149
|
-
"serviceName": serviceName,
|
150
|
-
"requestBody": {
|
151
|
-
"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 }),
|
152
|
-
"clientEventList": {
|
153
|
-
"clientEvent": []
|
154
|
-
}
|
155
|
-
}
|
156
|
-
};
|
157
|
-
return new Promise((resolve, reject) => {
|
158
|
-
DataFetcher.get()
|
159
|
-
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
160
|
-
.then(result => resolve(result))
|
161
|
-
.catch(error => reject(error));
|
162
|
-
});
|
163
|
-
}
|
164
|
-
addSearchListener(entityName, dataUnitID, listener) {
|
165
|
-
var _a;
|
166
|
-
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
167
|
-
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
168
|
-
if (!entityListener) {
|
169
|
-
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
170
|
-
}
|
171
|
-
else {
|
172
|
-
for (const type of Object.keys(listener)) {
|
173
|
-
if (type in entityListener.listener) {
|
174
|
-
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
175
|
-
if (listenerFunctionIsEquals)
|
176
|
-
continue;
|
177
|
-
entityListener.listener[type] = listener[type];
|
178
|
-
}
|
179
|
-
}
|
180
|
-
}
|
181
|
-
return () => {
|
182
|
-
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
183
|
-
if (!newListeners.length) {
|
184
|
-
this._searchListenersByDataUnit.delete(dataUnitID);
|
185
|
-
return;
|
186
|
-
}
|
187
|
-
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
188
|
-
};
|
189
|
-
}
|
190
|
-
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
191
|
-
var _a;
|
192
|
-
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
193
|
-
if (!dataUnitId)
|
194
|
-
return;
|
195
|
-
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
196
|
-
if (!entityListener)
|
197
|
-
return;
|
198
|
-
const { listener } = entityListener;
|
199
|
-
if (!(listenerType in listener))
|
200
|
-
return;
|
201
|
-
return listener[listenerType]({ argument, criteria, searchOptions });
|
202
|
-
}
|
203
|
-
}
|
204
|
-
function convertParamType(dataType) {
|
205
|
-
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
206
|
-
//atual da pesquisa... em geral, somente inteiros,
|
207
|
-
//data (com ou sem hora) e string são realmente relevantes
|
208
|
-
switch (dataType) {
|
209
|
-
case DataType.NUMBER:
|
210
|
-
return "I";
|
211
|
-
case DataType.DATE:
|
212
|
-
return "D";
|
213
|
-
default:
|
214
|
-
return "S";
|
215
|
-
}
|
216
|
-
}
|
217
|
-
|
218
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);
|
219
72
|
|
220
73
|
class TotalsFetcher {
|
@@ -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';
|
@@ -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 };
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-cfd4bb13.js';
|
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-5e99fa75.js';
|
4
4
|
import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
5
|
+
import { P as PesquisaFetcher } from './pesquisa-fetcher-e60477d1.js';
|
5
6
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-ec0850af.js';
|
6
7
|
import { G as GridConfigFetcher, C as ConfigStorage } from './ConfigStorage-1b64cd96.js';
|
7
8
|
import { R as ResourceFetcher } from './form-config-fetcher-677f86dd.js';
|
@@ -67,154 +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._searchListenersByDataUnit = new Map();
|
75
|
-
this.buldTemplates();
|
76
|
-
}
|
77
|
-
buldTemplates() {
|
78
|
-
this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
79
|
-
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
80
|
-
value
|
81
|
-
label
|
82
|
-
}
|
83
|
-
}`);
|
84
|
-
}
|
85
|
-
loadSearchOptions(entityName, argument, criteria, options) {
|
86
|
-
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
87
|
-
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
88
|
-
const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, options);
|
89
|
-
const values = {
|
90
|
-
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
91
|
-
entityName,
|
92
|
-
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
93
|
-
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
94
|
-
};
|
95
|
-
return new Promise((resolve, reject) => {
|
96
|
-
DataFetcher.get()
|
97
|
-
.callGraphQL({
|
98
|
-
values,
|
99
|
-
query: this._templateByQuery.get("search"),
|
100
|
-
})
|
101
|
-
.then((result) => {
|
102
|
-
resolve(result);
|
103
|
-
})
|
104
|
-
.catch((error) => {
|
105
|
-
reject(error);
|
106
|
-
});
|
107
|
-
});
|
108
|
-
}
|
109
|
-
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
110
|
-
var _a, _b, _c;
|
111
|
-
const listenerResult = this.applySearchListener('beforeSearch', entityName, argument, criteria, searchOptions);
|
112
|
-
const values = {
|
113
|
-
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
114
|
-
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
115
|
-
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
116
|
-
};
|
117
|
-
const serviceName = "PesquisaSP.getSuggestion";
|
118
|
-
const externalCriteria = {
|
119
|
-
query: {
|
120
|
-
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
121
|
-
}
|
122
|
-
};
|
123
|
-
if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
|
124
|
-
externalCriteria.params = {
|
125
|
-
param: values.criteria.params.map(param => {
|
126
|
-
let value = param.value;
|
127
|
-
let type = param.dataType;
|
128
|
-
if (type === DataType.OBJECT) {
|
129
|
-
value = value.value;
|
130
|
-
type = "S";
|
131
|
-
}
|
132
|
-
else {
|
133
|
-
type = convertParamType(param.dataType);
|
134
|
-
}
|
135
|
-
return { $: value, type };
|
136
|
-
})
|
137
|
-
};
|
138
|
-
}
|
139
|
-
const options = searchOptions != undefined
|
140
|
-
? {
|
141
|
-
"pkFieldName": searchOptions.codeFieldName,
|
142
|
-
"label": searchOptions.descriptionFieldName,
|
143
|
-
"fieldName": searchOptions.codeFieldName,
|
144
|
-
"useDescriptionOptions": false,
|
145
|
-
"enableRowsCounter": true
|
146
|
-
}
|
147
|
-
: undefined;
|
148
|
-
const reqBody = {
|
149
|
-
"serviceName": serviceName,
|
150
|
-
"requestBody": {
|
151
|
-
"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 }),
|
152
|
-
"clientEventList": {
|
153
|
-
"clientEvent": []
|
154
|
-
}
|
155
|
-
}
|
156
|
-
};
|
157
|
-
return new Promise((resolve, reject) => {
|
158
|
-
DataFetcher.get()
|
159
|
-
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
160
|
-
.then(result => resolve(result))
|
161
|
-
.catch(error => reject(error));
|
162
|
-
});
|
163
|
-
}
|
164
|
-
addSearchListener(entityName, dataUnitID, listener) {
|
165
|
-
var _a;
|
166
|
-
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
167
|
-
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
168
|
-
if (!entityListener) {
|
169
|
-
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
170
|
-
}
|
171
|
-
else {
|
172
|
-
for (const type of Object.keys(listener)) {
|
173
|
-
if (type in entityListener.listener) {
|
174
|
-
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
175
|
-
if (listenerFunctionIsEquals)
|
176
|
-
continue;
|
177
|
-
entityListener.listener[type] = listener[type];
|
178
|
-
}
|
179
|
-
}
|
180
|
-
}
|
181
|
-
return () => {
|
182
|
-
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
183
|
-
if (!newListeners.length) {
|
184
|
-
this._searchListenersByDataUnit.delete(dataUnitID);
|
185
|
-
return;
|
186
|
-
}
|
187
|
-
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
188
|
-
};
|
189
|
-
}
|
190
|
-
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
191
|
-
var _a;
|
192
|
-
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
193
|
-
if (!dataUnitId)
|
194
|
-
return;
|
195
|
-
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
196
|
-
if (!entityListener)
|
197
|
-
return;
|
198
|
-
const { listener } = entityListener;
|
199
|
-
if (!(listenerType in listener))
|
200
|
-
return;
|
201
|
-
return listener[listenerType]({ argument, criteria, searchOptions });
|
202
|
-
}
|
203
|
-
}
|
204
|
-
function convertParamType(dataType) {
|
205
|
-
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
206
|
-
//atual da pesquisa... em geral, somente inteiros,
|
207
|
-
//data (com ou sem hora) e string são realmente relevantes
|
208
|
-
switch (dataType) {
|
209
|
-
case DataType.NUMBER:
|
210
|
-
return "I";
|
211
|
-
case DataType.DATE:
|
212
|
-
return "D";
|
213
|
-
default:
|
214
|
-
return "S";
|
215
|
-
}
|
216
|
-
}
|
217
|
-
|
218
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);
|
219
72
|
|
220
73
|
class TotalsFetcher {
|
@@ -2,6 +2,7 @@ import { r as registerInstance, c as createEvent, h, g as getElement } from './i
|
|
2
2
|
import { ElementIDUtils, ApplicationContext } from '@sankhyalabs/core';
|
3
3
|
import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
|
4
4
|
import './DataFetcher-5e99fa75.js';
|
5
|
+
import './pesquisa-fetcher-e60477d1.js';
|
5
6
|
import { P as PresentationMode } from './index-6519a79e.js';
|
6
7
|
import { c as VIEW_MODE } from './constants-15617e7d.js';
|
7
8
|
import './index-e467ade5.js';
|
@@ -2,11 +2,12 @@ import { r as registerInstance, c as createEvent, f as forceUpdate, h, H as Host
|
|
2
2
|
import { S as SnkFormConfigManager } from './SnkFormConfigManager-0d9752c3.js';
|
3
3
|
import { FormMetadata, buildFormMetadata } from '@sankhyalabs/ezui/dist/collection/utils/form';
|
4
4
|
import './DataFetcher-5e99fa75.js';
|
5
|
+
import './pesquisa-fetcher-e60477d1.js';
|
5
6
|
import '@sankhyalabs/core';
|
6
7
|
import { P as PresentationMode } from './index-6519a79e.js';
|
7
8
|
import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
|
8
9
|
import { c as VIEW_MODE } from './constants-15617e7d.js';
|
9
|
-
import { S as SnkGuidesViewer } from './snk-guides-viewer-
|
10
|
+
import { S as SnkGuidesViewer } from './snk-guides-viewer-3a29e72b.js';
|
10
11
|
import './ConfigStorage-1b64cd96.js';
|
11
12
|
import './form-config-fetcher-677f86dd.js';
|
12
13
|
import './_commonjsHelpers-9943807e.js';
|
@@ -6,6 +6,7 @@ import { T as TaskbarProcessor } from './taskbar-processor-94402e6e.js';
|
|
6
6
|
import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
|
7
7
|
import { c as VIEW_MODE } from './constants-15617e7d.js';
|
8
8
|
import './DataFetcher-5e99fa75.js';
|
9
|
+
import './pesquisa-fetcher-e60477d1.js';
|
9
10
|
import { P as PresentationMode } from './index-6519a79e.js';
|
10
11
|
|
11
12
|
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}";
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { S as snk_guides_viewer } from './snk-guides-viewer-
|
1
|
+
export { S as snk_guides_viewer } from './snk-guides-viewer-3a29e72b.js';
|
2
2
|
import './index-cfd4bb13.js';
|
3
3
|
import '@sankhyalabs/core';
|
4
4
|
import './SnkFormConfigManager-0d9752c3.js';
|
@@ -12,3 +12,4 @@ import './taskbar-elements-10d80c79.js';
|
|
12
12
|
import './index-6519a79e.js';
|
13
13
|
import './index-e467ade5.js';
|
14
14
|
import './constants-15617e7d.js';
|
15
|
+
import './pesquisa-fetcher-e60477d1.js';
|
@@ -3,6 +3,7 @@ import { DataUnit, StringUtils, SortMode, DataType, ChangeOperation, ObjectUtils
|
|
3
3
|
import { c as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants-15617e7d.js';
|
4
4
|
import { T as TaskbarElement } from './taskbar-elements-10d80c79.js';
|
5
5
|
import './DataFetcher-5e99fa75.js';
|
6
|
+
import './pesquisa-fetcher-e60477d1.js';
|
6
7
|
import { P as PresentationMode } from './index-6519a79e.js';
|
7
8
|
import { T as TaskbarProcessor } from './taskbar-processor-94402e6e.js';
|
8
9
|
import './index-e467ade5.js';
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as i,c as e,h as s,F as t}from"./p-b9667fbe.js";import{ApplicationContext as r,ElementIDUtils as a}from"@sankhyalabs/core";import{S as n}from"./p-a6258eed.js";import{buildFormMetadata as d,FormMetadata as o}from"@sankhyalabs/ezui/dist/collection/utils/form";import{T as h}from"./p-c2beb95c.js";import{T as l}from"./p-74724fa7.js";import{c as u}from"./p-f587a454.js";import"./p-0c11c980.js";import"./p-a81f0854.js";import{P as v}from"./p-f132e371.js";const g="__FORM:",c=class{constructor(s){i(this,s),this.exit=e(this,"exit",7),this.actionClick=e(this,"actionClick",7),this._branchesCache=new Map,this.dataUnit=void 0,this.dataState=void 0,this.configName=void 0,this.entityPath=void 0,this.actionsList=void 0,this.recordsValidator=void 0,this.masterFormConfig=void 0,this.selectedGuide=void 0,this.taskbarManager=void 0,this.presentationMode=void 0,this._breadcrumbItems=[],this._guides=void 0,this._formEditorConfigManager=void 0,this._formEditorDataUnit=void 0}observeDataUnit(){this.loadGuides(!0)}observeDataState(i,e){this.loadGuides((null==e?void 0:e.insertionMode)!=(null==i?void 0:i.insertionMode))}observeMasterFormConfig(){this.loadGuides(!1)}async showFormConfig(i=!1){const e=!i||null==this._currentDetail;this._formEditorConfigManager=e?this._configManager:this._currentDetail.formConfigManager,this._formEditorDataUnit=e?this.dataUnit:this._currentDetail.dataUnit}exitViewer(){this.dataUnit.isDirty()?this.dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}onActionClick(i){i.detail===l.CONFIGURATOR&&"master"!=i.target.dataset.taskbarOwner&&(this._snkConfigurator.open(),i.stopImmediatePropagation(),i.stopPropagation())}onContentCardChanged(i){c.updateContentCard(i.detail.formName,i.detail.cardConfig,i.detail.propertyChanged,this._configManager).then((()=>this.masterFormConfig=this._configManager.getConfig(this.dataState.insertionMode,this.dataUnit)))}getMessage(i){return this._application.messagesBuilder.getMessage(i,this.dataUnit.getSelectedRecord())}loadGuides(i){if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this._masterFormMetadata=d(this.masterFormConfig,this.dataUnit,!0);const e=this._masterFormMetadata.getAllSheets(),s=this.dataUnit.getSelectedRecord(),t=!s||this.dataUnit.isNewRecord(s.__record__id__),r=[];Array.from(e.values()).forEach((i=>{const e={id:i.name,label:i.label};this.isDetail(i.name)&&t&&(e.tooltip="Para alterar detalhes é necessário estar com um registro selecionado.",e.disabled=!0),r.push(e)})),this._guides=r,i&&(this.selectedGuide=this._guides.length>0?this._guides[0]:void 0)}isDetail(i){return null!=o.getDetailName(i)}getChildrenMap(i){if(i&&Array.isArray(i.children))return new Map(i.children.map((i=>[i.id,i])))}restoreBranch(i,e){if(!e)return;const s=this.getChildrenMap(this._branchesCache.get(e));Array.isArray(i.children)&&s&&i.children.forEach((i=>{const e=s.get(i.id);e&&(i.children=e.children,i.expanded=e.expanded)})),this._branchesCache.set(e,i)}updateGuide(i,{item:e,recordId:s}){e&&this.restoreBranch(e,s),this._guideNavigator&&this._guideNavigator.getItem(i).then((i=>{i&&(i.children=e?[e]:void 0,i.expanded=!0,this._guideNavigator.updateItem(i),this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i})))}))}loadTaskbarProcessor(){var i,e;const s=(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkGuideViewer.finish_edition":"snkGuideViewer.regular",t=[];this.dataState&&this.dataState.hasPrevious||t.push("PREVIOUS"),this.dataState&&this.dataState.hasNext||t.push("NEXT"),(null===(e=this.dataState)||void 0===e?void 0:e.selectionInfo)&&(this.dataState.selectionInfo.length>1&&t.push("CLONE"),this.dataState.selectionInfo.isAllRecords()&&t.push("REMOVE"));const r=["PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","GRID_MODE","CONFIGURATOR"];this.presentationMode==v.SECONDARY?r.unshift("INSERT"):r.push("INSERT"),this._taskbarProcessor=new h({"snkGuideViewer.regular":r,"snkGuideViewer.finish_edition":["CANCEL","SAVE"]}),this._taskbarProcessor.process(s,this.taskbarManager,this.dataState,t)}static updateContentCard(i,e,s,t){return t.saveCardState(i,e,s)}static buildFixedForms(i,e,r,a,n,d){const o=null==i?void 0:i.cardsState;if(null!=o)return s(t,null,Array.from(o.entries()).filter((([i,e])=>(null==e?void 0:e.fixed)&&i!=r)).sort((([,i],[,e])=>((null==i?void 0:i.fixSequence)||0)-((null==e?void 0:e.fixSequence)||0))).map((([t,r])=>{var o;const h=e.getSheet(t);if(null!=h)return s("snk-form-view",{levelPath:d,label:h.label,name:t,fields:h.fields,formMetadata:e,dataUnit:a,recordsValidator:n,contracted:"CONTRACTED"===(null==r?void 0:r.presentation),fixed:null==r?void 0:r.fixed,summaryFields:null===(o=null==i?void 0:i.summary)||void 0===o?void 0:o.get(t),key:t})})))}wrapDetail(i,e){if(0===i.length)return e;const t=i.pop(),r=o.getDetailName(t);return r?this.wrapDetail(i,s("snk-data-unit",{dataUnitName:`${this.getDataUnitName(i,r)}`,entityName:r},e)):void 0}getDataUnitName(i,e){if(i.length>0){const s=i.map((i=>o.getDetailName(i)));return`${this.entityPath}/${s.join("/")}/${e}`}return`${this.entityPath}/${e}`}getContent(){var i,e,t,r;if(!this.selectedGuide)return;const a=this.selectedGuide.id;let n;const d=a.split("::"),h=d.pop(),l=o.getDetailName(h);let u=a;if(l||d.length>0){let i;a.includes(g)&&([u,i]=a.split(g)),n=this.wrapDetail(d,s("snk-detail-view",{ref:i=>this._currentDetail=i,dataUnitName:this.getDataUnitName(d,l),onSnkDetailGuidesChange:i=>this.updateGuide(u,i.detail),entityName:l,selectedForm:i,guideItemPath:this._breadcrumbItems,key:`detail${u}`,onSnkSwitchGuide:i=>this._guideNavigator.selectGuide(i.detail)}))}else{const d=this.selectedGuide.id,o=this._masterFormMetadata.getSheet(d);if(o){const h=null===(e=null===(i=this.masterFormConfig)||void 0===i?void 0:i.cardsState)||void 0===e?void 0:e.get(d);n=s("snk-form-view",{ref:i=>this._mainForm=i,fixed:null==h?void 0:h.fixed,summaryFields:null===(r=null===(t=this.masterFormConfig)||void 0===t?void 0:t.summary)||void 0===r?void 0:r.get(d),name:d,label:o.label,fields:o.fields,dataUnit:this.dataUnit,formMetadata:this._masterFormMetadata,recordsValidator:this.recordsValidator,key:a},this.presentationMode==v.SECONDARY&&this.buildTaskBar())}}return n}onBreadcrumbClickHandler(i){null!=(null==i?void 0:i.id)&&this._guideNavigator.selectGuide(i.id)}updateSelectedGuideHandler(i){this._guideHasChanged=this.selectedGuide!=i,this.selectedGuide=i,this._guideNavigator.getCurrentPath().then((i=>{this._breadcrumbItems=i}))}getConfigViewMode(){return u.GRID}changeConfigViewMode(i){this._currentDetail&&this._currentDetail.changeViewMode(i)}openConfig(i){this._snkConfigurator.close(),this._currentDetail&&(i===u.FORM?this.showFormConfig(!0):this._currentDetail.configGrid())}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__"),this._configManager=new n(this.configName,(i=>this.masterFormConfig=i)),this._configManager.loadConfig()}componentDidRender(){this._guideHasChanged&&(this._currentDetail?this._currentDetail.showUp():this._mainForm&&this._mainForm.showUp(),this._guideHasChanged=!1)}buildTaskBar(){var i;return s("div",{class:"ez-col ez-flex-item--align-center ez-col--sd-6 ez-col--tb-6 "+(this.presentationMode!=v.SECONDARY?"ez-align--right":"ez-padding-bottom--medium")},s("snk-taskbar",{key:"guideViewerTaskbar","data-element-id":"guideViewer",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.actionsList,presentationMode:this.presentationMode,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-taskbar-owner":"master",dataUnit:this.dataUnit}))}render(){var i,e;if(null!=this._formEditorConfigManager)return s("snk-form-config",{dataUnit:this._formEditorDataUnit,configManager:this._formEditorConfigManager,onConfigClose:()=>this._formEditorConfigManager=null});if(!this.dataUnit)return;if(!this._configManager.isLoaded)return;this.loadTaskbarProcessor();const t=this._guides&&this._guides.length>1;return s("section",{class:"snk-guides-viewer"},s("div",{class:"ez-row snk-guides-viewer__header"},s("div",{class:"ez-col ez-col--sd-6 ez-col--tb-6 ez-flex--align-items-center ez-flex-item--align-center ez-padding-left--large",key:"header"},s("ez-button",{onClick:()=>this.exitViewer(),title:this.getMessage("snkCrud.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small"}),s("div",{class:"ez-flex ez-flex--column ez-flex-item--auto"},s("h1",{class:"ez-title ez-title--primary ez-title--xlarge"},this.getMessage("snkCrud.title")),(null===(i=this._breadcrumbItems)||void 0===i?void 0:i.length)>1&&s("div",{class:"ez-margin-top--extra-small"},s("ez-breadcrumb",Object.assign({items:this._breadcrumbItems,onSelectedItem:i=>this.onBreadcrumbClickHandler(null==i?void 0:i.detail)},{[a.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${a.getInternalIDInfo("breadcrumb")}`}))))),this.presentationMode!=v.SECONDARY&&this.buildTaskBar()),s("div",{class:t?"snk-guides-viewer__container":void 0},t&&s("ez-guide-navigator",{ref:i=>this._guideNavigator=i,class:"snk-guides-viewer__guide-navigator",items:this._guides,selectedId:this.selectedGuide?this.selectedGuide.id:void 0,onEzChange:i=>this.updateSelectedGuideHandler(i.detail)}),s("div",{class:"snk-guides-viewer__detail-container"},c.buildFixedForms(this.masterFormConfig,this._masterFormMetadata,null===(e=this.selectedGuide)||void 0===e?void 0:e.id,this.dataUnit,this.recordsValidator),this.getContent())),s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this.getConfigViewMode(),onConfigSelected:i=>this.changeConfigViewMode(i.detail),onOpenConfig:i=>this.openConfig(i.detail)}))}static get watchers(){return{dataUnit:["observeDataUnit"],dataState:["observeDataState"],masterFormConfig:["observeMasterFormConfig"]}}};c.style=".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}";export{c as S}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as i,f as s,h as e,H as a}from"./p-b9667fbe.js";import{S as o}from"./p-a6258eed.js";import{FormMetadata as h,buildFormMetadata as r}from"@sankhyalabs/ezui/dist/collection/utils/form";import"./p-0c11c980.js";import"./p-a81f0854.js";import"@sankhyalabs/core";import{P as n}from"./p-f132e371.js";import{T as d}from"./p-74724fa7.js";import{c as l}from"./p-f587a454.js";import{S as c}from"./p-1da34865.js";import"./p-3c4823fc.js";import"./p-9f98fc3c.js";import"./p-112455b1.js";import"./p-98f7f796.js";import"./p-c2beb95c.js";const u=class{constructor(s){t(this,s),this.snkDetailGuidesChange=i(this,"snkDetailGuidesChange",7),this.snkSwitchGuide=i(this,"snkSwitchGuide",7),this._disabledButtons=void 0,this.formConfigManager=void 0,this.dataUnitName=void 0,this.guideItemPath=void 0,this.entityName=void 0,this.label=void 0,this.dataUnit=void 0,this.selectedForm=void 0,this.dataState=void 0}observerDataState(t,i){var s;const e=!(null==i?void 0:i.insertionMode)&&(null==t?void 0:t.insertionMode),a=(null==i?void 0:i.insertionMode)&&!(null==t?void 0:t.insertionMode);if((e||a)&&this.loadMetadata(),null==this._formMetadata)return;const o=null===(s=this.dataState)||void 0===s?void 0:s.selectedRecord,h=this.getNewGuideItem(o);this.snkDetailGuidesChange.emit({item:h,recordId:null==o?void 0:o.__record__id__}),e&&setTimeout((()=>{this.changeViewMode(l.FORM)}),0),a&&this.changeViewMode(l.GRID);const r=[];this.dataState.hasPrevious||r.push(d.PREVIOUS),this.dataState.hasNext||r.push(d.NEXT),this._disabledButtons=r}async changeViewMode(t){this.emitSwitchEvent(t)}async configGrid(){this._snkGrid&&this._snkGrid.showConfig()}async showUp(){this._snkFormView&&this._snkFormView.showUp(),this._snkGrid&&this._snkGrid.scrollIntoView({behavior:"smooth",block:"start"})}onContentCardChanged(t){c.updateContentCard(t.detail.formName,t.detail.cardConfig,t.detail.propertyChanged,this.formConfigManager).then((()=>s(this))),t.stopPropagation()}updateLabel(){const t=this.guideItemPath?this.guideItemPath.length:0;if(t>0){const i=t>0?this.guideItemPath.map((t=>t.label)):void 0;this.label=i.pop(),this._levelPath=i.length>0?i.join(" / "):void 0,this._guideId=this.guideItemPath[t-1].id}else this.label="",this._levelPath=void 0,this._guideId=void 0}getNewGuideItem(t){if(null==t)return;const i=this.dataUnit.isNewRecord(t.__record__id__),s=Array.from(this._formMetadata.getAllSheets().values()).map((t=>{const{name:s,label:e}=t,a=null!=h.getDetailName(s.split("::").pop()),o=a&&i;return{id:a?this.getChildGuideId(s):this.getFormGuideId(s),label:e,disabled:o,tooltip:o?"Finalize o cadastro para ter acesso a esta guia.":void 0}})),e=s.shift();return e.label=i?"Novo Registro":t.__record__label__,e.children=s,e.expanded=!0,e}getFormGuideId(t){var i;if(!t){if(null==(null===(i=this.dataState)||void 0===i?void 0:i.selectedRecord))return;const s=Array.from(this._formMetadata.getAllSheets().keys());if(!s||0==s.length)return;t=s[0]}return`${this.stripFormPattern(this._guideId)}__FORM:${t}`}getChildGuideId(t){return`${this.stripFormPattern(this._guideId)}::${t}`}stripFormPattern(t){return t.replace(u.REGEX_FORM_ID,"")}loadMetadata(){var t;if(!this.dataUnit)return;if(!this.formConfigManager.isLoaded)return;const i=this.formConfigManager.getConfig(null===(t=this.dataState)||void 0===t?void 0:t.insertionMode,this.dataUnit);this._formMetadata=r(null==i||0===i.fields.length?void 0:i,this.dataUnit,!0)}dataUnitReadyHandler(t){this.dataUnit=t.detail,this.loadMetadata()}updateViewStack(t){t.show(this.selectedForm?1:0)}getFormFields(){return this.selectedForm&&this._formMetadata?this._formMetadata.getSheet(this.selectedForm).fields:[]}emitSwitchEvent(t){const i=t===l.GRID?this.stripFormPattern(this._guideId):this.getFormGuideId();i&&this.snkSwitchGuide.emit(i)}executeActionHandler(t){t.detail===d.GRID_MODE&&(this.emitSwitchEvent(l.GRID),t.stopPropagation()),t.detail===d.FORM_MODE&&(this.emitSwitchEvent(l.FORM),t.stopPropagation())}componentWillLoad(){this._configName=`dynaform.${this.entityName}`,this.formConfigManager=new o(this._configName,(()=>this.loadMetadata())),this.formConfigManager.loadConfig()}render(){return this.updateLabel(),e(a,null,e("snk-data-unit",{dataUnitName:`${this.dataUnitName}`,onDataUnitReady:t=>this.dataUnitReadyHandler(t),entityName:this.entityName,onDataStateChange:t=>this.dataState=t.detail},e("ez-view-stack",{ref:t=>this.updateViewStack(t)},e("stack-item",null,e("div",{class:"ez-box ez-box--shadow grid-container"},e("div",{class:"ez-flex ez-size-width--full ez-padding--large detail-header"},e("div",{class:"ez-flex ez-text ez-text--bold ez-flex--justify-start ez-flex--align-items-center"},this._levelPath?e("span",{class:"level-path"},this._levelPath+" /"):void 0,this.label)),e("snk-grid",{class:"ez-size-width--full ez-size-height--full",ref:t=>this._snkGrid=t,configName:this._configName,onGridDoubleClick:()=>this.emitSwitchEvent(l.FORM),onActionClick:t=>this.executeActionHandler(t),presentationMode:n.SECONDARY}))),e("stack-item",null,e("snk-form-view",{ref:t=>this._snkFormView=t,canExpand:!1,canFix:!1,name:this.selectedForm,formMetadata:this._formMetadata,dataUnit:this.dataUnit,fields:this.getFormFields(),label:this.label,levelPath:this._levelPath},e("snk-taskbar",{key:"guideViewerTaskbar",class:"form-taskbar","data-element-id":"guideViewer",configName:this._configName,disabledButtons:this._disabledButtons,buttons:"INSERT,PREVIOUS,NEXT,DIVIDER,CLONE,REMOVE,MORE_OPTIONS,DIVIDER,GRID_MODE,CONFIGURATOR",primaryButton:"INSERT",presentationMode:n.SECONDARY,onActionClick:t=>this.executeActionHandler(t),dataUnit:this.dataUnit}))))))}static get watchers(){return{dataState:["observerDataState"]}}};u.REGEX_FORM_ID=/__FORM:[^:]+/g,u.style=".sc-snk-detail-view-h{display:flex;row-gap:24px;flex-direction:column;width:100%;height:100%}.level-path.sc-snk-detail-view{color:var(--color--title-primary, #2B3A54);font-weight:var(--text-weight--medium, 400);padding-right:3px}.form-taskbar.sc-snk-detail-view{padding-bottom:var(--space--medium)}.grid-container.sc-snk-detail-view{background-color:#FFF;min-height:100px}.detail-header.sc-snk-detail-view{padding-bottom:0}";export{u as snk_detail_view}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as t,c as i,h as s,g as e}from"./p-b9667fbe.js";import{ElementIDUtils as h,ApplicationContext as a}from"@sankhyalabs/core";import{T as o}from"./p-74724fa7.js";import"./p-0c11c980.js";import"./p-a81f0854.js";import{P as n}from"./p-f132e371.js";import{c as r}from"./p-f587a454.js";import"./p-98f7f796.js";import"./p-112455b1.js";const d=class{constructor(s){t(this,s),this.actionClick=i(this,"actionClick",7),this._dataUnit=void 0,this._dataState=void 0,this._currentViewMode=r.GRID,this.configName=void 0,this.actionsList=void 0,this.taskbarManager=void 0,this.recordsValidator=void 0,this.statusResolver=void 0,this.multipleSelection=!0,this.presentationMode=n.PRIMARY}async goToView(t){this.executeAction(t)}async gridToForm(t=!1){this._backToGrid=!t&&await this._viewStack.getSelectedIndex()===r.GRID,this.setViewMode(r.FORM)}async executeAction(t){t===o.GRID_MODE?this.setViewMode(r.GRID):t===o.FORM_MODE||t===o.UPDATE?this.gridToForm(t!==o.UPDATE):t===o.CONFIGURATOR&&this._snkConfigurator.open()}setViewMode(t){this._viewStack.show(t),this._currentViewMode=t}openConfig(t){this._snkConfigurator.close(),t===r.GRID?this._snkGrid.showConfig():t===r.FORM&&this._guidesViewer.showFormConfig()}addDataElementID(){h.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this.setViewMode(r.GRID)}componentWillLoad(){let t=this._element.parentElement;for(;t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.addDataElementID():this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail,this.addDataElementID()})),this._snkDataUnit.addEventListener("dataStateChange",(t=>{this._dataState=t.detail}));break}t=t.parentElement}if(!this.configName){const t=a.getContextValue("__SNK__APPLICATION__");this.configName=t.configName}}render(){return s("ez-view-stack",{ref:t=>this._viewStack=t,"data-element-id":"crud"},s("stack-item",null,s("snk-grid",{ref:t=>this._snkGrid=t,"data-element-id":"crud_grid",configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail),actionsList:this.actionsList,statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,presentationMode:this.presentationMode},s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-guides-viewer",{ref:t=>this._guidesViewer=t,entityPath:this._snkDataUnit.entityName,onExit:()=>this.setViewMode(r.GRID),dataState:this._dataState,dataUnit:this._dataUnit,actionsList:this.actionsList,taskbarManager:this.taskbarManager,configName:this.configName,onActionClick:t=>this.executeAction(t.detail),presentationMode:this.presentationMode,"data-element-id":"crud_form"},s("slot",{name:"SnkFormTaskBar"}))),s("snk-configurator",{ref:t=>this._snkConfigurator=t,viewMode:this._currentViewMode,onConfigSelected:t=>this.setViewMode(t.detail),onOpenConfig:t=>this.openConfig(t.detail)}))}get _element(){return e(this)}};d.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{d as snk_crud}
|