@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,56 +1,42 @@
|
|
|
1
1
|
import { Host, h } from '@stencil/core';
|
|
2
|
-
import { Action, ApplicationContext, DataUnitAction, ObjectUtils } from '@sankhyalabs/core';
|
|
2
|
+
import { Action, ApplicationContext, DataUnitAction, ObjectUtils, StringUtils } from '@sankhyalabs/core';
|
|
3
3
|
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
4
|
import { OperationMap, SnkMessageBuilder } from '../../lib/message/SnkMessageBuilder';
|
|
5
|
+
import { DatasetStrategy } from '../../lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy';
|
|
6
|
+
import { getRecordValue } from '../../lib/dataUnit/ValueFormatter';
|
|
5
7
|
import { getSelectedIDs } from '../snk-data-exporter/utils/RecordIDUtils';
|
|
6
8
|
export class SnkDataUnit {
|
|
7
9
|
constructor() {
|
|
8
10
|
this._onDataUnitResolve = [];
|
|
9
11
|
this._openedAlert = false;
|
|
10
|
-
this.
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
this._fieldsWithRmp = [];
|
|
13
|
+
this._fieldsWithRmPrecision = [];
|
|
14
|
+
this._metadataByRow = new Map();
|
|
15
|
+
this._rowMetadataCache = new Map();
|
|
16
|
+
this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
|
|
17
|
+
this._dataUnitObserver = async (action) => {
|
|
18
|
+
const duState = this.buildDataState(action.type);
|
|
13
19
|
this.dataState = duState;
|
|
14
|
-
if (action.type === Action.DATA_SAVED) {
|
|
15
|
-
if (this.ignoreSaveMessage) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
19
|
-
if (msg != undefined) {
|
|
20
|
-
this.showSuccessMessage(msg);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
24
|
-
this.insertionMode.emit();
|
|
25
|
-
}
|
|
26
|
-
if (action.type === Action.EDITION_CANCELED) {
|
|
27
|
-
this.cancelEdition.emit();
|
|
28
|
-
}
|
|
29
|
-
if (action.type === Action.RECORDS_REMOVED) {
|
|
30
|
-
const cachedRecords = action.payload.cachedRecords;
|
|
31
|
-
let removeFinishMsg;
|
|
32
|
-
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
|
33
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
37
|
-
}
|
|
38
|
-
if (removeFinishMsg != undefined) {
|
|
39
|
-
this.showSuccessMessage(removeFinishMsg);
|
|
40
|
-
}
|
|
41
|
-
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
42
|
-
const paginationInfo = this.dataUnit.getPaginationInfo();
|
|
43
|
-
if (paginationInfo) {
|
|
44
|
-
if (recordsCount > 0 || paginationInfo.hasMore) {
|
|
45
|
-
this.dataUnit.gotoPage(paginationInfo.currentPage);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
this.dataUnit.gotoPage(0);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
20
|
this.messagesBuilder.currentOperation = this.getMessageOperation();
|
|
21
|
+
switch (action.type) {
|
|
22
|
+
case Action.DATA_SAVED:
|
|
23
|
+
await this.handleDataSaved(action);
|
|
24
|
+
break;
|
|
25
|
+
case Action.RECORDS_ADDED:
|
|
26
|
+
case Action.RECORDS_COPIED:
|
|
27
|
+
this.insertionMode.emit();
|
|
28
|
+
break;
|
|
29
|
+
case Action.EDITION_CANCELED:
|
|
30
|
+
this.cancelEdition.emit();
|
|
31
|
+
break;
|
|
32
|
+
case Action.RECORDS_REMOVED:
|
|
33
|
+
this.handleRecordsRemoved(action);
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
53
38
|
};
|
|
39
|
+
this.fieldsToLink = [];
|
|
54
40
|
this.dataState = undefined;
|
|
55
41
|
this.messagesBuilder = undefined;
|
|
56
42
|
this.dataUnitName = undefined;
|
|
@@ -120,141 +106,334 @@ export class SnkDataUnit {
|
|
|
120
106
|
async getSelectedRecordsIDsInfo() {
|
|
121
107
|
return Promise.resolve(getSelectedIDs(this.dataUnit));
|
|
122
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Retorna os campos que possuem a propriedade "rmp" (Row Metadata Provider).
|
|
111
|
+
*/
|
|
112
|
+
async getFieldsWithRmp() {
|
|
113
|
+
return this._fieldsWithRmp;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Retorna os campos que possuem a propriedade "rm_precision" (Row Metadata Precision).
|
|
117
|
+
*/
|
|
118
|
+
async getFieldsWithRmPrecision() {
|
|
119
|
+
return this._fieldsWithRmPrecision;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Busca os metadados da linha selecionada.
|
|
123
|
+
*/
|
|
124
|
+
async getRowMetadata(record) {
|
|
125
|
+
return this.doGetRowMetadata(record);
|
|
126
|
+
}
|
|
127
|
+
doGetRowMetadata(record) {
|
|
128
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
|
129
|
+
if (!record && !selectedRecord) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const currentRecord = record || selectedRecord;
|
|
133
|
+
const recordId = typeof currentRecord === 'string' ? currentRecord : currentRecord.__record__id__;
|
|
134
|
+
const rowMetadata = this._metadataByRow.get(recordId);
|
|
135
|
+
if (!rowMetadata) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
|
139
|
+
return Object.assign({}, rowMetadata);
|
|
140
|
+
}
|
|
141
|
+
buildGetPropRowMetadata(rowMetadata) {
|
|
142
|
+
return (propPath, fieldName) => {
|
|
143
|
+
if (propPath === "rm_precision") {
|
|
144
|
+
propPath = this.resolvePrecisionFromMetadata(fieldName);
|
|
145
|
+
}
|
|
146
|
+
return ObjectUtils.getProp(rowMetadata, propPath);
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
resolvePrecisionFromMetadata(fieldName) {
|
|
150
|
+
var _a, _b;
|
|
151
|
+
if (!fieldName) {
|
|
152
|
+
ApplicationUtils.error(this.getMessage("snkDataUnit.fieldNameRequired"));
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
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;
|
|
156
|
+
if (!rmPrecision) {
|
|
157
|
+
return '';
|
|
158
|
+
}
|
|
159
|
+
let rmPrecisionPath = rmPrecision.split('.').filter((_, index) => index !== 1).join('.');
|
|
160
|
+
return rmPrecisionPath;
|
|
161
|
+
}
|
|
123
162
|
getCleanOnCopyFields() {
|
|
124
163
|
var _a;
|
|
125
164
|
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);
|
|
126
165
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
var _a
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (this.isAllowed("CLONE")) {
|
|
141
|
-
const cleanFields = this.getCleanOnCopyFields();
|
|
142
|
-
if (cleanFields.length > 0) {
|
|
143
|
-
const records = action.payload;
|
|
144
|
-
action = new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
|
|
145
|
-
const newRecord = Object.assign({}, record);
|
|
146
|
-
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
147
|
-
return newRecord;
|
|
148
|
-
}));
|
|
149
|
-
}
|
|
150
|
-
resolve(action);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
154
|
-
}
|
|
155
|
-
break;
|
|
156
|
-
case Action.DATA_CHANGED:
|
|
157
|
-
case Action.CHANGING_DATA:
|
|
158
|
-
if (this.isAllowed("UPDATE"))
|
|
159
|
-
return resolve(action);
|
|
160
|
-
if (this._openedAlert)
|
|
161
|
-
return this.dataUnit.cancelEdition();
|
|
162
|
-
this._openedAlert = true;
|
|
163
|
-
this.dataUnit.cancelEdition();
|
|
164
|
-
ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
|
|
165
|
-
this._openedAlert = false;
|
|
166
|
-
});
|
|
167
|
-
break;
|
|
168
|
-
case Action.SAVING_DATA:
|
|
169
|
-
if (this.beforeSave) {
|
|
170
|
-
const continueAction = this.beforeSave(this.dataUnit);
|
|
171
|
-
if (continueAction instanceof Promise) {
|
|
172
|
-
continueAction.then(result => resolve(result ? action : undefined));
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
resolve(continueAction ? action : undefined);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
resolve(action);
|
|
180
|
-
}
|
|
181
|
-
break;
|
|
182
|
-
case Action.DATA_SAVED:
|
|
183
|
-
if (this.afterSave) {
|
|
184
|
-
this.afterSave(this.dataUnit);
|
|
185
|
-
}
|
|
186
|
-
else {
|
|
187
|
-
resolve(action);
|
|
188
|
-
}
|
|
189
|
-
break;
|
|
190
|
-
case Action.EDITION_CANCELED:
|
|
191
|
-
if (!this.useCancelConfirm)
|
|
192
|
-
return resolve(action);
|
|
193
|
-
if (this.dataState.hasDirtyRecords) {
|
|
194
|
-
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
195
|
-
if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
|
|
196
|
-
resolve(action);
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
if (cancelConfirmation == undefined) {
|
|
200
|
-
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
201
|
-
resolve(action);
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
205
|
-
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
|
206
|
-
.then((result) => {
|
|
207
|
-
result && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
208
|
-
resolve(result ? action : undefined);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
resolve(action);
|
|
214
|
-
}
|
|
215
|
-
break;
|
|
216
|
-
case Action.REMOVING_RECORDS:
|
|
217
|
-
if (this.isAllowed("REMOVE")) {
|
|
218
|
-
let multipleSelection = false;
|
|
219
|
-
let removeConfirmation = !((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
|
220
|
-
const selection = (_d = this.dataUnit) === null || _d === void 0 ? void 0 : _d.getSelectionInfo();
|
|
221
|
-
if (!((_e = action.payload) === null || _e === void 0 ? void 0 : _e.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
|
222
|
-
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
|
223
|
-
multipleSelection = true;
|
|
224
|
-
}
|
|
225
|
-
if (!removeConfirmation) {
|
|
226
|
-
resolve(action);
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
const options = {
|
|
230
|
-
canClose: false,
|
|
231
|
-
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
|
232
|
-
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
|
233
|
-
btnConfirmDanger: false
|
|
234
|
-
};
|
|
235
|
-
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
236
|
-
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options)
|
|
237
|
-
.then((result) => resolve(result ? action : undefined));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
else {
|
|
241
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
242
|
-
}
|
|
243
|
-
break;
|
|
244
|
-
default:
|
|
245
|
-
resolve(action);
|
|
166
|
+
fillFieldsWithRmp(payload) {
|
|
167
|
+
payload.fields.forEach((field) => {
|
|
168
|
+
var _a;
|
|
169
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rmp) && !this._fieldsWithRmp.includes(field.name)) {
|
|
170
|
+
this._fieldsWithRmp.push(field.name);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
fillFieldsWithRmPrecision(payload) {
|
|
175
|
+
payload.fields.forEach((field) => {
|
|
176
|
+
var _a;
|
|
177
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !this._fieldsWithRmPrecision.includes(field.name)) {
|
|
178
|
+
this._fieldsWithRmPrecision.push(field.name);
|
|
246
179
|
}
|
|
247
180
|
});
|
|
248
181
|
}
|
|
182
|
+
getCacheName(fieldName, metadataName, fieldValue) {
|
|
183
|
+
const cacheName = [fieldName, metadataName, fieldValue].join("_");
|
|
184
|
+
return cacheName;
|
|
185
|
+
}
|
|
186
|
+
updateDataStateRmp(newValue) {
|
|
187
|
+
Object.assign(this.dataState.rowMetadata || {}, newValue);
|
|
188
|
+
}
|
|
189
|
+
saveCacheRmd(record) {
|
|
190
|
+
const rmd = record.__record__metadata__;
|
|
191
|
+
const keysRmd = Object.keys(rmd);
|
|
192
|
+
keysRmd.shift();
|
|
193
|
+
keysRmd.forEach((fieldName) => {
|
|
194
|
+
const fieldValue = getRecordValue(record, fieldName);
|
|
195
|
+
const cacheName = this.getCacheName(fieldName, rmd.provider, fieldValue);
|
|
196
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, rmd));
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
getMetadataByRow(payload) {
|
|
200
|
+
var _a;
|
|
201
|
+
if (!((_a = payload.records) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
202
|
+
return payload;
|
|
203
|
+
}
|
|
204
|
+
if (!this._fieldsWithRmp.length) {
|
|
205
|
+
const records = payload.records.map((record) => {
|
|
206
|
+
delete record.__record__metadata__;
|
|
207
|
+
return record;
|
|
208
|
+
});
|
|
209
|
+
return Object.assign(Object.assign({}, payload), { records });
|
|
210
|
+
}
|
|
211
|
+
const records = payload.records.map((record) => {
|
|
212
|
+
if (!record.__record__metadata__) {
|
|
213
|
+
return record;
|
|
214
|
+
}
|
|
215
|
+
this.saveCacheRmd(record);
|
|
216
|
+
const rowMetadata = Object.assign({}, record.__record__metadata__);
|
|
217
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
|
218
|
+
this._metadataByRow.set(record.__record__id__, rowMetadata);
|
|
219
|
+
delete record.__record__metadata__;
|
|
220
|
+
return record;
|
|
221
|
+
});
|
|
222
|
+
return Object.assign(Object.assign({}, payload), { records });
|
|
223
|
+
}
|
|
224
|
+
interceptRecordsAdded(action) {
|
|
225
|
+
if (!this.isAllowed("INSERT")) {
|
|
226
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
|
|
230
|
+
}
|
|
231
|
+
interceptRecordsCopied(action) {
|
|
232
|
+
if (!this.isAllowed("CLONE")) {
|
|
233
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
|
|
237
|
+
}
|
|
238
|
+
async interceptDataChange(action) {
|
|
239
|
+
if (this.isAllowed("UPDATE")) {
|
|
240
|
+
return action;
|
|
241
|
+
}
|
|
242
|
+
if (this._openedAlert) {
|
|
243
|
+
await this.dataUnit.cancelEdition();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
this._openedAlert = true;
|
|
247
|
+
await this.dataUnit.cancelEdition();
|
|
248
|
+
await ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
|
249
|
+
this._openedAlert = false;
|
|
250
|
+
}
|
|
251
|
+
async interceptSavingData(action) {
|
|
252
|
+
if (!this.beforeSave) {
|
|
253
|
+
return action;
|
|
254
|
+
}
|
|
255
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
|
256
|
+
if (continueAction instanceof Promise) {
|
|
257
|
+
const result = await continueAction;
|
|
258
|
+
return result ? action : undefined;
|
|
259
|
+
}
|
|
260
|
+
return continueAction ? action : undefined;
|
|
261
|
+
}
|
|
262
|
+
interceptDataSaved(action) {
|
|
263
|
+
if (this.afterSave) {
|
|
264
|
+
this.afterSave(this.dataUnit);
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
return action;
|
|
268
|
+
}
|
|
269
|
+
async interceptEditionCanceled(action) {
|
|
270
|
+
var _a, _b;
|
|
271
|
+
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)) {
|
|
272
|
+
return action;
|
|
273
|
+
}
|
|
274
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
275
|
+
if (cancelConfirmation == undefined) {
|
|
276
|
+
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
277
|
+
return action;
|
|
278
|
+
}
|
|
279
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
280
|
+
const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
|
|
281
|
+
confirm && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
282
|
+
return confirm ? action : undefined;
|
|
283
|
+
}
|
|
284
|
+
async interceptRemovingRecords(action) {
|
|
285
|
+
var _a, _b, _c;
|
|
286
|
+
if (!this.isAllowed("REMOVE")) {
|
|
287
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
let multipleSelection = false;
|
|
291
|
+
let removeConfirmation = !((_a = action.payload) === null || _a === void 0 ? void 0 : _a.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
|
292
|
+
const selection = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getSelectionInfo();
|
|
293
|
+
if (!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
|
294
|
+
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
|
295
|
+
multipleSelection = true;
|
|
296
|
+
}
|
|
297
|
+
if (!removeConfirmation) {
|
|
298
|
+
return action;
|
|
299
|
+
}
|
|
300
|
+
const options = {
|
|
301
|
+
canClose: false,
|
|
302
|
+
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
|
303
|
+
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
|
304
|
+
btnConfirmDanger: false
|
|
305
|
+
};
|
|
306
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
307
|
+
const confirm = await ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options);
|
|
308
|
+
return confirm ? action : undefined;
|
|
309
|
+
}
|
|
310
|
+
interceptDataLoaded(action) {
|
|
311
|
+
const newPayload = this.getMetadataByRow(action.payload);
|
|
312
|
+
action = new DataUnitAction(Action.DATA_LOADED, newPayload);
|
|
313
|
+
return action;
|
|
314
|
+
}
|
|
315
|
+
interceptMetadataLoaded(action) {
|
|
316
|
+
this.fillFieldsWithRmp(action.payload);
|
|
317
|
+
this.fillFieldsWithRmPrecision(action.payload);
|
|
318
|
+
return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
|
|
319
|
+
}
|
|
320
|
+
async interceptAction(action) {
|
|
321
|
+
switch (action.type) {
|
|
322
|
+
case Action.RECORDS_ADDED:
|
|
323
|
+
return this.interceptRecordsAdded(action);
|
|
324
|
+
case Action.RECORDS_COPIED:
|
|
325
|
+
return this.interceptRecordsCopied(action);
|
|
326
|
+
case Action.DATA_CHANGED:
|
|
327
|
+
await this.handleLoadRowMetadata(action);
|
|
328
|
+
return await this.interceptDataChange(action);
|
|
329
|
+
case Action.CHANGING_DATA:
|
|
330
|
+
return await this.interceptDataChange(action);
|
|
331
|
+
case Action.SAVING_DATA:
|
|
332
|
+
return await this.interceptSavingData(action);
|
|
333
|
+
case Action.DATA_SAVED:
|
|
334
|
+
return this.interceptDataSaved(action);
|
|
335
|
+
case Action.EDITION_CANCELED:
|
|
336
|
+
return await this.interceptEditionCanceled(action);
|
|
337
|
+
case Action.REMOVING_RECORDS:
|
|
338
|
+
return await this.interceptRemovingRecords(action);
|
|
339
|
+
case Action.DATA_LOADED:
|
|
340
|
+
return this.interceptDataLoaded(action);
|
|
341
|
+
case Action.METADATA_LOADED:
|
|
342
|
+
return this.interceptMetadataLoaded(action);
|
|
343
|
+
default:
|
|
344
|
+
return action;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
async handleLoadRowMetadata(action) {
|
|
348
|
+
const record = action.type === Action.DATA_CHANGED ? action.payload : action.payload.changes[0].record;
|
|
349
|
+
const keysPayload = Object.keys(record);
|
|
350
|
+
const rmpField = keysPayload.find((field) => this._fieldsWithRmp.includes(field));
|
|
351
|
+
if (rmpField) {
|
|
352
|
+
const metadataName = this.dataUnit.getField(rmpField).properties.rmp;
|
|
353
|
+
const fieldValue = getRecordValue(record, rmpField);
|
|
354
|
+
return await this.updateRowMetadata({
|
|
355
|
+
fieldName: rmpField,
|
|
356
|
+
fieldValue,
|
|
357
|
+
metadataName,
|
|
358
|
+
updatedFields: record,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
async updateRowMetadata({ fieldName, fieldValue, metadataName, updatedFields }) {
|
|
363
|
+
const cacheName = this.getCacheName(fieldName, metadataName, fieldValue);
|
|
364
|
+
const cacheValue = this._rowMetadataCache.get(cacheName);
|
|
365
|
+
if (cacheValue) {
|
|
366
|
+
this.updateDataStateRmp(cacheValue);
|
|
367
|
+
return cacheValue;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
const datasetStrategy = new DatasetStrategy();
|
|
371
|
+
const response = await datasetStrategy.loadRowMetadata(this, fieldName, metadataName, updatedFields);
|
|
372
|
+
this.updateDataStateRmp(response._rmd);
|
|
373
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, response._rmd));
|
|
374
|
+
return Object.assign({}, response._rmd);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
handleDULinksOnMetadataLoaded(payload) {
|
|
378
|
+
const metadata = Object.assign({}, payload);
|
|
379
|
+
this.processLinks(metadata);
|
|
380
|
+
return metadata;
|
|
381
|
+
}
|
|
382
|
+
handleRecordsCopied(initialRecords) {
|
|
383
|
+
let records = [...initialRecords];
|
|
384
|
+
records = this.handleCleanOnCopy(records);
|
|
385
|
+
return this.handleLinksWithParent(records);
|
|
386
|
+
}
|
|
387
|
+
handleLinksWithParent(records) {
|
|
388
|
+
var _a, _b;
|
|
389
|
+
const parentDataUnit = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
|
390
|
+
if (!parentDataUnit)
|
|
391
|
+
return records;
|
|
392
|
+
const parentSelectedRecord = parentDataUnit.getSelectedRecord();
|
|
393
|
+
const selfInfo = parentDataUnit === null || parentDataUnit === void 0 ? void 0 : parentDataUnit.getChildInfo(this.getCleanDataUnitName());
|
|
394
|
+
const { links } = selfInfo;
|
|
395
|
+
if (!links || links.length === 0)
|
|
396
|
+
return records;
|
|
397
|
+
return records.map(record => {
|
|
398
|
+
return this.buildRecordWithLinkedFields(record, links, parentSelectedRecord);
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
buildRecordWithLinkedFields(record, links, parentSelectedRecord) {
|
|
402
|
+
const newRecord = Object.assign({}, record);
|
|
403
|
+
links.forEach(link => newRecord[link.target] = parentSelectedRecord[link.source]);
|
|
404
|
+
return newRecord;
|
|
405
|
+
}
|
|
406
|
+
handleCleanOnCopy(records) {
|
|
407
|
+
const cleanFields = this.getCleanOnCopyFields();
|
|
408
|
+
if (cleanFields.length > 0) {
|
|
409
|
+
records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
|
|
410
|
+
}
|
|
411
|
+
return records;
|
|
412
|
+
}
|
|
413
|
+
buildCopyWithCleanedFields(record, cleanFields) {
|
|
414
|
+
const newRecord = Object.assign({}, record);
|
|
415
|
+
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
416
|
+
return newRecord;
|
|
417
|
+
}
|
|
249
418
|
showSuccessMessage(message) {
|
|
250
419
|
ApplicationUtils.info(message, { iconName: "check" });
|
|
251
420
|
}
|
|
252
421
|
isAllowed(flag) {
|
|
253
422
|
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
254
423
|
}
|
|
255
|
-
buildDataState() {
|
|
424
|
+
buildDataState(actionType) {
|
|
425
|
+
var _a;
|
|
256
426
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
|
257
427
|
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
|
428
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
|
429
|
+
let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
|
|
430
|
+
const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
|
|
431
|
+
if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
|
|
432
|
+
rowMetadata = this.doGetRowMetadata(selectedRecord);
|
|
433
|
+
}
|
|
434
|
+
else if (rowMetadata) {
|
|
435
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
|
436
|
+
}
|
|
258
437
|
return new DataStateImpl({
|
|
259
438
|
insertionMode: this.dataUnit.hasNewRecord(),
|
|
260
439
|
isStartingInsertionMode,
|
|
@@ -265,10 +444,48 @@ export class SnkDataUnit {
|
|
|
265
444
|
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
|
266
445
|
selectedRecords: undefined,
|
|
267
446
|
selectionInfo,
|
|
268
|
-
selectedRecord
|
|
269
|
-
recordsIsEmpty: this.dataUnit.records.length === 0
|
|
447
|
+
selectedRecord,
|
|
448
|
+
recordsIsEmpty: this.dataUnit.records.length === 0,
|
|
449
|
+
metadataByRow: this._metadataByRow,
|
|
450
|
+
rowMetadata
|
|
270
451
|
});
|
|
271
452
|
}
|
|
453
|
+
async handleDataSaved(action) {
|
|
454
|
+
const newRowMetadata = await this.handleLoadRowMetadata(action);
|
|
455
|
+
if (newRowMetadata) {
|
|
456
|
+
newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
|
|
457
|
+
}
|
|
458
|
+
const recordId = action.payload.records[0].__record__id__;
|
|
459
|
+
this._metadataByRow.set(recordId, newRowMetadata);
|
|
460
|
+
this.dataState = this.buildDataState();
|
|
461
|
+
if (this.ignoreSaveMessage) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
465
|
+
if (msg != undefined) {
|
|
466
|
+
this.showSuccessMessage(msg);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
handleRecordsRemoved(action) {
|
|
470
|
+
var _a, _b;
|
|
471
|
+
const cachedRecords = action.payload.cachedRecords;
|
|
472
|
+
let removeFinishMsg;
|
|
473
|
+
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
|
474
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
478
|
+
}
|
|
479
|
+
if (removeFinishMsg != undefined) {
|
|
480
|
+
this.showSuccessMessage(removeFinishMsg);
|
|
481
|
+
}
|
|
482
|
+
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
483
|
+
const paginationInfo = this.dataUnit.getPaginationInfo();
|
|
484
|
+
if (paginationInfo) {
|
|
485
|
+
const page = recordsCount > 0 || paginationInfo.hasMore ? paginationInfo.currentPage : 0;
|
|
486
|
+
this.dataUnit.gotoPage(page);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
272
489
|
/**
|
|
273
490
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
274
491
|
* através de um pequeno modulo na estrutura da aplicação:
|
|
@@ -303,13 +520,14 @@ export class SnkDataUnit {
|
|
|
303
520
|
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
|
304
521
|
if (this._parentSnkDataUnit) {
|
|
305
522
|
this._parentDataUnit = await ((_a = this._parentSnkDataUnit) === null || _a === void 0 ? void 0 : _a.getDataUnit());
|
|
306
|
-
return await this._application.getDataUnit(this.entityName, cacheName, this._parentDataUnit, this.configName, this.resourceID);
|
|
523
|
+
return await this._application.getDataUnit(this.entityName, cacheName, this._parentDataUnit, this.configName, this.resourceID, { skipLoadMetadata: true });
|
|
307
524
|
}
|
|
308
525
|
else {
|
|
309
|
-
return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID);
|
|
526
|
+
return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID, { skipLoadMetadata: true });
|
|
310
527
|
}
|
|
311
528
|
}
|
|
312
529
|
async loadDataUnit() {
|
|
530
|
+
var _a;
|
|
313
531
|
if (this.dataUnit == null && this._application && this.entityName) {
|
|
314
532
|
this.dataUnit = await this.getDataUnitParentOrChild();
|
|
315
533
|
}
|
|
@@ -318,6 +536,10 @@ export class SnkDataUnit {
|
|
|
318
536
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
319
537
|
this.dataUnit.addInterceptor(this);
|
|
320
538
|
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
539
|
+
await this.dataUnit.loadMetadata();
|
|
540
|
+
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
|
541
|
+
this.getMetadataByRow(this.dataUnit);
|
|
542
|
+
}
|
|
321
543
|
this.dataState = this.buildDataState();
|
|
322
544
|
let resolver;
|
|
323
545
|
while (resolver = this._onDataUnitResolve.pop()) {
|
|
@@ -336,20 +558,40 @@ export class SnkDataUnit {
|
|
|
336
558
|
return;
|
|
337
559
|
}
|
|
338
560
|
handlerLinkFields() {
|
|
339
|
-
var _a, _b;
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
561
|
+
var _a, _b, _c, _d;
|
|
562
|
+
const parentDU = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
|
563
|
+
if (!parentDU)
|
|
342
564
|
return;
|
|
343
|
-
const
|
|
565
|
+
const childName = (_c = this.entityName) !== null && _c !== void 0 ? _c : this.getCleanDataUnitName();
|
|
566
|
+
const child = parentDU.getChildInfo(childName);
|
|
344
567
|
if (!child)
|
|
345
568
|
return;
|
|
346
|
-
const
|
|
347
|
-
(
|
|
348
|
-
|
|
569
|
+
const links = (_d = child === null || child === void 0 ? void 0 : child.links) === null || _d === void 0 ? void 0 : _d.map(link => link.target);
|
|
570
|
+
this.handleDUWithLinks(links);
|
|
571
|
+
}
|
|
572
|
+
handleDUWithLinks(fieldsToLink) {
|
|
573
|
+
this.fieldsToLink = fieldsToLink;
|
|
574
|
+
const metadata = Object.assign({}, this.dataUnit.metadata);
|
|
575
|
+
this.processLinks(metadata);
|
|
576
|
+
this.dataUnit.metadata = metadata;
|
|
577
|
+
this.dataUnitFieldsHidded.emit();
|
|
578
|
+
}
|
|
579
|
+
processLinks(metadata) {
|
|
580
|
+
var _a;
|
|
581
|
+
(_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
582
|
+
var _a;
|
|
583
|
+
if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
|
|
349
584
|
field.visible = false;
|
|
350
585
|
}
|
|
351
586
|
});
|
|
352
|
-
|
|
587
|
+
}
|
|
588
|
+
getCleanDataUnitName() {
|
|
589
|
+
var _a;
|
|
590
|
+
const uri = this.dataUnit.name;
|
|
591
|
+
if (StringUtils.isEmpty(uri))
|
|
592
|
+
return uri;
|
|
593
|
+
const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
|
|
594
|
+
return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
|
|
353
595
|
}
|
|
354
596
|
static getNearestInstance(element) {
|
|
355
597
|
let parent = element.parentElement;
|
|
@@ -376,8 +618,9 @@ export class SnkDataUnit {
|
|
|
376
618
|
this.dataUnit.releaseCallbacks();
|
|
377
619
|
}
|
|
378
620
|
}
|
|
379
|
-
componentDidLoad() {
|
|
380
|
-
this.loadDataUnit();
|
|
621
|
+
async componentDidLoad() {
|
|
622
|
+
await this.loadDataUnit();
|
|
623
|
+
this.handlerLinkFields();
|
|
381
624
|
}
|
|
382
625
|
render() {
|
|
383
626
|
return (h(Host, null));
|
|
@@ -611,6 +854,11 @@ export class SnkDataUnit {
|
|
|
611
854
|
}
|
|
612
855
|
};
|
|
613
856
|
}
|
|
857
|
+
static get states() {
|
|
858
|
+
return {
|
|
859
|
+
"fieldsToLink": {}
|
|
860
|
+
};
|
|
861
|
+
}
|
|
614
862
|
static get events() {
|
|
615
863
|
return [{
|
|
616
864
|
"method": "dataStateChange",
|
|
@@ -671,6 +919,21 @@ export class SnkDataUnit {
|
|
|
671
919
|
}
|
|
672
920
|
}
|
|
673
921
|
}
|
|
922
|
+
}, {
|
|
923
|
+
"method": "dataUnitFieldsHidded",
|
|
924
|
+
"name": "dataUnitFieldsHidded",
|
|
925
|
+
"bubbles": true,
|
|
926
|
+
"cancelable": true,
|
|
927
|
+
"composed": true,
|
|
928
|
+
"docs": {
|
|
929
|
+
"tags": [],
|
|
930
|
+
"text": "Emitido quando h\u00E1 campos no DataUnit que devem ser ocultados."
|
|
931
|
+
},
|
|
932
|
+
"complexType": {
|
|
933
|
+
"original": "void",
|
|
934
|
+
"resolved": "void",
|
|
935
|
+
"references": {}
|
|
936
|
+
}
|
|
674
937
|
}, {
|
|
675
938
|
"method": "insertionMode",
|
|
676
939
|
"name": "insertionMode",
|
|
@@ -750,6 +1013,64 @@ export class SnkDataUnit {
|
|
|
750
1013
|
"text": "Retorna a lista de IDs dos registros selecionados."
|
|
751
1014
|
}]
|
|
752
1015
|
}
|
|
1016
|
+
},
|
|
1017
|
+
"getFieldsWithRmp": {
|
|
1018
|
+
"complexType": {
|
|
1019
|
+
"signature": "() => Promise<string[]>",
|
|
1020
|
+
"parameters": [],
|
|
1021
|
+
"references": {
|
|
1022
|
+
"Promise": {
|
|
1023
|
+
"location": "global"
|
|
1024
|
+
}
|
|
1025
|
+
},
|
|
1026
|
+
"return": "Promise<string[]>"
|
|
1027
|
+
},
|
|
1028
|
+
"docs": {
|
|
1029
|
+
"text": "Retorna os campos que possuem a propriedade \"rmp\" (Row Metadata Provider).",
|
|
1030
|
+
"tags": []
|
|
1031
|
+
}
|
|
1032
|
+
},
|
|
1033
|
+
"getFieldsWithRmPrecision": {
|
|
1034
|
+
"complexType": {
|
|
1035
|
+
"signature": "() => Promise<string[]>",
|
|
1036
|
+
"parameters": [],
|
|
1037
|
+
"references": {
|
|
1038
|
+
"Promise": {
|
|
1039
|
+
"location": "global"
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1042
|
+
"return": "Promise<string[]>"
|
|
1043
|
+
},
|
|
1044
|
+
"docs": {
|
|
1045
|
+
"text": "Retorna os campos que possuem a propriedade \"rm_precision\" (Row Metadata Precision).",
|
|
1046
|
+
"tags": []
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
"getRowMetadata": {
|
|
1050
|
+
"complexType": {
|
|
1051
|
+
"signature": "(record?: Record | string) => Promise<RowMetadata>",
|
|
1052
|
+
"parameters": [{
|
|
1053
|
+
"tags": [],
|
|
1054
|
+
"text": ""
|
|
1055
|
+
}],
|
|
1056
|
+
"references": {
|
|
1057
|
+
"Promise": {
|
|
1058
|
+
"location": "global"
|
|
1059
|
+
},
|
|
1060
|
+
"RowMetadata": {
|
|
1061
|
+
"location": "local"
|
|
1062
|
+
},
|
|
1063
|
+
"Record": {
|
|
1064
|
+
"location": "import",
|
|
1065
|
+
"path": "@sankhyalabs/core"
|
|
1066
|
+
}
|
|
1067
|
+
},
|
|
1068
|
+
"return": "Promise<RowMetadata>"
|
|
1069
|
+
},
|
|
1070
|
+
"docs": {
|
|
1071
|
+
"text": "Busca os metadados da linha selecionada.",
|
|
1072
|
+
"tags": []
|
|
1073
|
+
}
|
|
753
1074
|
}
|
|
754
1075
|
};
|
|
755
1076
|
}
|
|
@@ -788,6 +1109,8 @@ class DataStateImpl {
|
|
|
788
1109
|
this.selectionInfo = datastate.selectionInfo;
|
|
789
1110
|
this.selectedRecord = datastate.selectedRecord;
|
|
790
1111
|
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
|
1112
|
+
this.metadataByRow = datastate.metadataByRow;
|
|
1113
|
+
this.rowMetadata = datastate.rowMetadata;
|
|
791
1114
|
}
|
|
792
1115
|
get selectedRecords() {
|
|
793
1116
|
var _a;
|