@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-57523.0 → 0.0.0-bugfix-dev-59880.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{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-e286ef6a.js} +55 -12
- package/dist/cjs/{SnkFormConfigManager-4259edbe.js → SnkFormConfigManager-7b222c78.js} +4 -4
- 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-7a08e4dd.js} +74 -175
- 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 +95 -10
- package/dist/cjs/snk-data-exporter.cjs.entry.js +11 -9
- package/dist/cjs/snk-data-unit-3718477f.js +670 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +10 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +48 -7
- package/dist/cjs/snk-filter-bar.cjs.entry.js +8 -3
- 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 +67 -0
- package/dist/cjs/snk-form.cjs.entry.js +53 -7
- package/dist/cjs/snk-grid.cjs.entry.js +103 -11
- package/dist/cjs/{snk-guides-viewer-b0c44e0c.js → snk-guides-viewer-66dd6949.js} +36 -7
- 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 +153 -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/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 +230 -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/interfaces/IExporterProvider.js +14 -8
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +5 -0
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +2 -2
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +499 -176
- package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
- package/dist/collection/components/snk-form/snk-form.js +101 -4
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +2 -2
- package/dist/collection/components/snk-grid/snk-grid.js +219 -8
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +283 -9
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +6 -2
- 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/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/SnkFormConfigManager.js +2 -2
- package/dist/components/SnkMessageBuilder.js +6 -12
- package/dist/components/dataunit-fetcher.js +64 -166
- 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 +101 -10
- package/dist/components/snk-data-exporter2.js +6 -4
- package/dist/components/snk-data-unit2.js +424 -177
- package/dist/components/snk-detail-view2.js +87 -9
- package/dist/components/snk-filter-bar2.js +6 -1
- package/dist/components/snk-form-config2.js +1 -1
- package/dist/components/snk-form-view2.js +72 -1
- package/dist/components/snk-form.js +52 -5
- package/dist/components/snk-grid2.js +109 -12
- package/dist/components/snk-simple-crud2.js +157 -11
- 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-cf5a56ee.js} +54 -12
- package/dist/esm/{SnkFormConfigManager-a87ade7a.js → SnkFormConfigManager-3bdb3e1f.js} +4 -4
- 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-f3fa35b9.js} +63 -165
- 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 +95 -10
- package/dist/esm/snk-data-exporter.entry.js +8 -6
- package/dist/esm/snk-data-unit-8d6afa43.js +668 -0
- package/dist/esm/snk-data-unit.entry.js +10 -2
- package/dist/esm/snk-detail-view.entry.js +48 -7
- package/dist/esm/snk-filter-bar.entry.js +8 -3
- 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 +67 -0
- package/dist/esm/snk-form.entry.js +53 -7
- package/dist/esm/snk-grid.entry.js +104 -12
- package/dist/esm/{snk-guides-viewer-1fd41a25.js → snk-guides-viewer-11cf8dc7.js} +36 -7
- 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 +153 -14
- package/dist/sankhyablocks/p-010d475f.js +1 -0
- package/dist/sankhyablocks/p-0a28cb19.entry.js +1 -0
- package/dist/sankhyablocks/p-188e1432.entry.js +1 -0
- package/dist/sankhyablocks/p-1c6debe6.entry.js +1 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-2a84e45b.entry.js +1 -0
- package/dist/sankhyablocks/p-2cc2d8fd.entry.js +1 -0
- package/dist/sankhyablocks/p-3e4c2cfe.entry.js +11 -0
- package/dist/sankhyablocks/p-4a8a149d.entry.js +1 -0
- package/dist/sankhyablocks/p-4ce73e88.js +1 -0
- package/dist/sankhyablocks/p-50e72d6c.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-5bd78e4c.entry.js +1 -0
- package/dist/sankhyablocks/p-6b2be902.js +6 -0
- package/dist/sankhyablocks/p-8171e586.entry.js +1 -0
- package/dist/sankhyablocks/p-a6dfa396.js +1 -0
- package/dist/sankhyablocks/p-a97060b0.js +1 -0
- package/dist/sankhyablocks/p-aa854fa8.entry.js +1 -0
- package/dist/sankhyablocks/p-b27114c4.js +1 -0
- package/dist/sankhyablocks/p-b643f746.entry.js +1 -0
- package/dist/sankhyablocks/p-b68918fc.entry.js +1 -0
- package/dist/sankhyablocks/p-da7c81d6.entry.js +1 -0
- package/dist/sankhyablocks/p-e0c27486.js +26 -0
- package/dist/sankhyablocks/p-e238279a.entry.js +1 -0
- package/dist/sankhyablocks/p-eae66367.js +1 -0
- package/dist/sankhyablocks/p-fde91811.js +60 -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/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 +32 -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/interfaces/IExporterProvider.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-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 +42 -3
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +40 -2
- package/dist/types/components.d.ts +180 -4
- 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/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-0e8702f0.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-61b6126e.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-f92f1f5f.entry.js +0 -1
- package/dist/sankhyablocks/p-fa84e72f.entry.js +0 -1
|
@@ -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 {
|
|
@@ -18,6 +19,8 @@ export class SnkSimpleCrud {
|
|
|
18
19
|
this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
|
|
19
20
|
this._keyDownHandler = (event) => this.keyDownListener(event);
|
|
20
21
|
this._formConfigFetcher = new FormConfigFetcher();
|
|
22
|
+
this._customEditors = new Map();
|
|
23
|
+
this._customRenders = new Map();
|
|
21
24
|
this._taskbarProcessor = new TaskbarProcessor({
|
|
22
25
|
"snkSimpleCrudTaskbar.form_regular": this.getButtons(false, [TaskbarElement.GRID_MODE]),
|
|
23
26
|
"snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
|
|
@@ -38,6 +41,7 @@ export class SnkSimpleCrud {
|
|
|
38
41
|
this.gridConfig = undefined;
|
|
39
42
|
this.formConfig = undefined;
|
|
40
43
|
this._formFields = [];
|
|
44
|
+
this._fieldsProps = new Map();
|
|
41
45
|
this.multipleSelection = undefined;
|
|
42
46
|
this.useCancelConfirm = true;
|
|
43
47
|
this.pageSize = 150;
|
|
@@ -51,6 +55,32 @@ export class SnkSimpleCrud {
|
|
|
51
55
|
this.gridLegacyConfigName = undefined;
|
|
52
56
|
this.formLegacyConfigName = undefined;
|
|
53
57
|
this.ignoreReadOnlyFormFields = false;
|
|
58
|
+
this.autoLoad = undefined;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Registra um editor customizado para campos da grade e formulário.
|
|
62
|
+
*/
|
|
63
|
+
async addCustomEditor(fieldName, customEditor) {
|
|
64
|
+
if (this._grid && this._form) {
|
|
65
|
+
this._grid.addCustomEditor(fieldName, customEditor);
|
|
66
|
+
this._form.addCustomEditor(fieldName, customEditor);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const newCustomEditors = new Map(this._customEditors);
|
|
70
|
+
newCustomEditors.set(fieldName, customEditor);
|
|
71
|
+
this._customEditors = newCustomEditors;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Registra um render customizado para colunas da grid.
|
|
75
|
+
*/
|
|
76
|
+
async addGridCustomRender(fieldName, customRender) {
|
|
77
|
+
if (this._grid) {
|
|
78
|
+
this._grid.addGridCustomRender(fieldName, customRender);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const newCustomRenders = new Map(this._customRenders);
|
|
82
|
+
newCustomRenders.set(fieldName, customRender);
|
|
83
|
+
this._customRenders = newCustomRenders;
|
|
54
84
|
}
|
|
55
85
|
handleResourceIDChanged(newValue, oldValue) {
|
|
56
86
|
if (StringUtils.isEmpty(newValue)) {
|
|
@@ -62,6 +92,27 @@ export class SnkSimpleCrud {
|
|
|
62
92
|
this.loadFormConfig(true);
|
|
63
93
|
this.loadGridConfig(true);
|
|
64
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Registra um formatador de valores para uma coluna da grid.
|
|
97
|
+
*/
|
|
98
|
+
async addCustomValueFormatter(columnName, customFormatter) {
|
|
99
|
+
this._grid.addCustomValueFormatter(columnName, customFormatter);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Remove o formatador de valores de uma coluna da grid.
|
|
103
|
+
*/
|
|
104
|
+
async removeCustomValueFormatter(columnName) {
|
|
105
|
+
this._grid.removeCustomValueFormatter(columnName);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Altera/adiciona uma propriedade nos metadados do campo.
|
|
109
|
+
*/
|
|
110
|
+
async setFieldProp(fieldName, propName, value) {
|
|
111
|
+
const newCustomFieldProps = new Map(this._fieldsProps);
|
|
112
|
+
const currentProps = this._fieldsProps.get(fieldName);
|
|
113
|
+
newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
|
|
114
|
+
this._fieldsProps = newCustomFieldProps;
|
|
115
|
+
}
|
|
65
116
|
getButtons(selected, extraButtons) {
|
|
66
117
|
return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
|
|
67
118
|
.concat(extraButtons));
|
|
@@ -116,9 +167,7 @@ export class SnkSimpleCrud {
|
|
|
116
167
|
}
|
|
117
168
|
}
|
|
118
169
|
observeDataState(newValue, oldValue) {
|
|
119
|
-
|
|
120
|
-
this.dataStateChange.emit(newValue);
|
|
121
|
-
}
|
|
170
|
+
this.handleDataStateChange(newValue, oldValue);
|
|
122
171
|
}
|
|
123
172
|
async observeFormLegacy(newValue, oldValue) {
|
|
124
173
|
await this.handleUpdateFormLegacyConfig(newValue, oldValue);
|
|
@@ -126,6 +175,29 @@ export class SnkSimpleCrud {
|
|
|
126
175
|
async observeGridLegacy(newValue, oldValue) {
|
|
127
176
|
await this.handleUpdateGridLegacyConfig(newValue, oldValue);
|
|
128
177
|
}
|
|
178
|
+
async handleDataStateChange(newValue, oldValue) {
|
|
179
|
+
if (ObjectUtils.objectToString(oldValue) != ObjectUtils.objectToString(newValue)) {
|
|
180
|
+
this.dataStateChange.emit(newValue);
|
|
181
|
+
}
|
|
182
|
+
await this.processRmPrecision();
|
|
183
|
+
}
|
|
184
|
+
async processRmPrecision() {
|
|
185
|
+
var _a, _b;
|
|
186
|
+
const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
|
|
187
|
+
for (const field of fieldsWithRmPrecision || []) {
|
|
188
|
+
if (!field) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
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);
|
|
192
|
+
if (!rmPrecision && rmPrecision !== 0) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
await this.setFieldProp(field, 'precision', rmPrecision);
|
|
196
|
+
await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
|
|
197
|
+
}
|
|
198
|
+
;
|
|
199
|
+
this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
|
|
200
|
+
}
|
|
129
201
|
async handleUpdateGridLegacyConfig(newValue, oldValue) {
|
|
130
202
|
if (newValue == undefined || newValue == oldValue) {
|
|
131
203
|
return;
|
|
@@ -234,18 +306,56 @@ export class SnkSimpleCrud {
|
|
|
234
306
|
this.loadGridConfig();
|
|
235
307
|
this.loadFormConfig();
|
|
236
308
|
}
|
|
309
|
+
componentDidRender() {
|
|
310
|
+
this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
|
|
311
|
+
this.addGridCustomValueFormattters();
|
|
312
|
+
this.setFieldsProps();
|
|
313
|
+
this.setCustomRenders();
|
|
314
|
+
this.setCustomEditors();
|
|
315
|
+
}
|
|
237
316
|
componentWillLoad() {
|
|
238
317
|
this.processMetadata();
|
|
239
318
|
this.onModeChange();
|
|
240
319
|
this.configDatasource();
|
|
320
|
+
this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
|
|
241
321
|
}
|
|
242
322
|
componentDidLoad() {
|
|
243
323
|
CSSVarsUtils.applyVarsGrid(this._element, this._grid);
|
|
244
324
|
}
|
|
325
|
+
setCustomRenders() {
|
|
326
|
+
if (!this._grid) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
for (const [fieldName, customRender] of this._customRenders) {
|
|
330
|
+
this._grid.addGridCustomRender(fieldName, customRender);
|
|
331
|
+
this._customRenders.delete(fieldName);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
setCustomEditors() {
|
|
335
|
+
if (!this._grid || !this._form) {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
for (const [fieldName, customEditor] of this._customEditors) {
|
|
339
|
+
this._grid.addCustomEditor(fieldName, customEditor);
|
|
340
|
+
this._form.addCustomEditor(fieldName, customEditor);
|
|
341
|
+
this._customEditors.delete(fieldName);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
245
344
|
configDatasource() {
|
|
246
345
|
this._multiSelectionListDataSource.setApplication(this.application);
|
|
247
346
|
this._multiSelectionListDataSource.setDataUnit(this.dataUnit);
|
|
248
347
|
}
|
|
348
|
+
setFieldsProps() {
|
|
349
|
+
if (!this._form) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
for (const [fieldName, props] of this._fieldsProps) {
|
|
353
|
+
for (const prop in props) {
|
|
354
|
+
this._form.setFieldProp(fieldName, prop, props[prop]);
|
|
355
|
+
}
|
|
356
|
+
this._fieldsProps.delete(fieldName);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
249
359
|
getTaskBarId() {
|
|
250
360
|
var _a, _b;
|
|
251
361
|
if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
|
|
@@ -259,7 +369,7 @@ export class SnkSimpleCrud {
|
|
|
259
369
|
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
|
|
260
370
|
}
|
|
261
371
|
initInMemoryDataUnit() {
|
|
262
|
-
this._inMemoryLoader = new InMemoryLoader(this._metadata);
|
|
372
|
+
this._inMemoryLoader = new InMemoryLoader(this._metadata, undefined, { autoLoad: this.autoLoad });
|
|
263
373
|
this.dataUnit = this._inMemoryLoader.dataUnit;
|
|
264
374
|
this.dataUnitReady.emit(this.dataUnit);
|
|
265
375
|
}
|
|
@@ -298,12 +408,11 @@ export class SnkSimpleCrud {
|
|
|
298
408
|
var _a;
|
|
299
409
|
(_a = this._snkConfigurator) === null || _a === void 0 ? void 0 : _a.close();
|
|
300
410
|
}
|
|
301
|
-
updateConfig() {
|
|
411
|
+
async updateConfig() {
|
|
302
412
|
if (this._formConfigManager == undefined) {
|
|
303
413
|
this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
|
|
304
414
|
}
|
|
305
415
|
this._formConfigManager.setConfig(this.formConfig);
|
|
306
|
-
return;
|
|
307
416
|
}
|
|
308
417
|
processMetadata() {
|
|
309
418
|
const fieldsMetadataElem = this._element.querySelectorAll("snk-field-metadata");
|
|
@@ -335,6 +444,23 @@ export class SnkSimpleCrud {
|
|
|
335
444
|
};
|
|
336
445
|
}
|
|
337
446
|
}
|
|
447
|
+
addGridCustomValueFormattters() {
|
|
448
|
+
var _a, _b, _c;
|
|
449
|
+
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);
|
|
450
|
+
if (!metadataFields) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
const fieldsWithRmPrecision = [];
|
|
454
|
+
metadataFields.forEach((field) => {
|
|
455
|
+
var _a;
|
|
456
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !fieldsWithRmPrecision.includes(field.name)) {
|
|
457
|
+
fieldsWithRmPrecision.push(field.name);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
fieldsWithRmPrecision.forEach(field => {
|
|
461
|
+
this.addCustomValueFormatter(field, this._rmPrecisionCustomValueFormatter);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
338
464
|
onDataStateChange(evt) {
|
|
339
465
|
this.dataState = Object.assign({}, evt.detail);
|
|
340
466
|
}
|
|
@@ -549,15 +675,23 @@ export class SnkSimpleCrud {
|
|
|
549
675
|
}
|
|
550
676
|
return configFromManager;
|
|
551
677
|
}
|
|
678
|
+
updateFormConfig() {
|
|
679
|
+
const newConfig = Object.assign(Object.assign({}, this.formConfig), { fields: this.dataUnit.metadata.fields });
|
|
680
|
+
this.setFormConfig(newConfig, true);
|
|
681
|
+
if (this._formConfigManager == undefined) {
|
|
682
|
+
this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
|
|
683
|
+
}
|
|
684
|
+
this._formConfigManager.setConfig(this.formConfig);
|
|
685
|
+
}
|
|
552
686
|
/* istanbul ignore next */
|
|
553
687
|
render() {
|
|
554
688
|
var _a;
|
|
555
689
|
if (this.dataUnit == undefined) {
|
|
556
690
|
return;
|
|
557
691
|
}
|
|
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)
|
|
692
|
+
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, onDataUnitFieldsHidded: this.updateFormConfig.bind(this) }, 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
693
|
? 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() }))));
|
|
694
|
+
: 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
695
|
}
|
|
562
696
|
static get is() { return "snk-simple-crud"; }
|
|
563
697
|
static get encapsulation() { return "scoped"; }
|
|
@@ -929,6 +1063,23 @@ export class SnkSimpleCrud {
|
|
|
929
1063
|
"attribute": "ignore-read-only-form-fields",
|
|
930
1064
|
"reflect": false,
|
|
931
1065
|
"defaultValue": "false"
|
|
1066
|
+
},
|
|
1067
|
+
"autoLoad": {
|
|
1068
|
+
"type": "boolean",
|
|
1069
|
+
"mutable": false,
|
|
1070
|
+
"complexType": {
|
|
1071
|
+
"original": "boolean",
|
|
1072
|
+
"resolved": "boolean",
|
|
1073
|
+
"references": {}
|
|
1074
|
+
},
|
|
1075
|
+
"required": false,
|
|
1076
|
+
"optional": true,
|
|
1077
|
+
"docs": {
|
|
1078
|
+
"tags": [],
|
|
1079
|
+
"text": "Define se a carga dos dados ser\u00E1 feita assim que o componente for carregado."
|
|
1080
|
+
},
|
|
1081
|
+
"attribute": "auto-load",
|
|
1082
|
+
"reflect": false
|
|
932
1083
|
}
|
|
933
1084
|
};
|
|
934
1085
|
}
|
|
@@ -940,7 +1091,8 @@ export class SnkSimpleCrud {
|
|
|
940
1091
|
"_config": {},
|
|
941
1092
|
"_fieldToGetFocus": {},
|
|
942
1093
|
"_customContainerId": {},
|
|
943
|
-
"_formFields": {}
|
|
1094
|
+
"_formFields": {},
|
|
1095
|
+
"_fieldsProps": {}
|
|
944
1096
|
};
|
|
945
1097
|
}
|
|
946
1098
|
static get events() {
|
|
@@ -1055,6 +1207,128 @@ export class SnkSimpleCrud {
|
|
|
1055
1207
|
}
|
|
1056
1208
|
static get methods() {
|
|
1057
1209
|
return {
|
|
1210
|
+
"addCustomEditor": {
|
|
1211
|
+
"complexType": {
|
|
1212
|
+
"signature": "(fieldName: string, customEditor: ICustomEditor) => Promise<void>",
|
|
1213
|
+
"parameters": [{
|
|
1214
|
+
"tags": [],
|
|
1215
|
+
"text": ""
|
|
1216
|
+
}, {
|
|
1217
|
+
"tags": [],
|
|
1218
|
+
"text": ""
|
|
1219
|
+
}],
|
|
1220
|
+
"references": {
|
|
1221
|
+
"Promise": {
|
|
1222
|
+
"location": "global"
|
|
1223
|
+
},
|
|
1224
|
+
"ICustomEditor": {
|
|
1225
|
+
"location": "import",
|
|
1226
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
|
1227
|
+
}
|
|
1228
|
+
},
|
|
1229
|
+
"return": "Promise<void>"
|
|
1230
|
+
},
|
|
1231
|
+
"docs": {
|
|
1232
|
+
"text": "Registra um editor customizado para campos da grade e formul\u00E1rio.",
|
|
1233
|
+
"tags": []
|
|
1234
|
+
}
|
|
1235
|
+
},
|
|
1236
|
+
"addGridCustomRender": {
|
|
1237
|
+
"complexType": {
|
|
1238
|
+
"signature": "(fieldName: string, customRender: ICustomRender) => Promise<void>",
|
|
1239
|
+
"parameters": [{
|
|
1240
|
+
"tags": [],
|
|
1241
|
+
"text": ""
|
|
1242
|
+
}, {
|
|
1243
|
+
"tags": [],
|
|
1244
|
+
"text": ""
|
|
1245
|
+
}],
|
|
1246
|
+
"references": {
|
|
1247
|
+
"Promise": {
|
|
1248
|
+
"location": "global"
|
|
1249
|
+
},
|
|
1250
|
+
"ICustomRender": {
|
|
1251
|
+
"location": "import",
|
|
1252
|
+
"path": "@sankhyalabs/ezui/dist/types/utils"
|
|
1253
|
+
}
|
|
1254
|
+
},
|
|
1255
|
+
"return": "Promise<void>"
|
|
1256
|
+
},
|
|
1257
|
+
"docs": {
|
|
1258
|
+
"text": "Registra um render customizado para colunas da grid.",
|
|
1259
|
+
"tags": []
|
|
1260
|
+
}
|
|
1261
|
+
},
|
|
1262
|
+
"addCustomValueFormatter": {
|
|
1263
|
+
"complexType": {
|
|
1264
|
+
"signature": "(columnName: string, customFormatter: ICustomFormatter) => Promise<void>",
|
|
1265
|
+
"parameters": [{
|
|
1266
|
+
"tags": [],
|
|
1267
|
+
"text": ""
|
|
1268
|
+
}, {
|
|
1269
|
+
"tags": [],
|
|
1270
|
+
"text": ""
|
|
1271
|
+
}],
|
|
1272
|
+
"references": {
|
|
1273
|
+
"Promise": {
|
|
1274
|
+
"location": "global"
|
|
1275
|
+
},
|
|
1276
|
+
"ICustomFormatter": {
|
|
1277
|
+
"location": "import",
|
|
1278
|
+
"path": "@sankhyalabs/ezui/dist/types/components/ez-grid/interfaces"
|
|
1279
|
+
}
|
|
1280
|
+
},
|
|
1281
|
+
"return": "Promise<void>"
|
|
1282
|
+
},
|
|
1283
|
+
"docs": {
|
|
1284
|
+
"text": "Registra um formatador de valores para uma coluna da grid.",
|
|
1285
|
+
"tags": []
|
|
1286
|
+
}
|
|
1287
|
+
},
|
|
1288
|
+
"removeCustomValueFormatter": {
|
|
1289
|
+
"complexType": {
|
|
1290
|
+
"signature": "(columnName: string) => Promise<void>",
|
|
1291
|
+
"parameters": [{
|
|
1292
|
+
"tags": [],
|
|
1293
|
+
"text": ""
|
|
1294
|
+
}],
|
|
1295
|
+
"references": {
|
|
1296
|
+
"Promise": {
|
|
1297
|
+
"location": "global"
|
|
1298
|
+
}
|
|
1299
|
+
},
|
|
1300
|
+
"return": "Promise<void>"
|
|
1301
|
+
},
|
|
1302
|
+
"docs": {
|
|
1303
|
+
"text": "Remove o formatador de valores de uma coluna da grid.",
|
|
1304
|
+
"tags": []
|
|
1305
|
+
}
|
|
1306
|
+
},
|
|
1307
|
+
"setFieldProp": {
|
|
1308
|
+
"complexType": {
|
|
1309
|
+
"signature": "(fieldName: string, propName: string, value: any) => Promise<void>",
|
|
1310
|
+
"parameters": [{
|
|
1311
|
+
"tags": [],
|
|
1312
|
+
"text": ""
|
|
1313
|
+
}, {
|
|
1314
|
+
"tags": [],
|
|
1315
|
+
"text": ""
|
|
1316
|
+
}, {
|
|
1317
|
+
"tags": [],
|
|
1318
|
+
"text": ""
|
|
1319
|
+
}],
|
|
1320
|
+
"references": {
|
|
1321
|
+
"Promise": {
|
|
1322
|
+
"location": "global"
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
"return": "Promise<void>"
|
|
1326
|
+
},
|
|
1327
|
+
"docs": {
|
|
1328
|
+
"text": "Altera/adiciona uma propriedade nos metadados do campo.",
|
|
1329
|
+
"tags": []
|
|
1330
|
+
}
|
|
1331
|
+
},
|
|
1058
1332
|
"goToView": {
|
|
1059
1333
|
"complexType": {
|
|
1060
1334
|
"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 || rmPrecision === 0) {
|
|
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
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ChangeOperation, DataType, DataUnit, DateUtils, StringUtils, } from '@sankhyalabs/core';
|
|
2
2
|
import { applyFilter, applySorting, buildPaginationInfo } from './dataUnitInMemoryUtils';
|
|
3
3
|
export default class InMemoryLoader {
|
|
4
|
-
constructor(metadata, records) {
|
|
4
|
+
constructor(metadata, records, config) {
|
|
5
5
|
this.metadata = metadata;
|
|
6
6
|
this.records = records;
|
|
7
7
|
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
|
@@ -9,7 +9,11 @@ export default class InMemoryLoader {
|
|
|
9
9
|
this._dataUnit.dataLoader = (dataUnit, request) => this.inMemoryLoader(dataUnit, request, this.getRecordsToLoad());
|
|
10
10
|
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
|
11
11
|
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
|
12
|
-
this.dataUnit.loadMetadata().then(() =>
|
|
12
|
+
this.dataUnit.loadMetadata().then(() => {
|
|
13
|
+
if ((config === null || config === void 0 ? void 0 : config.autoLoad) !== false) {
|
|
14
|
+
this.dataUnit.loadData();
|
|
15
|
+
}
|
|
16
|
+
});
|
|
13
17
|
}
|
|
14
18
|
getRecordsToLoad() {
|
|
15
19
|
if (this._initialRecords == undefined && this.dataUnit.records.length > 0) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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;
|