@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
@@ -0,0 +1,687 @@
|
|
1
|
+
import { r as registerInstance, c as createEvent, h, g as getElement, H as Host } from './index-a7d3d3f1.js';
|
2
|
+
import { Action, ObjectUtils, DataUnitAction, StringUtils, ApplicationContext } from '@sankhyalabs/core';
|
3
|
+
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
4
|
+
import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder-571462fb.js';
|
5
|
+
import { g as getRecordValue, a as DatasetStrategy } from './dataunit-fetcher-264191b2.js';
|
6
|
+
import { g as getSelectedIDs } from './RecordIDUtils-87d02110.js';
|
7
|
+
import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
8
|
+
|
9
|
+
const SnkDataUnit = class {
|
10
|
+
constructor(hostRef) {
|
11
|
+
registerInstance(this, hostRef);
|
12
|
+
this.dataStateChange = createEvent(this, "dataStateChange", 3);
|
13
|
+
this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
|
14
|
+
this.messagesBuilderUpdated = createEvent(this, "messagesBuilderUpdated", 3);
|
15
|
+
this.dataUnitFieldsHidded = createEvent(this, "dataUnitFieldsHidded", 7);
|
16
|
+
this.insertionMode = createEvent(this, "insertionMode", 3);
|
17
|
+
this.cancelEdition = createEvent(this, "cancelEdition", 3);
|
18
|
+
this._onDataUnitResolve = [];
|
19
|
+
this._openedAlert = false;
|
20
|
+
this._fieldsWithRmp = [];
|
21
|
+
this._fieldsWithRmPrecision = [];
|
22
|
+
this._metadataByRow = new Map();
|
23
|
+
this._rowMetadataCache = new Map();
|
24
|
+
this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
|
25
|
+
this._dataUnitObserver = async (action) => {
|
26
|
+
const duState = this.buildDataState(action.type);
|
27
|
+
this.dataState = duState;
|
28
|
+
this.messagesBuilder.currentOperation = this.getMessageOperation();
|
29
|
+
switch (action.type) {
|
30
|
+
case Action.DATA_SAVED:
|
31
|
+
await this.handleDataSaved(action);
|
32
|
+
break;
|
33
|
+
case Action.RECORDS_ADDED:
|
34
|
+
case Action.RECORDS_COPIED:
|
35
|
+
this.insertionMode.emit();
|
36
|
+
break;
|
37
|
+
case Action.EDITION_CANCELED:
|
38
|
+
this.cancelEdition.emit();
|
39
|
+
break;
|
40
|
+
case Action.RECORDS_REMOVED:
|
41
|
+
this.handleRecordsRemoved(action);
|
42
|
+
break;
|
43
|
+
case Action.METADATA_LOADED:
|
44
|
+
this.fillFieldsWithRmp(this.dataUnit.metadata);
|
45
|
+
this.fillFieldsWithRmPrecision(this.dataUnit.metadata);
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
};
|
49
|
+
this.fieldsToLink = [];
|
50
|
+
this.dataState = undefined;
|
51
|
+
this.messagesBuilder = undefined;
|
52
|
+
this.dataUnitName = undefined;
|
53
|
+
this.entityName = undefined;
|
54
|
+
this.pageSize = 150;
|
55
|
+
this.dataUnit = undefined;
|
56
|
+
this.beforeSave = undefined;
|
57
|
+
this.afterSave = undefined;
|
58
|
+
this.useCancelConfirm = true;
|
59
|
+
this.ignoreSaveMessage = undefined;
|
60
|
+
this.configName = undefined;
|
61
|
+
this.resourceID = undefined;
|
62
|
+
this.domainMessagesBuilder = undefined;
|
63
|
+
}
|
64
|
+
observePageSize() {
|
65
|
+
if (this.dataUnit) {
|
66
|
+
this.dataUnit.pageSize = this.pageSize;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
observeDataUnitName(newValue, oldValue) {
|
70
|
+
if (oldValue != newValue) {
|
71
|
+
if (this.dataUnit) {
|
72
|
+
this._application.updateDataunitCache(oldValue, this.dataUnitName, this.dataUnit);
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
this.loadDataUnit();
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
observeEntityName(newValue, oldValue) {
|
80
|
+
if (oldValue != newValue) {
|
81
|
+
this.dataUnit = undefined;
|
82
|
+
this.entityName = newValue;
|
83
|
+
this.loadDataUnit();
|
84
|
+
}
|
85
|
+
}
|
86
|
+
observeDataState(newValue, oldValue) {
|
87
|
+
if (ObjectUtils.objectToString(oldValue) != ObjectUtils.objectToString(newValue)) {
|
88
|
+
this.dataStateChange.emit(newValue);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
observeDataUnit() {
|
92
|
+
this.handlerLinkFields();
|
93
|
+
this.dataUnitReady.emit(this.dataUnit);
|
94
|
+
}
|
95
|
+
observeMessagesBuilder(newValue) {
|
96
|
+
if (newValue) {
|
97
|
+
this.messagesBuilderUpdated.emit(newValue);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
/**
|
101
|
+
* Obtém o dataUnit.
|
102
|
+
*/
|
103
|
+
async getDataUnit() {
|
104
|
+
return new Promise((resolve) => {
|
105
|
+
if (this.dataUnit) {
|
106
|
+
resolve(this.dataUnit);
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
this._onDataUnitResolve.push(resolve);
|
110
|
+
}
|
111
|
+
});
|
112
|
+
}
|
113
|
+
/**
|
114
|
+
* Método que retorna a lista de IDs dos registros selecionados.
|
115
|
+
* @returns Retorna a lista de IDs dos registros selecionados.
|
116
|
+
*/
|
117
|
+
async getSelectedRecordsIDsInfo() {
|
118
|
+
return Promise.resolve(getSelectedIDs(this.dataUnit));
|
119
|
+
}
|
120
|
+
/**
|
121
|
+
* Retorna os campos que possuem a propriedade "rmp" (Row Metadata Provider).
|
122
|
+
*/
|
123
|
+
async getFieldsWithRmp() {
|
124
|
+
return this._fieldsWithRmp;
|
125
|
+
}
|
126
|
+
/**
|
127
|
+
* Retorna os campos que possuem a propriedade "rm_precision" (Row Metadata Precision).
|
128
|
+
*/
|
129
|
+
async getFieldsWithRmPrecision() {
|
130
|
+
return this._fieldsWithRmPrecision;
|
131
|
+
}
|
132
|
+
/**
|
133
|
+
* Busca os metadados da linha selecionada.
|
134
|
+
*/
|
135
|
+
async getRowMetadata(record) {
|
136
|
+
return this.doGetRowMetadata(record);
|
137
|
+
}
|
138
|
+
doGetRowMetadata(record) {
|
139
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
140
|
+
if (!record && !selectedRecord) {
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
const currentRecord = record || selectedRecord;
|
144
|
+
const recordId = typeof currentRecord === 'string' ? currentRecord : currentRecord.__record__id__;
|
145
|
+
const rowMetadata = this._metadataByRow.get(recordId);
|
146
|
+
if (!rowMetadata) {
|
147
|
+
return;
|
148
|
+
}
|
149
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
150
|
+
return Object.assign({}, rowMetadata);
|
151
|
+
}
|
152
|
+
buildGetPropRowMetadata(rowMetadata) {
|
153
|
+
return (propPath, fieldName) => {
|
154
|
+
if (propPath === "rm_precision") {
|
155
|
+
propPath = this.resolvePrecisionFromMetadata(fieldName);
|
156
|
+
}
|
157
|
+
return ObjectUtils.getProp(rowMetadata, propPath);
|
158
|
+
};
|
159
|
+
}
|
160
|
+
resolvePrecisionFromMetadata(fieldName) {
|
161
|
+
var _a, _b;
|
162
|
+
if (!fieldName) {
|
163
|
+
ApplicationUtils.error(this.getMessage("snkDataUnit.fieldNameRequired"));
|
164
|
+
return;
|
165
|
+
}
|
166
|
+
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;
|
167
|
+
if (!rmPrecision) {
|
168
|
+
return '';
|
169
|
+
}
|
170
|
+
let rmPrecisionPath = rmPrecision.split('.').filter((_, index) => index !== 1).join('.');
|
171
|
+
return rmPrecisionPath;
|
172
|
+
}
|
173
|
+
getCleanOnCopyFields() {
|
174
|
+
var _a;
|
175
|
+
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);
|
176
|
+
}
|
177
|
+
fillFieldsWithRmp(payload) {
|
178
|
+
payload.fields.forEach((field) => {
|
179
|
+
var _a;
|
180
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rmp) && !this._fieldsWithRmp.includes(field.name)) {
|
181
|
+
this._fieldsWithRmp.push(field.name);
|
182
|
+
}
|
183
|
+
});
|
184
|
+
}
|
185
|
+
fillFieldsWithRmPrecision(payload) {
|
186
|
+
payload.fields.forEach((field) => {
|
187
|
+
var _a;
|
188
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !this._fieldsWithRmPrecision.includes(field.name)) {
|
189
|
+
this._fieldsWithRmPrecision.push(field.name);
|
190
|
+
}
|
191
|
+
});
|
192
|
+
}
|
193
|
+
getCacheName(fieldName, metadataName, fieldValue) {
|
194
|
+
const cacheName = [fieldName, metadataName, fieldValue].join("_");
|
195
|
+
return cacheName;
|
196
|
+
}
|
197
|
+
updateDataStateRmp(newValue) {
|
198
|
+
const newRowMetadata = Object.assign({}, newValue);
|
199
|
+
this.dataState.rowMetadata = newRowMetadata;
|
200
|
+
}
|
201
|
+
saveCacheRmd(record) {
|
202
|
+
const rmd = record.__record__metadata__;
|
203
|
+
const keysRmd = Object.keys(rmd);
|
204
|
+
keysRmd.shift();
|
205
|
+
keysRmd.forEach((fieldName) => {
|
206
|
+
const fieldValue = getRecordValue(record, fieldName);
|
207
|
+
const cacheName = this.getCacheName(fieldName, rmd.provider, fieldValue);
|
208
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, rmd));
|
209
|
+
});
|
210
|
+
}
|
211
|
+
getMetadataByRow(payload) {
|
212
|
+
var _a;
|
213
|
+
if (!((_a = payload.records) === null || _a === void 0 ? void 0 : _a.length)) {
|
214
|
+
return payload;
|
215
|
+
}
|
216
|
+
if (!this._fieldsWithRmp.length) {
|
217
|
+
const records = payload.records.map((record) => {
|
218
|
+
delete record.__record__metadata__;
|
219
|
+
return record;
|
220
|
+
});
|
221
|
+
return Object.assign(Object.assign({}, payload), { records });
|
222
|
+
}
|
223
|
+
const records = payload.records.map((record) => {
|
224
|
+
if (!record.__record__metadata__) {
|
225
|
+
return record;
|
226
|
+
}
|
227
|
+
this.saveCacheRmd(record);
|
228
|
+
const rowMetadata = Object.assign({}, record.__record__metadata__);
|
229
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
230
|
+
this._metadataByRow.set(record.__record__id__, rowMetadata);
|
231
|
+
delete record.__record__metadata__;
|
232
|
+
return record;
|
233
|
+
});
|
234
|
+
return Object.assign(Object.assign({}, payload), { records });
|
235
|
+
}
|
236
|
+
interceptRecordsAdded(action) {
|
237
|
+
if (!this.isAllowed("INSERT")) {
|
238
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
239
|
+
return;
|
240
|
+
}
|
241
|
+
return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
|
242
|
+
}
|
243
|
+
interceptRecordsCopied(action) {
|
244
|
+
if (!this.isAllowed("CLONE")) {
|
245
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
246
|
+
return;
|
247
|
+
}
|
248
|
+
return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
|
249
|
+
}
|
250
|
+
async interceptDataChange(action) {
|
251
|
+
if (this.isAllowed("UPDATE")) {
|
252
|
+
return action;
|
253
|
+
}
|
254
|
+
if (this._openedAlert) {
|
255
|
+
await this.dataUnit.cancelEdition();
|
256
|
+
return;
|
257
|
+
}
|
258
|
+
this._openedAlert = true;
|
259
|
+
await this.dataUnit.cancelEdition();
|
260
|
+
await ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
261
|
+
this._openedAlert = false;
|
262
|
+
}
|
263
|
+
async interceptSavingData(action) {
|
264
|
+
if (!this.beforeSave) {
|
265
|
+
return action;
|
266
|
+
}
|
267
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
268
|
+
if (continueAction instanceof Promise) {
|
269
|
+
const result = await continueAction;
|
270
|
+
return result ? action : undefined;
|
271
|
+
}
|
272
|
+
return continueAction ? action : undefined;
|
273
|
+
}
|
274
|
+
interceptDataSaved(action) {
|
275
|
+
if (this.afterSave) {
|
276
|
+
this.afterSave(this.dataUnit);
|
277
|
+
return;
|
278
|
+
}
|
279
|
+
return action;
|
280
|
+
}
|
281
|
+
async interceptEditionCanceled(action) {
|
282
|
+
var _a, _b;
|
283
|
+
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)) {
|
284
|
+
return action;
|
285
|
+
}
|
286
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
287
|
+
if (cancelConfirmation == undefined) {
|
288
|
+
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
289
|
+
return action;
|
290
|
+
}
|
291
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
292
|
+
const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
|
293
|
+
confirm && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
294
|
+
return confirm ? action : undefined;
|
295
|
+
}
|
296
|
+
async interceptRemovingRecords(action) {
|
297
|
+
var _a, _b, _c;
|
298
|
+
if (!this.isAllowed("REMOVE")) {
|
299
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
300
|
+
return;
|
301
|
+
}
|
302
|
+
let multipleSelection = false;
|
303
|
+
let removeConfirmation = !((_a = action.payload) === null || _a === void 0 ? void 0 : _a.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
304
|
+
const selection = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getSelectionInfo();
|
305
|
+
if (!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
306
|
+
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
307
|
+
multipleSelection = true;
|
308
|
+
}
|
309
|
+
if (!removeConfirmation) {
|
310
|
+
return action;
|
311
|
+
}
|
312
|
+
const options = {
|
313
|
+
canClose: false,
|
314
|
+
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
315
|
+
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
316
|
+
btnConfirmDanger: false
|
317
|
+
};
|
318
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
319
|
+
const confirm = await ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options);
|
320
|
+
return confirm ? action : undefined;
|
321
|
+
}
|
322
|
+
interceptDataLoaded(action) {
|
323
|
+
const newPayload = this.getMetadataByRow(action.payload);
|
324
|
+
action = new DataUnitAction(Action.DATA_LOADED, newPayload);
|
325
|
+
return action;
|
326
|
+
}
|
327
|
+
interceptMetadataLoaded(action) {
|
328
|
+
this.fillFieldsWithRmp(action.payload);
|
329
|
+
this.fillFieldsWithRmPrecision(action.payload);
|
330
|
+
return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
|
331
|
+
}
|
332
|
+
async interceptAction(action) {
|
333
|
+
switch (action.type) {
|
334
|
+
case Action.RECORDS_ADDED:
|
335
|
+
return this.interceptRecordsAdded(action);
|
336
|
+
case Action.RECORDS_COPIED:
|
337
|
+
return this.interceptRecordsCopied(action);
|
338
|
+
case Action.DATA_CHANGED:
|
339
|
+
await this.handleLoadRowMetadata(action);
|
340
|
+
return await this.interceptDataChange(action);
|
341
|
+
case Action.CHANGING_DATA:
|
342
|
+
return await this.interceptDataChange(action);
|
343
|
+
case Action.SAVING_DATA:
|
344
|
+
return await this.interceptSavingData(action);
|
345
|
+
case Action.DATA_SAVED:
|
346
|
+
return this.interceptDataSaved(action);
|
347
|
+
case Action.EDITION_CANCELED:
|
348
|
+
return await this.interceptEditionCanceled(action);
|
349
|
+
case Action.REMOVING_RECORDS:
|
350
|
+
return await this.interceptRemovingRecords(action);
|
351
|
+
case Action.DATA_LOADED:
|
352
|
+
return this.interceptDataLoaded(action);
|
353
|
+
case Action.METADATA_LOADED:
|
354
|
+
return this.interceptMetadataLoaded(action);
|
355
|
+
default:
|
356
|
+
return action;
|
357
|
+
}
|
358
|
+
}
|
359
|
+
async handleLoadRowMetadata(action) {
|
360
|
+
const record = action.type === Action.DATA_CHANGED ? action.payload : action.payload.changes[0].record;
|
361
|
+
const keysPayload = Object.keys(record);
|
362
|
+
const rmpField = keysPayload.find((field) => this._fieldsWithRmp.includes(field));
|
363
|
+
if (rmpField) {
|
364
|
+
const metadataName = this.dataUnit.getField(rmpField).properties.rmp;
|
365
|
+
const fieldValue = getRecordValue(record, rmpField);
|
366
|
+
return await this.updateRowMetadata({
|
367
|
+
fieldName: rmpField,
|
368
|
+
fieldValue,
|
369
|
+
metadataName,
|
370
|
+
updatedFields: record,
|
371
|
+
});
|
372
|
+
}
|
373
|
+
}
|
374
|
+
async updateRowMetadata({ fieldName, fieldValue, metadataName, updatedFields }) {
|
375
|
+
const cacheName = this.getCacheName(fieldName, metadataName, fieldValue);
|
376
|
+
const cacheValue = this._rowMetadataCache.get(cacheName);
|
377
|
+
if (cacheValue) {
|
378
|
+
this.updateDataStateRmp(cacheValue);
|
379
|
+
return cacheValue;
|
380
|
+
}
|
381
|
+
else {
|
382
|
+
const datasetStrategy = new DatasetStrategy();
|
383
|
+
const response = await datasetStrategy.loadRowMetadata(this, fieldName, metadataName, updatedFields);
|
384
|
+
this.updateDataStateRmp(response._rmd);
|
385
|
+
this._rowMetadataCache.set(cacheName, Object.assign({}, response._rmd));
|
386
|
+
return Object.assign({}, response._rmd);
|
387
|
+
}
|
388
|
+
}
|
389
|
+
handleDULinksOnMetadataLoaded(payload) {
|
390
|
+
const metadata = Object.assign({}, payload);
|
391
|
+
this.processLinks(metadata);
|
392
|
+
return metadata;
|
393
|
+
}
|
394
|
+
handleRecordsCopied(initialRecords) {
|
395
|
+
let records = [...initialRecords];
|
396
|
+
records = this.handleCleanOnCopy(records);
|
397
|
+
return this.handleLinksWithParent(records);
|
398
|
+
}
|
399
|
+
handleLinksWithParent(records) {
|
400
|
+
var _a, _b;
|
401
|
+
const parentDataUnit = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
402
|
+
if (!parentDataUnit)
|
403
|
+
return records;
|
404
|
+
const parentSelectedRecord = parentDataUnit.getSelectedRecord();
|
405
|
+
const selfInfo = parentDataUnit === null || parentDataUnit === void 0 ? void 0 : parentDataUnit.getChildInfo(this.getCleanDataUnitName());
|
406
|
+
const { links } = selfInfo;
|
407
|
+
if (!links || links.length === 0)
|
408
|
+
return records;
|
409
|
+
return records.map(record => {
|
410
|
+
return this.buildRecordWithLinkedFields(record, links, parentSelectedRecord);
|
411
|
+
});
|
412
|
+
}
|
413
|
+
buildRecordWithLinkedFields(record, links, parentSelectedRecord) {
|
414
|
+
const newRecord = Object.assign({}, record);
|
415
|
+
links.forEach(link => {
|
416
|
+
const convertedParentSelectedRecord = convertType(this.dataUnit.getField(link.target).dataType, parentSelectedRecord[link.source]);
|
417
|
+
newRecord[link.target] = convertedParentSelectedRecord;
|
418
|
+
});
|
419
|
+
return newRecord;
|
420
|
+
}
|
421
|
+
handleCleanOnCopy(records) {
|
422
|
+
const cleanFields = this.getCleanOnCopyFields();
|
423
|
+
if (cleanFields.length > 0) {
|
424
|
+
records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
|
425
|
+
}
|
426
|
+
return records;
|
427
|
+
}
|
428
|
+
buildCopyWithCleanedFields(record, cleanFields) {
|
429
|
+
const newRecord = Object.assign({}, record);
|
430
|
+
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
431
|
+
return newRecord;
|
432
|
+
}
|
433
|
+
showSuccessMessage(message) {
|
434
|
+
ApplicationUtils.info(message, { iconName: "check" });
|
435
|
+
}
|
436
|
+
isAllowed(flag) {
|
437
|
+
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
438
|
+
}
|
439
|
+
buildDataState(actionType) {
|
440
|
+
var _a;
|
441
|
+
const selectionInfo = this.dataUnit.getSelectionInfo();
|
442
|
+
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
443
|
+
const selectedRecord = this.dataUnit.getSelectedRecord();
|
444
|
+
let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
|
445
|
+
const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
|
446
|
+
if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
|
447
|
+
rowMetadata = this.doGetRowMetadata(selectedRecord);
|
448
|
+
}
|
449
|
+
else if (rowMetadata) {
|
450
|
+
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
451
|
+
}
|
452
|
+
return new DataStateImpl({
|
453
|
+
insertionMode: this.dataUnit.hasNewRecord(),
|
454
|
+
isStartingInsertionMode,
|
455
|
+
hasNext: this.dataUnit.hasNext(),
|
456
|
+
hasPrevious: this.dataUnit.hasPrevious(),
|
457
|
+
copyMode: this.dataUnit.hasCopiedRecord(),
|
458
|
+
isDirty: this.dataUnit.isDirty(),
|
459
|
+
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
460
|
+
selectedRecords: undefined,
|
461
|
+
selectionInfo,
|
462
|
+
selectedRecord,
|
463
|
+
recordsIsEmpty: this.dataUnit.records.length === 0,
|
464
|
+
metadataByRow: this._metadataByRow,
|
465
|
+
rowMetadata
|
466
|
+
});
|
467
|
+
}
|
468
|
+
async handleDataSaved(action) {
|
469
|
+
const newRowMetadata = await this.handleLoadRowMetadata(action);
|
470
|
+
if (newRowMetadata) {
|
471
|
+
newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
|
472
|
+
}
|
473
|
+
const recordId = action.payload.records[0].__record__id__;
|
474
|
+
this._metadataByRow.set(recordId, newRowMetadata);
|
475
|
+
this.dataState = this.buildDataState();
|
476
|
+
if (this.ignoreSaveMessage) {
|
477
|
+
return;
|
478
|
+
}
|
479
|
+
const saveOperation = action.payload.changes[0]._operation.toLowerCase();
|
480
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0], saveOperation);
|
481
|
+
if (msg != undefined) {
|
482
|
+
this.showSuccessMessage(msg);
|
483
|
+
}
|
484
|
+
}
|
485
|
+
handleRecordsRemoved(action) {
|
486
|
+
var _a, _b;
|
487
|
+
const cachedRecords = action.payload.cachedRecords;
|
488
|
+
let removeFinishMsg;
|
489
|
+
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
490
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
491
|
+
}
|
492
|
+
else {
|
493
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
494
|
+
}
|
495
|
+
if (removeFinishMsg != undefined) {
|
496
|
+
this.showSuccessMessage(removeFinishMsg);
|
497
|
+
}
|
498
|
+
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
499
|
+
const paginationInfo = this.dataUnit.getPaginationInfo();
|
500
|
+
if (paginationInfo) {
|
501
|
+
const page = recordsCount > 0 || paginationInfo.hasMore ? paginationInfo.currentPage : 0;
|
502
|
+
this.dataUnit.gotoPage(page);
|
503
|
+
}
|
504
|
+
}
|
505
|
+
/**
|
506
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
507
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
508
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
509
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
|
510
|
+
*/
|
511
|
+
getMessage(key, params = undefined, customOperation) {
|
512
|
+
if (!params) {
|
513
|
+
params = this.getMessageParams();
|
514
|
+
}
|
515
|
+
if (customOperation) {
|
516
|
+
this.messagesBuilder.currentOperation = customOperation;
|
517
|
+
}
|
518
|
+
return this.messagesBuilder.getMessage(key, params);
|
519
|
+
}
|
520
|
+
getMessageParams() {
|
521
|
+
//FIXME: Devido ao recurso de multiseleção do dataunit, precisaremos criar um mecanismo para
|
522
|
+
//oferecer todos os registros selecionados para a mensagem, pois mensagens podem ficar incorretas.
|
523
|
+
return this.dataState.selectedRecord;
|
524
|
+
}
|
525
|
+
getMessageOperation() {
|
526
|
+
if (this.dataState.copyMode) {
|
527
|
+
return OperationMap.CLONE;
|
528
|
+
}
|
529
|
+
if (this.dataState.insertionMode || this.dataState.isStartingInsertionMode) {
|
530
|
+
return OperationMap.INSERT;
|
531
|
+
}
|
532
|
+
if (this.dataState.isDirty) {
|
533
|
+
return OperationMap.UPDATE;
|
534
|
+
}
|
535
|
+
return OperationMap.CLEAN;
|
536
|
+
}
|
537
|
+
async getDataUnitParentOrChild() {
|
538
|
+
var _a;
|
539
|
+
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
540
|
+
if (this._parentSnkDataUnit) {
|
541
|
+
this._parentDataUnit = await ((_a = this._parentSnkDataUnit) === null || _a === void 0 ? void 0 : _a.getDataUnit());
|
542
|
+
return await this._application.getDataUnit(this.entityName, cacheName, this._parentDataUnit, this.configName, this.resourceID);
|
543
|
+
}
|
544
|
+
else {
|
545
|
+
return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID);
|
546
|
+
}
|
547
|
+
}
|
548
|
+
async loadDataUnit() {
|
549
|
+
var _a;
|
550
|
+
if (this.dataUnit == null && this._application && this.entityName) {
|
551
|
+
this.dataUnit = await this.getDataUnitParentOrChild();
|
552
|
+
}
|
553
|
+
if (this.dataUnit) {
|
554
|
+
this.dataUnit.pageSize = this.pageSize;
|
555
|
+
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
556
|
+
this.dataUnit.addInterceptor(this);
|
557
|
+
this.dataUnit.subscribe(this._dataUnitObserver);
|
558
|
+
await this.dataUnit.loadMetadata();
|
559
|
+
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
560
|
+
this.getMetadataByRow(this.dataUnit);
|
561
|
+
}
|
562
|
+
this.dataState = this.buildDataState();
|
563
|
+
let resolver;
|
564
|
+
while (resolver = this._onDataUnitResolve.pop()) {
|
565
|
+
resolver(this.dataUnit);
|
566
|
+
}
|
567
|
+
}
|
568
|
+
}
|
569
|
+
getParentSnkDataUnit() {
|
570
|
+
let currentElement = this.element;
|
571
|
+
while (currentElement.parentNode) {
|
572
|
+
if (currentElement.parentNode.nodeName === 'SNK-DATA-UNIT') {
|
573
|
+
return currentElement.parentNode;
|
574
|
+
}
|
575
|
+
currentElement = currentElement.parentNode;
|
576
|
+
}
|
577
|
+
return;
|
578
|
+
}
|
579
|
+
handlerLinkFields() {
|
580
|
+
var _a, _b, _c, _d;
|
581
|
+
const parentDU = (_a = this._parentDataUnit) !== null && _a !== void 0 ? _a : (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getParentDataUnit();
|
582
|
+
if (!parentDU)
|
583
|
+
return;
|
584
|
+
const childName = (_c = this.entityName) !== null && _c !== void 0 ? _c : this.getCleanDataUnitName();
|
585
|
+
const child = parentDU.getChildInfo(childName);
|
586
|
+
if (!child)
|
587
|
+
return;
|
588
|
+
const links = (_d = child === null || child === void 0 ? void 0 : child.links) === null || _d === void 0 ? void 0 : _d.map(link => link.target);
|
589
|
+
this.handleDUWithLinks(links);
|
590
|
+
}
|
591
|
+
handleDUWithLinks(fieldsToLink) {
|
592
|
+
this.fieldsToLink = fieldsToLink;
|
593
|
+
const metadata = Object.assign({}, this.dataUnit.metadata);
|
594
|
+
this.processLinks(metadata);
|
595
|
+
this.dataUnit.metadata = metadata;
|
596
|
+
this.dataUnitFieldsHidded.emit();
|
597
|
+
}
|
598
|
+
processLinks(metadata) {
|
599
|
+
var _a;
|
600
|
+
(_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
601
|
+
var _a;
|
602
|
+
if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
|
603
|
+
field.visible = false;
|
604
|
+
}
|
605
|
+
});
|
606
|
+
}
|
607
|
+
getCleanDataUnitName() {
|
608
|
+
var _a;
|
609
|
+
const uri = this.dataUnit.name;
|
610
|
+
if (StringUtils.isEmpty(uri))
|
611
|
+
return uri;
|
612
|
+
const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
|
613
|
+
return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
|
614
|
+
}
|
615
|
+
static getNearestInstance(element) {
|
616
|
+
let parent = element.parentElement;
|
617
|
+
while (parent) {
|
618
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
619
|
+
return parent;
|
620
|
+
}
|
621
|
+
parent = parent.parentElement;
|
622
|
+
}
|
623
|
+
}
|
624
|
+
instanceMessagesBuilder() {
|
625
|
+
var _a;
|
626
|
+
if (this.messagesBuilder) {
|
627
|
+
return;
|
628
|
+
}
|
629
|
+
this.messagesBuilder = new SnkMessageBuilder((_a = this.domainMessagesBuilder) !== null && _a !== void 0 ? _a : this.entityName);
|
630
|
+
}
|
631
|
+
//---------------------------------------------
|
632
|
+
// Lifecycle web component
|
633
|
+
//---------------------------------------------
|
634
|
+
componentWillLoad() {
|
635
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
636
|
+
this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
|
637
|
+
this._parentSnkDataUnit = this.getParentSnkDataUnit();
|
638
|
+
this.instanceMessagesBuilder();
|
639
|
+
}
|
640
|
+
disconnectedCallback() {
|
641
|
+
if (this.dataUnit) {
|
642
|
+
this.dataUnit.releaseCallbacks();
|
643
|
+
}
|
644
|
+
}
|
645
|
+
async componentDidLoad() {
|
646
|
+
await this.loadDataUnit();
|
647
|
+
this.handlerLinkFields();
|
648
|
+
}
|
649
|
+
render() {
|
650
|
+
return (h(Host, null));
|
651
|
+
}
|
652
|
+
get element() { return getElement(this); }
|
653
|
+
static get watchers() { return {
|
654
|
+
"pageSize": ["observePageSize"],
|
655
|
+
"dataUnitName": ["observeDataUnitName"],
|
656
|
+
"entityName": ["observeEntityName"],
|
657
|
+
"dataState": ["observeDataState"],
|
658
|
+
"dataUnit": ["observeDataUnit"],
|
659
|
+
"messagesBuilder": ["observeMessagesBuilder"]
|
660
|
+
}; }
|
661
|
+
};
|
662
|
+
class DataStateImpl {
|
663
|
+
constructor(datastate) {
|
664
|
+
this.copyMode = datastate.copyMode;
|
665
|
+
this.insertionMode = datastate.insertionMode;
|
666
|
+
this.isStartingInsertionMode = datastate.isStartingInsertionMode;
|
667
|
+
this.isDirty = datastate.isDirty;
|
668
|
+
this.hasDirtyRecords = datastate.hasDirtyRecords;
|
669
|
+
this.hasNext = datastate.hasNext;
|
670
|
+
this.hasPrevious = datastate.hasPrevious;
|
671
|
+
this.selectionInfo = datastate.selectionInfo;
|
672
|
+
this.selectedRecord = datastate.selectedRecord;
|
673
|
+
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
674
|
+
this.metadataByRow = datastate.metadataByRow;
|
675
|
+
this.rowMetadata = datastate.rowMetadata;
|
676
|
+
}
|
677
|
+
get selectedRecords() {
|
678
|
+
var _a;
|
679
|
+
console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`.");
|
680
|
+
if ((_a = this.selectionInfo) === null || _a === void 0 ? void 0 : _a.isAllRecords()) {
|
681
|
+
throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");
|
682
|
+
}
|
683
|
+
return this.selectionInfo.records;
|
684
|
+
}
|
685
|
+
}
|
686
|
+
|
687
|
+
export { SnkDataUnit as S };
|
@@ -1,5 +1,15 @@
|
|
1
|
-
export { S as snk_data_unit } from './snk-data-unit-
|
1
|
+
export { S as snk_data_unit } from './snk-data-unit-f5cbe64b.js';
|
2
2
|
import './index-a7d3d3f1.js';
|
3
3
|
import '@sankhyalabs/core';
|
4
4
|
import '@sankhyalabs/ezui/dist/collection/utils';
|
5
|
-
import './SnkMessageBuilder-
|
5
|
+
import './SnkMessageBuilder-571462fb.js';
|
6
|
+
import './dataunit-fetcher-264191b2.js';
|
7
|
+
import './DataFetcher-c1baf61d.js';
|
8
|
+
import './PrintUtils-3e4ff0f5.js';
|
9
|
+
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
10
|
+
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
11
|
+
import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
12
|
+
import '@sankhyalabs/core/dist/utils/SortingUtils';
|
13
|
+
import './ResourceIDUtils-a114189a.js';
|
14
|
+
import './RecordIDUtils-87d02110.js';
|
15
|
+
import '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|