@sankhyalabs/sankhyablocks 8.15.3 → 8.16.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{ConfigStorage-942ce74b.js → ConfigStorage-a343e418.js} +1 -0
- package/dist/cjs/{SnkMultiSelectionListDataSource-3c08d25c.js → IExporterProvider-597949f9.js} +94 -4
- package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
- package/dist/cjs/{SnkFormConfigManager-f9dc0d28.js → SnkFormConfigManager-166cbd1f.js} +8 -7
- package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-897ffd08.js} +9 -13
- package/dist/cjs/{pesquisa-fetcher-562d281f.js → dataunit-fetcher-688d3f05.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 +5 -3
- package/dist/cjs/snk-application.cjs.entry.js +35 -12
- package/dist/cjs/snk-attach.cjs.entry.js +71 -46
- package/dist/cjs/snk-crud.cjs.entry.js +101 -10
- package/dist/cjs/snk-data-exporter.cjs.entry.js +315 -85
- package/dist/cjs/snk-data-unit-8fa7917a.js +689 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +12 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +50 -10
- package/dist/cjs/snk-filter-bar.cjs.entry.js +6 -2
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
- package/dist/cjs/snk-form.cjs.entry.js +52 -7
- package/dist/cjs/snk-grid.cjs.entry.js +165 -108
- package/dist/cjs/{snk-guides-viewer-bb6087cd.js → snk-guides-viewer-9c682034.js} +43 -10
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -7
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +268 -40
- 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 +305 -7
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +136 -2
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +161 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +134 -7
- 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 +538 -218
- 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 +7 -6
- package/dist/collection/components/snk-form-config/snk-form-config.js +1 -1
- package/dist/collection/components/snk-grid/snk-grid.js +240 -101
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +406 -20
- 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/configs/ConfigStorage.js +1 -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 +2 -1
- package/dist/components/ConfigStorage.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 +7 -6
- package/dist/components/SnkMessageBuilder.js +9 -13
- 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 +110 -11
- package/dist/components/snk-data-exporter2.js +309 -85
- package/dist/components/snk-data-unit2.js +485 -216
- package/dist/components/snk-detail-view2.js +96 -14
- package/dist/components/snk-expression-item2.js +1 -1
- package/dist/components/snk-filter-bar2.js +6 -1
- package/dist/components/snk-form-config2.js +1 -1
- package/dist/components/snk-form-view2.js +72 -1
- package/dist/components/snk-form.js +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 +263 -25
- package/dist/components/snk-taskbar2.js +6 -5
- package/dist/esm/{ConfigStorage-86187da3.js → ConfigStorage-3806514e.js} +1 -0
- package/dist/esm/{SnkMultiSelectionListDataSource-6a879955.js → IExporterProvider-63a188b6.js} +93 -5
- package/dist/esm/RecordIDUtils-87d02110.js +41 -0
- package/dist/esm/{SnkFormConfigManager-f53f9f87.js → SnkFormConfigManager-31b24066.js} +8 -7
- package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-571462fb.js} +9 -13
- package/dist/esm/{pesquisa-fetcher-c7ce8ee7.js → dataunit-fetcher-264191b2.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 +5 -3
- package/dist/esm/snk-application.entry.js +34 -11
- package/dist/esm/snk-attach.entry.js +66 -41
- package/dist/esm/snk-crud.entry.js +101 -10
- package/dist/esm/snk-data-exporter.entry.js +316 -86
- package/dist/esm/snk-data-unit-f5cbe64b.js +687 -0
- package/dist/esm/snk-data-unit.entry.js +12 -2
- package/dist/esm/snk-detail-view.entry.js +50 -10
- package/dist/esm/snk-filter-bar.entry.js +6 -2
- package/dist/esm/snk-filter-modal-item.entry.js +1 -1
- package/dist/esm/snk-form-config.entry.js +1 -1
- package/dist/esm/snk-form-view.entry.js +67 -0
- package/dist/esm/snk-form.entry.js +52 -7
- package/dist/esm/snk-grid.entry.js +163 -106
- package/dist/esm/{snk-guides-viewer-1d95ebf2.js → snk-guides-viewer-8f6960a2.js} +43 -10
- package/dist/esm/snk-guides-viewer.entry.js +9 -7
- package/dist/esm/snk-personalized-filter.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +256 -28
- 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-17def7cd.js +1 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-28ee0972.js +1 -0
- package/dist/sankhyablocks/p-2a408684.js +1 -0
- package/dist/sankhyablocks/{p-eae7a817.entry.js → p-2c68b3ae.entry.js} +1 -1
- package/dist/sankhyablocks/p-30cf616e.js +1 -0
- package/dist/sankhyablocks/p-3a212712.js +1 -0
- package/dist/sankhyablocks/p-450c60e4.entry.js +1 -0
- package/dist/sankhyablocks/{p-a1d72395.entry.js → p-47db7e88.entry.js} +1 -1
- package/dist/sankhyablocks/p-4e5e1313.entry.js +1 -0
- package/dist/sankhyablocks/{p-aff76a53.js → p-52920496.js} +1 -1
- package/dist/sankhyablocks/p-62ba211a.entry.js +1 -0
- package/dist/sankhyablocks/p-6bb2f3e9.entry.js +1 -0
- package/dist/sankhyablocks/p-7505da04.entry.js +1 -0
- package/dist/sankhyablocks/p-7619bdb1.entry.js +11 -0
- package/dist/sankhyablocks/p-7a85fd49.entry.js +1 -0
- package/dist/sankhyablocks/{p-ae4fc9a9.js → p-7e7a7473.js} +1 -1
- package/dist/sankhyablocks/p-7ef9c55c.js +1 -0
- package/dist/sankhyablocks/p-80042dc6.entry.js +1 -0
- package/dist/sankhyablocks/p-8c59edd7.entry.js +1 -0
- package/dist/sankhyablocks/p-9606509c.entry.js +1 -0
- package/dist/sankhyablocks/p-9863d682.js +1 -0
- package/dist/sankhyablocks/p-ae93d46a.entry.js +1 -0
- package/dist/sankhyablocks/p-af8efd95.js +6 -0
- package/dist/sankhyablocks/p-d6e26ea8.entry.js +1 -0
- package/dist/sankhyablocks/p-f2809746.entry.js +1 -0
- package/dist/sankhyablocks/p-f4450320.entry.js +1 -0
- package/dist/sankhyablocks/p-fe79f83a.js +60 -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 +45 -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 +24 -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 +66 -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-form-config/SnkFormConfigManager.d.ts +2 -2
- package/dist/types/components/snk-grid/snk-grid.d.ts +46 -6
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +62 -4
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
- package/dist/types/components.d.ts +261 -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-0594db5a.entry.js +0 -1
- package/dist/sankhyablocks/p-06e13db2.js +0 -1
- package/dist/sankhyablocks/p-07a61550.entry.js +0 -1
- package/dist/sankhyablocks/p-1403a4b6.entry.js +0 -1
- package/dist/sankhyablocks/p-14a08904.entry.js +0 -1
- package/dist/sankhyablocks/p-15802c59.entry.js +0 -1
- package/dist/sankhyablocks/p-235dc7b1.js +0 -65
- package/dist/sankhyablocks/p-32556aa6.js +0 -1
- package/dist/sankhyablocks/p-38289a55.js +0 -1
- package/dist/sankhyablocks/p-3c632d48.js +0 -1
- package/dist/sankhyablocks/p-3f833983.entry.js +0 -1
- package/dist/sankhyablocks/p-52c8e589.js +0 -1
- package/dist/sankhyablocks/p-5e1502b6.entry.js +0 -11
- package/dist/sankhyablocks/p-74d349c3.entry.js +0 -1
- package/dist/sankhyablocks/p-93167e28.entry.js +0 -1
- package/dist/sankhyablocks/p-add17f6a.entry.js +0 -1
- package/dist/sankhyablocks/p-bd47dd16.entry.js +0 -1
- package/dist/sankhyablocks/p-c1f88236.entry.js +0 -1
- package/dist/sankhyablocks/p-ccdd5332.entry.js +0 -1
- package/dist/sankhyablocks/p-ee9536bc.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;
|
@@ -62,6 +54,7 @@ export class SnkDataUnit {
|
|
62
54
|
this.ignoreSaveMessage = undefined;
|
63
55
|
this.configName = undefined;
|
64
56
|
this.resourceID = undefined;
|
57
|
+
this.domainMessagesBuilder = undefined;
|
65
58
|
}
|
66
59
|
observePageSize() {
|
67
60
|
if (this.dataUnit) {
|
@@ -117,179 +110,340 @@ export class SnkDataUnit {
|
|
117
110
|
* @returns Retorna a lista de IDs dos registros selecionados.
|
118
111
|
*/
|
119
112
|
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
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
113
|
+
return Promise.resolve(getSelectedIDs(this.dataUnit));
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* Retorna os campos que possuem a propriedade "rmp" (Row Metadata Provider).
|
117
|
+
*/
|
118
|
+
async getFieldsWithRmp() {
|
119
|
+
return this._fieldsWithRmp;
|
120
|
+
}
|
121
|
+
/**
|
122
|
+
* Retorna os campos que possuem a propriedade "rm_precision" (Row Metadata Precision).
|
123
|
+
*/
|
124
|
+
async getFieldsWithRmPrecision() {
|
125
|
+
return this._fieldsWithRmPrecision;
|
126
|
+
}
|
127
|
+
/**
|
128
|
+
* Busca os metadados da linha selecionada.
|
129
|
+
*/
|
130
|
+
async getRowMetadata(record) {
|
131
|
+
return this.doGetRowMetadata(record);
|
132
|
+
}
|
133
|
+
doGetRowMetadata(record) {
|
134
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
135
|
+
if (!record && !selectedRecord) {
|
136
|
+
return;
|
137
|
+
}
|
138
|
+
const currentRecord = record || selectedRecord;
|
139
|
+
const recordId = typeof currentRecord === 'string' ? currentRecord : currentRecord.__record__id__;
|
140
|
+
const rowMetadata = this._metadataByRow.get(recordId);
|
141
|
+
if (!rowMetadata) {
|
142
|
+
return;
|
143
|
+
}
|
144
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
145
|
+
return Object.assign({}, rowMetadata);
|
146
|
+
}
|
147
|
+
buildGetPropRowMetadata(rowMetadata) {
|
148
|
+
return (propPath, fieldName) => {
|
149
|
+
if (propPath === "rm_precision") {
|
150
|
+
propPath = this.resolvePrecisionFromMetadata(fieldName);
|
151
|
+
}
|
152
|
+
return ObjectUtils.getProp(rowMetadata, propPath);
|
153
|
+
};
|
154
|
+
}
|
155
|
+
resolvePrecisionFromMetadata(fieldName) {
|
156
|
+
var _a, _b;
|
157
|
+
if (!fieldName) {
|
158
|
+
ApplicationUtils.error(this.getMessage("snkDataUnit.fieldNameRequired"));
|
159
|
+
return;
|
155
160
|
}
|
156
|
-
|
161
|
+
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;
|
162
|
+
if (!rmPrecision) {
|
163
|
+
return '';
|
164
|
+
}
|
165
|
+
let rmPrecisionPath = rmPrecision.split('.').filter((_, index) => index !== 1).join('.');
|
166
|
+
return rmPrecisionPath;
|
157
167
|
}
|
158
168
|
getCleanOnCopyFields() {
|
159
169
|
var _a;
|
160
170
|
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
171
|
}
|
162
|
-
|
163
|
-
|
164
|
-
var _a
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
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
|
-
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);
|
172
|
+
fillFieldsWithRmp(payload) {
|
173
|
+
payload.fields.forEach((field) => {
|
174
|
+
var _a;
|
175
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rmp) && !this._fieldsWithRmp.includes(field.name)) {
|
176
|
+
this._fieldsWithRmp.push(field.name);
|
177
|
+
}
|
178
|
+
});
|
179
|
+
}
|
180
|
+
fillFieldsWithRmPrecision(payload) {
|
181
|
+
payload.fields.forEach((field) => {
|
182
|
+
var _a;
|
183
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !this._fieldsWithRmPrecision.includes(field.name)) {
|
184
|
+
this._fieldsWithRmPrecision.push(field.name);
|
185
|
+
}
|
186
|
+
});
|
187
|
+
}
|
188
|
+
getCacheName(fieldName, metadataName, fieldValue) {
|
189
|
+
const cacheName = [fieldName, metadataName, fieldValue].join("_");
|
190
|
+
return cacheName;
|
191
|
+
}
|
192
|
+
updateDataStateRmp(newValue) {
|
193
|
+
const newRowMetadata = Object.assign({}, newValue);
|
194
|
+
this.dataState.rowMetadata = newRowMetadata;
|
195
|
+
}
|
196
|
+
saveCacheRmd(record) {
|
197
|
+
const rmd = record.__record__metadata__;
|
198
|
+
const keysRmd = Object.keys(rmd);
|
199
|
+
keysRmd.shift();
|
200
|
+
keysRmd.forEach((fieldName) => {
|
201
|
+
const fieldValue = getRecordValue(record, fieldName);
|
202
|
+
const cacheName = this.getCacheName(fieldName, rmd.provider, fieldValue);
|
203
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, rmd));
|
204
|
+
});
|
205
|
+
}
|
206
|
+
getMetadataByRow(payload) {
|
207
|
+
var _a;
|
208
|
+
if (!((_a = payload.records) === null || _a === void 0 ? void 0 : _a.length)) {
|
209
|
+
return payload;
|
210
|
+
}
|
211
|
+
if (!this._fieldsWithRmp.length) {
|
212
|
+
const records = payload.records.map((record) => {
|
213
|
+
delete record.__record__metadata__;
|
214
|
+
return record;
|
215
|
+
});
|
216
|
+
return Object.assign(Object.assign({}, payload), { records });
|
217
|
+
}
|
218
|
+
const records = payload.records.map((record) => {
|
219
|
+
if (!record.__record__metadata__) {
|
220
|
+
return record;
|
281
221
|
}
|
222
|
+
this.saveCacheRmd(record);
|
223
|
+
const rowMetadata = Object.assign({}, record.__record__metadata__);
|
224
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
225
|
+
this._metadataByRow.set(record.__record__id__, rowMetadata);
|
226
|
+
delete record.__record__metadata__;
|
227
|
+
return record;
|
228
|
+
});
|
229
|
+
return Object.assign(Object.assign({}, payload), { records });
|
230
|
+
}
|
231
|
+
interceptRecordsAdded(action) {
|
232
|
+
if (!this.isAllowed("INSERT")) {
|
233
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
|
237
|
+
}
|
238
|
+
interceptRecordsCopied(action) {
|
239
|
+
if (!this.isAllowed("CLONE")) {
|
240
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
241
|
+
return;
|
242
|
+
}
|
243
|
+
return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
|
244
|
+
}
|
245
|
+
async interceptDataChange(action) {
|
246
|
+
if (this.isAllowed("UPDATE")) {
|
247
|
+
return action;
|
248
|
+
}
|
249
|
+
if (this._openedAlert) {
|
250
|
+
await this.dataUnit.cancelEdition();
|
251
|
+
return;
|
252
|
+
}
|
253
|
+
this._openedAlert = true;
|
254
|
+
await this.dataUnit.cancelEdition();
|
255
|
+
await ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
256
|
+
this._openedAlert = false;
|
257
|
+
}
|
258
|
+
async interceptSavingData(action) {
|
259
|
+
if (!this.beforeSave) {
|
260
|
+
return action;
|
261
|
+
}
|
262
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
263
|
+
if (continueAction instanceof Promise) {
|
264
|
+
const result = await continueAction;
|
265
|
+
return result ? action : undefined;
|
266
|
+
}
|
267
|
+
return continueAction ? action : undefined;
|
268
|
+
}
|
269
|
+
interceptDataSaved(action) {
|
270
|
+
if (this.afterSave) {
|
271
|
+
this.afterSave(this.dataUnit);
|
272
|
+
return;
|
273
|
+
}
|
274
|
+
return action;
|
275
|
+
}
|
276
|
+
async interceptEditionCanceled(action) {
|
277
|
+
var _a, _b;
|
278
|
+
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)) {
|
279
|
+
return action;
|
280
|
+
}
|
281
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
282
|
+
if (cancelConfirmation == undefined) {
|
283
|
+
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
284
|
+
return action;
|
285
|
+
}
|
286
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
287
|
+
const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
|
288
|
+
confirm && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
289
|
+
return confirm ? action : undefined;
|
290
|
+
}
|
291
|
+
async interceptRemovingRecords(action) {
|
292
|
+
var _a, _b, _c;
|
293
|
+
if (!this.isAllowed("REMOVE")) {
|
294
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
295
|
+
return;
|
296
|
+
}
|
297
|
+
let multipleSelection = false;
|
298
|
+
let removeConfirmation = !((_a = action.payload) === null || _a === void 0 ? void 0 : _a.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
299
|
+
const selection = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getSelectionInfo();
|
300
|
+
if (!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
301
|
+
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
302
|
+
multipleSelection = true;
|
303
|
+
}
|
304
|
+
if (!removeConfirmation) {
|
305
|
+
return action;
|
306
|
+
}
|
307
|
+
const options = {
|
308
|
+
canClose: false,
|
309
|
+
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
310
|
+
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
311
|
+
btnConfirmDanger: false
|
312
|
+
};
|
313
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
314
|
+
const confirm = await ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options);
|
315
|
+
return confirm ? action : undefined;
|
316
|
+
}
|
317
|
+
interceptDataLoaded(action) {
|
318
|
+
const newPayload = this.getMetadataByRow(action.payload);
|
319
|
+
action = new DataUnitAction(Action.DATA_LOADED, newPayload);
|
320
|
+
return action;
|
321
|
+
}
|
322
|
+
interceptMetadataLoaded(action) {
|
323
|
+
this.fillFieldsWithRmp(action.payload);
|
324
|
+
this.fillFieldsWithRmPrecision(action.payload);
|
325
|
+
return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
|
326
|
+
}
|
327
|
+
async interceptAction(action) {
|
328
|
+
switch (action.type) {
|
329
|
+
case Action.RECORDS_ADDED:
|
330
|
+
return this.interceptRecordsAdded(action);
|
331
|
+
case Action.RECORDS_COPIED:
|
332
|
+
return this.interceptRecordsCopied(action);
|
333
|
+
case Action.DATA_CHANGED:
|
334
|
+
await this.handleLoadRowMetadata(action);
|
335
|
+
return await this.interceptDataChange(action);
|
336
|
+
case Action.CHANGING_DATA:
|
337
|
+
return await this.interceptDataChange(action);
|
338
|
+
case Action.SAVING_DATA:
|
339
|
+
return await this.interceptSavingData(action);
|
340
|
+
case Action.DATA_SAVED:
|
341
|
+
return this.interceptDataSaved(action);
|
342
|
+
case Action.EDITION_CANCELED:
|
343
|
+
return await this.interceptEditionCanceled(action);
|
344
|
+
case Action.REMOVING_RECORDS:
|
345
|
+
return await this.interceptRemovingRecords(action);
|
346
|
+
case Action.DATA_LOADED:
|
347
|
+
return this.interceptDataLoaded(action);
|
348
|
+
case Action.METADATA_LOADED:
|
349
|
+
return this.interceptMetadataLoaded(action);
|
350
|
+
default:
|
351
|
+
return action;
|
352
|
+
}
|
353
|
+
}
|
354
|
+
async handleLoadRowMetadata(action) {
|
355
|
+
const record = action.type === Action.DATA_CHANGED ? action.payload : action.payload.changes[0].record;
|
356
|
+
const keysPayload = Object.keys(record);
|
357
|
+
const rmpField = keysPayload.find((field) => this._fieldsWithRmp.includes(field));
|
358
|
+
if (rmpField) {
|
359
|
+
const metadataName = this.dataUnit.getField(rmpField).properties.rmp;
|
360
|
+
const fieldValue = getRecordValue(record, rmpField);
|
361
|
+
return await this.updateRowMetadata({
|
362
|
+
fieldName: rmpField,
|
363
|
+
fieldValue,
|
364
|
+
metadataName,
|
365
|
+
updatedFields: record,
|
366
|
+
});
|
367
|
+
}
|
368
|
+
}
|
369
|
+
async updateRowMetadata({ fieldName, fieldValue, metadataName, updatedFields }) {
|
370
|
+
const cacheName = this.getCacheName(fieldName, metadataName, fieldValue);
|
371
|
+
const cacheValue = this._rowMetadataCache.get(cacheName);
|
372
|
+
if (cacheValue) {
|
373
|
+
this.updateDataStateRmp(cacheValue);
|
374
|
+
return cacheValue;
|
375
|
+
}
|
376
|
+
else {
|
377
|
+
const datasetStrategy = new DatasetStrategy();
|
378
|
+
const response = await datasetStrategy.loadRowMetadata(this, fieldName, metadataName, updatedFields);
|
379
|
+
this.updateDataStateRmp(response._rmd);
|
380
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, response._rmd));
|
381
|
+
return Object.assign({}, response._rmd);
|
382
|
+
}
|
383
|
+
}
|
384
|
+
handleDULinksOnMetadataLoaded(payload) {
|
385
|
+
const metadata = Object.assign({}, payload);
|
386
|
+
this.processLinks(metadata);
|
387
|
+
return metadata;
|
388
|
+
}
|
389
|
+
handleRecordsCopied(initialRecords) {
|
390
|
+
let records = [...initialRecords];
|
391
|
+
records = this.handleCleanOnCopy(records);
|
392
|
+
return this.handleLinksWithParent(records);
|
393
|
+
}
|
394
|
+
handleLinksWithParent(records) {
|
395
|
+
var _a, _b;
|
396
|
+
const parentDataUnit = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
397
|
+
if (!parentDataUnit)
|
398
|
+
return records;
|
399
|
+
const parentSelectedRecord = parentDataUnit.getSelectedRecord();
|
400
|
+
const selfInfo = parentDataUnit === null || parentDataUnit === void 0 ? void 0 : parentDataUnit.getChildInfo(this.getCleanDataUnitName());
|
401
|
+
const { links } = selfInfo;
|
402
|
+
if (!links || links.length === 0)
|
403
|
+
return records;
|
404
|
+
return records.map(record => {
|
405
|
+
return this.buildRecordWithLinkedFields(record, links, parentSelectedRecord);
|
282
406
|
});
|
283
407
|
}
|
408
|
+
buildRecordWithLinkedFields(record, links, parentSelectedRecord) {
|
409
|
+
const newRecord = Object.assign({}, record);
|
410
|
+
links.forEach(link => {
|
411
|
+
const convertedParentSelectedRecord = convertType(this.dataUnit.getField(link.target).dataType, parentSelectedRecord[link.source]);
|
412
|
+
newRecord[link.target] = convertedParentSelectedRecord;
|
413
|
+
});
|
414
|
+
return newRecord;
|
415
|
+
}
|
416
|
+
handleCleanOnCopy(records) {
|
417
|
+
const cleanFields = this.getCleanOnCopyFields();
|
418
|
+
if (cleanFields.length > 0) {
|
419
|
+
records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
|
420
|
+
}
|
421
|
+
return records;
|
422
|
+
}
|
423
|
+
buildCopyWithCleanedFields(record, cleanFields) {
|
424
|
+
const newRecord = Object.assign({}, record);
|
425
|
+
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
426
|
+
return newRecord;
|
427
|
+
}
|
284
428
|
showSuccessMessage(message) {
|
285
429
|
ApplicationUtils.info(message, { iconName: "check" });
|
286
430
|
}
|
287
431
|
isAllowed(flag) {
|
288
432
|
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
289
433
|
}
|
290
|
-
buildDataState() {
|
434
|
+
buildDataState(actionType) {
|
435
|
+
var _a;
|
291
436
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
292
437
|
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
438
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
439
|
+
let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
|
440
|
+
const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
|
441
|
+
if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
|
442
|
+
rowMetadata = this.doGetRowMetadata(selectedRecord);
|
443
|
+
}
|
444
|
+
else if (rowMetadata) {
|
445
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
446
|
+
}
|
293
447
|
return new DataStateImpl({
|
294
448
|
insertionMode: this.dataUnit.hasNewRecord(),
|
295
449
|
isStartingInsertionMode,
|
@@ -300,20 +454,62 @@ export class SnkDataUnit {
|
|
300
454
|
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
301
455
|
selectedRecords: undefined,
|
302
456
|
selectionInfo,
|
303
|
-
selectedRecord
|
304
|
-
recordsIsEmpty: this.dataUnit.records.length === 0
|
457
|
+
selectedRecord,
|
458
|
+
recordsIsEmpty: this.dataUnit.records.length === 0,
|
459
|
+
metadataByRow: this._metadataByRow,
|
460
|
+
rowMetadata
|
305
461
|
});
|
306
462
|
}
|
463
|
+
async handleDataSaved(action) {
|
464
|
+
const newRowMetadata = await this.handleLoadRowMetadata(action);
|
465
|
+
if (newRowMetadata) {
|
466
|
+
newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
|
467
|
+
}
|
468
|
+
const recordId = action.payload.records[0].__record__id__;
|
469
|
+
this._metadataByRow.set(recordId, newRowMetadata);
|
470
|
+
this.dataState = this.buildDataState();
|
471
|
+
if (this.ignoreSaveMessage) {
|
472
|
+
return;
|
473
|
+
}
|
474
|
+
const saveOperation = action.payload.changes[0]._operation.toLowerCase();
|
475
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0], saveOperation);
|
476
|
+
if (msg != undefined) {
|
477
|
+
this.showSuccessMessage(msg);
|
478
|
+
}
|
479
|
+
}
|
480
|
+
handleRecordsRemoved(action) {
|
481
|
+
var _a, _b;
|
482
|
+
const cachedRecords = action.payload.cachedRecords;
|
483
|
+
let removeFinishMsg;
|
484
|
+
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
485
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
486
|
+
}
|
487
|
+
else {
|
488
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
489
|
+
}
|
490
|
+
if (removeFinishMsg != undefined) {
|
491
|
+
this.showSuccessMessage(removeFinishMsg);
|
492
|
+
}
|
493
|
+
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
494
|
+
const paginationInfo = this.dataUnit.getPaginationInfo();
|
495
|
+
if (paginationInfo) {
|
496
|
+
const page = recordsCount > 0 || paginationInfo.hasMore ? paginationInfo.currentPage : 0;
|
497
|
+
this.dataUnit.gotoPage(page);
|
498
|
+
}
|
499
|
+
}
|
307
500
|
/**
|
308
501
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
309
502
|
* através de um pequeno modulo na estrutura da aplicação:
|
310
503
|
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
311
504
|
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
|
312
505
|
*/
|
313
|
-
getMessage(key, params = undefined) {
|
506
|
+
getMessage(key, params = undefined, customOperation) {
|
314
507
|
if (!params) {
|
315
508
|
params = this.getMessageParams();
|
316
509
|
}
|
510
|
+
if (customOperation) {
|
511
|
+
this.messagesBuilder.currentOperation = customOperation;
|
512
|
+
}
|
317
513
|
return this.messagesBuilder.getMessage(key, params);
|
318
514
|
}
|
319
515
|
getMessageParams() {
|
@@ -345,6 +541,7 @@ export class SnkDataUnit {
|
|
345
541
|
}
|
346
542
|
}
|
347
543
|
async loadDataUnit() {
|
544
|
+
var _a;
|
348
545
|
if (this.dataUnit == null && this._application && this.entityName) {
|
349
546
|
this.dataUnit = await this.getDataUnitParentOrChild();
|
350
547
|
}
|
@@ -353,6 +550,10 @@ export class SnkDataUnit {
|
|
353
550
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
354
551
|
this.dataUnit.addInterceptor(this);
|
355
552
|
this.dataUnit.subscribe(this._dataUnitObserver);
|
553
|
+
await this.dataUnit.loadMetadata();
|
554
|
+
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
555
|
+
this.getMetadataByRow(this.dataUnit);
|
556
|
+
}
|
356
557
|
this.dataState = this.buildDataState();
|
357
558
|
let resolver;
|
358
559
|
while (resolver = this._onDataUnitResolve.pop()) {
|
@@ -371,20 +572,40 @@ export class SnkDataUnit {
|
|
371
572
|
return;
|
372
573
|
}
|
373
574
|
handlerLinkFields() {
|
374
|
-
var _a, _b;
|
375
|
-
const
|
376
|
-
if (!
|
575
|
+
var _a, _b, _c, _d;
|
576
|
+
const parentDU = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
577
|
+
if (!parentDU)
|
377
578
|
return;
|
378
|
-
const
|
579
|
+
const childName = (_c = this.entityName) !== null && _c !== void 0 ? _c : this.getCleanDataUnitName();
|
580
|
+
const child = parentDU.getChildInfo(childName);
|
379
581
|
if (!child)
|
380
582
|
return;
|
381
|
-
const
|
382
|
-
(
|
383
|
-
|
583
|
+
const links = (_d = child === null || child === void 0 ? void 0 : child.links) === null || _d === void 0 ? void 0 : _d.map(link => link.target);
|
584
|
+
this.handleDUWithLinks(links);
|
585
|
+
}
|
586
|
+
handleDUWithLinks(fieldsToLink) {
|
587
|
+
this.fieldsToLink = fieldsToLink;
|
588
|
+
const metadata = Object.assign({}, this.dataUnit.metadata);
|
589
|
+
this.processLinks(metadata);
|
590
|
+
this.dataUnit.metadata = metadata;
|
591
|
+
this.dataUnitFieldsHidded.emit();
|
592
|
+
}
|
593
|
+
processLinks(metadata) {
|
594
|
+
var _a;
|
595
|
+
(_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
596
|
+
var _a;
|
597
|
+
if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
|
384
598
|
field.visible = false;
|
385
599
|
}
|
386
600
|
});
|
387
|
-
|
601
|
+
}
|
602
|
+
getCleanDataUnitName() {
|
603
|
+
var _a;
|
604
|
+
const uri = this.dataUnit.name;
|
605
|
+
if (StringUtils.isEmpty(uri))
|
606
|
+
return uri;
|
607
|
+
const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
|
608
|
+
return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
|
388
609
|
}
|
389
610
|
static getNearestInstance(element) {
|
390
611
|
let parent = element.parentElement;
|
@@ -395,6 +616,13 @@ export class SnkDataUnit {
|
|
395
616
|
parent = parent.parentElement;
|
396
617
|
}
|
397
618
|
}
|
619
|
+
instanceMessagesBuilder() {
|
620
|
+
var _a;
|
621
|
+
if (this.messagesBuilder) {
|
622
|
+
return;
|
623
|
+
}
|
624
|
+
this.messagesBuilder = new SnkMessageBuilder((_a = this.domainMessagesBuilder) !== null && _a !== void 0 ? _a : this.entityName);
|
625
|
+
}
|
398
626
|
//---------------------------------------------
|
399
627
|
// Lifecycle web component
|
400
628
|
//---------------------------------------------
|
@@ -402,17 +630,16 @@ export class SnkDataUnit {
|
|
402
630
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
403
631
|
this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
|
404
632
|
this._parentSnkDataUnit = this.getParentSnkDataUnit();
|
405
|
-
|
406
|
-
this.messagesBuilder = new SnkMessageBuilder(this.entityName);
|
407
|
-
}
|
633
|
+
this.instanceMessagesBuilder();
|
408
634
|
}
|
409
635
|
disconnectedCallback() {
|
410
636
|
if (this.dataUnit) {
|
411
637
|
this.dataUnit.releaseCallbacks();
|
412
638
|
}
|
413
639
|
}
|
414
|
-
componentDidLoad() {
|
415
|
-
this.loadDataUnit();
|
640
|
+
async componentDidLoad() {
|
641
|
+
await this.loadDataUnit();
|
642
|
+
this.handlerLinkFields();
|
416
643
|
}
|
417
644
|
render() {
|
418
645
|
return (h(Host, null));
|
@@ -643,9 +870,31 @@ export class SnkDataUnit {
|
|
643
870
|
},
|
644
871
|
"attribute": "resource-i-d",
|
645
872
|
"reflect": false
|
873
|
+
},
|
874
|
+
"domainMessagesBuilder": {
|
875
|
+
"type": "string",
|
876
|
+
"mutable": false,
|
877
|
+
"complexType": {
|
878
|
+
"original": "string",
|
879
|
+
"resolved": "string",
|
880
|
+
"references": {}
|
881
|
+
},
|
882
|
+
"required": false,
|
883
|
+
"optional": false,
|
884
|
+
"docs": {
|
885
|
+
"tags": [],
|
886
|
+
"text": "Define a chave customizada para sobrescrever as mensagens (N\u00E3o pegando pela entidade)"
|
887
|
+
},
|
888
|
+
"attribute": "domain-messages-builder",
|
889
|
+
"reflect": false
|
646
890
|
}
|
647
891
|
};
|
648
892
|
}
|
893
|
+
static get states() {
|
894
|
+
return {
|
895
|
+
"fieldsToLink": {}
|
896
|
+
};
|
897
|
+
}
|
649
898
|
static get events() {
|
650
899
|
return [{
|
651
900
|
"method": "dataStateChange",
|
@@ -706,6 +955,21 @@ export class SnkDataUnit {
|
|
706
955
|
}
|
707
956
|
}
|
708
957
|
}
|
958
|
+
}, {
|
959
|
+
"method": "dataUnitFieldsHidded",
|
960
|
+
"name": "dataUnitFieldsHidded",
|
961
|
+
"bubbles": true,
|
962
|
+
"cancelable": true,
|
963
|
+
"composed": true,
|
964
|
+
"docs": {
|
965
|
+
"tags": [],
|
966
|
+
"text": "Emitido quando h\u00E1 campos no DataUnit que devem ser ocultados."
|
967
|
+
},
|
968
|
+
"complexType": {
|
969
|
+
"original": "void",
|
970
|
+
"resolved": "void",
|
971
|
+
"references": {}
|
972
|
+
}
|
709
973
|
}, {
|
710
974
|
"method": "insertionMode",
|
711
975
|
"name": "insertionMode",
|
@@ -774,10 +1038,6 @@ export class SnkDataUnit {
|
|
774
1038
|
},
|
775
1039
|
"Array": {
|
776
1040
|
"location": "global"
|
777
|
-
},
|
778
|
-
"Record": {
|
779
|
-
"location": "import",
|
780
|
-
"path": "@sankhyalabs/core"
|
781
1041
|
}
|
782
1042
|
},
|
783
1043
|
"return": "Promise<IRecordID[]>"
|
@@ -789,6 +1049,64 @@ export class SnkDataUnit {
|
|
789
1049
|
"text": "Retorna a lista de IDs dos registros selecionados."
|
790
1050
|
}]
|
791
1051
|
}
|
1052
|
+
},
|
1053
|
+
"getFieldsWithRmp": {
|
1054
|
+
"complexType": {
|
1055
|
+
"signature": "() => Promise<string[]>",
|
1056
|
+
"parameters": [],
|
1057
|
+
"references": {
|
1058
|
+
"Promise": {
|
1059
|
+
"location": "global"
|
1060
|
+
}
|
1061
|
+
},
|
1062
|
+
"return": "Promise<string[]>"
|
1063
|
+
},
|
1064
|
+
"docs": {
|
1065
|
+
"text": "Retorna os campos que possuem a propriedade \"rmp\" (Row Metadata Provider).",
|
1066
|
+
"tags": []
|
1067
|
+
}
|
1068
|
+
},
|
1069
|
+
"getFieldsWithRmPrecision": {
|
1070
|
+
"complexType": {
|
1071
|
+
"signature": "() => Promise<string[]>",
|
1072
|
+
"parameters": [],
|
1073
|
+
"references": {
|
1074
|
+
"Promise": {
|
1075
|
+
"location": "global"
|
1076
|
+
}
|
1077
|
+
},
|
1078
|
+
"return": "Promise<string[]>"
|
1079
|
+
},
|
1080
|
+
"docs": {
|
1081
|
+
"text": "Retorna os campos que possuem a propriedade \"rm_precision\" (Row Metadata Precision).",
|
1082
|
+
"tags": []
|
1083
|
+
}
|
1084
|
+
},
|
1085
|
+
"getRowMetadata": {
|
1086
|
+
"complexType": {
|
1087
|
+
"signature": "(record?: Record | string) => Promise<RowMetadata>",
|
1088
|
+
"parameters": [{
|
1089
|
+
"tags": [],
|
1090
|
+
"text": ""
|
1091
|
+
}],
|
1092
|
+
"references": {
|
1093
|
+
"Promise": {
|
1094
|
+
"location": "global"
|
1095
|
+
},
|
1096
|
+
"RowMetadata": {
|
1097
|
+
"location": "local"
|
1098
|
+
},
|
1099
|
+
"Record": {
|
1100
|
+
"location": "import",
|
1101
|
+
"path": "@sankhyalabs/core"
|
1102
|
+
}
|
1103
|
+
},
|
1104
|
+
"return": "Promise<RowMetadata>"
|
1105
|
+
},
|
1106
|
+
"docs": {
|
1107
|
+
"text": "Busca os metadados da linha selecionada.",
|
1108
|
+
"tags": []
|
1109
|
+
}
|
792
1110
|
}
|
793
1111
|
};
|
794
1112
|
}
|
@@ -827,6 +1145,8 @@ class DataStateImpl {
|
|
827
1145
|
this.selectionInfo = datastate.selectionInfo;
|
828
1146
|
this.selectedRecord = datastate.selectedRecord;
|
829
1147
|
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
1148
|
+
this.metadataByRow = datastate.metadataByRow;
|
1149
|
+
this.rowMetadata = datastate.rowMetadata;
|
830
1150
|
}
|
831
1151
|
get selectedRecords() {
|
832
1152
|
var _a;
|