@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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import { JSUtils, DataType, Action, ObjectUtils, DataUnitAction, ApplicationContext } from '@sankhyalabs/core';
|
|
2
|
+
import { JSUtils, DataType, Action, ObjectUtils, DataUnitAction, StringUtils, 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();
|
|
@@ -48,54 +49,37 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
48
49
|
this.dataStateChange = createEvent(this, "dataStateChange", 3);
|
|
49
50
|
this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
|
|
50
51
|
this.messagesBuilderUpdated = createEvent(this, "messagesBuilderUpdated", 3);
|
|
52
|
+
this.dataUnitFieldsHidded = createEvent(this, "dataUnitFieldsHidded", 7);
|
|
51
53
|
this.insertionMode = createEvent(this, "insertionMode", 3);
|
|
52
54
|
this.cancelEdition = createEvent(this, "cancelEdition", 3);
|
|
53
55
|
this._onDataUnitResolve = [];
|
|
54
56
|
this._openedAlert = false;
|
|
55
|
-
this.
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
this._fieldsWithRmp = [];
|
|
58
|
+
this._fieldsWithRmPrecision = [];
|
|
59
|
+
this._metadataByRow = new Map();
|
|
60
|
+
this._rowMetadataCache = new Map();
|
|
61
|
+
this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
|
|
62
|
+
this._dataUnitObserver = async (action) => {
|
|
63
|
+
const duState = this.buildDataState(action.type);
|
|
58
64
|
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
65
|
this.messagesBuilder.currentOperation = this.getMessageOperation();
|
|
66
|
+
switch (action.type) {
|
|
67
|
+
case Action.DATA_SAVED:
|
|
68
|
+
await this.handleDataSaved(action);
|
|
69
|
+
break;
|
|
70
|
+
case Action.RECORDS_ADDED:
|
|
71
|
+
case Action.RECORDS_COPIED:
|
|
72
|
+
this.insertionMode.emit();
|
|
73
|
+
break;
|
|
74
|
+
case Action.EDITION_CANCELED:
|
|
75
|
+
this.cancelEdition.emit();
|
|
76
|
+
break;
|
|
77
|
+
case Action.RECORDS_REMOVED:
|
|
78
|
+
this.handleRecordsRemoved(action);
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
98
81
|
};
|
|
82
|
+
this.fieldsToLink = [];
|
|
99
83
|
this.dataState = undefined;
|
|
100
84
|
this.messagesBuilder = undefined;
|
|
101
85
|
this.dataUnitName = undefined;
|
|
@@ -165,141 +149,334 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
165
149
|
async getSelectedRecordsIDsInfo() {
|
|
166
150
|
return Promise.resolve(getSelectedIDs(this.dataUnit));
|
|
167
151
|
}
|
|
152
|
+
/**
|
|
153
|
+
* Retorna os campos que possuem a propriedade "rmp" (Row Metadata Provider).
|
|
154
|
+
*/
|
|
155
|
+
async getFieldsWithRmp() {
|
|
156
|
+
return this._fieldsWithRmp;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Retorna os campos que possuem a propriedade "rm_precision" (Row Metadata Precision).
|
|
160
|
+
*/
|
|
161
|
+
async getFieldsWithRmPrecision() {
|
|
162
|
+
return this._fieldsWithRmPrecision;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Busca os metadados da linha selecionada.
|
|
166
|
+
*/
|
|
167
|
+
async getRowMetadata(record) {
|
|
168
|
+
return this.doGetRowMetadata(record);
|
|
169
|
+
}
|
|
170
|
+
doGetRowMetadata(record) {
|
|
171
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
|
172
|
+
if (!record && !selectedRecord) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const currentRecord = record || selectedRecord;
|
|
176
|
+
const recordId = typeof currentRecord === 'string' ? currentRecord : currentRecord.__record__id__;
|
|
177
|
+
const rowMetadata = this._metadataByRow.get(recordId);
|
|
178
|
+
if (!rowMetadata) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
|
182
|
+
return Object.assign({}, rowMetadata);
|
|
183
|
+
}
|
|
184
|
+
buildGetPropRowMetadata(rowMetadata) {
|
|
185
|
+
return (propPath, fieldName) => {
|
|
186
|
+
if (propPath === "rm_precision") {
|
|
187
|
+
propPath = this.resolvePrecisionFromMetadata(fieldName);
|
|
188
|
+
}
|
|
189
|
+
return ObjectUtils.getProp(rowMetadata, propPath);
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
resolvePrecisionFromMetadata(fieldName) {
|
|
193
|
+
var _a, _b;
|
|
194
|
+
if (!fieldName) {
|
|
195
|
+
ApplicationUtils.error(this.getMessage("snkDataUnit.fieldNameRequired"));
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
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;
|
|
199
|
+
if (!rmPrecision) {
|
|
200
|
+
return '';
|
|
201
|
+
}
|
|
202
|
+
let rmPrecisionPath = rmPrecision.split('.').filter((_, index) => index !== 1).join('.');
|
|
203
|
+
return rmPrecisionPath;
|
|
204
|
+
}
|
|
168
205
|
getCleanOnCopyFields() {
|
|
169
206
|
var _a;
|
|
170
207
|
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
208
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
var _a
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (this.isAllowed("INSERT")) {
|
|
178
|
-
resolve(action);
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
182
|
-
}
|
|
183
|
-
break;
|
|
184
|
-
case Action.RECORDS_COPIED:
|
|
185
|
-
if (this.isAllowed("CLONE")) {
|
|
186
|
-
const cleanFields = this.getCleanOnCopyFields();
|
|
187
|
-
if (cleanFields.length > 0) {
|
|
188
|
-
const records = action.payload;
|
|
189
|
-
action = new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
|
|
190
|
-
const newRecord = Object.assign({}, record);
|
|
191
|
-
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
192
|
-
return newRecord;
|
|
193
|
-
}));
|
|
194
|
-
}
|
|
195
|
-
resolve(action);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
199
|
-
}
|
|
200
|
-
break;
|
|
201
|
-
case Action.DATA_CHANGED:
|
|
202
|
-
case Action.CHANGING_DATA:
|
|
203
|
-
if (this.isAllowed("UPDATE"))
|
|
204
|
-
return resolve(action);
|
|
205
|
-
if (this._openedAlert)
|
|
206
|
-
return this.dataUnit.cancelEdition();
|
|
207
|
-
this._openedAlert = true;
|
|
208
|
-
this.dataUnit.cancelEdition();
|
|
209
|
-
ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
|
|
210
|
-
this._openedAlert = false;
|
|
211
|
-
});
|
|
212
|
-
break;
|
|
213
|
-
case Action.SAVING_DATA:
|
|
214
|
-
if (this.beforeSave) {
|
|
215
|
-
const continueAction = this.beforeSave(this.dataUnit);
|
|
216
|
-
if (continueAction instanceof Promise) {
|
|
217
|
-
continueAction.then(result => resolve(result ? action : undefined));
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
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);
|
|
209
|
+
fillFieldsWithRmp(payload) {
|
|
210
|
+
payload.fields.forEach((field) => {
|
|
211
|
+
var _a;
|
|
212
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rmp) && !this._fieldsWithRmp.includes(field.name)) {
|
|
213
|
+
this._fieldsWithRmp.push(field.name);
|
|
291
214
|
}
|
|
292
215
|
});
|
|
293
216
|
}
|
|
217
|
+
fillFieldsWithRmPrecision(payload) {
|
|
218
|
+
payload.fields.forEach((field) => {
|
|
219
|
+
var _a;
|
|
220
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !this._fieldsWithRmPrecision.includes(field.name)) {
|
|
221
|
+
this._fieldsWithRmPrecision.push(field.name);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
getCacheName(fieldName, metadataName, fieldValue) {
|
|
226
|
+
const cacheName = [fieldName, metadataName, fieldValue].join("_");
|
|
227
|
+
return cacheName;
|
|
228
|
+
}
|
|
229
|
+
updateDataStateRmp(newValue) {
|
|
230
|
+
Object.assign(this.dataState.rowMetadata || {}, newValue);
|
|
231
|
+
}
|
|
232
|
+
saveCacheRmd(record) {
|
|
233
|
+
const rmd = record.__record__metadata__;
|
|
234
|
+
const keysRmd = Object.keys(rmd);
|
|
235
|
+
keysRmd.shift();
|
|
236
|
+
keysRmd.forEach((fieldName) => {
|
|
237
|
+
const fieldValue = getRecordValue(record, fieldName);
|
|
238
|
+
const cacheName = this.getCacheName(fieldName, rmd.provider, fieldValue);
|
|
239
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, rmd));
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
getMetadataByRow(payload) {
|
|
243
|
+
var _a;
|
|
244
|
+
if (!((_a = payload.records) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
245
|
+
return payload;
|
|
246
|
+
}
|
|
247
|
+
if (!this._fieldsWithRmp.length) {
|
|
248
|
+
const records = payload.records.map((record) => {
|
|
249
|
+
delete record.__record__metadata__;
|
|
250
|
+
return record;
|
|
251
|
+
});
|
|
252
|
+
return Object.assign(Object.assign({}, payload), { records });
|
|
253
|
+
}
|
|
254
|
+
const records = payload.records.map((record) => {
|
|
255
|
+
if (!record.__record__metadata__) {
|
|
256
|
+
return record;
|
|
257
|
+
}
|
|
258
|
+
this.saveCacheRmd(record);
|
|
259
|
+
const rowMetadata = Object.assign({}, record.__record__metadata__);
|
|
260
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
|
261
|
+
this._metadataByRow.set(record.__record__id__, rowMetadata);
|
|
262
|
+
delete record.__record__metadata__;
|
|
263
|
+
return record;
|
|
264
|
+
});
|
|
265
|
+
return Object.assign(Object.assign({}, payload), { records });
|
|
266
|
+
}
|
|
267
|
+
interceptRecordsAdded(action) {
|
|
268
|
+
if (!this.isAllowed("INSERT")) {
|
|
269
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
|
|
273
|
+
}
|
|
274
|
+
interceptRecordsCopied(action) {
|
|
275
|
+
if (!this.isAllowed("CLONE")) {
|
|
276
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
|
|
280
|
+
}
|
|
281
|
+
async interceptDataChange(action) {
|
|
282
|
+
if (this.isAllowed("UPDATE")) {
|
|
283
|
+
return action;
|
|
284
|
+
}
|
|
285
|
+
if (this._openedAlert) {
|
|
286
|
+
await this.dataUnit.cancelEdition();
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
this._openedAlert = true;
|
|
290
|
+
await this.dataUnit.cancelEdition();
|
|
291
|
+
await ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
|
292
|
+
this._openedAlert = false;
|
|
293
|
+
}
|
|
294
|
+
async interceptSavingData(action) {
|
|
295
|
+
if (!this.beforeSave) {
|
|
296
|
+
return action;
|
|
297
|
+
}
|
|
298
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
|
299
|
+
if (continueAction instanceof Promise) {
|
|
300
|
+
const result = await continueAction;
|
|
301
|
+
return result ? action : undefined;
|
|
302
|
+
}
|
|
303
|
+
return continueAction ? action : undefined;
|
|
304
|
+
}
|
|
305
|
+
interceptDataSaved(action) {
|
|
306
|
+
if (this.afterSave) {
|
|
307
|
+
this.afterSave(this.dataUnit);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
return action;
|
|
311
|
+
}
|
|
312
|
+
async interceptEditionCanceled(action) {
|
|
313
|
+
var _a, _b;
|
|
314
|
+
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)) {
|
|
315
|
+
return action;
|
|
316
|
+
}
|
|
317
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
318
|
+
if (cancelConfirmation == undefined) {
|
|
319
|
+
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
320
|
+
return action;
|
|
321
|
+
}
|
|
322
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
323
|
+
const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
|
|
324
|
+
confirm && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
325
|
+
return confirm ? action : undefined;
|
|
326
|
+
}
|
|
327
|
+
async interceptRemovingRecords(action) {
|
|
328
|
+
var _a, _b, _c;
|
|
329
|
+
if (!this.isAllowed("REMOVE")) {
|
|
330
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
let multipleSelection = false;
|
|
334
|
+
let removeConfirmation = !((_a = action.payload) === null || _a === void 0 ? void 0 : _a.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
|
335
|
+
const selection = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getSelectionInfo();
|
|
336
|
+
if (!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
|
337
|
+
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
|
338
|
+
multipleSelection = true;
|
|
339
|
+
}
|
|
340
|
+
if (!removeConfirmation) {
|
|
341
|
+
return action;
|
|
342
|
+
}
|
|
343
|
+
const options = {
|
|
344
|
+
canClose: false,
|
|
345
|
+
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
|
346
|
+
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
|
347
|
+
btnConfirmDanger: false
|
|
348
|
+
};
|
|
349
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
350
|
+
const confirm = await ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options);
|
|
351
|
+
return confirm ? action : undefined;
|
|
352
|
+
}
|
|
353
|
+
interceptDataLoaded(action) {
|
|
354
|
+
const newPayload = this.getMetadataByRow(action.payload);
|
|
355
|
+
action = new DataUnitAction(Action.DATA_LOADED, newPayload);
|
|
356
|
+
return action;
|
|
357
|
+
}
|
|
358
|
+
interceptMetadataLoaded(action) {
|
|
359
|
+
this.fillFieldsWithRmp(action.payload);
|
|
360
|
+
this.fillFieldsWithRmPrecision(action.payload);
|
|
361
|
+
return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
|
|
362
|
+
}
|
|
363
|
+
async interceptAction(action) {
|
|
364
|
+
switch (action.type) {
|
|
365
|
+
case Action.RECORDS_ADDED:
|
|
366
|
+
return this.interceptRecordsAdded(action);
|
|
367
|
+
case Action.RECORDS_COPIED:
|
|
368
|
+
return this.interceptRecordsCopied(action);
|
|
369
|
+
case Action.DATA_CHANGED:
|
|
370
|
+
await this.handleLoadRowMetadata(action);
|
|
371
|
+
return await this.interceptDataChange(action);
|
|
372
|
+
case Action.CHANGING_DATA:
|
|
373
|
+
return await this.interceptDataChange(action);
|
|
374
|
+
case Action.SAVING_DATA:
|
|
375
|
+
return await this.interceptSavingData(action);
|
|
376
|
+
case Action.DATA_SAVED:
|
|
377
|
+
return this.interceptDataSaved(action);
|
|
378
|
+
case Action.EDITION_CANCELED:
|
|
379
|
+
return await this.interceptEditionCanceled(action);
|
|
380
|
+
case Action.REMOVING_RECORDS:
|
|
381
|
+
return await this.interceptRemovingRecords(action);
|
|
382
|
+
case Action.DATA_LOADED:
|
|
383
|
+
return this.interceptDataLoaded(action);
|
|
384
|
+
case Action.METADATA_LOADED:
|
|
385
|
+
return this.interceptMetadataLoaded(action);
|
|
386
|
+
default:
|
|
387
|
+
return action;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
async handleLoadRowMetadata(action) {
|
|
391
|
+
const record = action.type === Action.DATA_CHANGED ? action.payload : action.payload.changes[0].record;
|
|
392
|
+
const keysPayload = Object.keys(record);
|
|
393
|
+
const rmpField = keysPayload.find((field) => this._fieldsWithRmp.includes(field));
|
|
394
|
+
if (rmpField) {
|
|
395
|
+
const metadataName = this.dataUnit.getField(rmpField).properties.rmp;
|
|
396
|
+
const fieldValue = getRecordValue(record, rmpField);
|
|
397
|
+
return await this.updateRowMetadata({
|
|
398
|
+
fieldName: rmpField,
|
|
399
|
+
fieldValue,
|
|
400
|
+
metadataName,
|
|
401
|
+
updatedFields: record,
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
async updateRowMetadata({ fieldName, fieldValue, metadataName, updatedFields }) {
|
|
406
|
+
const cacheName = this.getCacheName(fieldName, metadataName, fieldValue);
|
|
407
|
+
const cacheValue = this._rowMetadataCache.get(cacheName);
|
|
408
|
+
if (cacheValue) {
|
|
409
|
+
this.updateDataStateRmp(cacheValue);
|
|
410
|
+
return cacheValue;
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
const datasetStrategy = new DatasetStrategy();
|
|
414
|
+
const response = await datasetStrategy.loadRowMetadata(this, fieldName, metadataName, updatedFields);
|
|
415
|
+
this.updateDataStateRmp(response._rmd);
|
|
416
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, response._rmd));
|
|
417
|
+
return Object.assign({}, response._rmd);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
handleDULinksOnMetadataLoaded(payload) {
|
|
421
|
+
const metadata = Object.assign({}, payload);
|
|
422
|
+
this.processLinks(metadata);
|
|
423
|
+
return metadata;
|
|
424
|
+
}
|
|
425
|
+
handleRecordsCopied(initialRecords) {
|
|
426
|
+
let records = [...initialRecords];
|
|
427
|
+
records = this.handleCleanOnCopy(records);
|
|
428
|
+
return this.handleLinksWithParent(records);
|
|
429
|
+
}
|
|
430
|
+
handleLinksWithParent(records) {
|
|
431
|
+
var _a, _b;
|
|
432
|
+
const parentDataUnit = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
|
433
|
+
if (!parentDataUnit)
|
|
434
|
+
return records;
|
|
435
|
+
const parentSelectedRecord = parentDataUnit.getSelectedRecord();
|
|
436
|
+
const selfInfo = parentDataUnit === null || parentDataUnit === void 0 ? void 0 : parentDataUnit.getChildInfo(this.getCleanDataUnitName());
|
|
437
|
+
const { links } = selfInfo;
|
|
438
|
+
if (!links || links.length === 0)
|
|
439
|
+
return records;
|
|
440
|
+
return records.map(record => {
|
|
441
|
+
return this.buildRecordWithLinkedFields(record, links, parentSelectedRecord);
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
buildRecordWithLinkedFields(record, links, parentSelectedRecord) {
|
|
445
|
+
const newRecord = Object.assign({}, record);
|
|
446
|
+
links.forEach(link => newRecord[link.target] = parentSelectedRecord[link.source]);
|
|
447
|
+
return newRecord;
|
|
448
|
+
}
|
|
449
|
+
handleCleanOnCopy(records) {
|
|
450
|
+
const cleanFields = this.getCleanOnCopyFields();
|
|
451
|
+
if (cleanFields.length > 0) {
|
|
452
|
+
records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
|
|
453
|
+
}
|
|
454
|
+
return records;
|
|
455
|
+
}
|
|
456
|
+
buildCopyWithCleanedFields(record, cleanFields) {
|
|
457
|
+
const newRecord = Object.assign({}, record);
|
|
458
|
+
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
459
|
+
return newRecord;
|
|
460
|
+
}
|
|
294
461
|
showSuccessMessage(message) {
|
|
295
462
|
ApplicationUtils.info(message, { iconName: "check" });
|
|
296
463
|
}
|
|
297
464
|
isAllowed(flag) {
|
|
298
465
|
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
299
466
|
}
|
|
300
|
-
buildDataState() {
|
|
467
|
+
buildDataState(actionType) {
|
|
468
|
+
var _a;
|
|
301
469
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
|
302
470
|
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
|
471
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
|
472
|
+
let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
|
|
473
|
+
const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
|
|
474
|
+
if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
|
|
475
|
+
rowMetadata = this.doGetRowMetadata(selectedRecord);
|
|
476
|
+
}
|
|
477
|
+
else if (rowMetadata) {
|
|
478
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
|
479
|
+
}
|
|
303
480
|
return new DataStateImpl({
|
|
304
481
|
insertionMode: this.dataUnit.hasNewRecord(),
|
|
305
482
|
isStartingInsertionMode,
|
|
@@ -310,10 +487,48 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
310
487
|
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
|
311
488
|
selectedRecords: undefined,
|
|
312
489
|
selectionInfo,
|
|
313
|
-
selectedRecord
|
|
314
|
-
recordsIsEmpty: this.dataUnit.records.length === 0
|
|
490
|
+
selectedRecord,
|
|
491
|
+
recordsIsEmpty: this.dataUnit.records.length === 0,
|
|
492
|
+
metadataByRow: this._metadataByRow,
|
|
493
|
+
rowMetadata
|
|
315
494
|
});
|
|
316
495
|
}
|
|
496
|
+
async handleDataSaved(action) {
|
|
497
|
+
const newRowMetadata = await this.handleLoadRowMetadata(action);
|
|
498
|
+
if (newRowMetadata) {
|
|
499
|
+
newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
|
|
500
|
+
}
|
|
501
|
+
const recordId = action.payload.records[0].__record__id__;
|
|
502
|
+
this._metadataByRow.set(recordId, newRowMetadata);
|
|
503
|
+
this.dataState = this.buildDataState();
|
|
504
|
+
if (this.ignoreSaveMessage) {
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
508
|
+
if (msg != undefined) {
|
|
509
|
+
this.showSuccessMessage(msg);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
handleRecordsRemoved(action) {
|
|
513
|
+
var _a, _b;
|
|
514
|
+
const cachedRecords = action.payload.cachedRecords;
|
|
515
|
+
let removeFinishMsg;
|
|
516
|
+
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
|
517
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
|
518
|
+
}
|
|
519
|
+
else {
|
|
520
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
521
|
+
}
|
|
522
|
+
if (removeFinishMsg != undefined) {
|
|
523
|
+
this.showSuccessMessage(removeFinishMsg);
|
|
524
|
+
}
|
|
525
|
+
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
526
|
+
const paginationInfo = this.dataUnit.getPaginationInfo();
|
|
527
|
+
if (paginationInfo) {
|
|
528
|
+
const page = recordsCount > 0 || paginationInfo.hasMore ? paginationInfo.currentPage : 0;
|
|
529
|
+
this.dataUnit.gotoPage(page);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
317
532
|
/**
|
|
318
533
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
319
534
|
* através de um pequeno modulo na estrutura da aplicação:
|
|
@@ -348,13 +563,14 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
348
563
|
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
|
349
564
|
if (this._parentSnkDataUnit) {
|
|
350
565
|
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);
|
|
566
|
+
return await this._application.getDataUnit(this.entityName, cacheName, this._parentDataUnit, this.configName, this.resourceID, { skipLoadMetadata: true });
|
|
352
567
|
}
|
|
353
568
|
else {
|
|
354
|
-
return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID);
|
|
569
|
+
return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID, { skipLoadMetadata: true });
|
|
355
570
|
}
|
|
356
571
|
}
|
|
357
572
|
async loadDataUnit() {
|
|
573
|
+
var _a;
|
|
358
574
|
if (this.dataUnit == null && this._application && this.entityName) {
|
|
359
575
|
this.dataUnit = await this.getDataUnitParentOrChild();
|
|
360
576
|
}
|
|
@@ -363,6 +579,10 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
363
579
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
364
580
|
this.dataUnit.addInterceptor(this);
|
|
365
581
|
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
582
|
+
await this.dataUnit.loadMetadata();
|
|
583
|
+
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
|
584
|
+
this.getMetadataByRow(this.dataUnit);
|
|
585
|
+
}
|
|
366
586
|
this.dataState = this.buildDataState();
|
|
367
587
|
let resolver;
|
|
368
588
|
while (resolver = this._onDataUnitResolve.pop()) {
|
|
@@ -381,20 +601,40 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
381
601
|
return;
|
|
382
602
|
}
|
|
383
603
|
handlerLinkFields() {
|
|
384
|
-
var _a, _b;
|
|
385
|
-
const
|
|
386
|
-
if (!
|
|
604
|
+
var _a, _b, _c, _d;
|
|
605
|
+
const parentDU = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
|
606
|
+
if (!parentDU)
|
|
387
607
|
return;
|
|
388
|
-
const
|
|
608
|
+
const childName = (_c = this.entityName) !== null && _c !== void 0 ? _c : this.getCleanDataUnitName();
|
|
609
|
+
const child = parentDU.getChildInfo(childName);
|
|
389
610
|
if (!child)
|
|
390
611
|
return;
|
|
391
|
-
const
|
|
392
|
-
(
|
|
393
|
-
|
|
612
|
+
const links = (_d = child === null || child === void 0 ? void 0 : child.links) === null || _d === void 0 ? void 0 : _d.map(link => link.target);
|
|
613
|
+
this.handleDUWithLinks(links);
|
|
614
|
+
}
|
|
615
|
+
handleDUWithLinks(fieldsToLink) {
|
|
616
|
+
this.fieldsToLink = fieldsToLink;
|
|
617
|
+
const metadata = Object.assign({}, this.dataUnit.metadata);
|
|
618
|
+
this.processLinks(metadata);
|
|
619
|
+
this.dataUnit.metadata = metadata;
|
|
620
|
+
this.dataUnitFieldsHidded.emit();
|
|
621
|
+
}
|
|
622
|
+
processLinks(metadata) {
|
|
623
|
+
var _a;
|
|
624
|
+
(_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
625
|
+
var _a;
|
|
626
|
+
if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
|
|
394
627
|
field.visible = false;
|
|
395
628
|
}
|
|
396
629
|
});
|
|
397
|
-
|
|
630
|
+
}
|
|
631
|
+
getCleanDataUnitName() {
|
|
632
|
+
var _a;
|
|
633
|
+
const uri = this.dataUnit.name;
|
|
634
|
+
if (StringUtils.isEmpty(uri))
|
|
635
|
+
return uri;
|
|
636
|
+
const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
|
|
637
|
+
return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
|
|
398
638
|
}
|
|
399
639
|
static getNearestInstance(element) {
|
|
400
640
|
let parent = element.parentElement;
|
|
@@ -421,8 +661,9 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
421
661
|
this.dataUnit.releaseCallbacks();
|
|
422
662
|
}
|
|
423
663
|
}
|
|
424
|
-
componentDidLoad() {
|
|
425
|
-
this.loadDataUnit();
|
|
664
|
+
async componentDidLoad() {
|
|
665
|
+
await this.loadDataUnit();
|
|
666
|
+
this.handlerLinkFields();
|
|
426
667
|
}
|
|
427
668
|
render() {
|
|
428
669
|
return (h(Host, null));
|
|
@@ -449,8 +690,12 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
449
690
|
"ignoreSaveMessage": [4, "ignore-save-message"],
|
|
450
691
|
"configName": [1, "config-name"],
|
|
451
692
|
"resourceID": [1, "resource-i-d"],
|
|
693
|
+
"fieldsToLink": [32],
|
|
452
694
|
"getDataUnit": [64],
|
|
453
|
-
"getSelectedRecordsIDsInfo": [64]
|
|
695
|
+
"getSelectedRecordsIDsInfo": [64],
|
|
696
|
+
"getFieldsWithRmp": [64],
|
|
697
|
+
"getFieldsWithRmPrecision": [64],
|
|
698
|
+
"getRowMetadata": [64]
|
|
454
699
|
}]);
|
|
455
700
|
class DataStateImpl {
|
|
456
701
|
constructor(datastate) {
|
|
@@ -464,6 +709,8 @@ class DataStateImpl {
|
|
|
464
709
|
this.selectionInfo = datastate.selectionInfo;
|
|
465
710
|
this.selectedRecord = datastate.selectedRecord;
|
|
466
711
|
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
|
712
|
+
this.metadataByRow = datastate.metadataByRow;
|
|
713
|
+
this.rowMetadata = datastate.rowMetadata;
|
|
467
714
|
}
|
|
468
715
|
get selectedRecords() {
|
|
469
716
|
var _a;
|