@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-kb-67792.0 → 0.0.0-bugfix-dev-kb-67792.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/{ConfigStorage-0a690675.js → ConfigStorage-e49214c6.js} +1 -0
- package/dist/cjs/{SnkMultiSelectionListDataSource-f79d220c.js → IExporterProvider-10b7fed5.js} +94 -4
- package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
- package/dist/cjs/{SnkFormConfigManager-d6d5db6d.js → SnkFormConfigManager-beebf47a.js} +8 -7
- package/dist/cjs/{SnkMessageBuilder-96b0f549.js → SnkMessageBuilder-cceebbae.js} +9 -13
- package/dist/cjs/{pesquisa-fetcher-cba1b3d0.js → dataunit-fetcher-d4873076.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-a1d0353f.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-f0221097.js +690 -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 +168 -111
- package/dist/cjs/{snk-guides-viewer-bfcad2d6.js → snk-guides-viewer-aafc3073.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 +269 -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 +540 -219
- 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.css +2 -0
- package/dist/collection/components/snk-grid/snk-grid.js +242 -103
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +407 -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 +487 -217
- 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 +171 -109
- package/dist/components/snk-personalized-filter2.js +1 -1
- package/dist/components/snk-simple-crud2.js +264 -25
- package/dist/components/snk-taskbar2.js +6 -5
- package/dist/esm/{ConfigStorage-8c2ddac8.js → ConfigStorage-e476378d.js} +1 -0
- package/dist/esm/{SnkMultiSelectionListDataSource-a4805051.js → IExporterProvider-d597f27d.js} +93 -5
- package/dist/esm/RecordIDUtils-87d02110.js +41 -0
- package/dist/esm/{SnkFormConfigManager-c01b9d9d.js → SnkFormConfigManager-298cd647.js} +8 -7
- package/dist/esm/{SnkMessageBuilder-72423074.js → SnkMessageBuilder-ae87b754.js} +9 -13
- package/dist/esm/{pesquisa-fetcher-34a8b8be.js → dataunit-fetcher-3d2ec959.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-a87445a0.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-1ef94aef.js +688 -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 +166 -109
- package/dist/esm/{snk-guides-viewer-edeac29f.js → snk-guides-viewer-62124f3d.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 +257 -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-08c28ddd.entry.js +1 -0
- package/dist/sankhyablocks/p-091ce761.js +60 -0
- package/dist/sankhyablocks/p-094eebf6.entry.js +1 -0
- package/dist/sankhyablocks/p-0c68f40f.entry.js +1 -0
- package/dist/sankhyablocks/p-162b9a59.entry.js +11 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-25f1fc39.js +6 -0
- package/dist/sankhyablocks/p-2e9c764c.entry.js +1 -0
- package/dist/sankhyablocks/p-30cf616e.js +1 -0
- package/dist/sankhyablocks/{p-96621231.js → p-3287a6cc.js} +1 -1
- package/dist/sankhyablocks/p-421bec84.entry.js +1 -0
- package/dist/sankhyablocks/p-42f7b05d.entry.js +1 -0
- package/dist/sankhyablocks/p-51999ab5.entry.js +1 -0
- package/dist/sankhyablocks/p-5f016aed.js +1 -0
- package/dist/sankhyablocks/p-6c364d25.entry.js +1 -0
- package/dist/sankhyablocks/p-70001ac1.js +1 -0
- package/dist/sankhyablocks/p-74c665d5.entry.js +1 -0
- package/dist/sankhyablocks/p-76a65660.js +1 -0
- package/dist/sankhyablocks/p-7c4aabe2.js +1 -0
- package/dist/sankhyablocks/{p-ae4fc9a9.js → p-7e7a7473.js} +1 -1
- package/dist/sankhyablocks/p-8c1ff936.entry.js +1 -0
- package/dist/sankhyablocks/p-939e15d3.entry.js +1 -0
- package/dist/sankhyablocks/p-9863d682.js +1 -0
- package/dist/sankhyablocks/{p-41c2c191.entry.js → p-9dfda04a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c2ae0fab.entry.js → p-bd008859.entry.js} +1 -1
- package/dist/sankhyablocks/p-c273d6ee.js +1 -0
- package/dist/sankhyablocks/p-d65d98ed.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 +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 +67 -3
- 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-559ac55c.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-44215df7.js +0 -460
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
- package/dist/sankhyablocks/p-176c3491.entry.js +0 -1
- package/dist/sankhyablocks/p-37e5d563.js +0 -65
- package/dist/sankhyablocks/p-38289a55.js +0 -1
- package/dist/sankhyablocks/p-46e55a95.entry.js +0 -1
- package/dist/sankhyablocks/p-4e728357.entry.js +0 -1
- package/dist/sankhyablocks/p-5571bdfe.js +0 -1
- package/dist/sankhyablocks/p-5630574e.js +0 -1
- package/dist/sankhyablocks/p-5f8c0426.entry.js +0 -1
- package/dist/sankhyablocks/p-80c64add.entry.js +0 -1
- package/dist/sankhyablocks/p-86af4cc2.js +0 -1
- package/dist/sankhyablocks/p-8b690717.js +0 -1
- package/dist/sankhyablocks/p-a1832166.entry.js +0 -1
- package/dist/sankhyablocks/p-a809d944.entry.js +0 -1
- package/dist/sankhyablocks/p-a97226f6.entry.js +0 -1
- package/dist/sankhyablocks/p-add17f6a.entry.js +0 -1
- package/dist/sankhyablocks/p-c5a9a5d9.entry.js +0 -1
- package/dist/sankhyablocks/p-c5aa7d70.entry.js +0 -11
- package/dist/sankhyablocks/p-cb0147ab.entry.js +0 -1
- package/dist/sankhyablocks/p-f0145e3b.js +0 -1
- package/dist/sankhyablocks/p-f03e4199.entry.js +0 -1
- package/dist/sankhyablocks/p-f607db63.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() {
|
|
@@ -344,7 +540,8 @@ export class SnkDataUnit {
|
|
|
344
540
|
return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID);
|
|
345
541
|
}
|
|
346
542
|
}
|
|
347
|
-
async loadDataUnit() {
|
|
543
|
+
async loadDataUnit(forceMetadataLoad = true) {
|
|
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,11 @@ export class SnkDataUnit {
|
|
|
353
550
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
354
551
|
this.dataUnit.addInterceptor(this);
|
|
355
552
|
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
553
|
+
if (forceMetadataLoad || !this.dataUnit.metadata)
|
|
554
|
+
await this.dataUnit.loadMetadata();
|
|
555
|
+
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
|
556
|
+
this.getMetadataByRow(this.dataUnit);
|
|
557
|
+
}
|
|
356
558
|
this.dataState = this.buildDataState();
|
|
357
559
|
let resolver;
|
|
358
560
|
while (resolver = this._onDataUnitResolve.pop()) {
|
|
@@ -371,20 +573,40 @@ export class SnkDataUnit {
|
|
|
371
573
|
return;
|
|
372
574
|
}
|
|
373
575
|
handlerLinkFields() {
|
|
374
|
-
var _a, _b;
|
|
375
|
-
const
|
|
376
|
-
if (!
|
|
576
|
+
var _a, _b, _c, _d;
|
|
577
|
+
const parentDU = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
|
578
|
+
if (!parentDU)
|
|
377
579
|
return;
|
|
378
|
-
const
|
|
580
|
+
const childName = (_c = this.entityName) !== null && _c !== void 0 ? _c : this.getCleanDataUnitName();
|
|
581
|
+
const child = parentDU.getChildInfo(childName);
|
|
379
582
|
if (!child)
|
|
380
583
|
return;
|
|
381
|
-
const
|
|
382
|
-
(
|
|
383
|
-
|
|
584
|
+
const links = (_d = child === null || child === void 0 ? void 0 : child.links) === null || _d === void 0 ? void 0 : _d.map(link => link.target);
|
|
585
|
+
this.handleDUWithLinks(links);
|
|
586
|
+
}
|
|
587
|
+
handleDUWithLinks(fieldsToLink) {
|
|
588
|
+
this.fieldsToLink = fieldsToLink;
|
|
589
|
+
const metadata = Object.assign({}, this.dataUnit.metadata);
|
|
590
|
+
this.processLinks(metadata);
|
|
591
|
+
this.dataUnit.metadata = metadata;
|
|
592
|
+
this.dataUnitFieldsHidded.emit();
|
|
593
|
+
}
|
|
594
|
+
processLinks(metadata) {
|
|
595
|
+
var _a;
|
|
596
|
+
(_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
597
|
+
var _a;
|
|
598
|
+
if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
|
|
384
599
|
field.visible = false;
|
|
385
600
|
}
|
|
386
601
|
});
|
|
387
|
-
|
|
602
|
+
}
|
|
603
|
+
getCleanDataUnitName() {
|
|
604
|
+
var _a;
|
|
605
|
+
const uri = this.dataUnit.name;
|
|
606
|
+
if (StringUtils.isEmpty(uri))
|
|
607
|
+
return uri;
|
|
608
|
+
const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
|
|
609
|
+
return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
|
|
388
610
|
}
|
|
389
611
|
static getNearestInstance(element) {
|
|
390
612
|
let parent = element.parentElement;
|
|
@@ -395,6 +617,13 @@ export class SnkDataUnit {
|
|
|
395
617
|
parent = parent.parentElement;
|
|
396
618
|
}
|
|
397
619
|
}
|
|
620
|
+
instanceMessagesBuilder() {
|
|
621
|
+
var _a;
|
|
622
|
+
if (this.messagesBuilder) {
|
|
623
|
+
return;
|
|
624
|
+
}
|
|
625
|
+
this.messagesBuilder = new SnkMessageBuilder((_a = this.domainMessagesBuilder) !== null && _a !== void 0 ? _a : this.entityName);
|
|
626
|
+
}
|
|
398
627
|
//---------------------------------------------
|
|
399
628
|
// Lifecycle web component
|
|
400
629
|
//---------------------------------------------
|
|
@@ -402,17 +631,16 @@ export class SnkDataUnit {
|
|
|
402
631
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
403
632
|
this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
|
|
404
633
|
this._parentSnkDataUnit = this.getParentSnkDataUnit();
|
|
405
|
-
|
|
406
|
-
this.messagesBuilder = new SnkMessageBuilder(this.entityName);
|
|
407
|
-
}
|
|
634
|
+
this.instanceMessagesBuilder();
|
|
408
635
|
}
|
|
409
636
|
disconnectedCallback() {
|
|
410
637
|
if (this.dataUnit) {
|
|
411
638
|
this.dataUnit.releaseCallbacks();
|
|
412
639
|
}
|
|
413
640
|
}
|
|
414
|
-
componentDidLoad() {
|
|
415
|
-
this.loadDataUnit();
|
|
641
|
+
async componentDidLoad() {
|
|
642
|
+
await this.loadDataUnit(false);
|
|
643
|
+
this.handlerLinkFields();
|
|
416
644
|
}
|
|
417
645
|
render() {
|
|
418
646
|
return (h(Host, null));
|
|
@@ -643,9 +871,31 @@ export class SnkDataUnit {
|
|
|
643
871
|
},
|
|
644
872
|
"attribute": "resource-i-d",
|
|
645
873
|
"reflect": false
|
|
874
|
+
},
|
|
875
|
+
"domainMessagesBuilder": {
|
|
876
|
+
"type": "string",
|
|
877
|
+
"mutable": false,
|
|
878
|
+
"complexType": {
|
|
879
|
+
"original": "string",
|
|
880
|
+
"resolved": "string",
|
|
881
|
+
"references": {}
|
|
882
|
+
},
|
|
883
|
+
"required": false,
|
|
884
|
+
"optional": false,
|
|
885
|
+
"docs": {
|
|
886
|
+
"tags": [],
|
|
887
|
+
"text": "Define a chave customizada para sobrescrever as mensagens (N\u00E3o pegando pela entidade)"
|
|
888
|
+
},
|
|
889
|
+
"attribute": "domain-messages-builder",
|
|
890
|
+
"reflect": false
|
|
646
891
|
}
|
|
647
892
|
};
|
|
648
893
|
}
|
|
894
|
+
static get states() {
|
|
895
|
+
return {
|
|
896
|
+
"fieldsToLink": {}
|
|
897
|
+
};
|
|
898
|
+
}
|
|
649
899
|
static get events() {
|
|
650
900
|
return [{
|
|
651
901
|
"method": "dataStateChange",
|
|
@@ -706,6 +956,21 @@ export class SnkDataUnit {
|
|
|
706
956
|
}
|
|
707
957
|
}
|
|
708
958
|
}
|
|
959
|
+
}, {
|
|
960
|
+
"method": "dataUnitFieldsHidded",
|
|
961
|
+
"name": "dataUnitFieldsHidded",
|
|
962
|
+
"bubbles": true,
|
|
963
|
+
"cancelable": true,
|
|
964
|
+
"composed": true,
|
|
965
|
+
"docs": {
|
|
966
|
+
"tags": [],
|
|
967
|
+
"text": "Emitido quando h\u00E1 campos no DataUnit que devem ser ocultados."
|
|
968
|
+
},
|
|
969
|
+
"complexType": {
|
|
970
|
+
"original": "void",
|
|
971
|
+
"resolved": "void",
|
|
972
|
+
"references": {}
|
|
973
|
+
}
|
|
709
974
|
}, {
|
|
710
975
|
"method": "insertionMode",
|
|
711
976
|
"name": "insertionMode",
|
|
@@ -774,10 +1039,6 @@ export class SnkDataUnit {
|
|
|
774
1039
|
},
|
|
775
1040
|
"Array": {
|
|
776
1041
|
"location": "global"
|
|
777
|
-
},
|
|
778
|
-
"Record": {
|
|
779
|
-
"location": "import",
|
|
780
|
-
"path": "@sankhyalabs/core"
|
|
781
1042
|
}
|
|
782
1043
|
},
|
|
783
1044
|
"return": "Promise<IRecordID[]>"
|
|
@@ -789,6 +1050,64 @@ export class SnkDataUnit {
|
|
|
789
1050
|
"text": "Retorna a lista de IDs dos registros selecionados."
|
|
790
1051
|
}]
|
|
791
1052
|
}
|
|
1053
|
+
},
|
|
1054
|
+
"getFieldsWithRmp": {
|
|
1055
|
+
"complexType": {
|
|
1056
|
+
"signature": "() => Promise<string[]>",
|
|
1057
|
+
"parameters": [],
|
|
1058
|
+
"references": {
|
|
1059
|
+
"Promise": {
|
|
1060
|
+
"location": "global"
|
|
1061
|
+
}
|
|
1062
|
+
},
|
|
1063
|
+
"return": "Promise<string[]>"
|
|
1064
|
+
},
|
|
1065
|
+
"docs": {
|
|
1066
|
+
"text": "Retorna os campos que possuem a propriedade \"rmp\" (Row Metadata Provider).",
|
|
1067
|
+
"tags": []
|
|
1068
|
+
}
|
|
1069
|
+
},
|
|
1070
|
+
"getFieldsWithRmPrecision": {
|
|
1071
|
+
"complexType": {
|
|
1072
|
+
"signature": "() => Promise<string[]>",
|
|
1073
|
+
"parameters": [],
|
|
1074
|
+
"references": {
|
|
1075
|
+
"Promise": {
|
|
1076
|
+
"location": "global"
|
|
1077
|
+
}
|
|
1078
|
+
},
|
|
1079
|
+
"return": "Promise<string[]>"
|
|
1080
|
+
},
|
|
1081
|
+
"docs": {
|
|
1082
|
+
"text": "Retorna os campos que possuem a propriedade \"rm_precision\" (Row Metadata Precision).",
|
|
1083
|
+
"tags": []
|
|
1084
|
+
}
|
|
1085
|
+
},
|
|
1086
|
+
"getRowMetadata": {
|
|
1087
|
+
"complexType": {
|
|
1088
|
+
"signature": "(record?: Record | string) => Promise<RowMetadata>",
|
|
1089
|
+
"parameters": [{
|
|
1090
|
+
"tags": [],
|
|
1091
|
+
"text": ""
|
|
1092
|
+
}],
|
|
1093
|
+
"references": {
|
|
1094
|
+
"Promise": {
|
|
1095
|
+
"location": "global"
|
|
1096
|
+
},
|
|
1097
|
+
"RowMetadata": {
|
|
1098
|
+
"location": "local"
|
|
1099
|
+
},
|
|
1100
|
+
"Record": {
|
|
1101
|
+
"location": "import",
|
|
1102
|
+
"path": "@sankhyalabs/core"
|
|
1103
|
+
}
|
|
1104
|
+
},
|
|
1105
|
+
"return": "Promise<RowMetadata>"
|
|
1106
|
+
},
|
|
1107
|
+
"docs": {
|
|
1108
|
+
"text": "Busca os metadados da linha selecionada.",
|
|
1109
|
+
"tags": []
|
|
1110
|
+
}
|
|
792
1111
|
}
|
|
793
1112
|
};
|
|
794
1113
|
}
|
|
@@ -827,6 +1146,8 @@ class DataStateImpl {
|
|
|
827
1146
|
this.selectionInfo = datastate.selectionInfo;
|
|
828
1147
|
this.selectedRecord = datastate.selectedRecord;
|
|
829
1148
|
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
|
1149
|
+
this.metadataByRow = datastate.metadataByRow;
|
|
1150
|
+
this.rowMetadata = datastate.rowMetadata;
|
|
830
1151
|
}
|
|
831
1152
|
get selectedRecords() {
|
|
832
1153
|
var _a;
|