@sankhyalabs/sankhyablocks 8.15.1 → 8.16.0-dev.1
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/{SnkMultiSelectionListDataSource-303e85d1.js → IExporterProvider-c78cb1b8.js} +94 -4
- package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
- package/dist/cjs/{SnkFormConfigManager-f9dc0d28.js → SnkFormConfigManager-1b13bacd.js} +6 -3
- package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-722b104e.js} +8 -12
- package/dist/cjs/{pesquisa-fetcher-213797ec.js → dataunit-fetcher-620b29a1.js} +87 -180
- package/dist/cjs/{index-0922807b.js → index-1dfc7a6e.js} +5 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-fetcher-680e198f.js +166 -0
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +4 -2
- package/dist/cjs/snk-application.cjs.entry.js +34 -11
- package/dist/cjs/snk-attach.cjs.entry.js +71 -46
- package/dist/cjs/snk-crud.cjs.entry.js +96 -10
- package/dist/cjs/snk-data-exporter.cjs.entry.js +315 -85
- package/dist/cjs/snk-data-unit-82dea87e.js +679 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +12 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +48 -7
- package/dist/cjs/snk-filter-bar.cjs.entry.js +5 -1
- package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
- package/dist/cjs/snk-form.cjs.entry.js +51 -6
- package/dist/cjs/snk-grid.cjs.entry.js +164 -107
- package/dist/cjs/{snk-guides-viewer-4b6ecda8.js → snk-guides-viewer-05a1ba27.js} +36 -8
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -6
- package/dist/cjs/snk-simple-crud.cjs.entry.js +264 -37
- package/dist/cjs/snk-taskbar.cjs.entry.js +4 -3
- package/dist/cjs/{taskbar-elements-3ecd1278.js → taskbar-elements-9ad1f9c0.js} +3 -3
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/snk-application/snk-application.js +35 -11
- package/dist/collection/components/snk-attach/snk-attach.js +67 -44
- 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 +249 -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/exporter-strategy/ClientSideExporterStrategy.js +97 -0
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +74 -0
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +54 -1
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +1 -0
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +58 -0
- package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +55 -0
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +59 -52
- package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +62 -0
- package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +88 -0
- package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +20 -0
- package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +38 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +507 -214
- package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
- package/dist/collection/components/snk-data-unit/test/resources/parentMetadataMock.js +18 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
- package/dist/collection/components/snk-form/snk-form.js +102 -5
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +6 -3
- package/dist/collection/components/snk-grid/snk-grid.js +240 -101
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +386 -18
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +2 -1
- package/dist/collection/lib/@types/index.js +5 -0
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +7 -3
- 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/DataUnitDataLoader.js +3 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +4 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +11 -13
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.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 +53 -4
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +4 -4
- package/dist/collection/lib/message/SnkMessageBuilder.js +5 -12
- package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +2 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
- package/dist/components/{field-search.js → IExporterProvider.js} +93 -6
- package/dist/components/ISave.js +47 -0
- package/dist/components/SnkFormConfigManager.js +6 -3
- package/dist/components/SnkMessageBuilder.js +8 -12
- package/dist/components/dataunit-fetcher.js +84 -182
- package/dist/components/index2.js +198 -33
- package/dist/components/pesquisa-fetcher.js +164 -0
- package/dist/components/snk-actions-button2.js +4 -11
- package/dist/components/snk-application2.js +31 -9
- package/dist/components/snk-attach2.js +65 -41
- package/dist/components/snk-crud.js +103 -11
- package/dist/components/snk-data-exporter2.js +309 -85
- package/dist/components/snk-data-unit2.js +470 -212
- package/dist/components/snk-detail-view2.js +87 -10
- package/dist/components/snk-expression-item2.js +1 -1
- package/dist/components/snk-filter-bar2.js +6 -1
- package/dist/components/snk-form-view2.js +72 -1
- package/dist/components/snk-form.js +53 -6
- package/dist/components/snk-grid2.js +168 -106
- package/dist/components/snk-personalized-filter2.js +1 -1
- package/dist/components/snk-simple-crud2.js +259 -23
- package/dist/components/snk-taskbar2.js +6 -5
- package/dist/esm/{SnkMultiSelectionListDataSource-36918dbf.js → IExporterProvider-343272b3.js} +93 -5
- package/dist/esm/RecordIDUtils-87d02110.js +41 -0
- package/dist/esm/{SnkFormConfigManager-f53f9f87.js → SnkFormConfigManager-d4554df9.js} +6 -3
- package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-89925609.js} +8 -12
- package/dist/esm/{pesquisa-fetcher-fe6f3826.js → dataunit-fetcher-3fbf9d12.js} +83 -181
- package/dist/esm/{index-0ece87a6.js → index-3aa4977a.js} +6 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-fetcher-03c8f919.js +164 -0
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +4 -2
- package/dist/esm/snk-application.entry.js +33 -10
- package/dist/esm/snk-attach.entry.js +66 -41
- package/dist/esm/snk-crud.entry.js +96 -10
- package/dist/esm/snk-data-exporter.entry.js +316 -86
- package/dist/esm/snk-data-unit-8f98b45f.js +677 -0
- package/dist/esm/snk-data-unit.entry.js +12 -2
- package/dist/esm/snk-detail-view.entry.js +48 -7
- package/dist/esm/snk-filter-bar.entry.js +5 -1
- package/dist/esm/snk-form-view.entry.js +67 -0
- package/dist/esm/snk-form.entry.js +51 -6
- package/dist/esm/snk-grid.entry.js +162 -105
- package/dist/esm/{snk-guides-viewer-113be3fd.js → snk-guides-viewer-aee2cafe.js} +36 -8
- package/dist/esm/snk-guides-viewer.entry.js +8 -6
- package/dist/esm/snk-simple-crud.entry.js +252 -25
- package/dist/esm/snk-taskbar.entry.js +4 -3
- package/dist/esm/{taskbar-elements-2473c8ac.js → taskbar-elements-d59867f1.js} +3 -3
- package/dist/sankhyablocks/p-0d91b10f.entry.js +1 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-26394a01.entry.js +1 -0
- package/dist/sankhyablocks/p-2d649237.entry.js +1 -0
- package/dist/sankhyablocks/p-30cf616e.js +1 -0
- package/dist/sankhyablocks/p-44767378.entry.js +1 -0
- package/dist/sankhyablocks/p-47b60deb.entry.js +1 -0
- package/dist/sankhyablocks/p-4f72727a.entry.js +1 -0
- package/dist/sankhyablocks/p-550fee49.entry.js +1 -0
- package/dist/sankhyablocks/p-5539ecb4.entry.js +1 -0
- package/dist/sankhyablocks/p-672302c3.js +60 -0
- package/dist/sankhyablocks/p-7a337364.js +1 -0
- package/dist/sankhyablocks/{p-ae4fc9a9.js → p-7e7a7473.js} +1 -1
- package/dist/sankhyablocks/p-829d4045.js +1 -0
- package/dist/sankhyablocks/p-8a5910a7.entry.js +1 -0
- package/dist/sankhyablocks/p-8cc64963.entry.js +1 -0
- package/dist/sankhyablocks/p-8fc470e5.entry.js +1 -0
- package/dist/sankhyablocks/p-9863d682.js +1 -0
- package/dist/sankhyablocks/p-9e99a92a.js +1 -0
- package/dist/sankhyablocks/p-af8efd95.js +6 -0
- package/dist/sankhyablocks/p-be603a24.js +1 -0
- package/dist/sankhyablocks/p-d09feef1.js +1 -0
- package/dist/sankhyablocks/p-e95b3b93.entry.js +11 -0
- package/dist/sankhyablocks/p-f2809746.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +7 -3
- package/dist/types/components/snk-attach/snk-attach.d.ts +11 -9
- 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 +36 -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/exporter-strategy/ClientSideExporterStrategy.d.ts +14 -0
- package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +12 -0
- package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +24 -4
- package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +5 -0
- package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +17 -0
- package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +17 -0
- package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +4 -1
- package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +21 -0
- package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +77 -0
- package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +4 -0
- package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.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-data-unit/test/resources/parentMetadataMock.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 +46 -6
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +58 -4
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
- package/dist/types/components.d.ts +220 -4
- package/dist/types/lib/@types/index.d.ts +5 -0
- 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/DataUnitDataLoader.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -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 +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/snk-data-unit-41c29713.js +0 -462
- package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +0 -34
- package/dist/components/index3.js +0 -199
- package/dist/esm/snk-data-unit-de1d140d.js +0 -460
- package/dist/sankhyablocks/p-032fe52e.js +0 -1
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
- package/dist/sankhyablocks/p-07a61550.entry.js +0 -1
- package/dist/sankhyablocks/p-0899e0b5.entry.js +0 -1
- package/dist/sankhyablocks/p-154a7f33.entry.js +0 -1
- package/dist/sankhyablocks/p-15802c59.entry.js +0 -1
- package/dist/sankhyablocks/p-164666b1.js +0 -65
- package/dist/sankhyablocks/p-32556aa6.js +0 -1
- package/dist/sankhyablocks/p-328585d0.entry.js +0 -1
- package/dist/sankhyablocks/p-38289a55.js +0 -1
- package/dist/sankhyablocks/p-52c8e589.js +0 -1
- package/dist/sankhyablocks/p-5cb07080.js +0 -1
- package/dist/sankhyablocks/p-74d349c3.entry.js +0 -1
- package/dist/sankhyablocks/p-7fe120b8.entry.js +0 -11
- package/dist/sankhyablocks/p-add17f6a.entry.js +0 -1
- package/dist/sankhyablocks/p-af1ac81f.entry.js +0 -1
- package/dist/sankhyablocks/p-b4525fc0.entry.js +0 -1
- package/dist/sankhyablocks/p-cce0865d.js +0 -1
- package/dist/sankhyablocks/p-dec65f6c.entry.js +0 -1
- package/dist/sankhyablocks/p-ee9536bc.entry.js +0 -1
- package/dist/sankhyablocks/p-f13f7616.entry.js +0 -1
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +0 -3
@@ -1,55 +1,47 @@
|
|
1
1
|
import { Host, h } from '@stencil/core';
|
2
|
-
import { Action, ApplicationContext, DataUnitAction, ObjectUtils,
|
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';
|
7
|
+
import { getSelectedIDs } from '../snk-data-exporter/utils/RecordIDUtils';
|
8
|
+
import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
5
9
|
export class SnkDataUnit {
|
6
10
|
constructor() {
|
7
11
|
this._onDataUnitResolve = [];
|
8
12
|
this._openedAlert = false;
|
9
|
-
this.
|
10
|
-
|
11
|
-
|
13
|
+
this._fieldsWithRmp = [];
|
14
|
+
this._fieldsWithRmPrecision = [];
|
15
|
+
this._metadataByRow = new Map();
|
16
|
+
this._rowMetadataCache = new Map();
|
17
|
+
this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
|
18
|
+
this._dataUnitObserver = async (action) => {
|
19
|
+
const duState = this.buildDataState(action.type);
|
12
20
|
this.dataState = duState;
|
13
|
-
if (action.type === Action.DATA_SAVED) {
|
14
|
-
if (this.ignoreSaveMessage) {
|
15
|
-
return;
|
16
|
-
}
|
17
|
-
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
18
|
-
if (msg != undefined) {
|
19
|
-
this.showSuccessMessage(msg);
|
20
|
-
}
|
21
|
-
}
|
22
|
-
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
23
|
-
this.insertionMode.emit();
|
24
|
-
}
|
25
|
-
if (action.type === Action.EDITION_CANCELED) {
|
26
|
-
this.cancelEdition.emit();
|
27
|
-
}
|
28
|
-
if (action.type === Action.RECORDS_REMOVED) {
|
29
|
-
const cachedRecords = action.payload.cachedRecords;
|
30
|
-
let removeFinishMsg;
|
31
|
-
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
32
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
33
|
-
}
|
34
|
-
else {
|
35
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
36
|
-
}
|
37
|
-
if (removeFinishMsg != undefined) {
|
38
|
-
this.showSuccessMessage(removeFinishMsg);
|
39
|
-
}
|
40
|
-
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
41
|
-
const paginationInfo = this.dataUnit.getPaginationInfo();
|
42
|
-
if (paginationInfo) {
|
43
|
-
if (recordsCount > 0 || paginationInfo.hasMore) {
|
44
|
-
this.dataUnit.gotoPage(paginationInfo.currentPage);
|
45
|
-
}
|
46
|
-
else {
|
47
|
-
this.dataUnit.gotoPage(0);
|
48
|
-
}
|
49
|
-
}
|
50
|
-
}
|
51
21
|
this.messagesBuilder.currentOperation = this.getMessageOperation();
|
22
|
+
switch (action.type) {
|
23
|
+
case Action.DATA_SAVED:
|
24
|
+
await this.handleDataSaved(action);
|
25
|
+
break;
|
26
|
+
case Action.RECORDS_ADDED:
|
27
|
+
case Action.RECORDS_COPIED:
|
28
|
+
this.insertionMode.emit();
|
29
|
+
break;
|
30
|
+
case Action.EDITION_CANCELED:
|
31
|
+
this.cancelEdition.emit();
|
32
|
+
break;
|
33
|
+
case Action.RECORDS_REMOVED:
|
34
|
+
this.handleRecordsRemoved(action);
|
35
|
+
break;
|
36
|
+
case Action.METADATA_LOADED:
|
37
|
+
this.fillFieldsWithRmp(this.dataUnit.metadata);
|
38
|
+
this.fillFieldsWithRmPrecision(this.dataUnit.metadata);
|
39
|
+
break;
|
40
|
+
default:
|
41
|
+
break;
|
42
|
+
}
|
52
43
|
};
|
44
|
+
this.fieldsToLink = [];
|
53
45
|
this.dataState = undefined;
|
54
46
|
this.messagesBuilder = undefined;
|
55
47
|
this.dataUnitName = undefined;
|
@@ -117,179 +109,340 @@ export class SnkDataUnit {
|
|
117
109
|
* @returns Retorna a lista de IDs dos registros selecionados.
|
118
110
|
*/
|
119
111
|
async getSelectedRecordsIDsInfo() {
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
const revertBase64ToObject = JSON.parse(window.atob(__record__id__));
|
145
|
-
Object.entries(revertBase64ToObject).forEach(([name, value]) => {
|
146
|
-
var _a;
|
147
|
-
const metadataField = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
|
148
|
-
if (metadataField == undefined) {
|
149
|
-
return;
|
150
|
-
}
|
151
|
-
selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
|
152
|
-
});
|
153
|
-
}
|
154
|
-
});
|
112
|
+
return Promise.resolve(getSelectedIDs(this.dataUnit));
|
113
|
+
}
|
114
|
+
/**
|
115
|
+
* Retorna os campos que possuem a propriedade "rmp" (Row Metadata Provider).
|
116
|
+
*/
|
117
|
+
async getFieldsWithRmp() {
|
118
|
+
return this._fieldsWithRmp;
|
119
|
+
}
|
120
|
+
/**
|
121
|
+
* Retorna os campos que possuem a propriedade "rm_precision" (Row Metadata Precision).
|
122
|
+
*/
|
123
|
+
async getFieldsWithRmPrecision() {
|
124
|
+
return this._fieldsWithRmPrecision;
|
125
|
+
}
|
126
|
+
/**
|
127
|
+
* Busca os metadados da linha selecionada.
|
128
|
+
*/
|
129
|
+
async getRowMetadata(record) {
|
130
|
+
return this.doGetRowMetadata(record);
|
131
|
+
}
|
132
|
+
doGetRowMetadata(record) {
|
133
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
134
|
+
if (!record && !selectedRecord) {
|
135
|
+
return;
|
155
136
|
}
|
156
|
-
|
137
|
+
const currentRecord = record || selectedRecord;
|
138
|
+
const recordId = typeof currentRecord === 'string' ? currentRecord : currentRecord.__record__id__;
|
139
|
+
const rowMetadata = this._metadataByRow.get(recordId);
|
140
|
+
if (!rowMetadata) {
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
144
|
+
return Object.assign({}, rowMetadata);
|
145
|
+
}
|
146
|
+
buildGetPropRowMetadata(rowMetadata) {
|
147
|
+
return (propPath, fieldName) => {
|
148
|
+
if (propPath === "rm_precision") {
|
149
|
+
propPath = this.resolvePrecisionFromMetadata(fieldName);
|
150
|
+
}
|
151
|
+
return ObjectUtils.getProp(rowMetadata, propPath);
|
152
|
+
};
|
153
|
+
}
|
154
|
+
resolvePrecisionFromMetadata(fieldName) {
|
155
|
+
var _a, _b;
|
156
|
+
if (!fieldName) {
|
157
|
+
ApplicationUtils.error(this.getMessage("snkDataUnit.fieldNameRequired"));
|
158
|
+
return;
|
159
|
+
}
|
160
|
+
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;
|
161
|
+
if (!rmPrecision) {
|
162
|
+
return '';
|
163
|
+
}
|
164
|
+
let rmPrecisionPath = rmPrecision.split('.').filter((_, index) => index !== 1).join('.');
|
165
|
+
return rmPrecisionPath;
|
157
166
|
}
|
158
167
|
getCleanOnCopyFields() {
|
159
168
|
var _a;
|
160
169
|
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);
|
161
170
|
}
|
162
|
-
|
163
|
-
|
164
|
-
var _a
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
if (this.isAllowed("CLONE")) {
|
176
|
-
const cleanFields = this.getCleanOnCopyFields();
|
177
|
-
if (cleanFields.length > 0) {
|
178
|
-
const records = action.payload;
|
179
|
-
action = new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
|
180
|
-
const newRecord = Object.assign({}, record);
|
181
|
-
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
182
|
-
return newRecord;
|
183
|
-
}));
|
184
|
-
}
|
185
|
-
resolve(action);
|
186
|
-
}
|
187
|
-
else {
|
188
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
189
|
-
}
|
190
|
-
break;
|
191
|
-
case Action.DATA_CHANGED:
|
192
|
-
case Action.CHANGING_DATA:
|
193
|
-
if (this.isAllowed("UPDATE"))
|
194
|
-
return resolve(action);
|
195
|
-
if (this._openedAlert)
|
196
|
-
return this.dataUnit.cancelEdition();
|
197
|
-
this._openedAlert = true;
|
198
|
-
this.dataUnit.cancelEdition();
|
199
|
-
ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
|
200
|
-
this._openedAlert = false;
|
201
|
-
});
|
202
|
-
break;
|
203
|
-
case Action.SAVING_DATA:
|
204
|
-
if (this.beforeSave) {
|
205
|
-
const continueAction = this.beforeSave(this.dataUnit);
|
206
|
-
if (continueAction instanceof Promise) {
|
207
|
-
continueAction.then(result => resolve(result ? action : undefined));
|
208
|
-
}
|
209
|
-
else {
|
210
|
-
resolve(continueAction ? action : undefined);
|
211
|
-
}
|
212
|
-
}
|
213
|
-
else {
|
214
|
-
resolve(action);
|
215
|
-
}
|
216
|
-
break;
|
217
|
-
case Action.DATA_SAVED:
|
218
|
-
if (this.afterSave) {
|
219
|
-
this.afterSave(this.dataUnit);
|
220
|
-
}
|
221
|
-
else {
|
222
|
-
resolve(action);
|
223
|
-
}
|
224
|
-
break;
|
225
|
-
case Action.EDITION_CANCELED:
|
226
|
-
if (!this.useCancelConfirm)
|
227
|
-
return resolve(action);
|
228
|
-
if (this.dataState.hasDirtyRecords) {
|
229
|
-
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
230
|
-
if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
|
231
|
-
resolve(action);
|
232
|
-
return;
|
233
|
-
}
|
234
|
-
if (cancelConfirmation == undefined) {
|
235
|
-
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
236
|
-
resolve(action);
|
237
|
-
}
|
238
|
-
else {
|
239
|
-
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
240
|
-
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
241
|
-
.then((result) => {
|
242
|
-
result && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
243
|
-
resolve(result ? action : undefined);
|
244
|
-
});
|
245
|
-
}
|
246
|
-
}
|
247
|
-
else {
|
248
|
-
resolve(action);
|
249
|
-
}
|
250
|
-
break;
|
251
|
-
case Action.REMOVING_RECORDS:
|
252
|
-
if (this.isAllowed("REMOVE")) {
|
253
|
-
let multipleSelection = false;
|
254
|
-
let removeConfirmation = !((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
255
|
-
const selection = (_d = this.dataUnit) === null || _d === void 0 ? void 0 : _d.getSelectionInfo();
|
256
|
-
if (!((_e = action.payload) === null || _e === void 0 ? void 0 : _e.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
257
|
-
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
258
|
-
multipleSelection = true;
|
259
|
-
}
|
260
|
-
if (!removeConfirmation) {
|
261
|
-
resolve(action);
|
262
|
-
}
|
263
|
-
else {
|
264
|
-
const options = {
|
265
|
-
canClose: false,
|
266
|
-
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
267
|
-
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
268
|
-
btnConfirmDanger: false
|
269
|
-
};
|
270
|
-
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
271
|
-
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options)
|
272
|
-
.then((result) => resolve(result ? action : undefined));
|
273
|
-
}
|
274
|
-
}
|
275
|
-
else {
|
276
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
277
|
-
}
|
278
|
-
break;
|
279
|
-
default:
|
280
|
-
resolve(action);
|
171
|
+
fillFieldsWithRmp(payload) {
|
172
|
+
payload.fields.forEach((field) => {
|
173
|
+
var _a;
|
174
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rmp) && !this._fieldsWithRmp.includes(field.name)) {
|
175
|
+
this._fieldsWithRmp.push(field.name);
|
176
|
+
}
|
177
|
+
});
|
178
|
+
}
|
179
|
+
fillFieldsWithRmPrecision(payload) {
|
180
|
+
payload.fields.forEach((field) => {
|
181
|
+
var _a;
|
182
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !this._fieldsWithRmPrecision.includes(field.name)) {
|
183
|
+
this._fieldsWithRmPrecision.push(field.name);
|
281
184
|
}
|
282
185
|
});
|
283
186
|
}
|
187
|
+
getCacheName(fieldName, metadataName, fieldValue) {
|
188
|
+
const cacheName = [fieldName, metadataName, fieldValue].join("_");
|
189
|
+
return cacheName;
|
190
|
+
}
|
191
|
+
updateDataStateRmp(newValue) {
|
192
|
+
const newRowMetadata = Object.assign({}, newValue);
|
193
|
+
this.dataState.rowMetadata = newRowMetadata;
|
194
|
+
}
|
195
|
+
saveCacheRmd(record) {
|
196
|
+
const rmd = record.__record__metadata__;
|
197
|
+
const keysRmd = Object.keys(rmd);
|
198
|
+
keysRmd.shift();
|
199
|
+
keysRmd.forEach((fieldName) => {
|
200
|
+
const fieldValue = getRecordValue(record, fieldName);
|
201
|
+
const cacheName = this.getCacheName(fieldName, rmd.provider, fieldValue);
|
202
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, rmd));
|
203
|
+
});
|
204
|
+
}
|
205
|
+
getMetadataByRow(payload) {
|
206
|
+
var _a;
|
207
|
+
if (!((_a = payload.records) === null || _a === void 0 ? void 0 : _a.length)) {
|
208
|
+
return payload;
|
209
|
+
}
|
210
|
+
if (!this._fieldsWithRmp.length) {
|
211
|
+
const records = payload.records.map((record) => {
|
212
|
+
delete record.__record__metadata__;
|
213
|
+
return record;
|
214
|
+
});
|
215
|
+
return Object.assign(Object.assign({}, payload), { records });
|
216
|
+
}
|
217
|
+
const records = payload.records.map((record) => {
|
218
|
+
if (!record.__record__metadata__) {
|
219
|
+
return record;
|
220
|
+
}
|
221
|
+
this.saveCacheRmd(record);
|
222
|
+
const rowMetadata = Object.assign({}, record.__record__metadata__);
|
223
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
224
|
+
this._metadataByRow.set(record.__record__id__, rowMetadata);
|
225
|
+
delete record.__record__metadata__;
|
226
|
+
return record;
|
227
|
+
});
|
228
|
+
return Object.assign(Object.assign({}, payload), { records });
|
229
|
+
}
|
230
|
+
interceptRecordsAdded(action) {
|
231
|
+
if (!this.isAllowed("INSERT")) {
|
232
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
233
|
+
return;
|
234
|
+
}
|
235
|
+
return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
|
236
|
+
}
|
237
|
+
interceptRecordsCopied(action) {
|
238
|
+
if (!this.isAllowed("CLONE")) {
|
239
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
|
243
|
+
}
|
244
|
+
async interceptDataChange(action) {
|
245
|
+
if (this.isAllowed("UPDATE")) {
|
246
|
+
return action;
|
247
|
+
}
|
248
|
+
if (this._openedAlert) {
|
249
|
+
await this.dataUnit.cancelEdition();
|
250
|
+
return;
|
251
|
+
}
|
252
|
+
this._openedAlert = true;
|
253
|
+
await this.dataUnit.cancelEdition();
|
254
|
+
await ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
255
|
+
this._openedAlert = false;
|
256
|
+
}
|
257
|
+
async interceptSavingData(action) {
|
258
|
+
if (!this.beforeSave) {
|
259
|
+
return action;
|
260
|
+
}
|
261
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
262
|
+
if (continueAction instanceof Promise) {
|
263
|
+
const result = await continueAction;
|
264
|
+
return result ? action : undefined;
|
265
|
+
}
|
266
|
+
return continueAction ? action : undefined;
|
267
|
+
}
|
268
|
+
interceptDataSaved(action) {
|
269
|
+
if (this.afterSave) {
|
270
|
+
this.afterSave(this.dataUnit);
|
271
|
+
return;
|
272
|
+
}
|
273
|
+
return action;
|
274
|
+
}
|
275
|
+
async interceptEditionCanceled(action) {
|
276
|
+
var _a, _b;
|
277
|
+
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)) {
|
278
|
+
return action;
|
279
|
+
}
|
280
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
281
|
+
if (cancelConfirmation == undefined) {
|
282
|
+
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
283
|
+
return action;
|
284
|
+
}
|
285
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
286
|
+
const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
|
287
|
+
confirm && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
288
|
+
return confirm ? action : undefined;
|
289
|
+
}
|
290
|
+
async interceptRemovingRecords(action) {
|
291
|
+
var _a, _b, _c;
|
292
|
+
if (!this.isAllowed("REMOVE")) {
|
293
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
294
|
+
return;
|
295
|
+
}
|
296
|
+
let multipleSelection = false;
|
297
|
+
let removeConfirmation = !((_a = action.payload) === null || _a === void 0 ? void 0 : _a.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
298
|
+
const selection = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getSelectionInfo();
|
299
|
+
if (!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
300
|
+
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
301
|
+
multipleSelection = true;
|
302
|
+
}
|
303
|
+
if (!removeConfirmation) {
|
304
|
+
return action;
|
305
|
+
}
|
306
|
+
const options = {
|
307
|
+
canClose: false,
|
308
|
+
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
309
|
+
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
310
|
+
btnConfirmDanger: false
|
311
|
+
};
|
312
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
313
|
+
const confirm = await ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options);
|
314
|
+
return confirm ? action : undefined;
|
315
|
+
}
|
316
|
+
interceptDataLoaded(action) {
|
317
|
+
const newPayload = this.getMetadataByRow(action.payload);
|
318
|
+
action = new DataUnitAction(Action.DATA_LOADED, newPayload);
|
319
|
+
return action;
|
320
|
+
}
|
321
|
+
interceptMetadataLoaded(action) {
|
322
|
+
this.fillFieldsWithRmp(action.payload);
|
323
|
+
this.fillFieldsWithRmPrecision(action.payload);
|
324
|
+
return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
|
325
|
+
}
|
326
|
+
async interceptAction(action) {
|
327
|
+
switch (action.type) {
|
328
|
+
case Action.RECORDS_ADDED:
|
329
|
+
return this.interceptRecordsAdded(action);
|
330
|
+
case Action.RECORDS_COPIED:
|
331
|
+
return this.interceptRecordsCopied(action);
|
332
|
+
case Action.DATA_CHANGED:
|
333
|
+
await this.handleLoadRowMetadata(action);
|
334
|
+
return await this.interceptDataChange(action);
|
335
|
+
case Action.CHANGING_DATA:
|
336
|
+
return await this.interceptDataChange(action);
|
337
|
+
case Action.SAVING_DATA:
|
338
|
+
return await this.interceptSavingData(action);
|
339
|
+
case Action.DATA_SAVED:
|
340
|
+
return this.interceptDataSaved(action);
|
341
|
+
case Action.EDITION_CANCELED:
|
342
|
+
return await this.interceptEditionCanceled(action);
|
343
|
+
case Action.REMOVING_RECORDS:
|
344
|
+
return await this.interceptRemovingRecords(action);
|
345
|
+
case Action.DATA_LOADED:
|
346
|
+
return this.interceptDataLoaded(action);
|
347
|
+
case Action.METADATA_LOADED:
|
348
|
+
return this.interceptMetadataLoaded(action);
|
349
|
+
default:
|
350
|
+
return action;
|
351
|
+
}
|
352
|
+
}
|
353
|
+
async handleLoadRowMetadata(action) {
|
354
|
+
const record = action.type === Action.DATA_CHANGED ? action.payload : action.payload.changes[0].record;
|
355
|
+
const keysPayload = Object.keys(record);
|
356
|
+
const rmpField = keysPayload.find((field) => this._fieldsWithRmp.includes(field));
|
357
|
+
if (rmpField) {
|
358
|
+
const metadataName = this.dataUnit.getField(rmpField).properties.rmp;
|
359
|
+
const fieldValue = getRecordValue(record, rmpField);
|
360
|
+
return await this.updateRowMetadata({
|
361
|
+
fieldName: rmpField,
|
362
|
+
fieldValue,
|
363
|
+
metadataName,
|
364
|
+
updatedFields: record,
|
365
|
+
});
|
366
|
+
}
|
367
|
+
}
|
368
|
+
async updateRowMetadata({ fieldName, fieldValue, metadataName, updatedFields }) {
|
369
|
+
const cacheName = this.getCacheName(fieldName, metadataName, fieldValue);
|
370
|
+
const cacheValue = this._rowMetadataCache.get(cacheName);
|
371
|
+
if (cacheValue) {
|
372
|
+
this.updateDataStateRmp(cacheValue);
|
373
|
+
return cacheValue;
|
374
|
+
}
|
375
|
+
else {
|
376
|
+
const datasetStrategy = new DatasetStrategy();
|
377
|
+
const response = await datasetStrategy.loadRowMetadata(this, fieldName, metadataName, updatedFields);
|
378
|
+
this.updateDataStateRmp(response._rmd);
|
379
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, response._rmd));
|
380
|
+
return Object.assign({}, response._rmd);
|
381
|
+
}
|
382
|
+
}
|
383
|
+
handleDULinksOnMetadataLoaded(payload) {
|
384
|
+
const metadata = Object.assign({}, payload);
|
385
|
+
this.processLinks(metadata);
|
386
|
+
return metadata;
|
387
|
+
}
|
388
|
+
handleRecordsCopied(initialRecords) {
|
389
|
+
let records = [...initialRecords];
|
390
|
+
records = this.handleCleanOnCopy(records);
|
391
|
+
return this.handleLinksWithParent(records);
|
392
|
+
}
|
393
|
+
handleLinksWithParent(records) {
|
394
|
+
var _a, _b;
|
395
|
+
const parentDataUnit = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
396
|
+
if (!parentDataUnit)
|
397
|
+
return records;
|
398
|
+
const parentSelectedRecord = parentDataUnit.getSelectedRecord();
|
399
|
+
const selfInfo = parentDataUnit === null || parentDataUnit === void 0 ? void 0 : parentDataUnit.getChildInfo(this.getCleanDataUnitName());
|
400
|
+
const { links } = selfInfo;
|
401
|
+
if (!links || links.length === 0)
|
402
|
+
return records;
|
403
|
+
return records.map(record => {
|
404
|
+
return this.buildRecordWithLinkedFields(record, links, parentSelectedRecord);
|
405
|
+
});
|
406
|
+
}
|
407
|
+
buildRecordWithLinkedFields(record, links, parentSelectedRecord) {
|
408
|
+
const newRecord = Object.assign({}, record);
|
409
|
+
links.forEach(link => {
|
410
|
+
const convertedParentSelectedRecord = convertType(this.dataUnit.getField(link.target).dataType, parentSelectedRecord[link.source]);
|
411
|
+
newRecord[link.target] = convertedParentSelectedRecord;
|
412
|
+
});
|
413
|
+
return newRecord;
|
414
|
+
}
|
415
|
+
handleCleanOnCopy(records) {
|
416
|
+
const cleanFields = this.getCleanOnCopyFields();
|
417
|
+
if (cleanFields.length > 0) {
|
418
|
+
records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
|
419
|
+
}
|
420
|
+
return records;
|
421
|
+
}
|
422
|
+
buildCopyWithCleanedFields(record, cleanFields) {
|
423
|
+
const newRecord = Object.assign({}, record);
|
424
|
+
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
425
|
+
return newRecord;
|
426
|
+
}
|
284
427
|
showSuccessMessage(message) {
|
285
428
|
ApplicationUtils.info(message, { iconName: "check" });
|
286
429
|
}
|
287
430
|
isAllowed(flag) {
|
288
431
|
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
289
432
|
}
|
290
|
-
buildDataState() {
|
433
|
+
buildDataState(actionType) {
|
434
|
+
var _a;
|
291
435
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
292
436
|
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
437
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
438
|
+
let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
|
439
|
+
const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
|
440
|
+
if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
|
441
|
+
rowMetadata = this.doGetRowMetadata(selectedRecord);
|
442
|
+
}
|
443
|
+
else if (rowMetadata) {
|
444
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
445
|
+
}
|
293
446
|
return new DataStateImpl({
|
294
447
|
insertionMode: this.dataUnit.hasNewRecord(),
|
295
448
|
isStartingInsertionMode,
|
@@ -300,10 +453,48 @@ export class SnkDataUnit {
|
|
300
453
|
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
301
454
|
selectedRecords: undefined,
|
302
455
|
selectionInfo,
|
303
|
-
selectedRecord
|
304
|
-
recordsIsEmpty: this.dataUnit.records.length === 0
|
456
|
+
selectedRecord,
|
457
|
+
recordsIsEmpty: this.dataUnit.records.length === 0,
|
458
|
+
metadataByRow: this._metadataByRow,
|
459
|
+
rowMetadata
|
305
460
|
});
|
306
461
|
}
|
462
|
+
async handleDataSaved(action) {
|
463
|
+
const newRowMetadata = await this.handleLoadRowMetadata(action);
|
464
|
+
if (newRowMetadata) {
|
465
|
+
newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
|
466
|
+
}
|
467
|
+
const recordId = action.payload.records[0].__record__id__;
|
468
|
+
this._metadataByRow.set(recordId, newRowMetadata);
|
469
|
+
this.dataState = this.buildDataState();
|
470
|
+
if (this.ignoreSaveMessage) {
|
471
|
+
return;
|
472
|
+
}
|
473
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
474
|
+
if (msg != undefined) {
|
475
|
+
this.showSuccessMessage(msg);
|
476
|
+
}
|
477
|
+
}
|
478
|
+
handleRecordsRemoved(action) {
|
479
|
+
var _a, _b;
|
480
|
+
const cachedRecords = action.payload.cachedRecords;
|
481
|
+
let removeFinishMsg;
|
482
|
+
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
483
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
484
|
+
}
|
485
|
+
else {
|
486
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
487
|
+
}
|
488
|
+
if (removeFinishMsg != undefined) {
|
489
|
+
this.showSuccessMessage(removeFinishMsg);
|
490
|
+
}
|
491
|
+
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
492
|
+
const paginationInfo = this.dataUnit.getPaginationInfo();
|
493
|
+
if (paginationInfo) {
|
494
|
+
const page = recordsCount > 0 || paginationInfo.hasMore ? paginationInfo.currentPage : 0;
|
495
|
+
this.dataUnit.gotoPage(page);
|
496
|
+
}
|
497
|
+
}
|
307
498
|
/**
|
308
499
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
309
500
|
* através de um pequeno modulo na estrutura da aplicação:
|
@@ -345,6 +536,7 @@ export class SnkDataUnit {
|
|
345
536
|
}
|
346
537
|
}
|
347
538
|
async loadDataUnit() {
|
539
|
+
var _a;
|
348
540
|
if (this.dataUnit == null && this._application && this.entityName) {
|
349
541
|
this.dataUnit = await this.getDataUnitParentOrChild();
|
350
542
|
}
|
@@ -353,6 +545,10 @@ export class SnkDataUnit {
|
|
353
545
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
354
546
|
this.dataUnit.addInterceptor(this);
|
355
547
|
this.dataUnit.subscribe(this._dataUnitObserver);
|
548
|
+
await this.dataUnit.loadMetadata();
|
549
|
+
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
550
|
+
this.getMetadataByRow(this.dataUnit);
|
551
|
+
}
|
356
552
|
this.dataState = this.buildDataState();
|
357
553
|
let resolver;
|
358
554
|
while (resolver = this._onDataUnitResolve.pop()) {
|
@@ -371,20 +567,40 @@ export class SnkDataUnit {
|
|
371
567
|
return;
|
372
568
|
}
|
373
569
|
handlerLinkFields() {
|
374
|
-
var _a, _b;
|
375
|
-
const
|
376
|
-
if (!
|
570
|
+
var _a, _b, _c, _d;
|
571
|
+
const parentDU = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
572
|
+
if (!parentDU)
|
377
573
|
return;
|
378
|
-
const
|
574
|
+
const childName = (_c = this.entityName) !== null && _c !== void 0 ? _c : this.getCleanDataUnitName();
|
575
|
+
const child = parentDU.getChildInfo(childName);
|
379
576
|
if (!child)
|
380
577
|
return;
|
381
|
-
const
|
382
|
-
(
|
383
|
-
|
578
|
+
const links = (_d = child === null || child === void 0 ? void 0 : child.links) === null || _d === void 0 ? void 0 : _d.map(link => link.target);
|
579
|
+
this.handleDUWithLinks(links);
|
580
|
+
}
|
581
|
+
handleDUWithLinks(fieldsToLink) {
|
582
|
+
this.fieldsToLink = fieldsToLink;
|
583
|
+
const metadata = Object.assign({}, this.dataUnit.metadata);
|
584
|
+
this.processLinks(metadata);
|
585
|
+
this.dataUnit.metadata = metadata;
|
586
|
+
this.dataUnitFieldsHidded.emit();
|
587
|
+
}
|
588
|
+
processLinks(metadata) {
|
589
|
+
var _a;
|
590
|
+
(_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
591
|
+
var _a;
|
592
|
+
if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
|
384
593
|
field.visible = false;
|
385
594
|
}
|
386
595
|
});
|
387
|
-
|
596
|
+
}
|
597
|
+
getCleanDataUnitName() {
|
598
|
+
var _a;
|
599
|
+
const uri = this.dataUnit.name;
|
600
|
+
if (StringUtils.isEmpty(uri))
|
601
|
+
return uri;
|
602
|
+
const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
|
603
|
+
return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
|
388
604
|
}
|
389
605
|
static getNearestInstance(element) {
|
390
606
|
let parent = element.parentElement;
|
@@ -411,8 +627,9 @@ export class SnkDataUnit {
|
|
411
627
|
this.dataUnit.releaseCallbacks();
|
412
628
|
}
|
413
629
|
}
|
414
|
-
componentDidLoad() {
|
415
|
-
this.loadDataUnit();
|
630
|
+
async componentDidLoad() {
|
631
|
+
await this.loadDataUnit();
|
632
|
+
this.handlerLinkFields();
|
416
633
|
}
|
417
634
|
render() {
|
418
635
|
return (h(Host, null));
|
@@ -646,6 +863,11 @@ export class SnkDataUnit {
|
|
646
863
|
}
|
647
864
|
};
|
648
865
|
}
|
866
|
+
static get states() {
|
867
|
+
return {
|
868
|
+
"fieldsToLink": {}
|
869
|
+
};
|
870
|
+
}
|
649
871
|
static get events() {
|
650
872
|
return [{
|
651
873
|
"method": "dataStateChange",
|
@@ -706,6 +928,21 @@ export class SnkDataUnit {
|
|
706
928
|
}
|
707
929
|
}
|
708
930
|
}
|
931
|
+
}, {
|
932
|
+
"method": "dataUnitFieldsHidded",
|
933
|
+
"name": "dataUnitFieldsHidded",
|
934
|
+
"bubbles": true,
|
935
|
+
"cancelable": true,
|
936
|
+
"composed": true,
|
937
|
+
"docs": {
|
938
|
+
"tags": [],
|
939
|
+
"text": "Emitido quando h\u00E1 campos no DataUnit que devem ser ocultados."
|
940
|
+
},
|
941
|
+
"complexType": {
|
942
|
+
"original": "void",
|
943
|
+
"resolved": "void",
|
944
|
+
"references": {}
|
945
|
+
}
|
709
946
|
}, {
|
710
947
|
"method": "insertionMode",
|
711
948
|
"name": "insertionMode",
|
@@ -774,10 +1011,6 @@ export class SnkDataUnit {
|
|
774
1011
|
},
|
775
1012
|
"Array": {
|
776
1013
|
"location": "global"
|
777
|
-
},
|
778
|
-
"Record": {
|
779
|
-
"location": "import",
|
780
|
-
"path": "@sankhyalabs/core"
|
781
1014
|
}
|
782
1015
|
},
|
783
1016
|
"return": "Promise<IRecordID[]>"
|
@@ -789,6 +1022,64 @@ export class SnkDataUnit {
|
|
789
1022
|
"text": "Retorna a lista de IDs dos registros selecionados."
|
790
1023
|
}]
|
791
1024
|
}
|
1025
|
+
},
|
1026
|
+
"getFieldsWithRmp": {
|
1027
|
+
"complexType": {
|
1028
|
+
"signature": "() => Promise<string[]>",
|
1029
|
+
"parameters": [],
|
1030
|
+
"references": {
|
1031
|
+
"Promise": {
|
1032
|
+
"location": "global"
|
1033
|
+
}
|
1034
|
+
},
|
1035
|
+
"return": "Promise<string[]>"
|
1036
|
+
},
|
1037
|
+
"docs": {
|
1038
|
+
"text": "Retorna os campos que possuem a propriedade \"rmp\" (Row Metadata Provider).",
|
1039
|
+
"tags": []
|
1040
|
+
}
|
1041
|
+
},
|
1042
|
+
"getFieldsWithRmPrecision": {
|
1043
|
+
"complexType": {
|
1044
|
+
"signature": "() => Promise<string[]>",
|
1045
|
+
"parameters": [],
|
1046
|
+
"references": {
|
1047
|
+
"Promise": {
|
1048
|
+
"location": "global"
|
1049
|
+
}
|
1050
|
+
},
|
1051
|
+
"return": "Promise<string[]>"
|
1052
|
+
},
|
1053
|
+
"docs": {
|
1054
|
+
"text": "Retorna os campos que possuem a propriedade \"rm_precision\" (Row Metadata Precision).",
|
1055
|
+
"tags": []
|
1056
|
+
}
|
1057
|
+
},
|
1058
|
+
"getRowMetadata": {
|
1059
|
+
"complexType": {
|
1060
|
+
"signature": "(record?: Record | string) => Promise<RowMetadata>",
|
1061
|
+
"parameters": [{
|
1062
|
+
"tags": [],
|
1063
|
+
"text": ""
|
1064
|
+
}],
|
1065
|
+
"references": {
|
1066
|
+
"Promise": {
|
1067
|
+
"location": "global"
|
1068
|
+
},
|
1069
|
+
"RowMetadata": {
|
1070
|
+
"location": "local"
|
1071
|
+
},
|
1072
|
+
"Record": {
|
1073
|
+
"location": "import",
|
1074
|
+
"path": "@sankhyalabs/core"
|
1075
|
+
}
|
1076
|
+
},
|
1077
|
+
"return": "Promise<RowMetadata>"
|
1078
|
+
},
|
1079
|
+
"docs": {
|
1080
|
+
"text": "Busca os metadados da linha selecionada.",
|
1081
|
+
"tags": []
|
1082
|
+
}
|
792
1083
|
}
|
793
1084
|
};
|
794
1085
|
}
|
@@ -827,6 +1118,8 @@ class DataStateImpl {
|
|
827
1118
|
this.selectionInfo = datastate.selectionInfo;
|
828
1119
|
this.selectedRecord = datastate.selectedRecord;
|
829
1120
|
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
1121
|
+
this.metadataByRow = datastate.metadataByRow;
|
1122
|
+
this.rowMetadata = datastate.rowMetadata;
|
830
1123
|
}
|
831
1124
|
get selectedRecords() {
|
832
1125
|
var _a;
|