@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
@@ -2,6 +2,7 @@ import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/
|
|
2
2
|
import { JSUtils, DataType, Action, ObjectUtils, DataUnitAction, ApplicationContext } from '@sankhyalabs/core';
|
3
3
|
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
4
4
|
import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder.js';
|
5
|
+
import { g as getRecordValue, d as DatasetStrategy } from './dataunit-fetcher.js';
|
5
6
|
|
6
7
|
const getSelectedIDs = (dataUnit) => {
|
7
8
|
const selectionInfo = dataUnit.getSelectionInfo();
|
@@ -52,49 +53,29 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
52
53
|
this.cancelEdition = createEvent(this, "cancelEdition", 3);
|
53
54
|
this._onDataUnitResolve = [];
|
54
55
|
this._openedAlert = false;
|
55
|
-
this.
|
56
|
-
|
57
|
-
|
56
|
+
this._fieldsWithRmp = [];
|
57
|
+
this._fieldsWithRmPrecision = [];
|
58
|
+
this._metadataByRow = new Map();
|
59
|
+
this._rowMetadataCache = new Map();
|
60
|
+
this._dataUnitObserver = async (action) => {
|
61
|
+
const duState = this.buildDataState(action.type);
|
58
62
|
this.dataState = duState;
|
59
|
-
if (action.type === Action.DATA_SAVED) {
|
60
|
-
if (this.ignoreSaveMessage) {
|
61
|
-
return;
|
62
|
-
}
|
63
|
-
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
64
|
-
if (msg != undefined) {
|
65
|
-
this.showSuccessMessage(msg);
|
66
|
-
}
|
67
|
-
}
|
68
|
-
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
69
|
-
this.insertionMode.emit();
|
70
|
-
}
|
71
|
-
if (action.type === Action.EDITION_CANCELED) {
|
72
|
-
this.cancelEdition.emit();
|
73
|
-
}
|
74
|
-
if (action.type === Action.RECORDS_REMOVED) {
|
75
|
-
const cachedRecords = action.payload.cachedRecords;
|
76
|
-
let removeFinishMsg;
|
77
|
-
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
78
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
79
|
-
}
|
80
|
-
else {
|
81
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
82
|
-
}
|
83
|
-
if (removeFinishMsg != undefined) {
|
84
|
-
this.showSuccessMessage(removeFinishMsg);
|
85
|
-
}
|
86
|
-
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
87
|
-
const paginationInfo = this.dataUnit.getPaginationInfo();
|
88
|
-
if (paginationInfo) {
|
89
|
-
if (recordsCount > 0 || paginationInfo.hasMore) {
|
90
|
-
this.dataUnit.gotoPage(paginationInfo.currentPage);
|
91
|
-
}
|
92
|
-
else {
|
93
|
-
this.dataUnit.gotoPage(0);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
}
|
97
63
|
this.messagesBuilder.currentOperation = this.getMessageOperation();
|
64
|
+
switch (action.type) {
|
65
|
+
case Action.DATA_SAVED:
|
66
|
+
await this.handleDataSaved(action);
|
67
|
+
break;
|
68
|
+
case Action.RECORDS_ADDED:
|
69
|
+
case Action.RECORDS_COPIED:
|
70
|
+
this.insertionMode.emit();
|
71
|
+
break;
|
72
|
+
case Action.EDITION_CANCELED:
|
73
|
+
this.cancelEdition.emit();
|
74
|
+
break;
|
75
|
+
case Action.RECORDS_REMOVED:
|
76
|
+
this.handleRecordsRemoved(action);
|
77
|
+
break;
|
78
|
+
}
|
98
79
|
};
|
99
80
|
this.dataState = undefined;
|
100
81
|
this.messagesBuilder = undefined;
|
@@ -165,131 +146,282 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
165
146
|
async getSelectedRecordsIDsInfo() {
|
166
147
|
return Promise.resolve(getSelectedIDs(this.dataUnit));
|
167
148
|
}
|
149
|
+
/**
|
150
|
+
* Retorna os campos que possuem a propriedade "rmp" (Row Metadata Provider).
|
151
|
+
*/
|
152
|
+
async getFieldsWithRmp() {
|
153
|
+
return this._fieldsWithRmp;
|
154
|
+
}
|
155
|
+
/**
|
156
|
+
* Retorna os campos que possuem a propriedade "rm_precision" (Row Metadata Precision).
|
157
|
+
*/
|
158
|
+
async getFieldsWithRmPrecision() {
|
159
|
+
return this._fieldsWithRmPrecision;
|
160
|
+
}
|
161
|
+
/**
|
162
|
+
* Busca os metadados da linha selecionada.
|
163
|
+
*/
|
164
|
+
async getRowMetadata(record) {
|
165
|
+
return this.doGetRowMetadata(record);
|
166
|
+
}
|
167
|
+
doGetRowMetadata(record) {
|
168
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
169
|
+
if (!record && !selectedRecord) {
|
170
|
+
return;
|
171
|
+
}
|
172
|
+
const currentRecord = record || selectedRecord;
|
173
|
+
const recordId = typeof currentRecord === 'string' ? currentRecord : currentRecord.__record__id__;
|
174
|
+
const rowMetadata = this._metadataByRow.get(recordId);
|
175
|
+
if (!rowMetadata) {
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
179
|
+
return Object.assign({}, rowMetadata);
|
180
|
+
}
|
181
|
+
buildGetPropRowMetadata(rowMetadata) {
|
182
|
+
return (propPath, fieldName) => {
|
183
|
+
if (propPath === "rm_precision") {
|
184
|
+
propPath = this.resolvePrecisionFromMetadata(fieldName);
|
185
|
+
}
|
186
|
+
return ObjectUtils.getProp(rowMetadata, propPath);
|
187
|
+
};
|
188
|
+
}
|
189
|
+
resolvePrecisionFromMetadata(fieldName) {
|
190
|
+
var _a, _b;
|
191
|
+
if (!fieldName) {
|
192
|
+
ApplicationUtils.error(this.getMessage("snkDataUnit.fieldNameRequired"));
|
193
|
+
return;
|
194
|
+
}
|
195
|
+
const rmPrecision = (_b = (_a = this.dataUnit.getField(fieldName)) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.rm_precision;
|
196
|
+
if (!rmPrecision) {
|
197
|
+
return '';
|
198
|
+
}
|
199
|
+
let rmPrecisionPath = rmPrecision.split('.').filter((_, index) => index !== 1).join('.');
|
200
|
+
return rmPrecisionPath;
|
201
|
+
}
|
168
202
|
getCleanOnCopyFields() {
|
169
203
|
var _a;
|
170
204
|
return (_a = this.dataUnit.metadata) === null || _a === void 0 ? void 0 : _a.fields.filter(field => { var _a; return (_a = field.properties) === null || _a === void 0 ? void 0 : _a.cleanOnCopy; }).map(field => field.name);
|
171
205
|
}
|
172
|
-
|
173
|
-
|
174
|
-
var _a
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
resolve(continueAction ? action : undefined);
|
221
|
-
}
|
222
|
-
}
|
223
|
-
else {
|
224
|
-
resolve(action);
|
225
|
-
}
|
226
|
-
break;
|
227
|
-
case Action.DATA_SAVED:
|
228
|
-
if (this.afterSave) {
|
229
|
-
this.afterSave(this.dataUnit);
|
230
|
-
}
|
231
|
-
else {
|
232
|
-
resolve(action);
|
233
|
-
}
|
234
|
-
break;
|
235
|
-
case Action.EDITION_CANCELED:
|
236
|
-
if (!this.useCancelConfirm)
|
237
|
-
return resolve(action);
|
238
|
-
if (this.dataState.hasDirtyRecords) {
|
239
|
-
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
240
|
-
if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
|
241
|
-
resolve(action);
|
242
|
-
return;
|
243
|
-
}
|
244
|
-
if (cancelConfirmation == undefined) {
|
245
|
-
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
246
|
-
resolve(action);
|
247
|
-
}
|
248
|
-
else {
|
249
|
-
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
250
|
-
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
251
|
-
.then((result) => {
|
252
|
-
result && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
253
|
-
resolve(result ? action : undefined);
|
254
|
-
});
|
255
|
-
}
|
256
|
-
}
|
257
|
-
else {
|
258
|
-
resolve(action);
|
259
|
-
}
|
260
|
-
break;
|
261
|
-
case Action.REMOVING_RECORDS:
|
262
|
-
if (this.isAllowed("REMOVE")) {
|
263
|
-
let multipleSelection = false;
|
264
|
-
let removeConfirmation = !((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
265
|
-
const selection = (_d = this.dataUnit) === null || _d === void 0 ? void 0 : _d.getSelectionInfo();
|
266
|
-
if (!((_e = action.payload) === null || _e === void 0 ? void 0 : _e.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
267
|
-
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
268
|
-
multipleSelection = true;
|
269
|
-
}
|
270
|
-
if (!removeConfirmation) {
|
271
|
-
resolve(action);
|
272
|
-
}
|
273
|
-
else {
|
274
|
-
const options = {
|
275
|
-
canClose: false,
|
276
|
-
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
277
|
-
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
278
|
-
btnConfirmDanger: false
|
279
|
-
};
|
280
|
-
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
281
|
-
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options)
|
282
|
-
.then((result) => resolve(result ? action : undefined));
|
283
|
-
}
|
284
|
-
}
|
285
|
-
else {
|
286
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
287
|
-
}
|
288
|
-
break;
|
289
|
-
default:
|
290
|
-
resolve(action);
|
206
|
+
fillFieldsWithRmp(payload) {
|
207
|
+
payload.fields.forEach((field) => {
|
208
|
+
var _a;
|
209
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rmp) && !this._fieldsWithRmp.includes(field.name)) {
|
210
|
+
this._fieldsWithRmp.push(field.name);
|
211
|
+
}
|
212
|
+
});
|
213
|
+
}
|
214
|
+
fillFieldsWithRmPrecision(payload) {
|
215
|
+
payload.fields.forEach((field) => {
|
216
|
+
var _a;
|
217
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !this._fieldsWithRmPrecision.includes(field.name)) {
|
218
|
+
this._fieldsWithRmPrecision.push(field.name);
|
219
|
+
}
|
220
|
+
});
|
221
|
+
}
|
222
|
+
getCacheName(fieldName, metadataName, fieldValue) {
|
223
|
+
const cacheName = [fieldName, metadataName, fieldValue].join("_");
|
224
|
+
return cacheName;
|
225
|
+
}
|
226
|
+
updateDataStateRmp(newValue) {
|
227
|
+
Object.assign(this.dataState.rowMetadata || {}, newValue);
|
228
|
+
}
|
229
|
+
saveCacheRmd(record) {
|
230
|
+
const rmd = record.__record__metadata__;
|
231
|
+
const keysRmd = Object.keys(rmd);
|
232
|
+
keysRmd.shift();
|
233
|
+
keysRmd.forEach((fieldName) => {
|
234
|
+
const fieldValue = getRecordValue(record, fieldName);
|
235
|
+
const cacheName = this.getCacheName(fieldName, rmd.provider, fieldValue);
|
236
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, rmd));
|
237
|
+
});
|
238
|
+
}
|
239
|
+
getMetadataByRow(payload) {
|
240
|
+
var _a;
|
241
|
+
if (!((_a = payload.records) === null || _a === void 0 ? void 0 : _a.length)) {
|
242
|
+
return payload;
|
243
|
+
}
|
244
|
+
if (!this._fieldsWithRmp.length) {
|
245
|
+
const records = payload.records.map((record) => {
|
246
|
+
delete record.__record__metadata__;
|
247
|
+
return record;
|
248
|
+
});
|
249
|
+
return Object.assign(Object.assign({}, payload), { records });
|
250
|
+
}
|
251
|
+
const records = payload.records.map((record) => {
|
252
|
+
if (!record.__record__metadata__) {
|
253
|
+
return record;
|
291
254
|
}
|
255
|
+
this.saveCacheRmd(record);
|
256
|
+
const rowMetadata = Object.assign({}, record.__record__metadata__);
|
257
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
258
|
+
this._metadataByRow.set(record.__record__id__, rowMetadata);
|
259
|
+
delete record.__record__metadata__;
|
260
|
+
return record;
|
292
261
|
});
|
262
|
+
return Object.assign(Object.assign({}, payload), { records });
|
263
|
+
}
|
264
|
+
interceptRecordsAdded(action) {
|
265
|
+
if (!this.isAllowed("INSERT")) {
|
266
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
267
|
+
return;
|
268
|
+
}
|
269
|
+
return action;
|
270
|
+
}
|
271
|
+
interceptRecordsCopied(action) {
|
272
|
+
if (!this.isAllowed("CLONE")) {
|
273
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
274
|
+
return;
|
275
|
+
}
|
276
|
+
const cleanFields = this.getCleanOnCopyFields();
|
277
|
+
if (cleanFields.length > 0) {
|
278
|
+
const records = action.payload;
|
279
|
+
action = new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
|
280
|
+
const newRecord = Object.assign({}, record);
|
281
|
+
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
282
|
+
return newRecord;
|
283
|
+
}));
|
284
|
+
}
|
285
|
+
return action;
|
286
|
+
}
|
287
|
+
async interceptDataChange(action) {
|
288
|
+
if (this.isAllowed("UPDATE")) {
|
289
|
+
return action;
|
290
|
+
}
|
291
|
+
if (this._openedAlert) {
|
292
|
+
await this.dataUnit.cancelEdition();
|
293
|
+
return;
|
294
|
+
}
|
295
|
+
this._openedAlert = true;
|
296
|
+
await this.dataUnit.cancelEdition();
|
297
|
+
await ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
298
|
+
this._openedAlert = false;
|
299
|
+
}
|
300
|
+
async interceptSavingData(action) {
|
301
|
+
if (!this.beforeSave) {
|
302
|
+
return action;
|
303
|
+
}
|
304
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
305
|
+
if (continueAction instanceof Promise) {
|
306
|
+
const result = await continueAction;
|
307
|
+
return result ? action : undefined;
|
308
|
+
}
|
309
|
+
return continueAction ? action : undefined;
|
310
|
+
}
|
311
|
+
interceptDataSaved(action) {
|
312
|
+
if (this.afterSave) {
|
313
|
+
this.afterSave(this.dataUnit);
|
314
|
+
return;
|
315
|
+
}
|
316
|
+
return action;
|
317
|
+
}
|
318
|
+
async interceptEditionCanceled(action) {
|
319
|
+
var _a, _b;
|
320
|
+
if (!this.useCancelConfirm || !this.dataState.hasDirtyRecords || ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
|
321
|
+
return action;
|
322
|
+
}
|
323
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
324
|
+
if (cancelConfirmation == undefined) {
|
325
|
+
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
326
|
+
return action;
|
327
|
+
}
|
328
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
329
|
+
const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
|
330
|
+
confirm && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
331
|
+
return confirm ? action : undefined;
|
332
|
+
}
|
333
|
+
async interceptRemovingRecords(action) {
|
334
|
+
var _a, _b, _c;
|
335
|
+
if (!this.isAllowed("REMOVE")) {
|
336
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
337
|
+
return;
|
338
|
+
}
|
339
|
+
let multipleSelection = false;
|
340
|
+
let removeConfirmation = !((_a = action.payload) === null || _a === void 0 ? void 0 : _a.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
341
|
+
const selection = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getSelectionInfo();
|
342
|
+
if (!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
343
|
+
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
344
|
+
multipleSelection = true;
|
345
|
+
}
|
346
|
+
if (!removeConfirmation) {
|
347
|
+
return action;
|
348
|
+
}
|
349
|
+
const options = {
|
350
|
+
canClose: false,
|
351
|
+
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
352
|
+
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
353
|
+
btnConfirmDanger: false
|
354
|
+
};
|
355
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
356
|
+
const confirm = await ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options);
|
357
|
+
return confirm ? action : undefined;
|
358
|
+
}
|
359
|
+
interceptDataLoaded(action) {
|
360
|
+
const newPayload = this.getMetadataByRow(action.payload);
|
361
|
+
action = new DataUnitAction(Action.DATA_LOADED, newPayload);
|
362
|
+
return action;
|
363
|
+
}
|
364
|
+
interceptMetadataLoaded(action) {
|
365
|
+
this.fillFieldsWithRmp(action.payload);
|
366
|
+
this.fillFieldsWithRmPrecision(action.payload);
|
367
|
+
return action;
|
368
|
+
}
|
369
|
+
async interceptAction(action) {
|
370
|
+
switch (action.type) {
|
371
|
+
case Action.RECORDS_ADDED:
|
372
|
+
return this.interceptRecordsAdded(action);
|
373
|
+
case Action.RECORDS_COPIED:
|
374
|
+
return this.interceptRecordsCopied(action);
|
375
|
+
case Action.DATA_CHANGED:
|
376
|
+
await this.handleLoadRowMetadata(action);
|
377
|
+
return await this.interceptDataChange(action);
|
378
|
+
case Action.CHANGING_DATA:
|
379
|
+
return await this.interceptDataChange(action);
|
380
|
+
case Action.SAVING_DATA:
|
381
|
+
return await this.interceptSavingData(action);
|
382
|
+
case Action.DATA_SAVED:
|
383
|
+
return this.interceptDataSaved(action);
|
384
|
+
case Action.EDITION_CANCELED:
|
385
|
+
return await this.interceptEditionCanceled(action);
|
386
|
+
case Action.REMOVING_RECORDS:
|
387
|
+
return await this.interceptRemovingRecords(action);
|
388
|
+
case Action.DATA_LOADED:
|
389
|
+
return this.interceptDataLoaded(action);
|
390
|
+
case Action.METADATA_LOADED:
|
391
|
+
return this.interceptMetadataLoaded(action);
|
392
|
+
default:
|
393
|
+
return action;
|
394
|
+
}
|
395
|
+
}
|
396
|
+
async handleLoadRowMetadata(action) {
|
397
|
+
const record = action.type === Action.DATA_CHANGED ? action.payload : action.payload.changes[0].record;
|
398
|
+
const keysPayload = Object.keys(record);
|
399
|
+
const rmpField = keysPayload.find((field) => this._fieldsWithRmp.includes(field));
|
400
|
+
if (rmpField) {
|
401
|
+
const metadataName = this.dataUnit.getField(rmpField).properties.rmp;
|
402
|
+
const fieldValue = getRecordValue(record, rmpField);
|
403
|
+
return await this.updateRowMetadata({
|
404
|
+
fieldName: rmpField,
|
405
|
+
fieldValue,
|
406
|
+
metadataName,
|
407
|
+
updatedFields: record,
|
408
|
+
});
|
409
|
+
}
|
410
|
+
}
|
411
|
+
async updateRowMetadata({ fieldName, fieldValue, metadataName, updatedFields }) {
|
412
|
+
const cacheName = this.getCacheName(fieldName, metadataName, fieldValue);
|
413
|
+
const cacheValue = this._rowMetadataCache.get(cacheName);
|
414
|
+
if (cacheValue) {
|
415
|
+
this.updateDataStateRmp(cacheValue);
|
416
|
+
return cacheValue;
|
417
|
+
}
|
418
|
+
else {
|
419
|
+
const datasetStrategy = new DatasetStrategy();
|
420
|
+
const response = await datasetStrategy.loadRowMetadata(this, fieldName, metadataName, updatedFields);
|
421
|
+
this.updateDataStateRmp(response._rmd);
|
422
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, response._rmd));
|
423
|
+
return Object.assign({}, response._rmd);
|
424
|
+
}
|
293
425
|
}
|
294
426
|
showSuccessMessage(message) {
|
295
427
|
ApplicationUtils.info(message, { iconName: "check" });
|
@@ -297,9 +429,19 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
297
429
|
isAllowed(flag) {
|
298
430
|
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
299
431
|
}
|
300
|
-
buildDataState() {
|
432
|
+
buildDataState(actionType) {
|
433
|
+
var _a;
|
301
434
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
302
435
|
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
436
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
437
|
+
let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
|
438
|
+
const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
|
439
|
+
if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
|
440
|
+
rowMetadata = this.doGetRowMetadata(selectedRecord);
|
441
|
+
}
|
442
|
+
else if (rowMetadata) {
|
443
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
444
|
+
}
|
303
445
|
return new DataStateImpl({
|
304
446
|
insertionMode: this.dataUnit.hasNewRecord(),
|
305
447
|
isStartingInsertionMode,
|
@@ -310,10 +452,48 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
310
452
|
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
311
453
|
selectedRecords: undefined,
|
312
454
|
selectionInfo,
|
313
|
-
selectedRecord
|
314
|
-
recordsIsEmpty: this.dataUnit.records.length === 0
|
455
|
+
selectedRecord,
|
456
|
+
recordsIsEmpty: this.dataUnit.records.length === 0,
|
457
|
+
metadataByRow: this._metadataByRow,
|
458
|
+
rowMetadata
|
315
459
|
});
|
316
460
|
}
|
461
|
+
async handleDataSaved(action) {
|
462
|
+
const newRowMetadata = await this.handleLoadRowMetadata(action);
|
463
|
+
if (newRowMetadata) {
|
464
|
+
newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
|
465
|
+
}
|
466
|
+
const recordId = action.payload.records[0].__record__id__;
|
467
|
+
this._metadataByRow.set(recordId, newRowMetadata);
|
468
|
+
this.dataState = this.buildDataState();
|
469
|
+
if (this.ignoreSaveMessage) {
|
470
|
+
return;
|
471
|
+
}
|
472
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
473
|
+
if (msg != undefined) {
|
474
|
+
this.showSuccessMessage(msg);
|
475
|
+
}
|
476
|
+
}
|
477
|
+
handleRecordsRemoved(action) {
|
478
|
+
var _a, _b;
|
479
|
+
const cachedRecords = action.payload.cachedRecords;
|
480
|
+
let removeFinishMsg;
|
481
|
+
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
482
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
483
|
+
}
|
484
|
+
else {
|
485
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
486
|
+
}
|
487
|
+
if (removeFinishMsg != undefined) {
|
488
|
+
this.showSuccessMessage(removeFinishMsg);
|
489
|
+
}
|
490
|
+
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
491
|
+
const paginationInfo = this.dataUnit.getPaginationInfo();
|
492
|
+
if (paginationInfo) {
|
493
|
+
const page = recordsCount > 0 || paginationInfo.hasMore ? paginationInfo.currentPage : 0;
|
494
|
+
this.dataUnit.gotoPage(page);
|
495
|
+
}
|
496
|
+
}
|
317
497
|
/**
|
318
498
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
319
499
|
* através de um pequeno modulo na estrutura da aplicação:
|
@@ -348,13 +528,14 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
348
528
|
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
349
529
|
if (this._parentSnkDataUnit) {
|
350
530
|
this._parentDataUnit = await ((_a = this._parentSnkDataUnit) === null || _a === void 0 ? void 0 : _a.getDataUnit());
|
351
|
-
return await this._application.getDataUnit(this.entityName, cacheName, this._parentDataUnit, this.configName, this.resourceID);
|
531
|
+
return await this._application.getDataUnit(this.entityName, cacheName, this._parentDataUnit, this.configName, this.resourceID, { skipLoadMetadata: true });
|
352
532
|
}
|
353
533
|
else {
|
354
|
-
return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID);
|
534
|
+
return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID, { skipLoadMetadata: true });
|
355
535
|
}
|
356
536
|
}
|
357
537
|
async loadDataUnit() {
|
538
|
+
var _a;
|
358
539
|
if (this.dataUnit == null && this._application && this.entityName) {
|
359
540
|
this.dataUnit = await this.getDataUnitParentOrChild();
|
360
541
|
}
|
@@ -363,6 +544,10 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
363
544
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
364
545
|
this.dataUnit.addInterceptor(this);
|
365
546
|
this.dataUnit.subscribe(this._dataUnitObserver);
|
547
|
+
await this.dataUnit.loadMetadata();
|
548
|
+
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
549
|
+
this.getMetadataByRow(this.dataUnit);
|
550
|
+
}
|
366
551
|
this.dataState = this.buildDataState();
|
367
552
|
let resolver;
|
368
553
|
while (resolver = this._onDataUnitResolve.pop()) {
|
@@ -450,7 +635,10 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
450
635
|
"configName": [1, "config-name"],
|
451
636
|
"resourceID": [1, "resource-i-d"],
|
452
637
|
"getDataUnit": [64],
|
453
|
-
"getSelectedRecordsIDsInfo": [64]
|
638
|
+
"getSelectedRecordsIDsInfo": [64],
|
639
|
+
"getFieldsWithRmp": [64],
|
640
|
+
"getFieldsWithRmPrecision": [64],
|
641
|
+
"getRowMetadata": [64]
|
454
642
|
}]);
|
455
643
|
class DataStateImpl {
|
456
644
|
constructor(datastate) {
|
@@ -464,6 +652,8 @@ class DataStateImpl {
|
|
464
652
|
this.selectionInfo = datastate.selectionInfo;
|
465
653
|
this.selectedRecord = datastate.selectedRecord;
|
466
654
|
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
655
|
+
this.metadataByRow = datastate.metadataByRow;
|
656
|
+
this.rowMetadata = datastate.rowMetadata;
|
467
657
|
}
|
468
658
|
get selectedRecords() {
|
469
659
|
var _a;
|