@sankhyalabs/sankhyablocks 8.15.1 → 8.16.0-dev.2
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-9479f618.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-0c7106a0.js} +88 -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-16791a2f.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-d82746e8.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 +8 -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 +85 -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-5a858363.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-f7e0ffc0.js} +84 -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-a327d22c.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-874da66f.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-0046959e.entry.js +1 -0
- package/dist/sankhyablocks/p-0e11ee18.entry.js +1 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-30cf616e.js +1 -0
- package/dist/sankhyablocks/p-47b60deb.entry.js +1 -0
- package/dist/sankhyablocks/p-60e46675.entry.js +11 -0
- package/dist/sankhyablocks/p-6d4f4614.js +60 -0
- package/dist/sankhyablocks/p-6ded2076.entry.js +1 -0
- package/dist/sankhyablocks/p-7a337364.js +1 -0
- package/dist/sankhyablocks/p-7d9baaf4.entry.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-8c6b44ea.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-a4b1f1eb.js +1 -0
- package/dist/sankhyablocks/p-af8efd95.js +6 -0
- package/dist/sankhyablocks/p-b7c4feeb.entry.js +1 -0
- package/dist/sankhyablocks/p-b8cde0d8.entry.js +1 -0
- package/dist/sankhyablocks/p-c7cbad38.js +1 -0
- package/dist/sankhyablocks/p-e0b9f59a.entry.js +1 -0
- package/dist/sankhyablocks/p-e6210aec.js +1 -0
- package/dist/sankhyablocks/p-e9bbc3d5.entry.js +1 -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
package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js
CHANGED
@@ -26,6 +26,8 @@ export class SnkDetailView {
|
|
26
26
|
this.branchGuide = undefined;
|
27
27
|
this.canEdit = true;
|
28
28
|
this.taskbarCustomContainerId = undefined;
|
29
|
+
this.customEditors = undefined;
|
30
|
+
this.customRenders = undefined;
|
29
31
|
}
|
30
32
|
observeDataUnit(newDataUnit, oldDataUnit) {
|
31
33
|
newDataUnit === null || newDataUnit === void 0 ? void 0 : newDataUnit.subscribe(this.dataUnitActionHandler.bind(this));
|
@@ -93,10 +95,38 @@ export class SnkDetailView {
|
|
93
95
|
this._snkGrid.scrollIntoView({ behavior: "smooth", block: "start" });
|
94
96
|
}
|
95
97
|
}
|
98
|
+
/**
|
99
|
+
* Registra um editor customizado para campos da grade e formulário.
|
100
|
+
*/
|
101
|
+
async addCustomEditor(fieldName, customEditor) {
|
102
|
+
var _a;
|
103
|
+
const detailContext = this.normalizeBranchGuideId((_a = this.branchGuide) === null || _a === void 0 ? void 0 : _a.id);
|
104
|
+
this._snkGrid.addCustomEditor(fieldName, customEditor, detailContext);
|
105
|
+
this._snkFormView.addCustomEditor(fieldName, customEditor, detailContext);
|
106
|
+
}
|
107
|
+
async observerPropsCustomEditor(newValue) {
|
108
|
+
for (const fieldName in newValue) {
|
109
|
+
await this.addCustomEditor(fieldName, newValue[fieldName]);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
/**
|
113
|
+
* Registra um render customizado para colunas da grid.
|
114
|
+
*/
|
115
|
+
async addGridCustomRender(fieldName, customRender) {
|
116
|
+
var _a;
|
117
|
+
const detailContext = this.normalizeBranchGuideId((_a = this.branchGuide) === null || _a === void 0 ? void 0 : _a.id);
|
118
|
+
await this._snkGrid.addGridCustomRender(fieldName, customRender, detailContext);
|
119
|
+
}
|
96
120
|
onContentCardChanged(evt) {
|
97
121
|
SnkGuidesViewer.updateContentCard(evt.detail.formName, evt.detail.cardConfig, evt.detail.propertyChanged, this.formConfigManager).then(() => forceUpdate(this));
|
98
122
|
evt.stopPropagation();
|
99
123
|
}
|
124
|
+
async observeCustomRenders(newValue) {
|
125
|
+
for (const field in newValue) {
|
126
|
+
const customRender = newValue[field];
|
127
|
+
await this.addGridCustomRender(field, customRender);
|
128
|
+
}
|
129
|
+
}
|
100
130
|
updateLabel() {
|
101
131
|
const guideItemPathSize = this.guideItemPath ? this.guideItemPath.length : 0;
|
102
132
|
if (guideItemPathSize > 0) {
|
@@ -199,6 +229,10 @@ export class SnkDetailView {
|
|
199
229
|
this.messagesBuilder = new SnkMessageBuilder(this.entityName);
|
200
230
|
}
|
201
231
|
}
|
232
|
+
async componentDidLoad() {
|
233
|
+
await this.observerPropsCustomEditor(this.customEditors);
|
234
|
+
await this.observeCustomRenders(this.customRenders);
|
235
|
+
}
|
202
236
|
async dataUnitActionHandler(action) {
|
203
237
|
if (action.type === Action.FIELD_INVALIDATED) {
|
204
238
|
this.addErrorBadgeToBranchGuide();
|
@@ -208,6 +242,9 @@ export class SnkDetailView {
|
|
208
242
|
this.branchGuide = Object.assign(Object.assign({}, this.branchGuide), { badge: 'error' });
|
209
243
|
this.snkDetailGuidesChange.emit(new GuideBuilder(this.branchGuide, this._formMetadata, this.dataUnit));
|
210
244
|
}
|
245
|
+
normalizeBranchGuideId(id) {
|
246
|
+
return id === null || id === void 0 ? void 0 : id.replace(/child\[(.*?)\]/g, '$1').replace(/::/g, '>');
|
247
|
+
}
|
211
248
|
render() {
|
212
249
|
this.updateLabel();
|
213
250
|
//const cardConfig: IFormCardConfig = this._cardsState?.get(this.selectedForm);
|
@@ -469,6 +506,46 @@ export class SnkDetailView {
|
|
469
506
|
},
|
470
507
|
"attribute": "taskbar-custom-container-id",
|
471
508
|
"reflect": false
|
509
|
+
},
|
510
|
+
"customEditors": {
|
511
|
+
"type": "unknown",
|
512
|
+
"mutable": false,
|
513
|
+
"complexType": {
|
514
|
+
"original": "PropsCustomEditor",
|
515
|
+
"resolved": "PropsCustomEditor",
|
516
|
+
"references": {
|
517
|
+
"PropsCustomEditor": {
|
518
|
+
"location": "import",
|
519
|
+
"path": "../../interfaces/PropsCustomEditor"
|
520
|
+
}
|
521
|
+
}
|
522
|
+
},
|
523
|
+
"required": false,
|
524
|
+
"optional": false,
|
525
|
+
"docs": {
|
526
|
+
"tags": [],
|
527
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio."
|
528
|
+
}
|
529
|
+
},
|
530
|
+
"customRenders": {
|
531
|
+
"type": "unknown",
|
532
|
+
"mutable": false,
|
533
|
+
"complexType": {
|
534
|
+
"original": "PropsCustomRender",
|
535
|
+
"resolved": "PropsCustomRender",
|
536
|
+
"references": {
|
537
|
+
"PropsCustomRender": {
|
538
|
+
"location": "import",
|
539
|
+
"path": "../../interfaces/PropsCustomRender"
|
540
|
+
}
|
541
|
+
}
|
542
|
+
},
|
543
|
+
"required": false,
|
544
|
+
"optional": false,
|
545
|
+
"docs": {
|
546
|
+
"tags": [],
|
547
|
+
"text": "Render customizados da grade."
|
548
|
+
}
|
472
549
|
}
|
473
550
|
};
|
474
551
|
}
|
@@ -601,6 +678,58 @@ export class SnkDetailView {
|
|
601
678
|
"text": "",
|
602
679
|
"tags": []
|
603
680
|
}
|
681
|
+
},
|
682
|
+
"addCustomEditor": {
|
683
|
+
"complexType": {
|
684
|
+
"signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
|
685
|
+
"parameters": [{
|
686
|
+
"tags": [],
|
687
|
+
"text": ""
|
688
|
+
}, {
|
689
|
+
"tags": [],
|
690
|
+
"text": ""
|
691
|
+
}],
|
692
|
+
"references": {
|
693
|
+
"Promise": {
|
694
|
+
"location": "global"
|
695
|
+
},
|
696
|
+
"ICustomEditor": {
|
697
|
+
"location": "import",
|
698
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
699
|
+
}
|
700
|
+
},
|
701
|
+
"return": "Promise<void>"
|
702
|
+
},
|
703
|
+
"docs": {
|
704
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
|
705
|
+
"tags": []
|
706
|
+
}
|
707
|
+
},
|
708
|
+
"addGridCustomRender": {
|
709
|
+
"complexType": {
|
710
|
+
"signature": "(fieldName: string, customRender: ICustomRender) => Promise<void>",
|
711
|
+
"parameters": [{
|
712
|
+
"tags": [],
|
713
|
+
"text": ""
|
714
|
+
}, {
|
715
|
+
"tags": [],
|
716
|
+
"text": ""
|
717
|
+
}],
|
718
|
+
"references": {
|
719
|
+
"Promise": {
|
720
|
+
"location": "global"
|
721
|
+
},
|
722
|
+
"ICustomRender": {
|
723
|
+
"location": "import",
|
724
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
725
|
+
}
|
726
|
+
},
|
727
|
+
"return": "Promise<void>"
|
728
|
+
},
|
729
|
+
"docs": {
|
730
|
+
"text": "Registra um render customizado para colunas da grid.",
|
731
|
+
"tags": []
|
732
|
+
}
|
604
733
|
}
|
605
734
|
};
|
606
735
|
}
|
@@ -611,6 +740,12 @@ export class SnkDetailView {
|
|
611
740
|
}, {
|
612
741
|
"propName": "dataState",
|
613
742
|
"methodName": "observerDataState"
|
743
|
+
}, {
|
744
|
+
"propName": "customEditors",
|
745
|
+
"methodName": "observerPropsCustomEditor"
|
746
|
+
}, {
|
747
|
+
"propName": "customRenders",
|
748
|
+
"methodName": "observeCustomRenders"
|
614
749
|
}];
|
615
750
|
}
|
616
751
|
static get listeners() {
|
@@ -3,6 +3,8 @@ import { Host, h } from "@stencil/core";
|
|
3
3
|
import { DataBinder } from "@sankhyalabs/ezui/dist/collection/utils/form";
|
4
4
|
export class SnkFormView {
|
5
5
|
constructor() {
|
6
|
+
this._customEditors = new Map();
|
7
|
+
this._fieldProps = new Map();
|
6
8
|
this.levelPath = undefined;
|
7
9
|
this.label = undefined;
|
8
10
|
this.name = undefined;
|
@@ -16,12 +18,47 @@ export class SnkFormView {
|
|
16
18
|
this.canFix = true;
|
17
19
|
this.recordsValidator = undefined;
|
18
20
|
this.fieldToFocus = undefined;
|
21
|
+
this.customEditors = undefined;
|
22
|
+
this.fieldsProps = undefined;
|
19
23
|
}
|
20
24
|
async showUp() {
|
21
25
|
if (this._formView) {
|
22
26
|
this._formView.showUp();
|
23
27
|
}
|
24
28
|
}
|
29
|
+
/**
|
30
|
+
* Registra um editor customizado para campos da grade e formulário
|
31
|
+
*/
|
32
|
+
async addCustomEditor(fieldName, customEditor, detailContext) {
|
33
|
+
if (this._formView) {
|
34
|
+
this._formView.addCustomEditor(fieldName, customEditor, detailContext);
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
const newCustomEditors = new Map(this._customEditors);
|
38
|
+
newCustomEditors.set(fieldName, { customEditor, detailContext });
|
39
|
+
this._customEditors = newCustomEditors;
|
40
|
+
}
|
41
|
+
observePropsCustomEditor(newValue) {
|
42
|
+
for (const fieldName in newValue) {
|
43
|
+
this.addCustomEditor(fieldName, newValue[fieldName]);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* Altera/adiciona uma propriedade nos metadados do campo.
|
48
|
+
*/
|
49
|
+
async setFieldProp(fieldName, propName, value) {
|
50
|
+
const props = this._fieldProps.get(fieldName) || [];
|
51
|
+
this._fieldProps.set(fieldName, [...props, { propName, value }]);
|
52
|
+
}
|
53
|
+
async observeFieldsProps(newValue) {
|
54
|
+
for (const field in newValue) {
|
55
|
+
const fieldProps = newValue[field];
|
56
|
+
const propNames = Object.keys(fieldProps);
|
57
|
+
for (const propName of propNames) {
|
58
|
+
await this.setFieldProp(field, propName, fieldProps[propName]);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
25
62
|
changeFix() {
|
26
63
|
this.fixed = !this.fixed;
|
27
64
|
this.emitEvent("fixed");
|
@@ -80,7 +117,13 @@ export class SnkFormView {
|
|
80
117
|
this._dataBinder.onDisconnectedCallback();
|
81
118
|
}
|
82
119
|
}
|
120
|
+
componentDidLoad() {
|
121
|
+
this.observePropsCustomEditor(this.customEditors);
|
122
|
+
this.observeFieldsProps(this.fieldsProps);
|
123
|
+
}
|
83
124
|
componentDidRender() {
|
125
|
+
this.setCustomEditors();
|
126
|
+
this.setFieldProps();
|
84
127
|
if (this.fieldToFocus == undefined) {
|
85
128
|
return;
|
86
129
|
}
|
@@ -92,6 +135,26 @@ export class SnkFormView {
|
|
92
135
|
this.snkRequestClearFieldToFocus.emit();
|
93
136
|
});
|
94
137
|
}
|
138
|
+
setCustomEditors() {
|
139
|
+
if (!this._formView) {
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
for (const [fieldName, customEditorProps] of this._customEditors) {
|
143
|
+
this._formView.addCustomEditor(fieldName, customEditorProps.customEditor, customEditorProps.detailContext);
|
144
|
+
this._customEditors.delete(fieldName);
|
145
|
+
}
|
146
|
+
}
|
147
|
+
setFieldProps() {
|
148
|
+
if (!this._formView) {
|
149
|
+
return;
|
150
|
+
}
|
151
|
+
for (const [fieldName, propsToChange] of this._fieldProps) {
|
152
|
+
propsToChange.forEach(prop => {
|
153
|
+
this._formView.setFieldProp(fieldName, prop.propName, prop.value);
|
154
|
+
this._fieldProps.delete(fieldName);
|
155
|
+
});
|
156
|
+
}
|
157
|
+
}
|
95
158
|
render() {
|
96
159
|
return (h(Host, { class: "ez-box__container" }, h("div", { class: "summary-header ez-flex ez-size-width--full" }, h("div", { class: "ez-flex ez-text ez-title--primary ez-text--bold ez-flex--justify-start ez-flex--align-items-center ez-col--sd-9" }, this.levelPath ? h("span", { class: "level-path" }, this.levelPath + " /") : undefined, this.label), h("div", { class: "ez-flex ez-flex--justify-end ez-col--sd-3" }, this.canFix &&
|
97
160
|
h("ez-button", { class: "ez-padding-left--medium", mode: "icon", size: "small", iconName: this.fixed ? "un-pin" : "push-pin", "data-element-id": ElementIDUtils.getInternalIDInfo("toggleFixed_ezFormCard"), onClick: () => this.changeFix(), title: this.fixed ? "Desafixar" : "Fixar" }), this.canExpand &&
|
@@ -361,6 +424,41 @@ export class SnkFormView {
|
|
361
424
|
},
|
362
425
|
"attribute": "field-to-focus",
|
363
426
|
"reflect": false
|
427
|
+
},
|
428
|
+
"customEditors": {
|
429
|
+
"type": "unknown",
|
430
|
+
"mutable": false,
|
431
|
+
"complexType": {
|
432
|
+
"original": "PropsCustomEditor",
|
433
|
+
"resolved": "PropsCustomEditor",
|
434
|
+
"references": {
|
435
|
+
"PropsCustomEditor": {
|
436
|
+
"location": "import",
|
437
|
+
"path": "../interfaces/PropsCustomEditor"
|
438
|
+
}
|
439
|
+
}
|
440
|
+
},
|
441
|
+
"required": false,
|
442
|
+
"optional": false,
|
443
|
+
"docs": {
|
444
|
+
"tags": [],
|
445
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio."
|
446
|
+
}
|
447
|
+
},
|
448
|
+
"fieldsProps": {
|
449
|
+
"type": "unknown",
|
450
|
+
"mutable": false,
|
451
|
+
"complexType": {
|
452
|
+
"original": "object",
|
453
|
+
"resolved": "object",
|
454
|
+
"references": {}
|
455
|
+
},
|
456
|
+
"required": false,
|
457
|
+
"optional": false,
|
458
|
+
"docs": {
|
459
|
+
"tags": [],
|
460
|
+
"text": "Lista de propriedades que ser\u00E3o alteradas/adicionadas por coluna."
|
461
|
+
}
|
364
462
|
}
|
365
463
|
};
|
366
464
|
}
|
@@ -441,7 +539,70 @@ export class SnkFormView {
|
|
441
539
|
"text": "",
|
442
540
|
"tags": []
|
443
541
|
}
|
542
|
+
},
|
543
|
+
"addCustomEditor": {
|
544
|
+
"complexType": {
|
545
|
+
"signature": "(fieldName: string, customEditor: ICustomEditor, detailContext?: string) => Promise<void>",
|
546
|
+
"parameters": [{
|
547
|
+
"tags": [],
|
548
|
+
"text": ""
|
549
|
+
}, {
|
550
|
+
"tags": [],
|
551
|
+
"text": ""
|
552
|
+
}, {
|
553
|
+
"tags": [],
|
554
|
+
"text": ""
|
555
|
+
}],
|
556
|
+
"references": {
|
557
|
+
"Promise": {
|
558
|
+
"location": "global"
|
559
|
+
},
|
560
|
+
"ICustomEditor": {
|
561
|
+
"location": "import",
|
562
|
+
"path": "@sankhyalabs/ezui/dist/types/utils/customEditor/interfaces/ICustomEditor"
|
563
|
+
}
|
564
|
+
},
|
565
|
+
"return": "Promise<void>"
|
566
|
+
},
|
567
|
+
"docs": {
|
568
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio",
|
569
|
+
"tags": []
|
570
|
+
}
|
571
|
+
},
|
572
|
+
"setFieldProp": {
|
573
|
+
"complexType": {
|
574
|
+
"signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
|
575
|
+
"parameters": [{
|
576
|
+
"tags": [],
|
577
|
+
"text": ""
|
578
|
+
}, {
|
579
|
+
"tags": [],
|
580
|
+
"text": ""
|
581
|
+
}, {
|
582
|
+
"tags": [],
|
583
|
+
"text": ""
|
584
|
+
}],
|
585
|
+
"references": {
|
586
|
+
"Promise": {
|
587
|
+
"location": "global"
|
588
|
+
}
|
589
|
+
},
|
590
|
+
"return": "Promise<void>"
|
591
|
+
},
|
592
|
+
"docs": {
|
593
|
+
"text": "Altera/adiciona uma propriedade nos metadados do campo.",
|
594
|
+
"tags": []
|
595
|
+
}
|
444
596
|
}
|
445
597
|
};
|
446
598
|
}
|
599
|
+
static get watchers() {
|
600
|
+
return [{
|
601
|
+
"propName": "customEditors",
|
602
|
+
"methodName": "observePropsCustomEditor"
|
603
|
+
}, {
|
604
|
+
"propName": "fieldsProps",
|
605
|
+
"methodName": "observeFieldsProps"
|
606
|
+
}];
|
607
|
+
}
|
447
608
|
}
|
@@ -33,6 +33,9 @@ export class SnkGuidesViewer {
|
|
33
33
|
this._formEditorConfigManager = undefined;
|
34
34
|
this._formEditorDataUnit = undefined;
|
35
35
|
this._fieldToGetFocus = undefined;
|
36
|
+
this._customEditors = undefined;
|
37
|
+
this._customRenders = undefined;
|
38
|
+
this._fieldsProps = {};
|
36
39
|
}
|
37
40
|
observeDataUnit() {
|
38
41
|
this.loadGuides(true);
|
@@ -63,6 +66,28 @@ export class SnkGuidesViewer {
|
|
63
66
|
async findField() {
|
64
67
|
await openFieldSearch(this._moreOptions, this._fieldSearch);
|
65
68
|
}
|
69
|
+
/**
|
70
|
+
* Registra um editor customizado para campos da grade e formulário
|
71
|
+
*/
|
72
|
+
async addCustomEditor(fieldName, customEditor) {
|
73
|
+
this._customEditors = Object.assign(Object.assign({}, this._customEditors), { [fieldName]: customEditor });
|
74
|
+
}
|
75
|
+
/**
|
76
|
+
* Registra um render customizado para colunas da grid.
|
77
|
+
*/
|
78
|
+
async addGridCustomRender(fieldName, customRender) {
|
79
|
+
this._customRenders = Object.assign(Object.assign({}, this._customRenders), { [fieldName]: customRender });
|
80
|
+
}
|
81
|
+
;
|
82
|
+
/**
|
83
|
+
* Altera/adiciona uma propriedade nos metadados do campo.
|
84
|
+
*/
|
85
|
+
async setFieldProp(fieldName, propName, value) {
|
86
|
+
const newFieldsProps = {
|
87
|
+
[fieldName]: Object.assign(Object.assign({}, this._fieldsProps[fieldName]), { [propName]: value })
|
88
|
+
};
|
89
|
+
this._fieldsProps = Object.assign(Object.assign({}, this._fieldsProps), newFieldsProps);
|
90
|
+
}
|
66
91
|
/**
|
67
92
|
* Atribui o foco para o componente.
|
68
93
|
*/
|
@@ -211,7 +236,7 @@ export class SnkGuidesViewer {
|
|
211
236
|
if (sheet == undefined) {
|
212
237
|
return;
|
213
238
|
}
|
214
|
-
return h("snk-form-view", { levelPath: params.levelPath, label: sheet.label, name: formName, fields: sheet.fields, formMetadata: params.formMetadata, dataUnit: params.dataUnit, recordsValidator: params.recordsValidator, contracted: (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.presentation) === "CONTRACTED", fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_b = (_a = params.formConfig) === null || _a === void 0 ? void 0 : _a.summary) === null || _b === void 0 ? void 0 : _b.get(formName), fieldToFocus: params.fieldToFocus, key: formName, onSnkRequestClearFieldToFocus: _ => { var _a; return (_a = params.onRequestClearFieldToFocus) === null || _a === void 0 ? void 0 : _a.call(params); } });
|
239
|
+
return h("snk-form-view", { levelPath: params.levelPath, label: sheet.label, name: formName, fields: sheet.fields, formMetadata: params.formMetadata, dataUnit: params.dataUnit, recordsValidator: params.recordsValidator, contracted: (cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.presentation) === "CONTRACTED", fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_b = (_a = params.formConfig) === null || _a === void 0 ? void 0 : _a.summary) === null || _b === void 0 ? void 0 : _b.get(formName), fieldToFocus: params.fieldToFocus, key: formName, onSnkRequestClearFieldToFocus: _ => { var _a; return (_a = params.onRequestClearFieldToFocus) === null || _a === void 0 ? void 0 : _a.call(params); }, customEditors: params.propsCustomEditor, fieldsProps: params.fieldsProps });
|
215
240
|
})));
|
216
241
|
}
|
217
242
|
wrapDetail(levels, content) {
|
@@ -253,14 +278,14 @@ export class SnkGuidesViewer {
|
|
253
278
|
else {
|
254
279
|
detailBranch = this.selectedGuide;
|
255
280
|
}
|
256
|
-
content = this.wrapDetail(levels, h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, canEdit: this.canEdit, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail), resourceID: this.resourceID, taskbarCustomContainerId: this.detailTaskbarCustomContainerId }));
|
281
|
+
content = this.wrapDetail(levels, h("snk-detail-view", { ref: (ref) => this._currentDetail = ref, dataUnitName: this.getDataUnitName(levels, childEntityName), onSnkDetailGuidesChange: (evt) => this.updateGuide(evt.detail), entityName: childEntityName, selectedForm: formName, branchGuide: detailBranch, guideItemPath: this._breadcrumbItems, key: `detail${detailId}`, canEdit: this.canEdit, onSnkSwitchGuide: evt => this._guideNavigator.selectGuide(evt.detail), resourceID: this.resourceID, taskbarCustomContainerId: this.detailTaskbarCustomContainerId, customEditors: this._customEditors, customRenders: this._customRenders }));
|
257
282
|
}
|
258
283
|
else {
|
259
284
|
const cardId = this.selectedGuide.id;
|
260
285
|
const sheet = this._masterFormMetadata.getSheet(cardId);
|
261
286
|
if (sheet) {
|
262
287
|
const cardConfig = (_c = (_b = this.masterFormConfig) === null || _b === void 0 ? void 0 : _b.cardsState) === null || _c === void 0 ? void 0 : _c.get(cardId);
|
263
|
-
content = h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_e = (_d = this.masterFormConfig) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, fieldToFocus: this._fieldToGetFocus, key: guideId, onSnkRequestClearFieldToFocus: _ => this.clearFieldToFocusHandler() }, this.presentationMode == PresentationMode.SECONDARY && this.buildTaskBar());
|
288
|
+
content = h("snk-form-view", { ref: ref => this._mainForm = ref, fixed: cardConfig === null || cardConfig === void 0 ? void 0 : cardConfig.fixed, summaryFields: (_e = (_d = this.masterFormConfig) === null || _d === void 0 ? void 0 : _d.summary) === null || _e === void 0 ? void 0 : _e.get(cardId), name: cardId, label: sheet.label, fields: sheet.fields, dataUnit: this.dataUnit, formMetadata: this._masterFormMetadata, recordsValidator: this.recordsValidator, fieldToFocus: this._fieldToGetFocus, key: guideId, onSnkRequestClearFieldToFocus: _ => this.clearFieldToFocusHandler(), customEditors: this._customEditors, fieldsProps: this._fieldsProps }, this.presentationMode == PresentationMode.SECONDARY && this.buildTaskBar());
|
264
289
|
}
|
265
290
|
}
|
266
291
|
return content;
|
@@ -463,7 +488,9 @@ export class SnkGuidesViewer {
|
|
463
488
|
dataUnit: this.dataUnit,
|
464
489
|
recordsValidator: this.recordsValidator,
|
465
490
|
fieldToFocus: this._fieldToGetFocus,
|
466
|
-
onRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this)
|
491
|
+
onRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this),
|
492
|
+
propsCustomEditor: this._customEditors,
|
493
|
+
fieldsProps: this._fieldsProps
|
467
494
|
}), this.getContent())), h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this.getConfigViewMode(), onConfigSelected: (evt) => this.changeConfigViewMode(evt.detail), messagesBuilder: this.messagesBuilder, onOpenConfig: (evt) => this.openConfig(evt.detail), resourceID: this.resourceID })));
|
468
495
|
}
|
469
496
|
static get is() { return "snk-guides-viewer"; }
|
@@ -777,7 +804,10 @@ export class SnkGuidesViewer {
|
|
777
804
|
"_guides": {},
|
778
805
|
"_formEditorConfigManager": {},
|
779
806
|
"_formEditorDataUnit": {},
|
780
|
-
"_fieldToGetFocus": {}
|
807
|
+
"_fieldToGetFocus": {},
|
808
|
+
"_customEditors": {},
|
809
|
+
"_customRenders": {},
|
810
|
+
"_fieldsProps": {}
|
781
811
|
};
|
782
812
|
}
|
783
813
|
static get events() {
|
@@ -878,6 +908,83 @@ export class SnkGuidesViewer {
|
|
878
908
|
"tags": []
|
879
909
|
}
|
880
910
|
},
|
911
|
+
"addCustomEditor": {
|
912
|
+
"complexType": {
|
913
|
+
"signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
|
914
|
+
"parameters": [{
|
915
|
+
"tags": [],
|
916
|
+
"text": ""
|
917
|
+
}, {
|
918
|
+
"tags": [],
|
919
|
+
"text": ""
|
920
|
+
}],
|
921
|
+
"references": {
|
922
|
+
"Promise": {
|
923
|
+
"location": "global"
|
924
|
+
},
|
925
|
+
"ICustomEditor": {
|
926
|
+
"location": "import",
|
927
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
928
|
+
}
|
929
|
+
},
|
930
|
+
"return": "Promise<void>"
|
931
|
+
},
|
932
|
+
"docs": {
|
933
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio",
|
934
|
+
"tags": []
|
935
|
+
}
|
936
|
+
},
|
937
|
+
"addGridCustomRender": {
|
938
|
+
"complexType": {
|
939
|
+
"signature": "(fieldName: string, customRender: ICustomRender) => Promise<void>",
|
940
|
+
"parameters": [{
|
941
|
+
"tags": [],
|
942
|
+
"text": ""
|
943
|
+
}, {
|
944
|
+
"tags": [],
|
945
|
+
"text": ""
|
946
|
+
}],
|
947
|
+
"references": {
|
948
|
+
"Promise": {
|
949
|
+
"location": "global"
|
950
|
+
},
|
951
|
+
"ICustomRender": {
|
952
|
+
"location": "import",
|
953
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
954
|
+
}
|
955
|
+
},
|
956
|
+
"return": "Promise<void>"
|
957
|
+
},
|
958
|
+
"docs": {
|
959
|
+
"text": "Registra um render customizado para colunas da grid.",
|
960
|
+
"tags": []
|
961
|
+
}
|
962
|
+
},
|
963
|
+
"setFieldProp": {
|
964
|
+
"complexType": {
|
965
|
+
"signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
|
966
|
+
"parameters": [{
|
967
|
+
"tags": [],
|
968
|
+
"text": ""
|
969
|
+
}, {
|
970
|
+
"tags": [],
|
971
|
+
"text": ""
|
972
|
+
}, {
|
973
|
+
"tags": [],
|
974
|
+
"text": ""
|
975
|
+
}],
|
976
|
+
"references": {
|
977
|
+
"Promise": {
|
978
|
+
"location": "global"
|
979
|
+
}
|
980
|
+
},
|
981
|
+
"return": "Promise<void>"
|
982
|
+
},
|
983
|
+
"docs": {
|
984
|
+
"text": "Altera/adiciona uma propriedade nos metadados do campo.",
|
985
|
+
"tags": []
|
986
|
+
}
|
987
|
+
},
|
881
988
|
"setFocus": {
|
882
989
|
"complexType": {
|
883
990
|
"signature": "() => Promise<void>",
|
package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
import { UserInterface } from "@sankhyalabs/core";
|
2
|
+
import { DataFetcher } from "../../../lib";
|
3
|
+
import { getOptionKey, getVisibleColumns } from "../utils/ParserExport";
|
4
|
+
import { DataExporterType } from "../../../lib/@types";
|
5
|
+
export default class ClientSideExporterStrategy {
|
6
|
+
constructor(provider) {
|
7
|
+
this._provider = provider;
|
8
|
+
}
|
9
|
+
async getParsedColumns() {
|
10
|
+
const columns = await this._provider.getColumnsMetadata();
|
11
|
+
const visibleColumns = getVisibleColumns(columns);
|
12
|
+
return visibleColumns;
|
13
|
+
}
|
14
|
+
async executeExport(resolveProps) {
|
15
|
+
const { methodName, titleGrid } = resolveProps;
|
16
|
+
const records = await this._provider.getRecords();
|
17
|
+
const columns = [DataExporterType.EXPORT_TO_PDF, DataExporterType.EXPORT_PAGE_TO_PDF, DataExporterType.EXPORT_PDF_TO_EMAIL, DataExporterType.EXPORT_ALL_RECORDS_TO_PDF].includes(getOptionKey(resolveProps === null || resolveProps === void 0 ? void 0 : resolveProps.exportOption)) ? await this.getParsedColumns() : await this._provider.getColumnsMetadata();
|
18
|
+
const [serviceName, processor] = this.getExecutor(methodName);
|
19
|
+
const payload = {
|
20
|
+
serviceName,
|
21
|
+
requestBody: {
|
22
|
+
grid: {
|
23
|
+
titleGrid,
|
24
|
+
columns: this.buildColumnsObject(columns),
|
25
|
+
rows: this.buildRowsObject(columns, records),
|
26
|
+
customOptions: { xlsxExtension: false }
|
27
|
+
}
|
28
|
+
}
|
29
|
+
};
|
30
|
+
return new Promise((resolve, reject) => {
|
31
|
+
DataFetcher.get()
|
32
|
+
.callServiceBroker(serviceName, payload)
|
33
|
+
.then(result => resolve(processor(result)))
|
34
|
+
.catch(error => reject(error));
|
35
|
+
});
|
36
|
+
}
|
37
|
+
getExecutor(methodName) {
|
38
|
+
if (methodName === "exportToPDF") {
|
39
|
+
return [
|
40
|
+
"GridPDFBuilderSP.buildPDFFromJson",
|
41
|
+
responseBody => ({
|
42
|
+
fileSessionKey: responseBody.chavePDF.valor,
|
43
|
+
canPrint: responseBody.permiteImprimir.valor === "S",
|
44
|
+
canExport: responseBody.permiteExportar.valor === "S",
|
45
|
+
canSendEmail: responseBody.canSendEmail.valor === "S",
|
46
|
+
useAppPrint: true
|
47
|
+
})
|
48
|
+
];
|
49
|
+
}
|
50
|
+
return [
|
51
|
+
"GridXLSBuilderSP.buildXLSFromJson",
|
52
|
+
responseBody => ({
|
53
|
+
fileSessionKey: responseBody.chaveXLS.valor,
|
54
|
+
canPrint: false,
|
55
|
+
canExport: false,
|
56
|
+
useAppPrint: false,
|
57
|
+
canSendEmail: false
|
58
|
+
})
|
59
|
+
];
|
60
|
+
}
|
61
|
+
buildColumnsObject(columns) {
|
62
|
+
return {
|
63
|
+
column: columns.map((column, index) => {
|
64
|
+
const { label, id, width, userInterface } = column;
|
65
|
+
return Object.assign({ index: index + 1, id,
|
66
|
+
label,
|
67
|
+
width, presentationType: "P" }, (TYPE_MAP[userInterface] || { type: "S", align: "left" }));
|
68
|
+
})
|
69
|
+
};
|
70
|
+
}
|
71
|
+
buildRowsObject(columns, records) {
|
72
|
+
return {
|
73
|
+
row: records.map(rawRecord => {
|
74
|
+
const record = {};
|
75
|
+
columns.forEach((column, index) => record["c" + (index + 1)] = { $: this.formatValue(rawRecord, column) });
|
76
|
+
return record;
|
77
|
+
})
|
78
|
+
};
|
79
|
+
}
|
80
|
+
formatValue(record, column) {
|
81
|
+
if (this._provider.formatValue != undefined) {
|
82
|
+
return this._provider.formatValue(record, column);
|
83
|
+
}
|
84
|
+
return record[column.id] || "";
|
85
|
+
}
|
86
|
+
}
|
87
|
+
class FormatedRecord {
|
88
|
+
}
|
89
|
+
const TYPE_MAP = {
|
90
|
+
[UserInterface.DATE]: { type: "D", align: "center" },
|
91
|
+
[UserInterface.DATETIME]: { type: "H", align: "center" },
|
92
|
+
[UserInterface.TIME]: { type: "I", align: "right" },
|
93
|
+
[UserInterface.ELAPSEDTIME]: { type: "I", align: "right" },
|
94
|
+
[UserInterface.DECIMALNUMBER]: { type: "F", align: "right" },
|
95
|
+
[UserInterface.INTEGERNUMBER]: { type: "I", align: "right" },
|
96
|
+
[UserInterface.SEARCH]: { type: "S", align: "right" }
|
97
|
+
};
|