@sankhyalabs/sankhyablocks 8.15.1 → 8.16.0-dev.2
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-9479f618.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-0c7106a0.js} +88 -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-16791a2f.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-d82746e8.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 +8 -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 +85 -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-5a858363.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-f7e0ffc0.js} +84 -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-a327d22c.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-874da66f.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-0046959e.entry.js +1 -0
- package/dist/sankhyablocks/p-0e11ee18.entry.js +1 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-30cf616e.js +1 -0
- package/dist/sankhyablocks/p-47b60deb.entry.js +1 -0
- package/dist/sankhyablocks/p-60e46675.entry.js +11 -0
- package/dist/sankhyablocks/p-6d4f4614.js +60 -0
- package/dist/sankhyablocks/p-6ded2076.entry.js +1 -0
- package/dist/sankhyablocks/p-7a337364.js +1 -0
- package/dist/sankhyablocks/p-7d9baaf4.entry.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-8c6b44ea.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-a4b1f1eb.js +1 -0
- package/dist/sankhyablocks/p-af8efd95.js +6 -0
- package/dist/sankhyablocks/p-b7c4feeb.entry.js +1 -0
- package/dist/sankhyablocks/p-b8cde0d8.entry.js +1 -0
- package/dist/sankhyablocks/p-c7cbad38.js +1 -0
- package/dist/sankhyablocks/p-e0b9f59a.entry.js +1 -0
- package/dist/sankhyablocks/p-e6210aec.js +1 -0
- package/dist/sankhyablocks/p-e9bbc3d5.entry.js +1 -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,7 +1,47 @@
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
2
|
-
import { Action, ObjectUtils,
|
2
|
+
import { JSUtils, DataType, Action, ObjectUtils, DataUnitAction, StringUtils, ApplicationContext } from '@sankhyalabs/core';
|
3
3
|
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
4
4
|
import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder.js';
|
5
|
+
import { g as getRecordValue, d as DatasetStrategy } from './dataunit-fetcher.js';
|
6
|
+
import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
7
|
+
|
8
|
+
const getSelectedIDs = (dataUnit) => {
|
9
|
+
const selectionInfo = dataUnit.getSelectionInfo();
|
10
|
+
if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
|
11
|
+
return [];
|
12
|
+
}
|
13
|
+
const selectedRecordsIDsInfo = [];
|
14
|
+
const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.recordIds;
|
15
|
+
if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
|
16
|
+
selectedRecords.forEach(recordId => {
|
17
|
+
if (!dataUnit.isNewRecord(recordId)) {
|
18
|
+
/*
|
19
|
+
Esse if foi necessário para tratar corretamente o ID
|
20
|
+
do record quando está sendo utilizado no modo standAlone
|
21
|
+
isso não faz a exportação da grid funcionar no modo standAlone
|
22
|
+
mas deixa de causar erro nas oprações de CRUD.
|
23
|
+
*/
|
24
|
+
if (!JSUtils.isBase64(recordId)) {
|
25
|
+
selectedRecordsIDsInfo.push({
|
26
|
+
name: "__record__id__",
|
27
|
+
type: DataType.TEXT,
|
28
|
+
value: recordId
|
29
|
+
});
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
const revertBase64ToObject = JSON.parse(window.atob(recordId));
|
33
|
+
Object.entries(revertBase64ToObject).forEach(([name, value]) => {
|
34
|
+
const metadataField = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(name);
|
35
|
+
if (metadataField == undefined) {
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
|
39
|
+
});
|
40
|
+
}
|
41
|
+
});
|
42
|
+
}
|
43
|
+
return selectedRecordsIDsInfo;
|
44
|
+
};
|
5
45
|
|
6
46
|
const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
7
47
|
constructor() {
|
@@ -10,54 +50,41 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
10
50
|
this.dataStateChange = createEvent(this, "dataStateChange", 3);
|
11
51
|
this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
|
12
52
|
this.messagesBuilderUpdated = createEvent(this, "messagesBuilderUpdated", 3);
|
53
|
+
this.dataUnitFieldsHidded = createEvent(this, "dataUnitFieldsHidded", 7);
|
13
54
|
this.insertionMode = createEvent(this, "insertionMode", 3);
|
14
55
|
this.cancelEdition = createEvent(this, "cancelEdition", 3);
|
15
56
|
this._onDataUnitResolve = [];
|
16
57
|
this._openedAlert = false;
|
17
|
-
this.
|
18
|
-
|
19
|
-
|
58
|
+
this._fieldsWithRmp = [];
|
59
|
+
this._fieldsWithRmPrecision = [];
|
60
|
+
this._metadataByRow = new Map();
|
61
|
+
this._rowMetadataCache = new Map();
|
62
|
+
this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
|
63
|
+
this._dataUnitObserver = async (action) => {
|
64
|
+
const duState = this.buildDataState(action.type);
|
20
65
|
this.dataState = duState;
|
21
|
-
if (action.type === Action.DATA_SAVED) {
|
22
|
-
if (this.ignoreSaveMessage) {
|
23
|
-
return;
|
24
|
-
}
|
25
|
-
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
26
|
-
if (msg != undefined) {
|
27
|
-
this.showSuccessMessage(msg);
|
28
|
-
}
|
29
|
-
}
|
30
|
-
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
31
|
-
this.insertionMode.emit();
|
32
|
-
}
|
33
|
-
if (action.type === Action.EDITION_CANCELED) {
|
34
|
-
this.cancelEdition.emit();
|
35
|
-
}
|
36
|
-
if (action.type === Action.RECORDS_REMOVED) {
|
37
|
-
const cachedRecords = action.payload.cachedRecords;
|
38
|
-
let removeFinishMsg;
|
39
|
-
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
40
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
41
|
-
}
|
42
|
-
else {
|
43
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
44
|
-
}
|
45
|
-
if (removeFinishMsg != undefined) {
|
46
|
-
this.showSuccessMessage(removeFinishMsg);
|
47
|
-
}
|
48
|
-
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
49
|
-
const paginationInfo = this.dataUnit.getPaginationInfo();
|
50
|
-
if (paginationInfo) {
|
51
|
-
if (recordsCount > 0 || paginationInfo.hasMore) {
|
52
|
-
this.dataUnit.gotoPage(paginationInfo.currentPage);
|
53
|
-
}
|
54
|
-
else {
|
55
|
-
this.dataUnit.gotoPage(0);
|
56
|
-
}
|
57
|
-
}
|
58
|
-
}
|
59
66
|
this.messagesBuilder.currentOperation = this.getMessageOperation();
|
67
|
+
switch (action.type) {
|
68
|
+
case Action.DATA_SAVED:
|
69
|
+
await this.handleDataSaved(action);
|
70
|
+
break;
|
71
|
+
case Action.RECORDS_ADDED:
|
72
|
+
case Action.RECORDS_COPIED:
|
73
|
+
this.insertionMode.emit();
|
74
|
+
break;
|
75
|
+
case Action.EDITION_CANCELED:
|
76
|
+
this.cancelEdition.emit();
|
77
|
+
break;
|
78
|
+
case Action.RECORDS_REMOVED:
|
79
|
+
this.handleRecordsRemoved(action);
|
80
|
+
break;
|
81
|
+
case Action.METADATA_LOADED:
|
82
|
+
this.fillFieldsWithRmp(this.dataUnit.metadata);
|
83
|
+
this.fillFieldsWithRmPrecision(this.dataUnit.metadata);
|
84
|
+
break;
|
85
|
+
}
|
60
86
|
};
|
87
|
+
this.fieldsToLink = [];
|
61
88
|
this.dataState = undefined;
|
62
89
|
this.messagesBuilder = undefined;
|
63
90
|
this.dataUnitName = undefined;
|
@@ -125,169 +152,320 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
125
152
|
* @returns Retorna a lista de IDs dos registros selecionados.
|
126
153
|
*/
|
127
154
|
async getSelectedRecordsIDsInfo() {
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
155
|
+
return Promise.resolve(getSelectedIDs(this.dataUnit));
|
156
|
+
}
|
157
|
+
/**
|
158
|
+
* Retorna os campos que possuem a propriedade "rmp" (Row Metadata Provider).
|
159
|
+
*/
|
160
|
+
async getFieldsWithRmp() {
|
161
|
+
return this._fieldsWithRmp;
|
162
|
+
}
|
163
|
+
/**
|
164
|
+
* Retorna os campos que possuem a propriedade "rm_precision" (Row Metadata Precision).
|
165
|
+
*/
|
166
|
+
async getFieldsWithRmPrecision() {
|
167
|
+
return this._fieldsWithRmPrecision;
|
168
|
+
}
|
169
|
+
/**
|
170
|
+
* Busca os metadados da linha selecionada.
|
171
|
+
*/
|
172
|
+
async getRowMetadata(record) {
|
173
|
+
return this.doGetRowMetadata(record);
|
174
|
+
}
|
175
|
+
doGetRowMetadata(record) {
|
176
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
177
|
+
if (!record && !selectedRecord) {
|
178
|
+
return;
|
179
|
+
}
|
180
|
+
const currentRecord = record || selectedRecord;
|
181
|
+
const recordId = typeof currentRecord === 'string' ? currentRecord : currentRecord.__record__id__;
|
182
|
+
const rowMetadata = this._metadataByRow.get(recordId);
|
183
|
+
if (!rowMetadata) {
|
184
|
+
return;
|
185
|
+
}
|
186
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
187
|
+
return Object.assign({}, rowMetadata);
|
188
|
+
}
|
189
|
+
buildGetPropRowMetadata(rowMetadata) {
|
190
|
+
return (propPath, fieldName) => {
|
191
|
+
if (propPath === "rm_precision") {
|
192
|
+
propPath = this.resolvePrecisionFromMetadata(fieldName);
|
193
|
+
}
|
194
|
+
return ObjectUtils.getProp(rowMetadata, propPath);
|
195
|
+
};
|
196
|
+
}
|
197
|
+
resolvePrecisionFromMetadata(fieldName) {
|
198
|
+
var _a, _b;
|
199
|
+
if (!fieldName) {
|
200
|
+
ApplicationUtils.error(this.getMessage("snkDataUnit.fieldNameRequired"));
|
201
|
+
return;
|
202
|
+
}
|
203
|
+
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;
|
204
|
+
if (!rmPrecision) {
|
205
|
+
return '';
|
163
206
|
}
|
164
|
-
|
207
|
+
let rmPrecisionPath = rmPrecision.split('.').filter((_, index) => index !== 1).join('.');
|
208
|
+
return rmPrecisionPath;
|
165
209
|
}
|
166
210
|
getCleanOnCopyFields() {
|
167
211
|
var _a;
|
168
212
|
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);
|
169
213
|
}
|
170
|
-
|
171
|
-
|
172
|
-
var _a
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
}
|
220
|
-
}
|
221
|
-
else {
|
222
|
-
resolve(action);
|
223
|
-
}
|
224
|
-
break;
|
225
|
-
case Action.DATA_SAVED:
|
226
|
-
if (this.afterSave) {
|
227
|
-
this.afterSave(this.dataUnit);
|
228
|
-
}
|
229
|
-
else {
|
230
|
-
resolve(action);
|
231
|
-
}
|
232
|
-
break;
|
233
|
-
case Action.EDITION_CANCELED:
|
234
|
-
if (!this.useCancelConfirm)
|
235
|
-
return resolve(action);
|
236
|
-
if (this.dataState.hasDirtyRecords) {
|
237
|
-
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
238
|
-
if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
|
239
|
-
resolve(action);
|
240
|
-
return;
|
241
|
-
}
|
242
|
-
if (cancelConfirmation == undefined) {
|
243
|
-
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
244
|
-
resolve(action);
|
245
|
-
}
|
246
|
-
else {
|
247
|
-
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
248
|
-
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
249
|
-
.then((result) => {
|
250
|
-
result && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
251
|
-
resolve(result ? action : undefined);
|
252
|
-
});
|
253
|
-
}
|
254
|
-
}
|
255
|
-
else {
|
256
|
-
resolve(action);
|
257
|
-
}
|
258
|
-
break;
|
259
|
-
case Action.REMOVING_RECORDS:
|
260
|
-
if (this.isAllowed("REMOVE")) {
|
261
|
-
let multipleSelection = false;
|
262
|
-
let removeConfirmation = !((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
263
|
-
const selection = (_d = this.dataUnit) === null || _d === void 0 ? void 0 : _d.getSelectionInfo();
|
264
|
-
if (!((_e = action.payload) === null || _e === void 0 ? void 0 : _e.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
265
|
-
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
266
|
-
multipleSelection = true;
|
267
|
-
}
|
268
|
-
if (!removeConfirmation) {
|
269
|
-
resolve(action);
|
270
|
-
}
|
271
|
-
else {
|
272
|
-
const options = {
|
273
|
-
canClose: false,
|
274
|
-
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
275
|
-
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
276
|
-
btnConfirmDanger: false
|
277
|
-
};
|
278
|
-
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
279
|
-
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options)
|
280
|
-
.then((result) => resolve(result ? action : undefined));
|
281
|
-
}
|
282
|
-
}
|
283
|
-
else {
|
284
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
285
|
-
}
|
286
|
-
break;
|
287
|
-
default:
|
288
|
-
resolve(action);
|
214
|
+
fillFieldsWithRmp(payload) {
|
215
|
+
payload.fields.forEach((field) => {
|
216
|
+
var _a;
|
217
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rmp) && !this._fieldsWithRmp.includes(field.name)) {
|
218
|
+
this._fieldsWithRmp.push(field.name);
|
219
|
+
}
|
220
|
+
});
|
221
|
+
}
|
222
|
+
fillFieldsWithRmPrecision(payload) {
|
223
|
+
payload.fields.forEach((field) => {
|
224
|
+
var _a;
|
225
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !this._fieldsWithRmPrecision.includes(field.name)) {
|
226
|
+
this._fieldsWithRmPrecision.push(field.name);
|
227
|
+
}
|
228
|
+
});
|
229
|
+
}
|
230
|
+
getCacheName(fieldName, metadataName, fieldValue) {
|
231
|
+
const cacheName = [fieldName, metadataName, fieldValue].join("_");
|
232
|
+
return cacheName;
|
233
|
+
}
|
234
|
+
updateDataStateRmp(newValue) {
|
235
|
+
const newRowMetadata = Object.assign({}, newValue);
|
236
|
+
this.dataState.rowMetadata = newRowMetadata;
|
237
|
+
}
|
238
|
+
saveCacheRmd(record) {
|
239
|
+
const rmd = record.__record__metadata__;
|
240
|
+
const keysRmd = Object.keys(rmd);
|
241
|
+
keysRmd.shift();
|
242
|
+
keysRmd.forEach((fieldName) => {
|
243
|
+
const fieldValue = getRecordValue(record, fieldName);
|
244
|
+
const cacheName = this.getCacheName(fieldName, rmd.provider, fieldValue);
|
245
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, rmd));
|
246
|
+
});
|
247
|
+
}
|
248
|
+
getMetadataByRow(payload) {
|
249
|
+
var _a;
|
250
|
+
if (!((_a = payload.records) === null || _a === void 0 ? void 0 : _a.length)) {
|
251
|
+
return payload;
|
252
|
+
}
|
253
|
+
if (!this._fieldsWithRmp.length) {
|
254
|
+
const records = payload.records.map((record) => {
|
255
|
+
delete record.__record__metadata__;
|
256
|
+
return record;
|
257
|
+
});
|
258
|
+
return Object.assign(Object.assign({}, payload), { records });
|
259
|
+
}
|
260
|
+
const records = payload.records.map((record) => {
|
261
|
+
if (!record.__record__metadata__) {
|
262
|
+
return record;
|
289
263
|
}
|
264
|
+
this.saveCacheRmd(record);
|
265
|
+
const rowMetadata = Object.assign({}, record.__record__metadata__);
|
266
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
267
|
+
this._metadataByRow.set(record.__record__id__, rowMetadata);
|
268
|
+
delete record.__record__metadata__;
|
269
|
+
return record;
|
290
270
|
});
|
271
|
+
return Object.assign(Object.assign({}, payload), { records });
|
272
|
+
}
|
273
|
+
interceptRecordsAdded(action) {
|
274
|
+
if (!this.isAllowed("INSERT")) {
|
275
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
276
|
+
return;
|
277
|
+
}
|
278
|
+
return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
|
279
|
+
}
|
280
|
+
interceptRecordsCopied(action) {
|
281
|
+
if (!this.isAllowed("CLONE")) {
|
282
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
283
|
+
return;
|
284
|
+
}
|
285
|
+
return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
|
286
|
+
}
|
287
|
+
async interceptDataChange(action) {
|
288
|
+
if (this.isAllowed("UPDATE")) {
|
289
|
+
return action;
|
290
|
+
}
|
291
|
+
if (this._openedAlert) {
|
292
|
+
await this.dataUnit.cancelEdition();
|
293
|
+
return;
|
294
|
+
}
|
295
|
+
this._openedAlert = true;
|
296
|
+
await this.dataUnit.cancelEdition();
|
297
|
+
await ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
298
|
+
this._openedAlert = false;
|
299
|
+
}
|
300
|
+
async interceptSavingData(action) {
|
301
|
+
if (!this.beforeSave) {
|
302
|
+
return action;
|
303
|
+
}
|
304
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
305
|
+
if (continueAction instanceof Promise) {
|
306
|
+
const result = await continueAction;
|
307
|
+
return result ? action : undefined;
|
308
|
+
}
|
309
|
+
return continueAction ? action : undefined;
|
310
|
+
}
|
311
|
+
interceptDataSaved(action) {
|
312
|
+
if (this.afterSave) {
|
313
|
+
this.afterSave(this.dataUnit);
|
314
|
+
return;
|
315
|
+
}
|
316
|
+
return action;
|
317
|
+
}
|
318
|
+
async interceptEditionCanceled(action) {
|
319
|
+
var _a, _b;
|
320
|
+
if (!this.useCancelConfirm || !this.dataState.hasDirtyRecords || ((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
|
321
|
+
return action;
|
322
|
+
}
|
323
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
324
|
+
if (cancelConfirmation == undefined) {
|
325
|
+
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
326
|
+
return action;
|
327
|
+
}
|
328
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
329
|
+
const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
|
330
|
+
confirm && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
331
|
+
return confirm ? action : undefined;
|
332
|
+
}
|
333
|
+
async interceptRemovingRecords(action) {
|
334
|
+
var _a, _b, _c;
|
335
|
+
if (!this.isAllowed("REMOVE")) {
|
336
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
337
|
+
return;
|
338
|
+
}
|
339
|
+
let multipleSelection = false;
|
340
|
+
let removeConfirmation = !((_a = action.payload) === null || _a === void 0 ? void 0 : _a.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
341
|
+
const selection = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getSelectionInfo();
|
342
|
+
if (!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
343
|
+
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
344
|
+
multipleSelection = true;
|
345
|
+
}
|
346
|
+
if (!removeConfirmation) {
|
347
|
+
return action;
|
348
|
+
}
|
349
|
+
const options = {
|
350
|
+
canClose: false,
|
351
|
+
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
352
|
+
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
353
|
+
btnConfirmDanger: false
|
354
|
+
};
|
355
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
356
|
+
const confirm = await ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options);
|
357
|
+
return confirm ? action : undefined;
|
358
|
+
}
|
359
|
+
interceptDataLoaded(action) {
|
360
|
+
const newPayload = this.getMetadataByRow(action.payload);
|
361
|
+
action = new DataUnitAction(Action.DATA_LOADED, newPayload);
|
362
|
+
return action;
|
363
|
+
}
|
364
|
+
interceptMetadataLoaded(action) {
|
365
|
+
this.fillFieldsWithRmp(action.payload);
|
366
|
+
this.fillFieldsWithRmPrecision(action.payload);
|
367
|
+
return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
|
368
|
+
}
|
369
|
+
async interceptAction(action) {
|
370
|
+
switch (action.type) {
|
371
|
+
case Action.RECORDS_ADDED:
|
372
|
+
return this.interceptRecordsAdded(action);
|
373
|
+
case Action.RECORDS_COPIED:
|
374
|
+
return this.interceptRecordsCopied(action);
|
375
|
+
case Action.DATA_CHANGED:
|
376
|
+
await this.handleLoadRowMetadata(action);
|
377
|
+
return await this.interceptDataChange(action);
|
378
|
+
case Action.CHANGING_DATA:
|
379
|
+
return await this.interceptDataChange(action);
|
380
|
+
case Action.SAVING_DATA:
|
381
|
+
return await this.interceptSavingData(action);
|
382
|
+
case Action.DATA_SAVED:
|
383
|
+
return this.interceptDataSaved(action);
|
384
|
+
case Action.EDITION_CANCELED:
|
385
|
+
return await this.interceptEditionCanceled(action);
|
386
|
+
case Action.REMOVING_RECORDS:
|
387
|
+
return await this.interceptRemovingRecords(action);
|
388
|
+
case Action.DATA_LOADED:
|
389
|
+
return this.interceptDataLoaded(action);
|
390
|
+
case Action.METADATA_LOADED:
|
391
|
+
return this.interceptMetadataLoaded(action);
|
392
|
+
default:
|
393
|
+
return action;
|
394
|
+
}
|
395
|
+
}
|
396
|
+
async handleLoadRowMetadata(action) {
|
397
|
+
const record = action.type === Action.DATA_CHANGED ? action.payload : action.payload.changes[0].record;
|
398
|
+
const keysPayload = Object.keys(record);
|
399
|
+
const rmpField = keysPayload.find((field) => this._fieldsWithRmp.includes(field));
|
400
|
+
if (rmpField) {
|
401
|
+
const metadataName = this.dataUnit.getField(rmpField).properties.rmp;
|
402
|
+
const fieldValue = getRecordValue(record, rmpField);
|
403
|
+
return await this.updateRowMetadata({
|
404
|
+
fieldName: rmpField,
|
405
|
+
fieldValue,
|
406
|
+
metadataName,
|
407
|
+
updatedFields: record,
|
408
|
+
});
|
409
|
+
}
|
410
|
+
}
|
411
|
+
async updateRowMetadata({ fieldName, fieldValue, metadataName, updatedFields }) {
|
412
|
+
const cacheName = this.getCacheName(fieldName, metadataName, fieldValue);
|
413
|
+
const cacheValue = this._rowMetadataCache.get(cacheName);
|
414
|
+
if (cacheValue) {
|
415
|
+
this.updateDataStateRmp(cacheValue);
|
416
|
+
return cacheValue;
|
417
|
+
}
|
418
|
+
else {
|
419
|
+
const datasetStrategy = new DatasetStrategy();
|
420
|
+
const response = await datasetStrategy.loadRowMetadata(this, fieldName, metadataName, updatedFields);
|
421
|
+
this.updateDataStateRmp(response._rmd);
|
422
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, response._rmd));
|
423
|
+
return Object.assign({}, response._rmd);
|
424
|
+
}
|
425
|
+
}
|
426
|
+
handleDULinksOnMetadataLoaded(payload) {
|
427
|
+
const metadata = Object.assign({}, payload);
|
428
|
+
this.processLinks(metadata);
|
429
|
+
return metadata;
|
430
|
+
}
|
431
|
+
handleRecordsCopied(initialRecords) {
|
432
|
+
let records = [...initialRecords];
|
433
|
+
records = this.handleCleanOnCopy(records);
|
434
|
+
return this.handleLinksWithParent(records);
|
435
|
+
}
|
436
|
+
handleLinksWithParent(records) {
|
437
|
+
var _a, _b;
|
438
|
+
const parentDataUnit = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
439
|
+
if (!parentDataUnit)
|
440
|
+
return records;
|
441
|
+
const parentSelectedRecord = parentDataUnit.getSelectedRecord();
|
442
|
+
const selfInfo = parentDataUnit === null || parentDataUnit === void 0 ? void 0 : parentDataUnit.getChildInfo(this.getCleanDataUnitName());
|
443
|
+
const { links } = selfInfo;
|
444
|
+
if (!links || links.length === 0)
|
445
|
+
return records;
|
446
|
+
return records.map(record => {
|
447
|
+
return this.buildRecordWithLinkedFields(record, links, parentSelectedRecord);
|
448
|
+
});
|
449
|
+
}
|
450
|
+
buildRecordWithLinkedFields(record, links, parentSelectedRecord) {
|
451
|
+
const newRecord = Object.assign({}, record);
|
452
|
+
links.forEach(link => {
|
453
|
+
const convertedParentSelectedRecord = convertType(this.dataUnit.getField(link.target).dataType, parentSelectedRecord[link.source]);
|
454
|
+
newRecord[link.target] = convertedParentSelectedRecord;
|
455
|
+
});
|
456
|
+
return newRecord;
|
457
|
+
}
|
458
|
+
handleCleanOnCopy(records) {
|
459
|
+
const cleanFields = this.getCleanOnCopyFields();
|
460
|
+
if (cleanFields.length > 0) {
|
461
|
+
records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
|
462
|
+
}
|
463
|
+
return records;
|
464
|
+
}
|
465
|
+
buildCopyWithCleanedFields(record, cleanFields) {
|
466
|
+
const newRecord = Object.assign({}, record);
|
467
|
+
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
468
|
+
return newRecord;
|
291
469
|
}
|
292
470
|
showSuccessMessage(message) {
|
293
471
|
ApplicationUtils.info(message, { iconName: "check" });
|
@@ -295,9 +473,19 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
295
473
|
isAllowed(flag) {
|
296
474
|
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
297
475
|
}
|
298
|
-
buildDataState() {
|
476
|
+
buildDataState(actionType) {
|
477
|
+
var _a;
|
299
478
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
300
479
|
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
480
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
481
|
+
let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
|
482
|
+
const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
|
483
|
+
if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
|
484
|
+
rowMetadata = this.doGetRowMetadata(selectedRecord);
|
485
|
+
}
|
486
|
+
else if (rowMetadata) {
|
487
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
488
|
+
}
|
301
489
|
return new DataStateImpl({
|
302
490
|
insertionMode: this.dataUnit.hasNewRecord(),
|
303
491
|
isStartingInsertionMode,
|
@@ -308,10 +496,48 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
308
496
|
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
309
497
|
selectedRecords: undefined,
|
310
498
|
selectionInfo,
|
311
|
-
selectedRecord
|
312
|
-
recordsIsEmpty: this.dataUnit.records.length === 0
|
499
|
+
selectedRecord,
|
500
|
+
recordsIsEmpty: this.dataUnit.records.length === 0,
|
501
|
+
metadataByRow: this._metadataByRow,
|
502
|
+
rowMetadata
|
313
503
|
});
|
314
504
|
}
|
505
|
+
async handleDataSaved(action) {
|
506
|
+
const newRowMetadata = await this.handleLoadRowMetadata(action);
|
507
|
+
if (newRowMetadata) {
|
508
|
+
newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
|
509
|
+
}
|
510
|
+
const recordId = action.payload.records[0].__record__id__;
|
511
|
+
this._metadataByRow.set(recordId, newRowMetadata);
|
512
|
+
this.dataState = this.buildDataState();
|
513
|
+
if (this.ignoreSaveMessage) {
|
514
|
+
return;
|
515
|
+
}
|
516
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
517
|
+
if (msg != undefined) {
|
518
|
+
this.showSuccessMessage(msg);
|
519
|
+
}
|
520
|
+
}
|
521
|
+
handleRecordsRemoved(action) {
|
522
|
+
var _a, _b;
|
523
|
+
const cachedRecords = action.payload.cachedRecords;
|
524
|
+
let removeFinishMsg;
|
525
|
+
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
526
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
527
|
+
}
|
528
|
+
else {
|
529
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
530
|
+
}
|
531
|
+
if (removeFinishMsg != undefined) {
|
532
|
+
this.showSuccessMessage(removeFinishMsg);
|
533
|
+
}
|
534
|
+
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
535
|
+
const paginationInfo = this.dataUnit.getPaginationInfo();
|
536
|
+
if (paginationInfo) {
|
537
|
+
const page = recordsCount > 0 || paginationInfo.hasMore ? paginationInfo.currentPage : 0;
|
538
|
+
this.dataUnit.gotoPage(page);
|
539
|
+
}
|
540
|
+
}
|
315
541
|
/**
|
316
542
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
317
543
|
* através de um pequeno modulo na estrutura da aplicação:
|
@@ -353,6 +579,7 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
353
579
|
}
|
354
580
|
}
|
355
581
|
async loadDataUnit() {
|
582
|
+
var _a;
|
356
583
|
if (this.dataUnit == null && this._application && this.entityName) {
|
357
584
|
this.dataUnit = await this.getDataUnitParentOrChild();
|
358
585
|
}
|
@@ -361,6 +588,10 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
361
588
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
362
589
|
this.dataUnit.addInterceptor(this);
|
363
590
|
this.dataUnit.subscribe(this._dataUnitObserver);
|
591
|
+
await this.dataUnit.loadMetadata();
|
592
|
+
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
593
|
+
this.getMetadataByRow(this.dataUnit);
|
594
|
+
}
|
364
595
|
this.dataState = this.buildDataState();
|
365
596
|
let resolver;
|
366
597
|
while (resolver = this._onDataUnitResolve.pop()) {
|
@@ -379,20 +610,40 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
379
610
|
return;
|
380
611
|
}
|
381
612
|
handlerLinkFields() {
|
382
|
-
var _a, _b;
|
383
|
-
const
|
384
|
-
if (!
|
613
|
+
var _a, _b, _c, _d;
|
614
|
+
const parentDU = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
615
|
+
if (!parentDU)
|
385
616
|
return;
|
386
|
-
const
|
617
|
+
const childName = (_c = this.entityName) !== null && _c !== void 0 ? _c : this.getCleanDataUnitName();
|
618
|
+
const child = parentDU.getChildInfo(childName);
|
387
619
|
if (!child)
|
388
620
|
return;
|
389
|
-
const
|
390
|
-
(
|
391
|
-
|
621
|
+
const links = (_d = child === null || child === void 0 ? void 0 : child.links) === null || _d === void 0 ? void 0 : _d.map(link => link.target);
|
622
|
+
this.handleDUWithLinks(links);
|
623
|
+
}
|
624
|
+
handleDUWithLinks(fieldsToLink) {
|
625
|
+
this.fieldsToLink = fieldsToLink;
|
626
|
+
const metadata = Object.assign({}, this.dataUnit.metadata);
|
627
|
+
this.processLinks(metadata);
|
628
|
+
this.dataUnit.metadata = metadata;
|
629
|
+
this.dataUnitFieldsHidded.emit();
|
630
|
+
}
|
631
|
+
processLinks(metadata) {
|
632
|
+
var _a;
|
633
|
+
(_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
634
|
+
var _a;
|
635
|
+
if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
|
392
636
|
field.visible = false;
|
393
637
|
}
|
394
638
|
});
|
395
|
-
|
639
|
+
}
|
640
|
+
getCleanDataUnitName() {
|
641
|
+
var _a;
|
642
|
+
const uri = this.dataUnit.name;
|
643
|
+
if (StringUtils.isEmpty(uri))
|
644
|
+
return uri;
|
645
|
+
const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
|
646
|
+
return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
|
396
647
|
}
|
397
648
|
static getNearestInstance(element) {
|
398
649
|
let parent = element.parentElement;
|
@@ -419,8 +670,9 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
419
670
|
this.dataUnit.releaseCallbacks();
|
420
671
|
}
|
421
672
|
}
|
422
|
-
componentDidLoad() {
|
423
|
-
this.loadDataUnit();
|
673
|
+
async componentDidLoad() {
|
674
|
+
await this.loadDataUnit();
|
675
|
+
this.handlerLinkFields();
|
424
676
|
}
|
425
677
|
render() {
|
426
678
|
return (h(Host, null));
|
@@ -447,8 +699,12 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
447
699
|
"ignoreSaveMessage": [4, "ignore-save-message"],
|
448
700
|
"configName": [1, "config-name"],
|
449
701
|
"resourceID": [1, "resource-i-d"],
|
702
|
+
"fieldsToLink": [32],
|
450
703
|
"getDataUnit": [64],
|
451
|
-
"getSelectedRecordsIDsInfo": [64]
|
704
|
+
"getSelectedRecordsIDsInfo": [64],
|
705
|
+
"getFieldsWithRmp": [64],
|
706
|
+
"getFieldsWithRmPrecision": [64],
|
707
|
+
"getRowMetadata": [64]
|
452
708
|
}]);
|
453
709
|
class DataStateImpl {
|
454
710
|
constructor(datastate) {
|
@@ -462,6 +718,8 @@ class DataStateImpl {
|
|
462
718
|
this.selectionInfo = datastate.selectionInfo;
|
463
719
|
this.selectedRecord = datastate.selectedRecord;
|
464
720
|
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
721
|
+
this.metadataByRow = datastate.metadataByRow;
|
722
|
+
this.rowMetadata = datastate.rowMetadata;
|
465
723
|
}
|
466
724
|
get selectedRecords() {
|
467
725
|
var _a;
|
@@ -486,4 +744,4 @@ function defineCustomElement() {
|
|
486
744
|
} });
|
487
745
|
}
|
488
746
|
|
489
|
-
export { SnkDataUnit as S, defineCustomElement as d };
|
747
|
+
export { SnkDataUnit as S, defineCustomElement as d, getSelectedIDs as g };
|