@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-65214.0 → 0.0.0-bugfix-dev-kb-67792.0
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-e49214c6.js → ConfigStorage-0a690675.js} +0 -1
- package/dist/cjs/{SnkFormConfigManager-beebf47a.js → SnkFormConfigManager-d6d5db6d.js} +7 -8
- package/dist/cjs/{SnkMessageBuilder-cceebbae.js → SnkMessageBuilder-96b0f549.js} +13 -9
- package/dist/cjs/{IExporterProvider-10b7fed5.js → SnkMultiSelectionListDataSource-f79d220c.js} +4 -94
- package/dist/cjs/{index-1dfc7a6e.js → index-0922807b.js} +0 -5
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{dataunit-fetcher-d4873076.js → pesquisa-fetcher-cba1b3d0.js} +180 -87
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +3 -5
- package/dist/cjs/snk-application.cjs.entry.js +12 -35
- package/dist/cjs/snk-attach.cjs.entry.js +46 -71
- package/dist/cjs/snk-crud.cjs.entry.js +10 -101
- package/dist/cjs/snk-data-exporter.cjs.entry.js +85 -315
- package/dist/cjs/snk-data-unit-559ac55c.js +462 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -12
- package/dist/cjs/snk-detail-view.cjs.entry.js +10 -50
- package/dist/cjs/snk-filter-bar.cjs.entry.js +12 -7
- 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 +0 -67
- package/dist/cjs/snk-form.cjs.entry.js +7 -52
- package/dist/cjs/snk-grid.cjs.entry.js +110 -167
- package/dist/cjs/{snk-guides-viewer-aafc3073.js → snk-guides-viewer-bfcad2d6.js} +10 -43
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +7 -9
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +40 -268
- package/dist/cjs/snk-taskbar.cjs.entry.js +3 -4
- package/dist/cjs/{taskbar-elements-9ad1f9c0.js → taskbar-elements-3ecd1278.js} +3 -3
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/snk-application/snk-application.js +11 -35
- package/dist/collection/components/snk-attach/snk-attach.js +44 -67
- package/dist/collection/components/snk-crud/snk-crud.js +7 -305
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +2 -136
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +0 -161
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +7 -134
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +1 -54
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +52 -59
- package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +0 -62
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +219 -540
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +11 -23
- package/dist/collection/components/snk-form/snk-form.js +5 -102
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +6 -7
- package/dist/collection/components/snk-form-config/snk-form-config.js +1 -1
- package/dist/collection/components/snk-grid/snk-grid.css +0 -2
- package/dist/collection/components/snk-grid/snk-grid.js +102 -241
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +20 -406
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +1 -2
- package/dist/collection/lib/@types/index.js +0 -5
- package/dist/collection/lib/configs/ConfigStorage.js +0 -1
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +3 -7
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +0 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +0 -4
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +13 -11
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +0 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +4 -53
- package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +34 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +4 -4
- package/dist/collection/lib/message/SnkMessageBuilder.js +12 -5
- package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +0 -2
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -2
- package/dist/components/ConfigStorage.js +0 -1
- package/dist/components/SnkFormConfigManager.js +6 -7
- package/dist/components/SnkMessageBuilder.js +13 -9
- package/dist/components/dataunit-fetcher.js +182 -84
- package/dist/components/{IExporterProvider.js → field-search.js} +6 -93
- package/dist/components/index2.js +33 -198
- package/dist/components/index3.js +199 -0
- package/dist/components/snk-actions-button2.js +11 -4
- package/dist/components/snk-application2.js +9 -31
- package/dist/components/snk-attach2.js +41 -65
- package/dist/components/snk-crud.js +11 -110
- package/dist/components/snk-data-exporter2.js +85 -309
- package/dist/components/snk-data-unit2.js +217 -487
- package/dist/components/snk-detail-view2.js +14 -96
- package/dist/components/snk-expression-item2.js +1 -1
- package/dist/components/snk-filter-bar2.js +11 -7
- package/dist/components/snk-form-config2.js +1 -1
- package/dist/components/snk-form-view2.js +1 -72
- package/dist/components/snk-form.js +6 -53
- package/dist/components/snk-grid2.js +108 -170
- package/dist/components/snk-personalized-filter2.js +1 -1
- package/dist/components/snk-simple-crud2.js +25 -263
- package/dist/components/snk-taskbar2.js +5 -6
- package/dist/esm/{ConfigStorage-e476378d.js → ConfigStorage-8c2ddac8.js} +0 -1
- package/dist/esm/{SnkFormConfigManager-298cd647.js → SnkFormConfigManager-c01b9d9d.js} +7 -8
- package/dist/esm/{SnkMessageBuilder-ae87b754.js → SnkMessageBuilder-72423074.js} +13 -9
- package/dist/esm/{IExporterProvider-d597f27d.js → SnkMultiSelectionListDataSource-a4805051.js} +5 -93
- package/dist/esm/{index-3aa4977a.js → index-0ece87a6.js} +1 -6
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{dataunit-fetcher-3d2ec959.js → pesquisa-fetcher-34a8b8be.js} +181 -83
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +3 -5
- package/dist/esm/snk-application.entry.js +11 -34
- package/dist/esm/snk-attach.entry.js +41 -66
- package/dist/esm/snk-crud.entry.js +10 -101
- package/dist/esm/snk-data-exporter.entry.js +86 -316
- package/dist/esm/snk-data-unit-44215df7.js +460 -0
- package/dist/esm/snk-data-unit.entry.js +2 -12
- package/dist/esm/snk-detail-view.entry.js +10 -50
- package/dist/esm/snk-filter-bar.entry.js +12 -7
- 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 +0 -67
- package/dist/esm/snk-form.entry.js +7 -52
- package/dist/esm/snk-grid.entry.js +108 -165
- package/dist/esm/{snk-guides-viewer-62124f3d.js → snk-guides-viewer-edeac29f.js} +10 -43
- package/dist/esm/snk-guides-viewer.entry.js +7 -9
- package/dist/esm/snk-personalized-filter.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +28 -256
- package/dist/esm/snk-taskbar.entry.js +3 -4
- package/dist/esm/{taskbar-elements-d59867f1.js → taskbar-elements-2473c8ac.js} +3 -3
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +1 -0
- package/dist/sankhyablocks/p-176c3491.entry.js +1 -0
- package/dist/sankhyablocks/p-37e5d563.js +65 -0
- package/dist/sankhyablocks/p-38289a55.js +1 -0
- package/dist/sankhyablocks/{p-9dfda04a.entry.js → p-41c2c191.entry.js} +1 -1
- package/dist/sankhyablocks/p-46e55a95.entry.js +1 -0
- package/dist/sankhyablocks/p-4e728357.entry.js +1 -0
- package/dist/sankhyablocks/p-5571bdfe.js +1 -0
- package/dist/sankhyablocks/p-5630574e.js +1 -0
- package/dist/sankhyablocks/p-5f8c0426.entry.js +1 -0
- package/dist/sankhyablocks/p-80c64add.entry.js +1 -0
- package/dist/sankhyablocks/p-86af4cc2.js +1 -0
- package/dist/sankhyablocks/p-8b690717.js +1 -0
- package/dist/sankhyablocks/{p-3287a6cc.js → p-96621231.js} +1 -1
- package/dist/sankhyablocks/p-a1832166.entry.js +1 -0
- package/dist/sankhyablocks/p-a809d944.entry.js +1 -0
- package/dist/sankhyablocks/p-a97226f6.entry.js +1 -0
- package/dist/sankhyablocks/p-add17f6a.entry.js +1 -0
- package/dist/sankhyablocks/{p-7e7a7473.js → p-ae4fc9a9.js} +1 -1
- package/dist/sankhyablocks/{p-bd008859.entry.js → p-c2ae0fab.entry.js} +1 -1
- package/dist/sankhyablocks/p-c5a9a5d9.entry.js +1 -0
- package/dist/sankhyablocks/p-c5aa7d70.entry.js +11 -0
- package/dist/sankhyablocks/p-cb0147ab.entry.js +1 -0
- package/dist/sankhyablocks/p-f0145e3b.js +1 -0
- package/dist/sankhyablocks/p-f03e4199.entry.js +1 -0
- package/dist/sankhyablocks/p-f607db63.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +3 -7
- package/dist/types/components/snk-attach/snk-attach.d.ts +9 -11
- package/dist/types/components/snk-crud/snk-crud.d.ts +1 -45
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +0 -23
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +3 -28
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +0 -24
- package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +4 -24
- package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +1 -4
- package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +0 -21
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +3 -67
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +1 -4
- package/dist/types/components/snk-form/snk-form.d.ts +0 -14
- package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +2 -2
- package/dist/types/components/snk-grid/snk-grid.d.ts +6 -46
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +4 -62
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
- package/dist/types/components.d.ts +4 -261
- package/dist/types/lib/@types/index.d.ts +0 -5
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +1 -2
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +1 -2
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +0 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +0 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +0 -6
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +0 -3
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +1 -2
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/RecordIDUtils-3735135c.js +0 -43
- package/dist/cjs/pesquisa-fetcher-a1d0353f.js +0 -166
- package/dist/cjs/snk-data-unit-f0221097.js +0 -690
- package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +0 -1
- package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +0 -1
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +0 -97
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +0 -74
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +0 -1
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +0 -58
- package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +0 -55
- package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +0 -88
- package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +0 -20
- package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +0 -38
- package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +0 -24
- package/dist/collection/components/snk-data-unit/test/resources/parentMetadataMock.js +0 -18
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +0 -35
- package/dist/collection/lib/dataUnit/ValueFormatter.js +0 -4
- package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +0 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +0 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +0 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +0 -22
- package/dist/components/ISave.js +0 -47
- package/dist/components/pesquisa-fetcher.js +0 -164
- package/dist/esm/RecordIDUtils-87d02110.js +0 -41
- package/dist/esm/pesquisa-fetcher-a87445a0.js +0 -164
- package/dist/esm/snk-data-unit-1ef94aef.js +0 -688
- package/dist/sankhyablocks/p-091ce761.js +0 -60
- package/dist/sankhyablocks/p-0c68f40f.entry.js +0 -1
- package/dist/sankhyablocks/p-162b9a59.entry.js +0 -11
- package/dist/sankhyablocks/p-1db45d26.entry.js +0 -1
- package/dist/sankhyablocks/p-25f1fc39.js +0 -6
- package/dist/sankhyablocks/p-2e9c764c.entry.js +0 -1
- package/dist/sankhyablocks/p-30cf616e.js +0 -1
- package/dist/sankhyablocks/p-421bec84.entry.js +0 -1
- package/dist/sankhyablocks/p-42f7b05d.entry.js +0 -1
- package/dist/sankhyablocks/p-51999ab5.entry.js +0 -1
- package/dist/sankhyablocks/p-52a6a293.entry.js +0 -1
- package/dist/sankhyablocks/p-5f016aed.js +0 -1
- package/dist/sankhyablocks/p-62f34e6f.entry.js +0 -1
- package/dist/sankhyablocks/p-684a2590.entry.js +0 -1
- package/dist/sankhyablocks/p-70001ac1.js +0 -1
- package/dist/sankhyablocks/p-74c665d5.entry.js +0 -1
- package/dist/sankhyablocks/p-76a65660.js +0 -1
- package/dist/sankhyablocks/p-7c4aabe2.js +0 -1
- package/dist/sankhyablocks/p-8c1ff936.entry.js +0 -1
- package/dist/sankhyablocks/p-939e15d3.entry.js +0 -1
- package/dist/sankhyablocks/p-9863d682.js +0 -1
- package/dist/sankhyablocks/p-c273d6ee.js +0 -1
- package/dist/sankhyablocks/p-d65d98ed.entry.js +0 -1
- package/dist/sankhyablocks/p-f2809746.entry.js +0 -1
- package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +0 -4
- package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +0 -4
- package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +0 -14
- package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +0 -12
- package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +0 -5
- package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +0 -17
- package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +0 -17
- package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +0 -77
- package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +0 -4
- package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
- package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +0 -3
- package/dist/types/components/snk-data-unit/test/resources/parentMetadataMock.d.ts +0 -3
- package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +0 -11
- package/dist/types/lib/dataUnit/ValueFormatter.d.ts +0 -2
- package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +0 -3
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +0 -10
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +0 -7
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +0 -20
|
@@ -1,47 +1,55 @@
|
|
|
1
1
|
import { Host, h } from '@stencil/core';
|
|
2
|
-
import { Action, ApplicationContext, DataUnitAction, ObjectUtils,
|
|
2
|
+
import { Action, ApplicationContext, DataUnitAction, ObjectUtils, DataType, JSUtils } 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';
|
|
9
5
|
export class SnkDataUnit {
|
|
10
6
|
constructor() {
|
|
11
7
|
this._onDataUnitResolve = [];
|
|
12
8
|
this._openedAlert = false;
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this._rowMetadataCache = new Map();
|
|
17
|
-
this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
|
|
18
|
-
this._dataUnitObserver = async (action) => {
|
|
19
|
-
const duState = this.buildDataState(action.type);
|
|
9
|
+
this._dataUnitObserver = (action) => {
|
|
10
|
+
var _a, _b;
|
|
11
|
+
const duState = this.buildDataState();
|
|
20
12
|
this.dataState = duState;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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;
|
|
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();
|
|
42
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
|
+
this.messagesBuilder.currentOperation = this.getMessageOperation();
|
|
43
52
|
};
|
|
44
|
-
this.fieldsToLink = [];
|
|
45
53
|
this.dataState = undefined;
|
|
46
54
|
this.messagesBuilder = undefined;
|
|
47
55
|
this.dataUnitName = undefined;
|
|
@@ -54,7 +62,6 @@ export class SnkDataUnit {
|
|
|
54
62
|
this.ignoreSaveMessage = undefined;
|
|
55
63
|
this.configName = undefined;
|
|
56
64
|
this.resourceID = undefined;
|
|
57
|
-
this.domainMessagesBuilder = undefined;
|
|
58
65
|
}
|
|
59
66
|
observePageSize() {
|
|
60
67
|
if (this.dataUnit) {
|
|
@@ -110,320 +117,169 @@ export class SnkDataUnit {
|
|
|
110
117
|
* @returns Retorna a lista de IDs dos registros selecionados.
|
|
111
118
|
*/
|
|
112
119
|
async getSelectedRecordsIDsInfo() {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
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;
|
|
160
|
-
}
|
|
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 '';
|
|
120
|
+
var _a;
|
|
121
|
+
const selectionInfo = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo();
|
|
122
|
+
if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
const selectedRecordsIDsInfo = [];
|
|
126
|
+
const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.records;
|
|
127
|
+
if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
|
|
128
|
+
selectedRecords.forEach(({ __record__id__ }) => {
|
|
129
|
+
if (!this.dataUnit.isNewRecord(__record__id__)) {
|
|
130
|
+
/*
|
|
131
|
+
Esse if foi necessário para tratar corretamente o ID
|
|
132
|
+
do record quando está sendo utilizado no modo standAlone
|
|
133
|
+
isso não faz a exportação da grid funcionar no modo standAlone
|
|
134
|
+
mas deixa de causar erro nas oprações de CRUD.
|
|
135
|
+
*/
|
|
136
|
+
if (!JSUtils.isBase64(__record__id__)) {
|
|
137
|
+
selectedRecordsIDsInfo.push({
|
|
138
|
+
name: "__record__id__",
|
|
139
|
+
type: DataType.TEXT,
|
|
140
|
+
value: __record__id__
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const revertBase64ToObject = JSON.parse(window.atob(__record__id__));
|
|
145
|
+
Object.entries(revertBase64ToObject).forEach(([name, value]) => {
|
|
146
|
+
var _a;
|
|
147
|
+
const metadataField = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
|
|
148
|
+
if (metadataField == undefined) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
});
|
|
164
155
|
}
|
|
165
|
-
|
|
166
|
-
return rmPrecisionPath;
|
|
156
|
+
return selectedRecordsIDsInfo;
|
|
167
157
|
}
|
|
168
158
|
getCleanOnCopyFields() {
|
|
169
159
|
var _a;
|
|
170
160
|
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);
|
|
171
161
|
}
|
|
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;
|
|
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
162
|
async interceptAction(action) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
163
|
+
return new Promise(resolve => {
|
|
164
|
+
var _a, _b, _c, _d, _e;
|
|
165
|
+
switch (action.type) {
|
|
166
|
+
case Action.RECORDS_ADDED:
|
|
167
|
+
if (this.isAllowed("INSERT")) {
|
|
168
|
+
resolve(action);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
172
|
+
}
|
|
173
|
+
break;
|
|
174
|
+
case Action.RECORDS_COPIED:
|
|
175
|
+
if (this.isAllowed("CLONE")) {
|
|
176
|
+
const cleanFields = this.getCleanOnCopyFields();
|
|
177
|
+
if (cleanFields.length > 0) {
|
|
178
|
+
const records = action.payload;
|
|
179
|
+
action = new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
|
|
180
|
+
const newRecord = Object.assign({}, record);
|
|
181
|
+
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
182
|
+
return newRecord;
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
resolve(action);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
191
|
+
case Action.DATA_CHANGED:
|
|
192
|
+
case Action.CHANGING_DATA:
|
|
193
|
+
if (this.isAllowed("UPDATE"))
|
|
194
|
+
return resolve(action);
|
|
195
|
+
if (this._openedAlert)
|
|
196
|
+
return this.dataUnit.cancelEdition();
|
|
197
|
+
this._openedAlert = true;
|
|
198
|
+
this.dataUnit.cancelEdition();
|
|
199
|
+
ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
|
|
200
|
+
this._openedAlert = false;
|
|
201
|
+
});
|
|
202
|
+
break;
|
|
203
|
+
case Action.SAVING_DATA:
|
|
204
|
+
if (this.beforeSave) {
|
|
205
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
|
206
|
+
if (continueAction instanceof Promise) {
|
|
207
|
+
continueAction.then(result => resolve(result ? action : undefined));
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
resolve(continueAction ? action : undefined);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
resolve(action);
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
case Action.DATA_SAVED:
|
|
218
|
+
if (this.afterSave) {
|
|
219
|
+
this.afterSave(this.dataUnit);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
resolve(action);
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case Action.EDITION_CANCELED:
|
|
226
|
+
if (!this.useCancelConfirm)
|
|
227
|
+
return resolve(action);
|
|
228
|
+
if (this.dataState.hasDirtyRecords) {
|
|
229
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
230
|
+
if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
|
|
231
|
+
resolve(action);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (cancelConfirmation == undefined) {
|
|
235
|
+
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
236
|
+
resolve(action);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
240
|
+
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
|
241
|
+
.then((result) => {
|
|
242
|
+
result && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
243
|
+
resolve(result ? action : undefined);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
resolve(action);
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
case Action.REMOVING_RECORDS:
|
|
252
|
+
if (this.isAllowed("REMOVE")) {
|
|
253
|
+
let multipleSelection = false;
|
|
254
|
+
let removeConfirmation = !((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
|
255
|
+
const selection = (_d = this.dataUnit) === null || _d === void 0 ? void 0 : _d.getSelectionInfo();
|
|
256
|
+
if (!((_e = action.payload) === null || _e === void 0 ? void 0 : _e.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
|
257
|
+
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
|
258
|
+
multipleSelection = true;
|
|
259
|
+
}
|
|
260
|
+
if (!removeConfirmation) {
|
|
261
|
+
resolve(action);
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
const options = {
|
|
265
|
+
canClose: false,
|
|
266
|
+
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
|
267
|
+
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
|
268
|
+
btnConfirmDanger: false
|
|
269
|
+
};
|
|
270
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
271
|
+
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options)
|
|
272
|
+
.then((result) => resolve(result ? action : undefined));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
277
|
+
}
|
|
278
|
+
break;
|
|
279
|
+
default:
|
|
280
|
+
resolve(action);
|
|
281
|
+
}
|
|
413
282
|
});
|
|
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
283
|
}
|
|
428
284
|
showSuccessMessage(message) {
|
|
429
285
|
ApplicationUtils.info(message, { iconName: "check" });
|
|
@@ -431,19 +287,9 @@ export class SnkDataUnit {
|
|
|
431
287
|
isAllowed(flag) {
|
|
432
288
|
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
433
289
|
}
|
|
434
|
-
buildDataState(
|
|
435
|
-
var _a;
|
|
290
|
+
buildDataState() {
|
|
436
291
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
|
437
292
|
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
|
-
}
|
|
447
293
|
return new DataStateImpl({
|
|
448
294
|
insertionMode: this.dataUnit.hasNewRecord(),
|
|
449
295
|
isStartingInsertionMode,
|
|
@@ -454,62 +300,20 @@ export class SnkDataUnit {
|
|
|
454
300
|
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
|
455
301
|
selectedRecords: undefined,
|
|
456
302
|
selectionInfo,
|
|
457
|
-
selectedRecord,
|
|
458
|
-
recordsIsEmpty: this.dataUnit.records.length === 0
|
|
459
|
-
metadataByRow: this._metadataByRow,
|
|
460
|
-
rowMetadata
|
|
303
|
+
selectedRecord: this.dataUnit.getSelectedRecord(),
|
|
304
|
+
recordsIsEmpty: this.dataUnit.records.length === 0
|
|
461
305
|
});
|
|
462
306
|
}
|
|
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
|
-
}
|
|
500
307
|
/**
|
|
501
308
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
502
309
|
* através de um pequeno modulo na estrutura da aplicação:
|
|
503
310
|
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
504
311
|
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
|
|
505
312
|
*/
|
|
506
|
-
getMessage(key, params = undefined
|
|
313
|
+
getMessage(key, params = undefined) {
|
|
507
314
|
if (!params) {
|
|
508
315
|
params = this.getMessageParams();
|
|
509
316
|
}
|
|
510
|
-
if (customOperation) {
|
|
511
|
-
this.messagesBuilder.currentOperation = customOperation;
|
|
512
|
-
}
|
|
513
317
|
return this.messagesBuilder.getMessage(key, params);
|
|
514
318
|
}
|
|
515
319
|
getMessageParams() {
|
|
@@ -540,8 +344,7 @@ export class SnkDataUnit {
|
|
|
540
344
|
return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID);
|
|
541
345
|
}
|
|
542
346
|
}
|
|
543
|
-
async loadDataUnit(
|
|
544
|
-
var _a;
|
|
347
|
+
async loadDataUnit() {
|
|
545
348
|
if (this.dataUnit == null && this._application && this.entityName) {
|
|
546
349
|
this.dataUnit = await this.getDataUnitParentOrChild();
|
|
547
350
|
}
|
|
@@ -550,11 +353,6 @@ export class SnkDataUnit {
|
|
|
550
353
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
551
354
|
this.dataUnit.addInterceptor(this);
|
|
552
355
|
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
|
-
}
|
|
558
356
|
this.dataState = this.buildDataState();
|
|
559
357
|
let resolver;
|
|
560
358
|
while (resolver = this._onDataUnitResolve.pop()) {
|
|
@@ -573,40 +371,20 @@ export class SnkDataUnit {
|
|
|
573
371
|
return;
|
|
574
372
|
}
|
|
575
373
|
handlerLinkFields() {
|
|
576
|
-
var _a, _b
|
|
577
|
-
const
|
|
578
|
-
if (!
|
|
374
|
+
var _a, _b;
|
|
375
|
+
const metadata = Object.assign({}, this.dataUnit.metadata);
|
|
376
|
+
if (!this._parentDataUnit)
|
|
579
377
|
return;
|
|
580
|
-
const
|
|
581
|
-
const child = parentDU.getChildInfo(childName);
|
|
378
|
+
const child = this._parentDataUnit.getChildInfo(this.entityName);
|
|
582
379
|
if (!child)
|
|
583
380
|
return;
|
|
584
|
-
const
|
|
585
|
-
|
|
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)) {
|
|
381
|
+
const fieldsLink = (_a = child === null || child === void 0 ? void 0 : child.links) === null || _a === void 0 ? void 0 : _a.map(link => link.target);
|
|
382
|
+
(_b = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _b === void 0 ? void 0 : _b.forEach(field => {
|
|
383
|
+
if (fieldsLink === null || fieldsLink === void 0 ? void 0 : fieldsLink.includes(field.name)) {
|
|
599
384
|
field.visible = false;
|
|
600
385
|
}
|
|
601
386
|
});
|
|
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;
|
|
387
|
+
this.dataUnit.metadata = metadata;
|
|
610
388
|
}
|
|
611
389
|
static getNearestInstance(element) {
|
|
612
390
|
let parent = element.parentElement;
|
|
@@ -617,13 +395,6 @@ export class SnkDataUnit {
|
|
|
617
395
|
parent = parent.parentElement;
|
|
618
396
|
}
|
|
619
397
|
}
|
|
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
|
-
}
|
|
627
398
|
//---------------------------------------------
|
|
628
399
|
// Lifecycle web component
|
|
629
400
|
//---------------------------------------------
|
|
@@ -631,16 +402,17 @@ export class SnkDataUnit {
|
|
|
631
402
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
632
403
|
this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
|
|
633
404
|
this._parentSnkDataUnit = this.getParentSnkDataUnit();
|
|
634
|
-
this.
|
|
405
|
+
if (this.messagesBuilder == undefined) {
|
|
406
|
+
this.messagesBuilder = new SnkMessageBuilder(this.entityName);
|
|
407
|
+
}
|
|
635
408
|
}
|
|
636
409
|
disconnectedCallback() {
|
|
637
410
|
if (this.dataUnit) {
|
|
638
411
|
this.dataUnit.releaseCallbacks();
|
|
639
412
|
}
|
|
640
413
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
this.handlerLinkFields();
|
|
414
|
+
componentDidLoad() {
|
|
415
|
+
this.loadDataUnit();
|
|
644
416
|
}
|
|
645
417
|
render() {
|
|
646
418
|
return (h(Host, null));
|
|
@@ -871,31 +643,9 @@ export class SnkDataUnit {
|
|
|
871
643
|
},
|
|
872
644
|
"attribute": "resource-i-d",
|
|
873
645
|
"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
|
|
891
646
|
}
|
|
892
647
|
};
|
|
893
648
|
}
|
|
894
|
-
static get states() {
|
|
895
|
-
return {
|
|
896
|
-
"fieldsToLink": {}
|
|
897
|
-
};
|
|
898
|
-
}
|
|
899
649
|
static get events() {
|
|
900
650
|
return [{
|
|
901
651
|
"method": "dataStateChange",
|
|
@@ -956,21 +706,6 @@ export class SnkDataUnit {
|
|
|
956
706
|
}
|
|
957
707
|
}
|
|
958
708
|
}
|
|
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
|
-
}
|
|
974
709
|
}, {
|
|
975
710
|
"method": "insertionMode",
|
|
976
711
|
"name": "insertionMode",
|
|
@@ -1039,6 +774,10 @@ export class SnkDataUnit {
|
|
|
1039
774
|
},
|
|
1040
775
|
"Array": {
|
|
1041
776
|
"location": "global"
|
|
777
|
+
},
|
|
778
|
+
"Record": {
|
|
779
|
+
"location": "import",
|
|
780
|
+
"path": "@sankhyalabs/core"
|
|
1042
781
|
}
|
|
1043
782
|
},
|
|
1044
783
|
"return": "Promise<IRecordID[]>"
|
|
@@ -1050,64 +789,6 @@ export class SnkDataUnit {
|
|
|
1050
789
|
"text": "Retorna a lista de IDs dos registros selecionados."
|
|
1051
790
|
}]
|
|
1052
791
|
}
|
|
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
|
-
}
|
|
1111
792
|
}
|
|
1112
793
|
};
|
|
1113
794
|
}
|
|
@@ -1146,8 +827,6 @@ class DataStateImpl {
|
|
|
1146
827
|
this.selectionInfo = datastate.selectionInfo;
|
|
1147
828
|
this.selectedRecord = datastate.selectedRecord;
|
|
1148
829
|
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
|
1149
|
-
this.metadataByRow = datastate.metadataByRow;
|
|
1150
|
-
this.rowMetadata = datastate.rowMetadata;
|
|
1151
830
|
}
|
|
1152
831
|
get selectedRecords() {
|
|
1153
832
|
var _a;
|