@sankhyalabs/sankhyablocks 8.15.1 → 8.16.0-dev.1
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/{SnkMultiSelectionListDataSource-303e85d1.js → IExporterProvider-c78cb1b8.js} +94 -4
- package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
- package/dist/cjs/{SnkFormConfigManager-f9dc0d28.js → SnkFormConfigManager-1b13bacd.js} +6 -3
- package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-722b104e.js} +8 -12
- package/dist/cjs/{pesquisa-fetcher-213797ec.js → dataunit-fetcher-620b29a1.js} +87 -180
- package/dist/cjs/{index-0922807b.js → index-1dfc7a6e.js} +5 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-fetcher-680e198f.js +166 -0
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +4 -2
- package/dist/cjs/snk-application.cjs.entry.js +34 -11
- package/dist/cjs/snk-attach.cjs.entry.js +71 -46
- package/dist/cjs/snk-crud.cjs.entry.js +96 -10
- package/dist/cjs/snk-data-exporter.cjs.entry.js +315 -85
- package/dist/cjs/snk-data-unit-82dea87e.js +679 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +12 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +48 -7
- package/dist/cjs/snk-filter-bar.cjs.entry.js +5 -1
- package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
- package/dist/cjs/snk-form.cjs.entry.js +51 -6
- package/dist/cjs/snk-grid.cjs.entry.js +164 -107
- package/dist/cjs/{snk-guides-viewer-4b6ecda8.js → snk-guides-viewer-05a1ba27.js} +36 -8
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -6
- package/dist/cjs/snk-simple-crud.cjs.entry.js +264 -37
- package/dist/cjs/snk-taskbar.cjs.entry.js +4 -3
- package/dist/cjs/{taskbar-elements-3ecd1278.js → taskbar-elements-9ad1f9c0.js} +3 -3
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/snk-application/snk-application.js +35 -11
- package/dist/collection/components/snk-attach/snk-attach.js +67 -44
- package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
- package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
- package/dist/collection/components/snk-crud/snk-crud.js +249 -7
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +135 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +161 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +112 -5
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +97 -0
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +74 -0
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +54 -1
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +1 -0
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +58 -0
- package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +55 -0
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +59 -52
- package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +62 -0
- package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +88 -0
- package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +20 -0
- package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +38 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +507 -214
- package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
- package/dist/collection/components/snk-data-unit/test/resources/parentMetadataMock.js +18 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
- package/dist/collection/components/snk-form/snk-form.js +102 -5
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +6 -3
- package/dist/collection/components/snk-grid/snk-grid.js +240 -101
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +386 -18
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +2 -1
- package/dist/collection/lib/@types/index.js +5 -0
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +7 -3
- package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
- package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +3 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +4 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +11 -13
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +53 -4
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +4 -4
- package/dist/collection/lib/message/SnkMessageBuilder.js +5 -12
- package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +2 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
- package/dist/components/{field-search.js → IExporterProvider.js} +93 -6
- package/dist/components/ISave.js +47 -0
- package/dist/components/SnkFormConfigManager.js +6 -3
- package/dist/components/SnkMessageBuilder.js +8 -12
- package/dist/components/dataunit-fetcher.js +84 -182
- package/dist/components/index2.js +198 -33
- package/dist/components/pesquisa-fetcher.js +164 -0
- package/dist/components/snk-actions-button2.js +4 -11
- package/dist/components/snk-application2.js +31 -9
- package/dist/components/snk-attach2.js +65 -41
- package/dist/components/snk-crud.js +103 -11
- package/dist/components/snk-data-exporter2.js +309 -85
- package/dist/components/snk-data-unit2.js +470 -212
- package/dist/components/snk-detail-view2.js +87 -10
- package/dist/components/snk-expression-item2.js +1 -1
- package/dist/components/snk-filter-bar2.js +6 -1
- package/dist/components/snk-form-view2.js +72 -1
- package/dist/components/snk-form.js +53 -6
- package/dist/components/snk-grid2.js +168 -106
- package/dist/components/snk-personalized-filter2.js +1 -1
- package/dist/components/snk-simple-crud2.js +259 -23
- package/dist/components/snk-taskbar2.js +6 -5
- package/dist/esm/{SnkMultiSelectionListDataSource-36918dbf.js → IExporterProvider-343272b3.js} +93 -5
- package/dist/esm/RecordIDUtils-87d02110.js +41 -0
- package/dist/esm/{SnkFormConfigManager-f53f9f87.js → SnkFormConfigManager-d4554df9.js} +6 -3
- package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-89925609.js} +8 -12
- package/dist/esm/{pesquisa-fetcher-fe6f3826.js → dataunit-fetcher-3fbf9d12.js} +83 -181
- package/dist/esm/{index-0ece87a6.js → index-3aa4977a.js} +6 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-fetcher-03c8f919.js +164 -0
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +4 -2
- package/dist/esm/snk-application.entry.js +33 -10
- package/dist/esm/snk-attach.entry.js +66 -41
- package/dist/esm/snk-crud.entry.js +96 -10
- package/dist/esm/snk-data-exporter.entry.js +316 -86
- package/dist/esm/snk-data-unit-8f98b45f.js +677 -0
- package/dist/esm/snk-data-unit.entry.js +12 -2
- package/dist/esm/snk-detail-view.entry.js +48 -7
- package/dist/esm/snk-filter-bar.entry.js +5 -1
- package/dist/esm/snk-form-view.entry.js +67 -0
- package/dist/esm/snk-form.entry.js +51 -6
- package/dist/esm/snk-grid.entry.js +162 -105
- package/dist/esm/{snk-guides-viewer-113be3fd.js → snk-guides-viewer-aee2cafe.js} +36 -8
- package/dist/esm/snk-guides-viewer.entry.js +8 -6
- package/dist/esm/snk-simple-crud.entry.js +252 -25
- package/dist/esm/snk-taskbar.entry.js +4 -3
- package/dist/esm/{taskbar-elements-2473c8ac.js → taskbar-elements-d59867f1.js} +3 -3
- package/dist/sankhyablocks/p-0d91b10f.entry.js +1 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-26394a01.entry.js +1 -0
- package/dist/sankhyablocks/p-2d649237.entry.js +1 -0
- package/dist/sankhyablocks/p-30cf616e.js +1 -0
- package/dist/sankhyablocks/p-44767378.entry.js +1 -0
- package/dist/sankhyablocks/p-47b60deb.entry.js +1 -0
- package/dist/sankhyablocks/p-4f72727a.entry.js +1 -0
- package/dist/sankhyablocks/p-550fee49.entry.js +1 -0
- package/dist/sankhyablocks/p-5539ecb4.entry.js +1 -0
- package/dist/sankhyablocks/p-672302c3.js +60 -0
- package/dist/sankhyablocks/p-7a337364.js +1 -0
- package/dist/sankhyablocks/{p-ae4fc9a9.js → p-7e7a7473.js} +1 -1
- package/dist/sankhyablocks/p-829d4045.js +1 -0
- package/dist/sankhyablocks/p-8a5910a7.entry.js +1 -0
- package/dist/sankhyablocks/p-8cc64963.entry.js +1 -0
- package/dist/sankhyablocks/p-8fc470e5.entry.js +1 -0
- package/dist/sankhyablocks/p-9863d682.js +1 -0
- package/dist/sankhyablocks/p-9e99a92a.js +1 -0
- package/dist/sankhyablocks/p-af8efd95.js +6 -0
- package/dist/sankhyablocks/p-be603a24.js +1 -0
- package/dist/sankhyablocks/p-d09feef1.js +1 -0
- package/dist/sankhyablocks/p-e95b3b93.entry.js +11 -0
- package/dist/sankhyablocks/p-f2809746.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +7 -3
- package/dist/types/components/snk-attach/snk-attach.d.ts +11 -9
- package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
- package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +36 -1
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +28 -3
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +19 -0
- package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +14 -0
- package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +12 -0
- package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +24 -4
- package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +5 -0
- package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +17 -0
- package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +17 -0
- package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +4 -1
- package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +21 -0
- package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +77 -0
- package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +4 -0
- package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +3 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +61 -2
- package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
- package/dist/types/components/snk-data-unit/test/resources/parentMetadataMock.d.ts +3 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
- package/dist/types/components/snk-form/snk-form.d.ts +14 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +46 -6
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +58 -4
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
- package/dist/types/components.d.ts +220 -4
- package/dist/types/lib/@types/index.d.ts +5 -0
- package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
- package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
- package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/snk-data-unit-41c29713.js +0 -462
- package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +0 -34
- package/dist/components/index3.js +0 -199
- package/dist/esm/snk-data-unit-de1d140d.js +0 -460
- package/dist/sankhyablocks/p-032fe52e.js +0 -1
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
- package/dist/sankhyablocks/p-07a61550.entry.js +0 -1
- package/dist/sankhyablocks/p-0899e0b5.entry.js +0 -1
- package/dist/sankhyablocks/p-154a7f33.entry.js +0 -1
- package/dist/sankhyablocks/p-15802c59.entry.js +0 -1
- package/dist/sankhyablocks/p-164666b1.js +0 -65
- package/dist/sankhyablocks/p-32556aa6.js +0 -1
- package/dist/sankhyablocks/p-328585d0.entry.js +0 -1
- package/dist/sankhyablocks/p-38289a55.js +0 -1
- package/dist/sankhyablocks/p-52c8e589.js +0 -1
- package/dist/sankhyablocks/p-5cb07080.js +0 -1
- package/dist/sankhyablocks/p-74d349c3.entry.js +0 -1
- package/dist/sankhyablocks/p-7fe120b8.entry.js +0 -11
- package/dist/sankhyablocks/p-add17f6a.entry.js +0 -1
- package/dist/sankhyablocks/p-af1ac81f.entry.js +0 -1
- package/dist/sankhyablocks/p-b4525fc0.entry.js +0 -1
- package/dist/sankhyablocks/p-cce0865d.js +0 -1
- package/dist/sankhyablocks/p-dec65f6c.entry.js +0 -1
- package/dist/sankhyablocks/p-ee9536bc.entry.js +0 -1
- package/dist/sankhyablocks/p-f13f7616.entry.js +0 -1
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +0 -3
@@ -0,0 +1,164 @@
|
|
1
|
+
import { DataType, ApplicationContext } from '@sankhyalabs/core';
|
2
|
+
import { d as dist, D as DataFetcher } from './DataFetcher.js';
|
3
|
+
|
4
|
+
class PesquisaFetcher {
|
5
|
+
constructor() {
|
6
|
+
this._defaultPageSize = 100;
|
7
|
+
this._templateByQuery = new Map();
|
8
|
+
this._searchListenersByDataUnit = new Map();
|
9
|
+
this.buldTemplates();
|
10
|
+
}
|
11
|
+
buldTemplates() {
|
12
|
+
this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
13
|
+
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
14
|
+
value
|
15
|
+
label
|
16
|
+
}
|
17
|
+
}`);
|
18
|
+
}
|
19
|
+
loadSearchOptions(entityName, argument, criteria, options) {
|
20
|
+
var _a;
|
21
|
+
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
22
|
+
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
23
|
+
criteria === null || criteria === void 0 ? void 0 : criteria.params.forEach(param => {
|
24
|
+
if (param.dataType === DataType.OBJECT) {
|
25
|
+
param.value = JSON.stringify(param.value);
|
26
|
+
}
|
27
|
+
});
|
28
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
29
|
+
const values = {
|
30
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
31
|
+
entityName,
|
32
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
33
|
+
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
34
|
+
};
|
35
|
+
if (values.options) {
|
36
|
+
(_a = values.options) === null || _a === void 0 ? true : delete _a.dataUnitId;
|
37
|
+
}
|
38
|
+
return new Promise((resolve, reject) => {
|
39
|
+
DataFetcher.get()
|
40
|
+
.callGraphQL({
|
41
|
+
values,
|
42
|
+
query: this._templateByQuery.get("search"),
|
43
|
+
})
|
44
|
+
.then((result) => {
|
45
|
+
resolve(result);
|
46
|
+
})
|
47
|
+
.catch((error) => {
|
48
|
+
reject(error);
|
49
|
+
});
|
50
|
+
});
|
51
|
+
}
|
52
|
+
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
53
|
+
var _a, _b, _c, _d, _e;
|
54
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
55
|
+
const values = {
|
56
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
57
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
58
|
+
searchOptions: Object.assign(Object.assign({}, searchOptions), listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions),
|
59
|
+
};
|
60
|
+
const serviceName = "PesquisaSP.getSuggestion";
|
61
|
+
const externalCriteria = {
|
62
|
+
query: {
|
63
|
+
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
64
|
+
}
|
65
|
+
};
|
66
|
+
if (((_c = (_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
67
|
+
externalCriteria.params = {
|
68
|
+
param: values.criteria.params.map(param => {
|
69
|
+
let value = param.value;
|
70
|
+
if (typeof value === "string") {
|
71
|
+
const match = /CTX\{([^}]+)\}/.exec(value);
|
72
|
+
if (match) {
|
73
|
+
value = ApplicationContext.getContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${match[1]})__`);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
let type = param.dataType;
|
77
|
+
if (type === DataType.OBJECT) {
|
78
|
+
value = value.value;
|
79
|
+
type = "S";
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
type = convertParamType(param.dataType);
|
83
|
+
}
|
84
|
+
return { $: value, type };
|
85
|
+
})
|
86
|
+
};
|
87
|
+
}
|
88
|
+
const options = searchOptions != undefined
|
89
|
+
? Object.assign(Object.assign({}, values === null || values === void 0 ? void 0 : values.searchOptions), { "pkFieldName": searchOptions.codeFieldName, "label": searchOptions.descriptionFieldName, "fieldName": searchOptions.codeFieldName, "useDescriptionOptions": false, "enableRowsCounter": true }) : undefined;
|
90
|
+
const reqBody = {
|
91
|
+
"serviceName": serviceName,
|
92
|
+
"requestBody": {
|
93
|
+
"criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": (_d = options === null || options === void 0 ? void 0 : options.ignoreEntityCriteria) !== null && _d !== void 0 ? _d : false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_e = values.searchOptions) === null || _e === void 0 ? void 0 : _e.rootEntity }, { options }),
|
94
|
+
"clientEventList": {
|
95
|
+
"clientEvent": []
|
96
|
+
}
|
97
|
+
}
|
98
|
+
};
|
99
|
+
return new Promise((resolve, reject) => {
|
100
|
+
DataFetcher.get()
|
101
|
+
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
102
|
+
.then(result => resolve(result))
|
103
|
+
.catch(error => reject(error));
|
104
|
+
});
|
105
|
+
}
|
106
|
+
addSearchListener(entityName, dataUnitID, listener) {
|
107
|
+
var _a;
|
108
|
+
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
109
|
+
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
110
|
+
if (!entityListener) {
|
111
|
+
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
for (const type of Object.keys(listener)) {
|
115
|
+
if (type in entityListener.listener) {
|
116
|
+
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
117
|
+
if (listenerFunctionIsEquals)
|
118
|
+
continue;
|
119
|
+
entityListener.listener[type] = listener[type];
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
return () => {
|
124
|
+
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
125
|
+
if (!newListeners.length) {
|
126
|
+
this._searchListenersByDataUnit.delete(dataUnitID);
|
127
|
+
return;
|
128
|
+
}
|
129
|
+
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
130
|
+
};
|
131
|
+
}
|
132
|
+
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
133
|
+
var _a;
|
134
|
+
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
135
|
+
if (!dataUnitId)
|
136
|
+
return;
|
137
|
+
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
138
|
+
if (!entityListener)
|
139
|
+
return;
|
140
|
+
const { listener } = entityListener;
|
141
|
+
if (!(listenerType in listener))
|
142
|
+
return;
|
143
|
+
return listener[listenerType]({ argument, criteria, searchOptions });
|
144
|
+
}
|
145
|
+
}
|
146
|
+
function convertParamType(dataType) {
|
147
|
+
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
148
|
+
//atual da pesquisa... em geral, somente inteiros,
|
149
|
+
//data (com ou sem hora) e string são realmente relevantes
|
150
|
+
switch (dataType) {
|
151
|
+
case DataType.NUMBER:
|
152
|
+
return "I";
|
153
|
+
case DataType.DATE:
|
154
|
+
return "D";
|
155
|
+
default:
|
156
|
+
return "S";
|
157
|
+
}
|
158
|
+
}
|
159
|
+
var SearchListenerType;
|
160
|
+
(function (SearchListenerType) {
|
161
|
+
SearchListenerType["beforeSearch"] = "beforeSearch";
|
162
|
+
})(SearchListenerType || (SearchListenerType = {}));
|
163
|
+
|
164
|
+
export { PesquisaFetcher as P };
|
@@ -2,10 +2,11 @@ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal
|
|
2
2
|
import { ApplicationContext, StringUtils, ErrorException, WarningException, ObjectUtils, DateUtils, ArrayUtils, ElementIDUtils } from '@sankhyalabs/core';
|
3
3
|
import { D as DataFetcher } from './DataFetcher.js';
|
4
4
|
import { P as ParamType } from './ParamType.js';
|
5
|
-
import './
|
6
|
-
import './
|
5
|
+
import './pesquisa-fetcher.js';
|
6
|
+
import './ISave.js';
|
7
7
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
8
8
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
9
|
+
import './dataunit-fetcher.js';
|
9
10
|
import './filter-item-type.enum.js';
|
10
11
|
import './form-config-fetcher.js';
|
11
12
|
import { R as ResourceIDUtils } from './ResourceIDUtils.js';
|
@@ -158,14 +159,6 @@ var RefreshType;
|
|
158
159
|
RefreshType["ALL"] = "ALL";
|
159
160
|
})(RefreshType || (RefreshType = {}));
|
160
161
|
|
161
|
-
var SaveErrorsEnum;
|
162
|
-
(function (SaveErrorsEnum) {
|
163
|
-
SaveErrorsEnum["LINK_AND_FILE_AT_THE_SAME_TIME"] = "LINK_AND_FILE_AT_THE_SAME_TIME";
|
164
|
-
SaveErrorsEnum["ANY_LINK_OR_FILE_FILLED"] = "ANY_LINK_OR_FILE_FILLED";
|
165
|
-
SaveErrorsEnum["UNKNOWN"] = "UNKNOWN";
|
166
|
-
SaveErrorsEnum["DESCRIPTION_CANNOT_BE_CHANGED"] = "DESCRIPTION_CANNOT_BE_CHANGED";
|
167
|
-
})(SaveErrorsEnum || (SaveErrorsEnum = {}));
|
168
|
-
|
169
162
|
const MASTER_ROW_PROPERTY = "__MASTER_ROW__";
|
170
163
|
const ENTITY_NAME_PROPERTY = '__ENTITY_NAME__';
|
171
164
|
const NUFIN_COLUMN = 'NUFIN';
|
@@ -735,4 +728,4 @@ function defineCustomElement() {
|
|
735
728
|
} });
|
736
729
|
}
|
737
730
|
|
738
|
-
export { SnkActionsButton as S,
|
731
|
+
export { SnkActionsButton as S, defineCustomElement as d };
|
@@ -4,7 +4,8 @@ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
4
|
import { C as ConfigStorage } from './ConfigStorage.js';
|
5
5
|
import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher.js';
|
6
6
|
import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher.js';
|
7
|
-
import { D as DataUnitFetcher
|
7
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher.js';
|
8
|
+
import { P as PesquisaFetcher } from './pesquisa-fetcher.js';
|
8
9
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder.js';
|
9
10
|
import { d as defineCustomElement$1 } from './snk-pesquisa2.js';
|
10
11
|
|
@@ -289,6 +290,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
289
290
|
this._duPromises = new Map();
|
290
291
|
this._requestListener = new RequestListenerLoadingBar();
|
291
292
|
this._pendingActions = new Map;
|
293
|
+
this._loadPkParameter = null;
|
292
294
|
this._isLoadedByPk = false;
|
293
295
|
this.messagesBuilder = undefined;
|
294
296
|
this.configName = undefined;
|
@@ -346,6 +348,12 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
346
348
|
});
|
347
349
|
}
|
348
350
|
}
|
351
|
+
watchPropHandler(newValue, _) {
|
352
|
+
if (newValue && this._loadPkParameter) {
|
353
|
+
this.loadByPK(this._loadPkParameter.pk, this._loadPkParameter.redirect);
|
354
|
+
this._loadPkParameter = null;
|
355
|
+
}
|
356
|
+
}
|
349
357
|
/**
|
350
358
|
* Obtém o controlador de teclado.
|
351
359
|
*
|
@@ -620,12 +628,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
620
628
|
if (!waitingDu) {
|
621
629
|
const dataUnit = this.dataUnitFetcher.getDataUnit(entityName, resourceID, parentDataUnit, configName);
|
622
630
|
dataUnit.loadMetadata().then(() => {
|
623
|
-
|
624
|
-
this.updateDataunitCache(undefined, dataUnitName, dataUnit);
|
625
|
-
}
|
626
|
-
while (duPromisses.length > 0) {
|
627
|
-
duPromisses.pop().resolve(dataUnit);
|
628
|
-
}
|
631
|
+
this.processResolveDataUnit(dataUnit, dataUnitName, duPromisses);
|
629
632
|
}).catch(reason => {
|
630
633
|
while (duPromisses.length > 0) {
|
631
634
|
duPromisses.pop().reject(reason);
|
@@ -634,6 +637,14 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
634
637
|
}
|
635
638
|
});
|
636
639
|
}
|
640
|
+
processResolveDataUnit(dataUnit, dataUnitName, duPromisses) {
|
641
|
+
if (dataUnitName) {
|
642
|
+
this.updateDataunitCache(undefined, dataUnitName, dataUnit);
|
643
|
+
}
|
644
|
+
while (duPromisses.length > 0) {
|
645
|
+
duPromisses.pop().resolve(dataUnit);
|
646
|
+
}
|
647
|
+
}
|
637
648
|
/**
|
638
649
|
* Atualiza o cache de dataunits da aplicação.
|
639
650
|
* @param oldName - Nome do dataunit que está em cache.
|
@@ -1047,15 +1058,23 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
1047
1058
|
return;
|
1048
1059
|
const resourceIDfromUrl = this.getResourceIdFromToken();
|
1049
1060
|
const pkObject = UrlUtils.getPkObjectFromUrlToken(top.window.location.hash);
|
1050
|
-
|
1061
|
+
const redirectFrom = window["redirectFrom"];
|
1062
|
+
if (pkObject === undefined) {
|
1051
1063
|
return;
|
1064
|
+
}
|
1065
|
+
if (!redirectFrom || redirectFrom.split("_")[0].indexOf(resourceIDfromUrl.split("_")[0]) === -1) {
|
1066
|
+
if (resourceIDfromUrl !== this.applicationResourceID) {
|
1067
|
+
return;
|
1068
|
+
}
|
1069
|
+
}
|
1052
1070
|
const pkParam = { pk: pkObject };
|
1053
1071
|
this._isLoadedByPk = true;
|
1054
1072
|
if (this.loadByPK) {
|
1055
|
-
this.loadByPK(pkParam);
|
1073
|
+
this.loadByPK(pkParam, redirectFrom);
|
1056
1074
|
this._currentPkParameter = pkHash;
|
1057
1075
|
return;
|
1058
1076
|
}
|
1077
|
+
this._loadPkParameter = { pk: pkParam, redirect: redirectFrom };
|
1059
1078
|
this.defaultLoadByPK(pkParam, pkHash);
|
1060
1079
|
}
|
1061
1080
|
getResourceIdFromToken() {
|
@@ -1246,6 +1265,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
1246
1265
|
return (h("div", null, h("ez-loading-bar", { ref: (ref) => this._requestListener.loadingBar = ref }), h("ez-popup", { opened: false, ref: (ref) => this._popUp = ref, onEzClosePopup: () => this.closePopUp() }), h("ez-modal", { opened: false, ref: (ref) => this._rightModal = ref, "modal-size": "small", closeOutsideClick: true, closeEsc: true })));
|
1247
1266
|
}
|
1248
1267
|
get _element() { return this; }
|
1268
|
+
static get watchers() { return {
|
1269
|
+
"loadByPK": ["watchPropHandler"]
|
1270
|
+
}; }
|
1249
1271
|
static get style() { return snkApplicationCss; }
|
1250
1272
|
}, [2, "snk-application", {
|
1251
1273
|
"messagesBuilder": [1040],
|
@@ -1,14 +1,15 @@
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
|
2
2
|
import { ApplicationContext, DataType, Action, UserInterface, StringUtils, DataUnit } from '@sankhyalabs/core';
|
3
3
|
import { D as DataFetcher } from './DataFetcher.js';
|
4
|
-
import
|
5
|
-
import './
|
6
|
-
import { a as
|
4
|
+
import './pesquisa-fetcher.js';
|
5
|
+
import { S as SaveErrorsEnum } from './ISave.js';
|
6
|
+
import { P as PreloadManager, a as applyFilter, b as applySorting, c as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher.js';
|
7
7
|
import './filter-item-type.enum.js';
|
8
8
|
import './form-config-fetcher.js';
|
9
9
|
import { V as VIEW_MODE } from './constants.js';
|
10
10
|
import { A as AutorizationType } from './auth-fetcher.js';
|
11
11
|
import { T as TaskbarElement, d as defineCustomElement$2 } from './snk-taskbar2.js';
|
12
|
+
import { d as defineCustomElement$f } from './snk-actions-button2.js';
|
12
13
|
import { d as defineCustomElement$e } from './snk-config-options2.js';
|
13
14
|
import { d as defineCustomElement$d } from './snk-configurator2.js';
|
14
15
|
import { d as defineCustomElement$c } from './snk-data-exporter2.js';
|
@@ -656,26 +657,37 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
656
657
|
this._currentDataUnit = undefined;
|
657
658
|
this.crudConfig = undefined;
|
658
659
|
}
|
659
|
-
registerKeyWatcher(newRegisterKey, oldRegisterKey) {
|
660
|
-
var _a
|
661
|
-
if (
|
660
|
+
async registerKeyWatcher(newRegisterKey, oldRegisterKey) {
|
661
|
+
var _a;
|
662
|
+
if (this._currentDataUnit == null) {
|
662
663
|
this.loadAttachmentDataUnit();
|
663
664
|
}
|
664
665
|
if (oldRegisterKey !== newRegisterKey) {
|
665
|
-
this.
|
666
|
-
if (this.fetcherType === "AnexoSistema") {
|
667
|
-
this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
668
|
-
(_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
|
669
|
-
return (_c = this._currentDataUnit) === null || _c === void 0 ? void 0 : _c.loadData();
|
670
|
-
}
|
671
|
-
if (this.fetcherType === "Attach") {
|
672
|
-
const hasMoreOneItem = ((_d = this.registerKey) === null || _d === void 0 ? void 0 : _d.split("_").length) > 1;
|
673
|
-
if (hasMoreOneItem)
|
674
|
-
return;
|
675
|
-
}
|
676
|
-
return (_f = (_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadMetadata()) === null || _f === void 0 ? void 0 : _f.then(this._currentDataUnit.loadData.bind(undefined, undefined, true, this.registerKey));
|
666
|
+
await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadData());
|
677
667
|
}
|
678
668
|
}
|
669
|
+
async initAttach() {
|
670
|
+
var _a, _b, _c, _d, _e, _f;
|
671
|
+
if (!this.fetcherType && !this.registerKey)
|
672
|
+
return;
|
673
|
+
if (!this.fetcherType) {
|
674
|
+
this.fetcherType = "AnexoSistema";
|
675
|
+
}
|
676
|
+
this.returnToGridMode();
|
677
|
+
if (this.fetcherType === "AnexoSistema") {
|
678
|
+
this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
679
|
+
(_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
|
680
|
+
await ((_c = this._currentDataUnit) === null || _c === void 0 ? void 0 : _c.loadData());
|
681
|
+
return;
|
682
|
+
}
|
683
|
+
if (this.fetcherType === "Attach") {
|
684
|
+
const hasMoreOneItem = ((_d = this.registerKey) === null || _d === void 0 ? void 0 : _d.split("_").length) > 1;
|
685
|
+
if (hasMoreOneItem)
|
686
|
+
return;
|
687
|
+
}
|
688
|
+
await ((_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadMetadata());
|
689
|
+
await ((_f = this._currentDataUnit) === null || _f === void 0 ? void 0 : _f.loadData(undefined, undefined, true, this.registerKey));
|
690
|
+
}
|
679
691
|
/**
|
680
692
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
681
693
|
* através de um pequeno modulo na estrutura da aplicação:
|
@@ -713,14 +725,14 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
713
725
|
if (this._crudElement)
|
714
726
|
this._crudElement.goToView(VIEW_MODE.GRID);
|
715
727
|
}
|
716
|
-
loadAttachmentDataUnit() {
|
728
|
+
async loadAttachmentDataUnit() {
|
717
729
|
try {
|
718
730
|
switch (this.fetcherType) {
|
719
731
|
case "AnexoSistema":
|
720
|
-
this.loadAnexoSistema();
|
732
|
+
await this.loadAnexoSistema();
|
721
733
|
break;
|
722
734
|
case "Attach":
|
723
|
-
this.loadAttach();
|
735
|
+
await this.loadAttach();
|
724
736
|
break;
|
725
737
|
default:
|
726
738
|
this._currentFetcher = this.fetcher;
|
@@ -732,28 +744,29 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
732
744
|
throw new Error('There was an error while creating the data unit');
|
733
745
|
}
|
734
746
|
}
|
735
|
-
loadAnexoSistema() {
|
736
|
-
var _a;
|
737
|
-
this._currentDataUnit =
|
747
|
+
async loadAnexoSistema() {
|
748
|
+
var _a, _b, _c;
|
749
|
+
this._currentDataUnit = new DataUnitFetcher().getDataUnit(RESOURCE_ID, DATA_UNIT_NAME);
|
738
750
|
this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
739
751
|
if (!this._currentDataUnit.metadata) {
|
740
|
-
this._currentDataUnit
|
741
|
-
|
742
|
-
.then(() => this.crudConfig = Object.assign({}, anexoSistemaCrudConfig));
|
752
|
+
await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadMetadata());
|
753
|
+
this.crudConfig = Object.assign({}, anexoSistemaCrudConfig);
|
743
754
|
}
|
744
|
-
this.
|
755
|
+
this.initDataUnitLoaders();
|
745
756
|
this._currentDataUnit.addFilterProvider({
|
746
757
|
getFilter: () => this._currentDataUnitBuilder.getFilters(this.registerKey)
|
747
758
|
});
|
748
759
|
this._currentDataUnit.addInterceptor({
|
749
760
|
interceptAction: (action) => this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement)
|
750
761
|
});
|
751
|
-
this._currentDataUnit.loadData()
|
762
|
+
await ((_c = this._currentDataUnit) === null || _c === void 0 ? void 0 : _c.loadData());
|
763
|
+
this.disableEditFieldsNotInForm();
|
752
764
|
}
|
753
|
-
loadAttach() {
|
754
|
-
var _a, _b
|
765
|
+
async loadAttach() {
|
766
|
+
var _a, _b;
|
755
767
|
this._currentFetcher = new AttachFetcher();
|
756
768
|
this._currentDataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
769
|
+
this.initDataUnitLoaders();
|
757
770
|
this._currentDataUnit.addInterceptor({
|
758
771
|
interceptAction: (action) => {
|
759
772
|
var _a;
|
@@ -764,16 +777,26 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
764
777
|
return this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement);
|
765
778
|
}
|
766
779
|
});
|
767
|
-
this._currentDataUnitBuilder = new AttachFetcherDataUnitFactory(this.getMessage.bind(this));
|
768
|
-
(_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, async () => {
|
769
|
-
this.returnToGridMode();
|
770
|
-
await this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
|
771
|
-
});
|
772
780
|
if (!this._currentDataUnit.metadata) {
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
781
|
+
await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadMetadata());
|
782
|
+
this.crudConfig = Object.assign({}, attachCrudConfig);
|
783
|
+
await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadData(undefined, undefined, true, this.registerKey));
|
784
|
+
this.disableEditFieldsNotInForm();
|
785
|
+
}
|
786
|
+
}
|
787
|
+
initDataUnitLoaders() {
|
788
|
+
var _a, _b, _c;
|
789
|
+
if (this.fetcherType === "AnexoSistema") {
|
790
|
+
this._currentFetcher = new AnexoSistemaFetcher(this.entityName, this.registerKey, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
791
|
+
this._currentDataUnitBuilder = new AnexoSistemaDataUnitFactory(this.entityName, this.getMessage.bind(this));
|
792
|
+
(_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
|
793
|
+
}
|
794
|
+
if (this.fetcherType === "Attach") {
|
795
|
+
this._currentFetcher = new AttachFetcher();
|
796
|
+
this._currentDataUnitBuilder = new AttachFetcherDataUnitFactory(this.getMessage.bind(this));
|
797
|
+
(_c = this._currentDataUnitBuilder) === null || _c === void 0 ? void 0 : _c.initLoaders(this._currentDataUnit, this._currentFetcher, async () => {
|
798
|
+
this.returnToGridMode();
|
799
|
+
await this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
|
777
800
|
});
|
778
801
|
}
|
779
802
|
}
|
@@ -787,8 +810,9 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
787
810
|
}
|
788
811
|
});
|
789
812
|
}
|
790
|
-
componentWillLoad() {
|
813
|
+
async componentWillLoad() {
|
791
814
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
815
|
+
await this.initAttach();
|
792
816
|
}
|
793
817
|
componentWillRender() {
|
794
818
|
if (!this.fetcherType) {
|
@@ -2,15 +2,16 @@ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/
|
|
2
2
|
import { StringUtils, ElementIDUtils, ApplicationContext, JSUtils, FloatingManager } from '@sankhyalabs/core';
|
3
3
|
import { T as TaskbarElement, d as defineCustomElement$3 } from './snk-taskbar2.js';
|
4
4
|
import './DataFetcher.js';
|
5
|
-
import './
|
6
|
-
import { P as PresentationMode } from './
|
7
|
-
import { d as defineCustomElement$w } from './snk-actions-button2.js';
|
5
|
+
import './pesquisa-fetcher.js';
|
6
|
+
import { P as PresentationMode } from './ISave.js';
|
8
7
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
9
8
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
9
|
+
import './dataunit-fetcher.js';
|
10
10
|
import './filter-item-type.enum.js';
|
11
11
|
import './form-config-fetcher.js';
|
12
12
|
import { V as VIEW_MODE } from './constants.js';
|
13
13
|
import { A as AutorizationType } from './auth-fetcher.js';
|
14
|
+
import { d as defineCustomElement$w } from './snk-actions-button2.js';
|
14
15
|
import { d as defineCustomElement$v } from './snk-attach2.js';
|
15
16
|
import { d as defineCustomElement$u } from './snk-config-options2.js';
|
16
17
|
import { d as defineCustomElement$t } from './snk-configurator2.js';
|
@@ -52,6 +53,8 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
52
53
|
this.formItemsReady = createEvent(this, "formItemsReady", 7);
|
53
54
|
this._keyDownHandler = async (event) => this.keyDownListener(event);
|
54
55
|
this._viewHistory = [];
|
56
|
+
this._customEditors = new Map();
|
57
|
+
this._customRenders = new Map();
|
55
58
|
this._dataUnit = undefined;
|
56
59
|
this._dataState = undefined;
|
57
60
|
this.attachmentRegisterKey = undefined;
|
@@ -74,6 +77,8 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
74
77
|
this.filterBarLegacyConfigName = undefined;
|
75
78
|
this.formLegacyConfigName = undefined;
|
76
79
|
this.disablePersonalizedFilter = undefined;
|
80
|
+
this.autoLoad = undefined;
|
81
|
+
this.autoFocus = true;
|
77
82
|
this.customContainerId = `SNK-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
|
78
83
|
}
|
79
84
|
/**
|
@@ -109,6 +114,49 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
109
114
|
async getFilterBar() {
|
110
115
|
return await this._snkGrid.getFilterBar();
|
111
116
|
}
|
117
|
+
/**
|
118
|
+
* Registra um editor customizado para campos da grade e formulário.
|
119
|
+
*/
|
120
|
+
async addCustomEditor(fieldName, customEditor) {
|
121
|
+
if (this._guidesViewer && this._snkGrid) {
|
122
|
+
this._guidesViewer.addCustomEditor(fieldName, customEditor);
|
123
|
+
this._snkGrid.addCustomEditor(fieldName, customEditor);
|
124
|
+
return;
|
125
|
+
}
|
126
|
+
const newCustomEditors = new Map(this._customEditors);
|
127
|
+
newCustomEditors.set(fieldName, customEditor);
|
128
|
+
this._customEditors = newCustomEditors;
|
129
|
+
}
|
130
|
+
/**
|
131
|
+
* Registra um render customizado para colunas da grid.
|
132
|
+
*/
|
133
|
+
async addGridCustomRender(fieldName, customRender) {
|
134
|
+
if (this._snkGrid) {
|
135
|
+
this._snkGrid.addGridCustomRender(fieldName, customRender);
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
const newCustomRenders = new Map(this._customRenders);
|
139
|
+
newCustomRenders.set(fieldName, customRender);
|
140
|
+
this._customRenders = newCustomRenders;
|
141
|
+
}
|
142
|
+
/**
|
143
|
+
* Registra um formatador de valores para uma coluna da grid.
|
144
|
+
*/
|
145
|
+
async addCustomValueFormatter(columnName, customFormatter) {
|
146
|
+
this._snkGrid.addCustomValueFormatter(columnName, customFormatter);
|
147
|
+
}
|
148
|
+
/**
|
149
|
+
* Remove o formatador de valores de uma coluna da grid.
|
150
|
+
*/
|
151
|
+
async removeCustomValueFormatter(columnName) {
|
152
|
+
this._snkGrid.removeCustomValueFormatter(columnName);
|
153
|
+
}
|
154
|
+
/**
|
155
|
+
* Altera/adiciona uma propriedade nos metadados do campo.
|
156
|
+
*/
|
157
|
+
async setFieldProp(fieldName, propName, value) {
|
158
|
+
await this._guidesViewer.setFieldProp(fieldName, propName, value);
|
159
|
+
}
|
112
160
|
currentViewModeWatcher(currentView) {
|
113
161
|
this._viewHistory = [...this._viewHistory.slice(-1), currentView];
|
114
162
|
}
|
@@ -168,6 +216,29 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
168
216
|
const joinedPrimaryKeys = recordCriteria.map(({ value }) => value).join('_');
|
169
217
|
return joinedPrimaryKeys;
|
170
218
|
}
|
219
|
+
setCustomRenders() {
|
220
|
+
if (!this._snkGrid) {
|
221
|
+
return;
|
222
|
+
}
|
223
|
+
for (const [fieldName, customRender] of this._customRenders) {
|
224
|
+
this._snkGrid.addGridCustomRender(fieldName, customRender);
|
225
|
+
this._customRenders.delete(fieldName);
|
226
|
+
}
|
227
|
+
}
|
228
|
+
setCustomEditors() {
|
229
|
+
if (!this._snkGrid || !this._guidesViewer) {
|
230
|
+
return;
|
231
|
+
}
|
232
|
+
for (const [fieldName, customEditor] of this._customEditors) {
|
233
|
+
this._guidesViewer.addCustomEditor(fieldName, customEditor);
|
234
|
+
this._snkGrid.addCustomEditor(fieldName, customEditor);
|
235
|
+
this._customEditors.delete(fieldName);
|
236
|
+
}
|
237
|
+
}
|
238
|
+
componentDidRender() {
|
239
|
+
this.setCustomRenders();
|
240
|
+
this.setCustomEditors();
|
241
|
+
}
|
171
242
|
componentWillLoad() {
|
172
243
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
173
244
|
let parent = this._element.parentElement;
|
@@ -190,12 +261,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
190
261
|
else {
|
191
262
|
this.initDataUnit();
|
192
263
|
}
|
193
|
-
this._snkDataUnit.addEventListener("dataStateChange",
|
194
|
-
this._dataState = dataState;
|
195
|
-
if (dataState.selectedRecord !== undefined) {
|
196
|
-
this.attachmentRegisterKey = await this.getAttachmentRegisterKey();
|
197
|
-
}
|
198
|
-
});
|
264
|
+
this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
|
199
265
|
break;
|
200
266
|
}
|
201
267
|
parent = parent.parentElement;
|
@@ -211,6 +277,25 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
211
277
|
this.removeShortcuts();
|
212
278
|
window.removeEventListener("keydown", this._keyDownHandler);
|
213
279
|
}
|
280
|
+
async handleDataStateChange(evt) {
|
281
|
+
var _a;
|
282
|
+
this._dataState = evt.detail;
|
283
|
+
if (this._dataState.selectedRecord !== undefined) {
|
284
|
+
this.attachmentRegisterKey = await this.getAttachmentRegisterKey();
|
285
|
+
}
|
286
|
+
const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
|
287
|
+
for (const field of fieldsWithRmPrecision || []) {
|
288
|
+
if (!field) {
|
289
|
+
continue;
|
290
|
+
}
|
291
|
+
const rmPrecision = (_a = this._dataState.rowMetadata) === null || _a === void 0 ? void 0 : _a.getProp('rm_precision', field);
|
292
|
+
if (!rmPrecision && rmPrecision !== 0) {
|
293
|
+
continue;
|
294
|
+
}
|
295
|
+
await this.setFieldProp(field, 'precision', rmPrecision);
|
296
|
+
await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
|
297
|
+
}
|
298
|
+
}
|
214
299
|
async initKeyboardManager() {
|
215
300
|
var _a;
|
216
301
|
const keyboardManager = await ((_a = this._application) === null || _a === void 0 ? void 0 : _a.getKeyboardManager());
|
@@ -330,7 +415,7 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
330
415
|
return;
|
331
416
|
}
|
332
417
|
this._snkDataUnit.ignoreSaveMessage = this._currentViewMode === VIEW_MODE.GRID;
|
333
|
-
return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, filterBarTitle: this.filterBarTitle, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode, recordsValidator: this.recordsValidator, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID, disablePersonalizedFilter: this.disablePersonalizedFilter, gridLegacyConfigName: this.gridLegacyConfigName, filterBarLegacyConfigName: this.filterBarLegacyConfigName }, h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form", canEdit: this._canEdit, recordsValidator: this.recordsValidator, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId, formLegacyConfigName: this.formLegacyConfigName }, h("slot", { name: "GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkFormTaskBar" }))), h("stack-item", null, h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this._snkDataUnit.entityName, onBack: this.backView.bind(this) })), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.setViewMode(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showActionButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this._resourceID, customContainerId: this.customContainerId })), h("div", { id: `${this.customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }), h("slot", { name: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" }))));
|
418
|
+
return (h(Host, null, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "crud" }, h("stack-item", null, h("snk-grid", { ref: (ref) => this._snkGrid = ref, filterBarTitle: this.filterBarTitle, "data-element-id": "crud_grid", configName: this.configName, onGridDoubleClick: () => this.gridToForm(true), taskbarManager: this.taskbarManager, onActionClick: evt => this.executeAction(evt.detail), messagesBuilder: this.messagesBuilder, actionsList: this.actionsList, statusResolver: this.statusResolver, multipleSelection: this.multipleSelection, presentationMode: this.presentationMode, recordsValidator: this.recordsValidator, selectionToastConfig: this.selectionToastConfig, useEnterLikeTab: this.useEnterLikeTab, canEdit: this._canEdit, resourceID: this._resourceID, disablePersonalizedFilter: this.disablePersonalizedFilter, gridLegacyConfigName: this.gridLegacyConfigName, filterBarLegacyConfigName: this.filterBarLegacyConfigName, autoLoad: this.autoLoad, autoFocus: this.autoFocus }, h("slot", { name: "GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkGridHeader" }), h("slot", { name: "SnkGridFooter" }), h("slot", { name: "SnkGridTaskBar" }))), h("stack-item", null, h("snk-guides-viewer", { ref: ref => this._guidesViewer = ref, entityPath: this._snkDataUnit.entityName, messagesBuilder: this.messagesBuilder, onExit: () => this.setViewMode(VIEW_MODE.GRID), dataState: this._dataState, dataUnit: this._dataUnit, actionsList: this.actionsList, taskbarManager: this.taskbarManager, configName: this.configName, onActionClick: evt => this.executeAction(evt.detail), presentationMode: this.presentationMode, "data-element-id": "crud_form", canEdit: this._canEdit, recordsValidator: this.recordsValidator, resourceID: this._resourceID, detailTaskbarCustomContainerId: this.customContainerId, formLegacyConfigName: this.formLegacyConfigName }, h("slot", { name: "GUIDES_VIEWER_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "SnkFormTaskBar" }))), h("stack-item", null, h("snk-attach", { registerKey: this.attachmentRegisterKey, messagesBuilder: this.messagesBuilder, entityName: this._snkDataUnit.entityName, onBack: this.backView.bind(this) })), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.setViewMode(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showActionButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this._resourceID, customContainerId: this.customContainerId })), h("div", { id: `${this.customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }), h("slot", { name: "DETAIL_GRID_HEADER_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_GRID_TASKBAR_CUSTOM_ELEMENTS" }), h("slot", { name: "DETAIL_TASKBAR_CUSTOM_ELEMENTS" }))));
|
334
419
|
}
|
335
420
|
get _element() { return this; }
|
336
421
|
static get watchers() { return {
|
@@ -354,6 +439,8 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
354
439
|
"filterBarLegacyConfigName": [1, "filter-bar-legacy-config-name"],
|
355
440
|
"formLegacyConfigName": [1, "form-legacy-config-name"],
|
356
441
|
"disablePersonalizedFilter": [4, "disable-personalized-filter"],
|
442
|
+
"autoLoad": [4, "auto-load"],
|
443
|
+
"autoFocus": [4, "auto-focus"],
|
357
444
|
"_dataUnit": [32],
|
358
445
|
"_dataState": [32],
|
359
446
|
"attachmentRegisterKey": [32],
|
@@ -365,7 +452,12 @@ const SnkCrud$1 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
365
452
|
"openConfigurator": [64],
|
366
453
|
"closeConfigurator": [64],
|
367
454
|
"reloadFilterBar": [64],
|
368
|
-
"getFilterBar": [64]
|
455
|
+
"getFilterBar": [64],
|
456
|
+
"addCustomEditor": [64],
|
457
|
+
"addGridCustomRender": [64],
|
458
|
+
"addCustomValueFormatter": [64],
|
459
|
+
"removeCustomValueFormatter": [64],
|
460
|
+
"setFieldProp": [64]
|
369
461
|
}]);
|
370
462
|
function defineCustomElement$1() {
|
371
463
|
if (typeof customElements === "undefined") {
|