@sankhyalabs/sankhyablocks 8.15.0-dev.61 → 8.15.0-dev.63
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/{ConfigStorage-7df9d3bb.js → ConfigStorage-9a53a42c.js} +12 -11
- package/dist/cjs/{form-config-fetcher-3c4daeb5.js → DataFetcher-515bda03.js} +0 -251
- package/dist/cjs/{IExporterProvider-c307e2b1.js → IExporterProvider-98a012a4.js} +55 -12
- package/dist/cjs/{SnkFormConfigManager-4259edbe.js → SnkFormConfigManager-dda10d75.js} +2 -2
- package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-4a95fe86.js} +6 -12
- package/dist/cjs/{auth-fetcher-e6112be7.js → auth-fetcher-5acb0335.js} +1 -1
- package/dist/cjs/{pesquisa-fetcher-cbdaba63.js → dataunit-fetcher-e2109392.js} +68 -173
- package/dist/cjs/form-config-fetcher-3f430aee.js +256 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-fetcher-916a935c.js +166 -0
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +10 -8
- package/dist/cjs/snk-application.cjs.entry.js +49 -39
- package/dist/cjs/snk-attach.cjs.entry.js +19 -17
- package/dist/cjs/snk-crud.cjs.entry.js +43 -9
- package/dist/cjs/snk-data-exporter.cjs.entry.js +9 -7
- package/dist/cjs/snk-data-unit-dee38ccd.js +614 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +10 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +8 -6
- package/dist/cjs/snk-filter-bar.cjs.entry.js +3 -2
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -2
- package/dist/cjs/snk-form-config.cjs.entry.js +2 -1
- package/dist/cjs/snk-form-view.cjs.entry.js +36 -0
- package/dist/cjs/snk-form.cjs.entry.js +28 -7
- package/dist/cjs/snk-grid.cjs.entry.js +55 -10
- package/dist/cjs/{snk-guides-viewer-b0c44e0c.js → snk-guides-viewer-af4a6ae5.js} +19 -6
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -6
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +96 -14
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/snk-application/snk-application.js +37 -17
- package/dist/collection/components/snk-crud/snk-crud.js +109 -6
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +79 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +41 -4
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +14 -8
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +5 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +413 -165
- package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
- package/dist/collection/components/snk-form/snk-form.js +50 -4
- package/dist/collection/components/snk-grid/snk-grid.js +96 -7
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +156 -8
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
- package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -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 +51 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +25 -32
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
- package/dist/components/ConfigStorage.js +2 -1
- package/dist/components/DataFetcher.js +7024 -0
- package/dist/components/IExporterProvider.js +54 -12
- package/dist/components/SnkMessageBuilder.js +6 -12
- package/dist/components/dataunit-fetcher.js +58 -164
- package/dist/components/form-config-fetcher.js +3 -7023
- package/dist/components/pesquisa-fetcher.js +164 -0
- package/dist/components/snk-actions-button2.js +4 -2
- package/dist/components/snk-application2.js +26 -17
- package/dist/components/snk-attach2.js +4 -2
- package/dist/components/snk-crud.js +46 -9
- package/dist/components/snk-data-exporter2.js +4 -2
- package/dist/components/snk-data-unit2.js +356 -166
- package/dist/components/snk-detail-view2.js +21 -6
- package/dist/components/snk-form-config2.js +1 -1
- package/dist/components/snk-form-view2.js +39 -1
- package/dist/components/snk-form.js +26 -5
- package/dist/components/snk-grid2.js +58 -11
- package/dist/components/snk-simple-crud2.js +96 -10
- package/dist/esm/{ConfigStorage-928c3bf4.js → ConfigStorage-174101b9.js} +2 -1
- package/dist/esm/{form-config-fetcher-e3094014.js → DataFetcher-4b4b7beb.js} +1 -250
- package/dist/esm/{IExporterProvider-e2a1195d.js → IExporterProvider-8f085554.js} +54 -12
- package/dist/esm/{SnkFormConfigManager-a87ade7a.js → SnkFormConfigManager-87bd8082.js} +2 -2
- package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-3a767111.js} +6 -12
- package/dist/esm/{auth-fetcher-e1cb288f.js → auth-fetcher-9f86c346.js} +1 -1
- package/dist/esm/{pesquisa-fetcher-6d8e50bb.js → dataunit-fetcher-87ecba4a.js} +57 -163
- package/dist/esm/form-config-fetcher-5d72aaf1.js +253 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-fetcher-9cfab836.js +164 -0
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +5 -3
- package/dist/esm/snk-application.entry.js +30 -20
- package/dist/esm/snk-attach.entry.js +5 -3
- package/dist/esm/snk-crud.entry.js +43 -9
- package/dist/esm/snk-data-exporter.entry.js +6 -4
- package/dist/esm/snk-data-unit-1132e40b.js +612 -0
- package/dist/esm/snk-data-unit.entry.js +10 -2
- package/dist/esm/snk-detail-view.entry.js +8 -6
- package/dist/esm/snk-filter-bar.entry.js +3 -2
- package/dist/esm/snk-filter-modal-item.entry.js +3 -2
- package/dist/esm/snk-form-config.entry.js +2 -1
- package/dist/esm/snk-form-view.entry.js +36 -0
- package/dist/esm/snk-form.entry.js +28 -7
- package/dist/esm/snk-grid.entry.js +56 -11
- package/dist/esm/{snk-guides-viewer-1fd41a25.js → snk-guides-viewer-359e39a7.js} +19 -6
- package/dist/esm/snk-guides-viewer.entry.js +8 -6
- package/dist/esm/snk-personalized-filter.entry.js +3 -2
- package/dist/esm/snk-simple-crud.entry.js +95 -13
- package/dist/sankhyablocks/p-00a7ede4.entry.js +1 -0
- package/dist/sankhyablocks/p-010d475f.js +1 -0
- package/dist/sankhyablocks/p-08fee6e8.js +60 -0
- package/dist/sankhyablocks/p-0bcc6e83.js +1 -0
- package/dist/sankhyablocks/p-2a84e45b.entry.js +1 -0
- package/dist/sankhyablocks/{p-0e8702f0.js → p-2eb90860.js} +1 -1
- package/dist/sankhyablocks/p-33f695d6.entry.js +1 -0
- package/dist/sankhyablocks/p-4ce73e88.js +1 -0
- package/dist/sankhyablocks/p-4ef47eb8.entry.js +1 -0
- package/dist/sankhyablocks/{p-e27496ed.js → p-566f5f50.js} +6 -6
- package/dist/sankhyablocks/p-59dccb7a.entry.js +1 -0
- package/dist/sankhyablocks/p-66a31d30.entry.js +11 -0
- package/dist/sankhyablocks/p-6b2be902.js +6 -0
- package/dist/sankhyablocks/p-7ecaaea2.entry.js +1 -0
- package/dist/sankhyablocks/p-80031650.js +1 -0
- package/dist/sankhyablocks/p-83950924.entry.js +1 -0
- package/dist/sankhyablocks/p-873d2e6a.entry.js +1 -0
- package/dist/sankhyablocks/p-931343a1.entry.js +1 -0
- package/dist/sankhyablocks/p-a6dfa396.js +1 -0
- package/dist/sankhyablocks/p-aa854fa8.entry.js +1 -0
- package/dist/sankhyablocks/p-b11921ca.entry.js +1 -0
- package/dist/sankhyablocks/p-cb91634d.js +1 -0
- package/dist/sankhyablocks/p-cf9d2d1e.entry.js +1 -0
- package/dist/sankhyablocks/p-d799aa7f.entry.js +1 -0
- package/dist/sankhyablocks/p-da6e3dcf.entry.js +1 -0
- package/dist/sankhyablocks/p-e0c27486.js +26 -0
- package/dist/sankhyablocks/p-f72e8835.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +6 -2
- package/dist/types/components/snk-crud/snk-crud.d.ts +14 -1
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +13 -1
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +6 -0
- package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +3 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +45 -1
- package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
- package/dist/types/components/snk-form/snk-form.d.ts +6 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +19 -3
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +22 -0
- package/dist/types/components.d.ts +68 -4
- package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
- package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -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 +2 -0
- package/package.json +1 -1
- package/dist/cjs/snk-data-unit-abd2113f.js +0 -427
- package/dist/esm/snk-data-unit-29eba11a.js +0 -425
- package/dist/sankhyablocks/p-029bfc09.js +0 -1
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
- package/dist/sankhyablocks/p-07825198.js +0 -1
- package/dist/sankhyablocks/p-13ea113d.entry.js +0 -1
- package/dist/sankhyablocks/p-314e2d1a.entry.js +0 -1
- package/dist/sankhyablocks/p-32556aa6.js +0 -1
- package/dist/sankhyablocks/p-3357af48.js +0 -1
- package/dist/sankhyablocks/p-3c2a1f4d.js +0 -65
- package/dist/sankhyablocks/p-3e7167dd.js +0 -1
- package/dist/sankhyablocks/p-536eeb16.js +0 -26
- package/dist/sankhyablocks/p-587f9dcf.entry.js +0 -1
- package/dist/sankhyablocks/p-61984566.entry.js +0 -1
- package/dist/sankhyablocks/p-65b6dba3.entry.js +0 -1
- package/dist/sankhyablocks/p-6a7bc5c8.entry.js +0 -1
- package/dist/sankhyablocks/p-6c9edfd8.entry.js +0 -1
- package/dist/sankhyablocks/p-89bde7d3.entry.js +0 -1
- package/dist/sankhyablocks/p-91dceecf.entry.js +0 -1
- package/dist/sankhyablocks/p-a40cbad8.entry.js +0 -1
- package/dist/sankhyablocks/p-b86ea293.entry.js +0 -1
- package/dist/sankhyablocks/p-d8ddb2a4.entry.js +0 -11
- package/dist/sankhyablocks/p-df73ac00.entry.js +0 -1
- package/dist/sankhyablocks/p-f92f1f5f.entry.js +0 -1
- package/dist/sankhyablocks/p-fa84e72f.entry.js +0 -1
@@ -26,6 +26,12 @@ export class SnkForm {
|
|
26
26
|
async hideConfig() {
|
27
27
|
this._showFormConfig = false;
|
28
28
|
}
|
29
|
+
/**
|
30
|
+
* Altera/adiciona uma propriedade nos metadados do campo.
|
31
|
+
*/
|
32
|
+
async setFieldProp(fieldName, propName, value) {
|
33
|
+
await this._form.setFieldProp(fieldName, propName, value);
|
34
|
+
}
|
29
35
|
closeConfig() {
|
30
36
|
this.hideConfig();
|
31
37
|
}
|
@@ -48,9 +54,7 @@ export class SnkForm {
|
|
48
54
|
this._dataUnit = evt.detail;
|
49
55
|
});
|
50
56
|
}
|
51
|
-
this._snkDataUnit.addEventListener("dataStateChange", (
|
52
|
-
this._dataState = evt.detail;
|
53
|
-
});
|
57
|
+
this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
|
54
58
|
break;
|
55
59
|
}
|
56
60
|
parent = parent.parentElement;
|
@@ -62,6 +66,23 @@ export class SnkForm {
|
|
62
66
|
this.addFormLegacyConfig();
|
63
67
|
this._configManager.loadConfig();
|
64
68
|
}
|
69
|
+
async handleDataStateChange(evt) {
|
70
|
+
var _a;
|
71
|
+
this._dataState = evt.detail;
|
72
|
+
const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
|
73
|
+
for (const field of fieldsWithRmPrecision || []) {
|
74
|
+
if (!field) {
|
75
|
+
continue;
|
76
|
+
}
|
77
|
+
const rmPrecision = (_a = this._dataState.rowMetadata) === null || _a === void 0 ? void 0 : _a.getProp('rm_precision', field);
|
78
|
+
if (!rmPrecision) {
|
79
|
+
continue;
|
80
|
+
}
|
81
|
+
await this.setFieldProp(field, 'precision', rmPrecision);
|
82
|
+
await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
|
83
|
+
}
|
84
|
+
;
|
85
|
+
}
|
65
86
|
addFormLegacyConfig() {
|
66
87
|
if (this.formLegacyConfigName) {
|
67
88
|
this._configManager.addFormLegacyConfig(this.formLegacyConfigName);
|
@@ -71,7 +92,7 @@ export class SnkForm {
|
|
71
92
|
if (!this._dataUnit || !this._dataState) {
|
72
93
|
return undefined;
|
73
94
|
}
|
74
|
-
return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataState.insertionMode, this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
|
95
|
+
return (h("section", null, h("div", { class: "ez-row" }, h("div", { class: "ez-col ez-col--sd-12" }, h("ez-form", { ref: ref => this._form = ref, key: "ezForm" + this._snkDataUnit.entityName, "data-element-id": "embedded", dataUnit: this._dataUnit, config: this._configManager.getConfig(this._dataState.insertionMode, this._dataUnit), recordsValidator: this.recordsValidator, class: this._showFormConfig ? 'snk-form__form--hidden' : '' }), this._showFormConfig &&
|
75
96
|
h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this._dataUnit, configManager: this._configManager, onConfigClose: () => this.closeConfig() })))));
|
76
97
|
}
|
77
98
|
static get is() { return "snk-form"; }
|
@@ -277,6 +298,31 @@ export class SnkForm {
|
|
277
298
|
"text": "Fecha a janela de configura\u00E7\u00F5es do formul\u00E1rio.",
|
278
299
|
"tags": []
|
279
300
|
}
|
301
|
+
},
|
302
|
+
"setFieldProp": {
|
303
|
+
"complexType": {
|
304
|
+
"signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
|
305
|
+
"parameters": [{
|
306
|
+
"tags": [],
|
307
|
+
"text": ""
|
308
|
+
}, {
|
309
|
+
"tags": [],
|
310
|
+
"text": ""
|
311
|
+
}, {
|
312
|
+
"tags": [],
|
313
|
+
"text": ""
|
314
|
+
}],
|
315
|
+
"references": {
|
316
|
+
"Promise": {
|
317
|
+
"location": "global"
|
318
|
+
}
|
319
|
+
},
|
320
|
+
"return": "Promise<void>"
|
321
|
+
},
|
322
|
+
"docs": {
|
323
|
+
"text": "Altera/adiciona uma propriedade nos metadados do campo.",
|
324
|
+
"tags": []
|
325
|
+
}
|
280
326
|
}
|
281
327
|
};
|
282
328
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { h, Fragment } from '@stencil/core';
|
2
|
-
import { ApplicationContext, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
|
2
|
+
import { Action as DUAction, ApplicationContext, ElementIDUtils, StringUtils } from '@sankhyalabs/core';
|
3
3
|
import { TaskbarElement } from '../snk-taskbar/elements/taskbar-elements';
|
4
4
|
import { ConfigStorage } from '../../lib/configs/ConfigStorage';
|
5
5
|
import { PresentationMode } from '../../lib/@types';
|
@@ -9,6 +9,7 @@ import SnkMultiSelectionListDataSource from './filtercolumn/SnkMultiSelectionLis
|
|
9
9
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
10
10
|
import { buildFieldSearch, openFieldSearch } from '../snk-taskbar/subcomponents/field-search';
|
11
11
|
import { CrudUtils } from '../../lib';
|
12
|
+
import RmPrecisionCustomValueFormatter from '../../lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter';
|
12
13
|
import ServerSideExporterProvider from '../snk-data-exporter/providers/ServerSideExporterProvider';
|
13
14
|
export class SnkGrid {
|
14
15
|
constructor() {
|
@@ -31,6 +32,14 @@ export class SnkGrid {
|
|
31
32
|
"snkGridHeaderTaskbar.singleTaskbar.detail.selected": ["UPDATE", "ATTACH", "CLONE", "REMOVE", "MORE_OPTIONS", "DIVIDER", "FORM_MODE", "CONFIGURATOR", "REFRESH"],
|
32
33
|
"snkGridHeaderTaskbar.singleTaskbar.finish_edition": ["CANCEL", "SAVE"]
|
33
34
|
});
|
35
|
+
this.dataUnitInterceptor = {
|
36
|
+
interceptAction: async (action) => {
|
37
|
+
if (action.type === DUAction.METADATA_LOADED) {
|
38
|
+
return await this.interceptMetadataLoaded(action);
|
39
|
+
}
|
40
|
+
return action;
|
41
|
+
}
|
42
|
+
};
|
34
43
|
this._dataUnit = undefined;
|
35
44
|
this._dataState = undefined;
|
36
45
|
this._gridConfig = undefined;
|
@@ -101,6 +110,18 @@ export class SnkGrid {
|
|
101
110
|
async findColumn() {
|
102
111
|
await openFieldSearch(this._moreOptions, this._columnSearch);
|
103
112
|
}
|
113
|
+
/**
|
114
|
+
* Registra um formatador de valores para uma coluna da grid.
|
115
|
+
*/
|
116
|
+
async addCustomValueFormatter(columnName, customFormatter) {
|
117
|
+
this._grid.addCustomValueFormatter(columnName, customFormatter);
|
118
|
+
}
|
119
|
+
/**
|
120
|
+
* Remove o formatador de valores de uma coluna da grid.
|
121
|
+
*/
|
122
|
+
async removeCustomValueFormatter(columnName) {
|
123
|
+
this._grid.removeCustomValueFormatter(columnName);
|
124
|
+
}
|
104
125
|
async handleGridLegacyConfigName(newLegacyConfig, oldLegacyConfig) {
|
105
126
|
if (!newLegacyConfig) {
|
106
127
|
return;
|
@@ -163,7 +184,23 @@ export class SnkGrid {
|
|
163
184
|
const dataInfo = { dataUnit: this._dataUnit };
|
164
185
|
ElementIDUtils.addIDInfo(this._element, null, dataInfo);
|
165
186
|
}
|
166
|
-
|
187
|
+
loadGridCustomFormatters(fields) {
|
188
|
+
if (!fields || !this._grid) {
|
189
|
+
return;
|
190
|
+
}
|
191
|
+
fields.forEach((field) => {
|
192
|
+
var _a;
|
193
|
+
if ((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) {
|
194
|
+
this.addCustomValueFormatter(field.name, this._rmPrecisionCustomValueFormatter);
|
195
|
+
}
|
196
|
+
});
|
197
|
+
}
|
198
|
+
async interceptMetadataLoaded(action) {
|
199
|
+
this.loadGridCustomFormatters(action.payload.fields);
|
200
|
+
return action;
|
201
|
+
}
|
202
|
+
finishLoading() {
|
203
|
+
this._dataUnit.addInterceptor(this.dataUnitInterceptor);
|
167
204
|
CrudUtils.assertDefaultSorting(this._gridConfig, this._dataUnit);
|
168
205
|
this.addElementID();
|
169
206
|
if (this.columnFilterDataSource != undefined) {
|
@@ -182,17 +219,15 @@ export class SnkGrid {
|
|
182
219
|
if (!this._dataUnit) {
|
183
220
|
this._snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
184
221
|
this._dataUnit = evt.detail;
|
185
|
-
this.
|
222
|
+
this.finishLoading();
|
186
223
|
});
|
187
224
|
}
|
188
225
|
else {
|
189
|
-
this.
|
226
|
+
this.finishLoading();
|
190
227
|
}
|
191
228
|
if (!this.messagesBuilder)
|
192
229
|
this.messagesBuilder = this._snkDataUnit.messagesBuilder;
|
193
|
-
this._snkDataUnit.addEventListener("dataStateChange", (
|
194
|
-
this._dataState = evt.detail;
|
195
|
-
});
|
230
|
+
this._snkDataUnit.addEventListener("dataStateChange", this.handleDataStateChange.bind(this));
|
196
231
|
this._snkDataUnit.addEventListener("cancelEdition", () => {
|
197
232
|
var _a;
|
198
233
|
if ((_a = this._dataState) === null || _a === void 0 ? void 0 : _a.recordsIsEmpty) {
|
@@ -203,9 +238,18 @@ export class SnkGrid {
|
|
203
238
|
}
|
204
239
|
parent = parent.parentElement;
|
205
240
|
}
|
241
|
+
this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
|
206
242
|
this.addGridLegacyConfigName();
|
207
243
|
this.loadConfig();
|
208
244
|
}
|
245
|
+
componentDidRender() {
|
246
|
+
this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
|
247
|
+
this.loadGridCustomFormatters(this._dataUnit.metadata.fields);
|
248
|
+
}
|
249
|
+
async handleDataStateChange(evt) {
|
250
|
+
this._dataState = evt.detail;
|
251
|
+
this._rmPrecisionCustomValueFormatter.setDataState(this._dataState);
|
252
|
+
}
|
209
253
|
getHeaderDisabledButtons() {
|
210
254
|
var _a;
|
211
255
|
const disabledButtons = [];
|
@@ -881,6 +925,51 @@ export class SnkGrid {
|
|
881
925
|
"text": "Abre o localizador de colunas",
|
882
926
|
"tags": []
|
883
927
|
}
|
928
|
+
},
|
929
|
+
"addCustomValueFormatter": {
|
930
|
+
"complexType": {
|
931
|
+
"signature": "(columnName: string, customFormatter: ICustomFormatter) => Promise<void>",
|
932
|
+
"parameters": [{
|
933
|
+
"tags": [],
|
934
|
+
"text": ""
|
935
|
+
}, {
|
936
|
+
"tags": [],
|
937
|
+
"text": ""
|
938
|
+
}],
|
939
|
+
"references": {
|
940
|
+
"Promise": {
|
941
|
+
"location": "global"
|
942
|
+
},
|
943
|
+
"ICustomFormatter": {
|
944
|
+
"location": "import",
|
945
|
+
"path": "@sankhyalabs/ezui/dist/types/components/ez-grid/interfaces"
|
946
|
+
}
|
947
|
+
},
|
948
|
+
"return": "Promise<void>"
|
949
|
+
},
|
950
|
+
"docs": {
|
951
|
+
"text": "Registra um formatador de valores para uma coluna da grid.",
|
952
|
+
"tags": []
|
953
|
+
}
|
954
|
+
},
|
955
|
+
"removeCustomValueFormatter": {
|
956
|
+
"complexType": {
|
957
|
+
"signature": "(columnName: string) => Promise<void>",
|
958
|
+
"parameters": [{
|
959
|
+
"tags": [],
|
960
|
+
"text": ""
|
961
|
+
}],
|
962
|
+
"references": {
|
963
|
+
"Promise": {
|
964
|
+
"location": "global"
|
965
|
+
}
|
966
|
+
},
|
967
|
+
"return": "Promise<void>"
|
968
|
+
},
|
969
|
+
"docs": {
|
970
|
+
"text": "Remove o formatador de valores de uma coluna da grid.",
|
971
|
+
"tags": []
|
972
|
+
}
|
884
973
|
}
|
885
974
|
};
|
886
975
|
}
|
@@ -11,6 +11,7 @@ import { buildFieldSearch, openFieldSearch } from '../snk-taskbar/subcomponents/
|
|
11
11
|
import { ConfigStorage } from '../../lib/configs/ConfigStorage';
|
12
12
|
import { SnkFormConfigManager } from '../snk-form-config/SnkFormConfigManager';
|
13
13
|
import { REGULAR_DEFAULT_BTNS, REGULAR_SELECTED_BTNS } from './regular-buttons';
|
14
|
+
import RmPrecisionCustomValueFormatter from '../../lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter';
|
14
15
|
import ClientSideExporterProvider from '../snk-data-exporter/providers/ClientSideExporterProvider';
|
15
16
|
import store from "../../lib/store";
|
16
17
|
export class SnkSimpleCrud {
|
@@ -38,6 +39,7 @@ export class SnkSimpleCrud {
|
|
38
39
|
this.gridConfig = undefined;
|
39
40
|
this.formConfig = undefined;
|
40
41
|
this._formFields = [];
|
42
|
+
this._fieldsProps = new Map();
|
41
43
|
this.multipleSelection = undefined;
|
42
44
|
this.useCancelConfirm = true;
|
43
45
|
this.pageSize = 150;
|
@@ -62,6 +64,27 @@ export class SnkSimpleCrud {
|
|
62
64
|
this.loadFormConfig(true);
|
63
65
|
this.loadGridConfig(true);
|
64
66
|
}
|
67
|
+
/**
|
68
|
+
* Registra um formatador de valores para uma coluna da grid.
|
69
|
+
*/
|
70
|
+
async addCustomValueFormatter(columnName, customFormatter) {
|
71
|
+
this._grid.addCustomValueFormatter(columnName, customFormatter);
|
72
|
+
}
|
73
|
+
/**
|
74
|
+
* Remove o formatador de valores de uma coluna da grid.
|
75
|
+
*/
|
76
|
+
async removeCustomValueFormatter(columnName) {
|
77
|
+
this._grid.removeCustomValueFormatter(columnName);
|
78
|
+
}
|
79
|
+
/**
|
80
|
+
* Altera/adiciona uma propriedade nos metadados do campo.
|
81
|
+
*/
|
82
|
+
async setFieldProp(fieldName, propName, value) {
|
83
|
+
const newCustomFieldProps = new Map(this._fieldsProps);
|
84
|
+
const currentProps = this._fieldsProps.get(fieldName);
|
85
|
+
newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
|
86
|
+
this._fieldsProps = newCustomFieldProps;
|
87
|
+
}
|
65
88
|
getButtons(selected, extraButtons) {
|
66
89
|
return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
|
67
90
|
.concat(extraButtons));
|
@@ -116,9 +139,7 @@ export class SnkSimpleCrud {
|
|
116
139
|
}
|
117
140
|
}
|
118
141
|
observeDataState(newValue, oldValue) {
|
119
|
-
|
120
|
-
this.dataStateChange.emit(newValue);
|
121
|
-
}
|
142
|
+
this.handleDataStateChange(newValue, oldValue);
|
122
143
|
}
|
123
144
|
async observeFormLegacy(newValue, oldValue) {
|
124
145
|
await this.handleUpdateFormLegacyConfig(newValue, oldValue);
|
@@ -126,6 +147,29 @@ export class SnkSimpleCrud {
|
|
126
147
|
async observeGridLegacy(newValue, oldValue) {
|
127
148
|
await this.handleUpdateGridLegacyConfig(newValue, oldValue);
|
128
149
|
}
|
150
|
+
async handleDataStateChange(newValue, oldValue) {
|
151
|
+
if (ObjectUtils.objectToString(oldValue) != ObjectUtils.objectToString(newValue)) {
|
152
|
+
this.dataStateChange.emit(newValue);
|
153
|
+
}
|
154
|
+
await this.processRmPrecision();
|
155
|
+
}
|
156
|
+
async processRmPrecision() {
|
157
|
+
var _a, _b;
|
158
|
+
const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
|
159
|
+
for (const field of fieldsWithRmPrecision || []) {
|
160
|
+
if (!field) {
|
161
|
+
continue;
|
162
|
+
}
|
163
|
+
const rmPrecision = (_b = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata) === null || _b === void 0 ? void 0 : _b.getProp('rm_precision', field);
|
164
|
+
if (!rmPrecision) {
|
165
|
+
continue;
|
166
|
+
}
|
167
|
+
await this.setFieldProp(field, 'precision', rmPrecision);
|
168
|
+
await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
|
169
|
+
}
|
170
|
+
;
|
171
|
+
this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
|
172
|
+
}
|
129
173
|
async handleUpdateGridLegacyConfig(newValue, oldValue) {
|
130
174
|
if (newValue == undefined || newValue == oldValue) {
|
131
175
|
return;
|
@@ -234,10 +278,16 @@ export class SnkSimpleCrud {
|
|
234
278
|
this.loadGridConfig();
|
235
279
|
this.loadFormConfig();
|
236
280
|
}
|
281
|
+
componentDidRender() {
|
282
|
+
this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
|
283
|
+
this.addGridCustomValueFormattters();
|
284
|
+
this.setFieldsProps();
|
285
|
+
}
|
237
286
|
componentWillLoad() {
|
238
287
|
this.processMetadata();
|
239
288
|
this.onModeChange();
|
240
289
|
this.configDatasource();
|
290
|
+
this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
|
241
291
|
}
|
242
292
|
componentDidLoad() {
|
243
293
|
CSSVarsUtils.applyVarsGrid(this._element, this._grid);
|
@@ -246,6 +296,17 @@ export class SnkSimpleCrud {
|
|
246
296
|
this._multiSelectionListDataSource.setApplication(this.application);
|
247
297
|
this._multiSelectionListDataSource.setDataUnit(this.dataUnit);
|
248
298
|
}
|
299
|
+
setFieldsProps() {
|
300
|
+
if (!this._form) {
|
301
|
+
return;
|
302
|
+
}
|
303
|
+
for (const [fieldName, props] of this._fieldsProps) {
|
304
|
+
for (const prop in props) {
|
305
|
+
this._form.setFieldProp(fieldName, prop, props[prop]);
|
306
|
+
}
|
307
|
+
this._fieldsProps.delete(fieldName);
|
308
|
+
}
|
309
|
+
}
|
249
310
|
getTaskBarId() {
|
250
311
|
var _a, _b;
|
251
312
|
if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
|
@@ -298,12 +359,11 @@ export class SnkSimpleCrud {
|
|
298
359
|
var _a;
|
299
360
|
(_a = this._snkConfigurator) === null || _a === void 0 ? void 0 : _a.close();
|
300
361
|
}
|
301
|
-
updateConfig() {
|
362
|
+
async updateConfig() {
|
302
363
|
if (this._formConfigManager == undefined) {
|
303
364
|
this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
|
304
365
|
}
|
305
366
|
this._formConfigManager.setConfig(this.formConfig);
|
306
|
-
return;
|
307
367
|
}
|
308
368
|
processMetadata() {
|
309
369
|
const fieldsMetadataElem = this._element.querySelectorAll("snk-field-metadata");
|
@@ -335,6 +395,23 @@ export class SnkSimpleCrud {
|
|
335
395
|
};
|
336
396
|
}
|
337
397
|
}
|
398
|
+
addGridCustomValueFormattters() {
|
399
|
+
var _a, _b, _c;
|
400
|
+
const metadataFields = ((_a = this._metadata) === null || _a === void 0 ? void 0 : _a.fields) || ((_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.fields);
|
401
|
+
if (!metadataFields) {
|
402
|
+
return;
|
403
|
+
}
|
404
|
+
const fieldsWithRmPrecision = [];
|
405
|
+
metadataFields.forEach((field) => {
|
406
|
+
var _a;
|
407
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !fieldsWithRmPrecision.includes(field.name)) {
|
408
|
+
fieldsWithRmPrecision.push(field.name);
|
409
|
+
}
|
410
|
+
});
|
411
|
+
fieldsWithRmPrecision.forEach(field => {
|
412
|
+
this.addCustomValueFormatter(field, this._rmPrecisionCustomValueFormatter);
|
413
|
+
});
|
414
|
+
}
|
338
415
|
onDataStateChange(evt) {
|
339
416
|
this.dataState = Object.assign({}, evt.detail);
|
340
417
|
}
|
@@ -555,9 +632,9 @@ export class SnkSimpleCrud {
|
|
555
632
|
if (this.dataUnit == undefined) {
|
556
633
|
return;
|
557
634
|
}
|
558
|
-
return (h("snk-data-unit", { class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
635
|
+
return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, h("snk-taskbar", { class: "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })), h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
559
636
|
? undefined
|
560
|
-
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
|
637
|
+
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { ref: ref => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
|
561
638
|
}
|
562
639
|
static get is() { return "snk-simple-crud"; }
|
563
640
|
static get encapsulation() { return "scoped"; }
|
@@ -940,7 +1017,8 @@ export class SnkSimpleCrud {
|
|
940
1017
|
"_config": {},
|
941
1018
|
"_fieldToGetFocus": {},
|
942
1019
|
"_customContainerId": {},
|
943
|
-
"_formFields": {}
|
1020
|
+
"_formFields": {},
|
1021
|
+
"_fieldsProps": {}
|
944
1022
|
};
|
945
1023
|
}
|
946
1024
|
static get events() {
|
@@ -1055,6 +1133,76 @@ export class SnkSimpleCrud {
|
|
1055
1133
|
}
|
1056
1134
|
static get methods() {
|
1057
1135
|
return {
|
1136
|
+
"addCustomValueFormatter": {
|
1137
|
+
"complexType": {
|
1138
|
+
"signature": "(columnName: string, customFormatter: ICustomFormatter) => Promise<void>",
|
1139
|
+
"parameters": [{
|
1140
|
+
"tags": [],
|
1141
|
+
"text": ""
|
1142
|
+
}, {
|
1143
|
+
"tags": [],
|
1144
|
+
"text": ""
|
1145
|
+
}],
|
1146
|
+
"references": {
|
1147
|
+
"Promise": {
|
1148
|
+
"location": "global"
|
1149
|
+
},
|
1150
|
+
"ICustomFormatter": {
|
1151
|
+
"location": "import",
|
1152
|
+
"path": "@sankhyalabs/ezui/dist/types/components/ez-grid/interfaces"
|
1153
|
+
}
|
1154
|
+
},
|
1155
|
+
"return": "Promise<void>"
|
1156
|
+
},
|
1157
|
+
"docs": {
|
1158
|
+
"text": "Registra um formatador de valores para uma coluna da grid.",
|
1159
|
+
"tags": []
|
1160
|
+
}
|
1161
|
+
},
|
1162
|
+
"removeCustomValueFormatter": {
|
1163
|
+
"complexType": {
|
1164
|
+
"signature": "(columnName: string) => Promise<void>",
|
1165
|
+
"parameters": [{
|
1166
|
+
"tags": [],
|
1167
|
+
"text": ""
|
1168
|
+
}],
|
1169
|
+
"references": {
|
1170
|
+
"Promise": {
|
1171
|
+
"location": "global"
|
1172
|
+
}
|
1173
|
+
},
|
1174
|
+
"return": "Promise<void>"
|
1175
|
+
},
|
1176
|
+
"docs": {
|
1177
|
+
"text": "Remove o formatador de valores de uma coluna da grid.",
|
1178
|
+
"tags": []
|
1179
|
+
}
|
1180
|
+
},
|
1181
|
+
"setFieldProp": {
|
1182
|
+
"complexType": {
|
1183
|
+
"signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
|
1184
|
+
"parameters": [{
|
1185
|
+
"tags": [],
|
1186
|
+
"text": ""
|
1187
|
+
}, {
|
1188
|
+
"tags": [],
|
1189
|
+
"text": ""
|
1190
|
+
}, {
|
1191
|
+
"tags": [],
|
1192
|
+
"text": ""
|
1193
|
+
}],
|
1194
|
+
"references": {
|
1195
|
+
"Promise": {
|
1196
|
+
"location": "global"
|
1197
|
+
}
|
1198
|
+
},
|
1199
|
+
"return": "Promise<void>"
|
1200
|
+
},
|
1201
|
+
"docs": {
|
1202
|
+
"text": "Altera/adiciona uma propriedade nos metadados do campo.",
|
1203
|
+
"tags": []
|
1204
|
+
}
|
1205
|
+
},
|
1058
1206
|
"goToView": {
|
1059
1207
|
"complexType": {
|
1060
1208
|
"signature": "(view: VIEW_MODE) => Promise<void>",
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import { NumberUtils, ObjectUtils } from "@sankhyalabs/core";
|
2
|
+
export default class RmPrecisionCustomValueFormatter {
|
3
|
+
setGrid(grid) {
|
4
|
+
if (this._grid) {
|
5
|
+
return;
|
6
|
+
}
|
7
|
+
this._grid = grid;
|
8
|
+
this.refreshSelectedRows();
|
9
|
+
}
|
10
|
+
setDataState(dataState) {
|
11
|
+
if (ObjectUtils.objectToString(dataState) === ObjectUtils.objectToString(this._dataState)) {
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
this._dataState = dataState;
|
15
|
+
this.refreshSelectedRows();
|
16
|
+
}
|
17
|
+
format(currentValue, column, recordId) {
|
18
|
+
var _a;
|
19
|
+
if (!currentValue) {
|
20
|
+
return currentValue;
|
21
|
+
}
|
22
|
+
const rowMetadata = (_a = this._dataState) === null || _a === void 0 ? void 0 : _a.metadataByRow.get(recordId);
|
23
|
+
const rmPrecision = rowMetadata === null || rowMetadata === void 0 ? void 0 : rowMetadata.getProp('rm_precision', column.name);
|
24
|
+
if (rmPrecision) {
|
25
|
+
return NumberUtils.format(currentValue, rmPrecision, rmPrecision);
|
26
|
+
}
|
27
|
+
else {
|
28
|
+
return currentValue;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
refreshSelectedRows() {
|
32
|
+
var _a;
|
33
|
+
(_a = this._grid) === null || _a === void 0 ? void 0 : _a.refreshSelectedRows();
|
34
|
+
}
|
35
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js
CHANGED
@@ -2,6 +2,7 @@ import { ApplicationContext, StringUtils, UserInterface, } from '@sankhyalabs/co
|
|
2
2
|
import { DataFetcher } from "../../../DataFetcher";
|
3
3
|
import DataUnitFetcher from "../dataunit-fetcher";
|
4
4
|
import InMemoryLoader from "../../../../../dataUnit/InMemoryLoader";
|
5
|
+
import { getRecordValue } from '../../../../../dataUnit/ValueFormatter';
|
5
6
|
export class DatasetStrategy {
|
6
7
|
canSlice() {
|
7
8
|
return false;
|
@@ -56,6 +57,53 @@ export class DatasetStrategy {
|
|
56
57
|
return Promise.reject(error);
|
57
58
|
}
|
58
59
|
}
|
60
|
+
async loadRowMetadata(snkDataUnit, fieldName, metadataName, updatedFields = {}) {
|
61
|
+
try {
|
62
|
+
const serviceName = "DatasetSP.loadRowMetadata";
|
63
|
+
const parsedRequestBody = await this.buildRequestBodyLoadRowMetadata({ snkDataUnit, fieldName, metadataName, serviceName, updatedFields });
|
64
|
+
const response = await DataFetcher.get().callServiceBroker(serviceName, parsedRequestBody);
|
65
|
+
return response;
|
66
|
+
}
|
67
|
+
catch (error) {
|
68
|
+
console.error(error);
|
69
|
+
return Promise.reject(error);
|
70
|
+
}
|
71
|
+
}
|
72
|
+
async buildRequestBodyLoadRowMetadata({ snkDataUnit, serviceName, fieldName, metadataName, updatedFields, }) {
|
73
|
+
const dataUnit = snkDataUnit.dataUnit;
|
74
|
+
const entityName = DataUnitFetcher.parseDataUnitName(dataUnit.name).entityName;
|
75
|
+
const recordIdInfo = await snkDataUnit.getSelectedRecordsIDsInfo();
|
76
|
+
const pk = recordIdInfo.reduce((accumulator, currentValue) => {
|
77
|
+
accumulator[currentValue.name] = currentValue.value;
|
78
|
+
return accumulator;
|
79
|
+
}, {});
|
80
|
+
const record = dataUnit.getSelectedRecord();
|
81
|
+
const fields = dataUnit.metadata.fields.filter(({ standAlone, name }) => !standAlone && !name.includes(".")).map(({ name }) => name);
|
82
|
+
const values = fields.reduce((accumulator, currentValue, currentIndex) => {
|
83
|
+
const recordValue = getRecordValue(record, currentValue);
|
84
|
+
const updatedFieldValue = getRecordValue(updatedFields, currentValue);
|
85
|
+
accumulator[currentIndex] = updatedFieldValue !== undefined ? updatedFieldValue : recordValue;
|
86
|
+
return accumulator;
|
87
|
+
}, {});
|
88
|
+
const requestBody = {
|
89
|
+
serviceName,
|
90
|
+
requestBody: {
|
91
|
+
dataSetID: dataUnit.dataUnitId,
|
92
|
+
entityName,
|
93
|
+
standAlone: false,
|
94
|
+
metadataName,
|
95
|
+
fieldName,
|
96
|
+
fields,
|
97
|
+
record: {
|
98
|
+
pk,
|
99
|
+
oldPk: pk,
|
100
|
+
values,
|
101
|
+
},
|
102
|
+
}
|
103
|
+
};
|
104
|
+
const parsedRequestBody = JSON.stringify(requestBody);
|
105
|
+
return parsedRequestBody;
|
106
|
+
}
|
59
107
|
getFieldsList(dataUnit) {
|
60
108
|
let fields = ["__record__id__", "__record__label__"];
|
61
109
|
dataUnit.metadata.fields.forEach((descriptor) => {
|
@@ -135,9 +183,11 @@ export class DatasetStrategy {
|
|
135
183
|
}
|
136
184
|
processRecords(dataUnit, fields, responseRecords) {
|
137
185
|
return responseRecords.map((dataFrame) => {
|
186
|
+
const lastElement = dataFrame[dataFrame.length - 1];
|
138
187
|
const duRecord = {
|
139
188
|
__record__id__: dataFrame[0],
|
140
|
-
__record__label__: dataFrame[1]
|
189
|
+
__record__label__: dataFrame[1],
|
190
|
+
__record__metadata__: lastElement['_rmd'],
|
141
191
|
};
|
142
192
|
dataUnit.metadata.fields.forEach(fieldDescriptor => {
|
143
193
|
duRecord[fieldDescriptor.name] = this.buildFieldValue(fieldDescriptor, fields, dataFrame);
|
@@ -0,0 +1,22 @@
|
|
1
|
+
const metadataMock = {
|
2
|
+
"label": "metadataMock",
|
3
|
+
"name": "metadataMock",
|
4
|
+
"fields": [
|
5
|
+
{
|
6
|
+
"name": "TESTE",
|
7
|
+
"label": "Teste",
|
8
|
+
"dataType": "TEXT"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"name": "TESTERMP",
|
12
|
+
"label": "Teste com RMP",
|
13
|
+
"dataType": "TEXT",
|
14
|
+
"properties": {
|
15
|
+
"rmp": {
|
16
|
+
"value": "PRODUTORMP"
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
]
|
21
|
+
};
|
22
|
+
export default metadataMock;
|