@sankhyalabs/sankhyablocks 4.8.1 → 4.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/pesquisa-fetcher-d9dda5c6.js +162 -0
- package/dist/cjs/snk-application.cjs.entry.js +2 -149
- package/dist/cjs/snk-crud.cjs.entry.js +1 -0
- package/dist/cjs/snk-detail-view.cjs.entry.js +2 -1
- package/dist/cjs/{snk-guides-viewer-cb02e675.js → snk-guides-viewer-19e24b86.js} +1 -0
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +3 -2
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +10 -2
- package/dist/components/pesquisa-fetcher.js +160 -0
- package/dist/components/snk-application2.js +2 -149
- package/dist/components/snk-crud.js +1 -0
- package/dist/components/snk-detail-view2.js +1 -0
- package/dist/components/snk-simple-crud.js +3 -2
- package/dist/esm/pesquisa-fetcher-b0c7f275.js +160 -0
- package/dist/esm/snk-application.entry.js +2 -149
- package/dist/esm/snk-crud.entry.js +1 -0
- package/dist/esm/snk-detail-view.entry.js +2 -1
- package/dist/esm/{snk-guides-viewer-b13cff0a.js → snk-guides-viewer-5284f800.js} +1 -0
- package/dist/esm/snk-guides-viewer.entry.js +2 -1
- package/dist/esm/snk-simple-crud.entry.js +3 -2
- package/dist/sankhyablocks/p-31dba496.js +1 -0
- package/dist/sankhyablocks/p-722f0e95.entry.js +83 -0
- package/dist/sankhyablocks/p-8e6681f8.entry.js +1 -0
- package/dist/sankhyablocks/{p-6181e6cb.entry.js → p-c7ca2118.entry.js} +1 -1
- package/dist/sankhyablocks/p-d3324c6c.js +6 -0
- package/dist/sankhyablocks/p-d9508a7f.entry.js +1 -0
- package/dist/sankhyablocks/p-f59bee89.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +4 -1
- package/package.json +1 -1
- package/dist/sankhyablocks/p-2eab10a4.entry.js +0 -88
- package/dist/sankhyablocks/p-5afa5b01.entry.js +0 -1
- package/dist/sankhyablocks/p-5b80ee28.entry.js +0 -1
- package/dist/sankhyablocks/p-64f21075.entry.js +0 -1
- package/dist/sankhyablocks/p-e1dbaecb.js +0 -1
@@ -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';
|
@@ -189,11 +190,11 @@ const SnkSimpleCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
189
190
|
this.onModeChange();
|
190
191
|
}
|
191
192
|
getTaskBarId() {
|
192
|
-
var _a, _b;
|
193
|
+
var _a, _b, _c;
|
193
194
|
if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
|
194
195
|
return "snkSimpleCrudTaskbar.finish_edition";
|
195
196
|
}
|
196
|
-
if (((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectedRecords.length) > 0) {
|
197
|
+
if (((_c = (_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectedRecords) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
197
198
|
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_selected" : "snkSimpleCrudTaskbar.form_selected";
|
198
199
|
}
|
199
200
|
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
|
@@ -0,0 +1,160 @@
|
|
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
|
+
var _a;
|
21
|
+
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
22
|
+
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
23
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
24
|
+
const values = {
|
25
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
26
|
+
entityName,
|
27
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
28
|
+
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
29
|
+
};
|
30
|
+
if (values.options) {
|
31
|
+
(_a = values.options) === null || _a === void 0 ? true : delete _a.dataUnitId;
|
32
|
+
}
|
33
|
+
return new Promise((resolve, reject) => {
|
34
|
+
DataFetcher.get()
|
35
|
+
.callGraphQL({
|
36
|
+
values,
|
37
|
+
query: this._templateByQuery.get("search"),
|
38
|
+
})
|
39
|
+
.then((result) => {
|
40
|
+
resolve(result);
|
41
|
+
})
|
42
|
+
.catch((error) => {
|
43
|
+
reject(error);
|
44
|
+
});
|
45
|
+
});
|
46
|
+
}
|
47
|
+
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
48
|
+
var _a, _b, _c;
|
49
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
50
|
+
const values = {
|
51
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
52
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
53
|
+
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
54
|
+
};
|
55
|
+
const serviceName = "PesquisaSP.getSuggestion";
|
56
|
+
const externalCriteria = {
|
57
|
+
query: {
|
58
|
+
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
59
|
+
}
|
60
|
+
};
|
61
|
+
if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
|
62
|
+
externalCriteria.params = {
|
63
|
+
param: values.criteria.params.map(param => {
|
64
|
+
let value = param.value;
|
65
|
+
let type = param.dataType;
|
66
|
+
if (type === DataType.OBJECT) {
|
67
|
+
value = value.value;
|
68
|
+
type = "S";
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
type = convertParamType(param.dataType);
|
72
|
+
}
|
73
|
+
return { $: value, type };
|
74
|
+
})
|
75
|
+
};
|
76
|
+
}
|
77
|
+
const options = searchOptions != undefined
|
78
|
+
? {
|
79
|
+
"pkFieldName": searchOptions.codeFieldName,
|
80
|
+
"label": searchOptions.descriptionFieldName,
|
81
|
+
"fieldName": searchOptions.codeFieldName,
|
82
|
+
"useDescriptionOptions": false,
|
83
|
+
"enableRowsCounter": true
|
84
|
+
}
|
85
|
+
: undefined;
|
86
|
+
const reqBody = {
|
87
|
+
"serviceName": serviceName,
|
88
|
+
"requestBody": {
|
89
|
+
"criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_c = values.searchOptions) === null || _c === void 0 ? void 0 : _c.rootEntity }, { options }),
|
90
|
+
"clientEventList": {
|
91
|
+
"clientEvent": []
|
92
|
+
}
|
93
|
+
}
|
94
|
+
};
|
95
|
+
return new Promise((resolve, reject) => {
|
96
|
+
DataFetcher.get()
|
97
|
+
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
98
|
+
.then(result => resolve(result))
|
99
|
+
.catch(error => reject(error));
|
100
|
+
});
|
101
|
+
}
|
102
|
+
addSearchListener(entityName, dataUnitID, listener) {
|
103
|
+
var _a;
|
104
|
+
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
105
|
+
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
106
|
+
if (!entityListener) {
|
107
|
+
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
108
|
+
}
|
109
|
+
else {
|
110
|
+
for (const type of Object.keys(listener)) {
|
111
|
+
if (type in entityListener.listener) {
|
112
|
+
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
113
|
+
if (listenerFunctionIsEquals)
|
114
|
+
continue;
|
115
|
+
entityListener.listener[type] = listener[type];
|
116
|
+
}
|
117
|
+
}
|
118
|
+
}
|
119
|
+
return () => {
|
120
|
+
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
121
|
+
if (!newListeners.length) {
|
122
|
+
this._searchListenersByDataUnit.delete(dataUnitID);
|
123
|
+
return;
|
124
|
+
}
|
125
|
+
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
126
|
+
};
|
127
|
+
}
|
128
|
+
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
129
|
+
var _a;
|
130
|
+
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
131
|
+
if (!dataUnitId)
|
132
|
+
return;
|
133
|
+
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
134
|
+
if (!entityListener)
|
135
|
+
return;
|
136
|
+
const { listener } = entityListener;
|
137
|
+
if (!(listenerType in listener))
|
138
|
+
return;
|
139
|
+
return listener[listenerType]({ argument, criteria, searchOptions });
|
140
|
+
}
|
141
|
+
}
|
142
|
+
function convertParamType(dataType) {
|
143
|
+
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
144
|
+
//atual da pesquisa... em geral, somente inteiros,
|
145
|
+
//data (com ou sem hora) e string são realmente relevantes
|
146
|
+
switch (dataType) {
|
147
|
+
case DataType.NUMBER:
|
148
|
+
return "I";
|
149
|
+
case DataType.DATE:
|
150
|
+
return "D";
|
151
|
+
default:
|
152
|
+
return "S";
|
153
|
+
}
|
154
|
+
}
|
155
|
+
var SearchListenerType;
|
156
|
+
(function (SearchListenerType) {
|
157
|
+
SearchListenerType["beforeSearch"] = "beforeSearch";
|
158
|
+
})(SearchListenerType || (SearchListenerType = {}));
|
159
|
+
|
160
|
+
export { PesquisaFetcher as P };
|
@@ -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-b0c7f275.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-b0c7f275.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-b0c7f275.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-5284f800.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-b0c7f275.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-5284f800.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-b0c7f275.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-b0c7f275.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';
|
@@ -187,11 +188,11 @@ const SnkSimpleCrud = class {
|
|
187
188
|
this.onModeChange();
|
188
189
|
}
|
189
190
|
getTaskBarId() {
|
190
|
-
var _a, _b;
|
191
|
+
var _a, _b, _c;
|
191
192
|
if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
|
192
193
|
return "snkSimpleCrudTaskbar.finish_edition";
|
193
194
|
}
|
194
|
-
if (((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectedRecords.length) > 0) {
|
195
|
+
if (((_c = (_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectedRecords) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
195
196
|
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_selected" : "snkSimpleCrudTaskbar.form_selected";
|
196
197
|
}
|
197
198
|
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
|
@@ -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-d3324c6c.js";import{P as v}from"./p-f132e371.js";const c="__FORM:",g=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){g.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(c)&&([u,i]=a.split(c)),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"},g.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"]}}};g.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{g as S}
|