@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,7 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
-
import {
|
|
2
|
+
import { Action, ObjectUtils, JSUtils, DataUnitAction, ApplicationContext, DataType } from '@sankhyalabs/core';
|
|
3
3
|
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
4
|
import { O as OperationMap, S as SnkMessageBuilder } from './SnkMessageBuilder.js';
|
|
5
|
-
import { g as getRecordValue, d as DatasetStrategy } from './dataunit-fetcher.js';
|
|
6
|
-
import { convertType } from '@sankhyalabs/core/dist/dataunit/metadata/DataType';
|
|
7
|
-
|
|
8
|
-
const getSelectedIDs = (dataUnit) => {
|
|
9
|
-
const selectionInfo = dataUnit.getSelectionInfo();
|
|
10
|
-
if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
const selectedRecordsIDsInfo = [];
|
|
14
|
-
const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.recordIds;
|
|
15
|
-
if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
|
|
16
|
-
selectedRecords.forEach(recordId => {
|
|
17
|
-
if (!dataUnit.isNewRecord(recordId)) {
|
|
18
|
-
/*
|
|
19
|
-
Esse if foi necessário para tratar corretamente o ID
|
|
20
|
-
do record quando está sendo utilizado no modo standAlone
|
|
21
|
-
isso não faz a exportação da grid funcionar no modo standAlone
|
|
22
|
-
mas deixa de causar erro nas oprações de CRUD.
|
|
23
|
-
*/
|
|
24
|
-
if (!JSUtils.isBase64(recordId)) {
|
|
25
|
-
selectedRecordsIDsInfo.push({
|
|
26
|
-
name: "__record__id__",
|
|
27
|
-
type: DataType.TEXT,
|
|
28
|
-
value: recordId
|
|
29
|
-
});
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const revertBase64ToObject = JSON.parse(window.atob(recordId));
|
|
33
|
-
Object.entries(revertBase64ToObject).forEach(([name, value]) => {
|
|
34
|
-
const metadataField = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(name);
|
|
35
|
-
if (metadataField == undefined) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
return selectedRecordsIDsInfo;
|
|
44
|
-
};
|
|
45
5
|
|
|
46
6
|
const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
47
7
|
constructor() {
|
|
@@ -50,41 +10,54 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
50
10
|
this.dataStateChange = createEvent(this, "dataStateChange", 3);
|
|
51
11
|
this.dataUnitReady = createEvent(this, "dataUnitReady", 3);
|
|
52
12
|
this.messagesBuilderUpdated = createEvent(this, "messagesBuilderUpdated", 3);
|
|
53
|
-
this.dataUnitFieldsHidded = createEvent(this, "dataUnitFieldsHidded", 7);
|
|
54
13
|
this.insertionMode = createEvent(this, "insertionMode", 3);
|
|
55
14
|
this.cancelEdition = createEvent(this, "cancelEdition", 3);
|
|
56
15
|
this._onDataUnitResolve = [];
|
|
57
16
|
this._openedAlert = false;
|
|
58
|
-
this.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this._rowMetadataCache = new Map();
|
|
62
|
-
this.REGEX_DATAUNIT_NAME = /dd:\/\/(.+?)\//;
|
|
63
|
-
this._dataUnitObserver = async (action) => {
|
|
64
|
-
const duState = this.buildDataState(action.type);
|
|
17
|
+
this._dataUnitObserver = (action) => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const duState = this.buildDataState();
|
|
65
20
|
this.dataState = duState;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
21
|
+
if (action.type === Action.DATA_SAVED) {
|
|
22
|
+
if (this.ignoreSaveMessage) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
26
|
+
if (msg != undefined) {
|
|
27
|
+
this.showSuccessMessage(msg);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
31
|
+
this.insertionMode.emit();
|
|
32
|
+
}
|
|
33
|
+
if (action.type === Action.EDITION_CANCELED) {
|
|
34
|
+
this.cancelEdition.emit();
|
|
35
|
+
}
|
|
36
|
+
if (action.type === Action.RECORDS_REMOVED) {
|
|
37
|
+
const cachedRecords = action.payload.cachedRecords;
|
|
38
|
+
let removeFinishMsg;
|
|
39
|
+
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
|
40
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
44
|
+
}
|
|
45
|
+
if (removeFinishMsg != undefined) {
|
|
46
|
+
this.showSuccessMessage(removeFinishMsg);
|
|
47
|
+
}
|
|
48
|
+
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
49
|
+
const paginationInfo = this.dataUnit.getPaginationInfo();
|
|
50
|
+
if (paginationInfo) {
|
|
51
|
+
if (recordsCount > 0 || paginationInfo.hasMore) {
|
|
52
|
+
this.dataUnit.gotoPage(paginationInfo.currentPage);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
this.dataUnit.gotoPage(0);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
85
58
|
}
|
|
59
|
+
this.messagesBuilder.currentOperation = this.getMessageOperation();
|
|
86
60
|
};
|
|
87
|
-
this.fieldsToLink = [];
|
|
88
61
|
this.dataState = undefined;
|
|
89
62
|
this.messagesBuilder = undefined;
|
|
90
63
|
this.dataUnitName = undefined;
|
|
@@ -97,7 +70,6 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
97
70
|
this.ignoreSaveMessage = undefined;
|
|
98
71
|
this.configName = undefined;
|
|
99
72
|
this.resourceID = undefined;
|
|
100
|
-
this.domainMessagesBuilder = undefined;
|
|
101
73
|
}
|
|
102
74
|
observePageSize() {
|
|
103
75
|
if (this.dataUnit) {
|
|
@@ -153,320 +125,169 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
153
125
|
* @returns Retorna a lista de IDs dos registros selecionados.
|
|
154
126
|
*/
|
|
155
127
|
async getSelectedRecordsIDsInfo() {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return (propPath, fieldName) => {
|
|
192
|
-
if (propPath === "rm_precision") {
|
|
193
|
-
propPath = this.resolvePrecisionFromMetadata(fieldName);
|
|
194
|
-
}
|
|
195
|
-
return ObjectUtils.getProp(rowMetadata, propPath);
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
resolvePrecisionFromMetadata(fieldName) {
|
|
199
|
-
var _a, _b;
|
|
200
|
-
if (!fieldName) {
|
|
201
|
-
ApplicationUtils.error(this.getMessage("snkDataUnit.fieldNameRequired"));
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
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;
|
|
205
|
-
if (!rmPrecision) {
|
|
206
|
-
return '';
|
|
128
|
+
var _a;
|
|
129
|
+
const selectionInfo = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getSelectionInfo();
|
|
130
|
+
if (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isAllRecords()) {
|
|
131
|
+
return [];
|
|
132
|
+
}
|
|
133
|
+
const selectedRecordsIDsInfo = [];
|
|
134
|
+
const selectedRecords = selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.records;
|
|
135
|
+
if ((selectedRecords === null || selectedRecords === void 0 ? void 0 : selectedRecords.length) > 0) {
|
|
136
|
+
selectedRecords.forEach(({ __record__id__ }) => {
|
|
137
|
+
if (!this.dataUnit.isNewRecord(__record__id__)) {
|
|
138
|
+
/*
|
|
139
|
+
Esse if foi necessário para tratar corretamente o ID
|
|
140
|
+
do record quando está sendo utilizado no modo standAlone
|
|
141
|
+
isso não faz a exportação da grid funcionar no modo standAlone
|
|
142
|
+
mas deixa de causar erro nas oprações de CRUD.
|
|
143
|
+
*/
|
|
144
|
+
if (!JSUtils.isBase64(__record__id__)) {
|
|
145
|
+
selectedRecordsIDsInfo.push({
|
|
146
|
+
name: "__record__id__",
|
|
147
|
+
type: DataType.TEXT,
|
|
148
|
+
value: __record__id__
|
|
149
|
+
});
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const revertBase64ToObject = JSON.parse(window.atob(__record__id__));
|
|
153
|
+
Object.entries(revertBase64ToObject).forEach(([name, value]) => {
|
|
154
|
+
var _a;
|
|
155
|
+
const metadataField = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(name);
|
|
156
|
+
if (metadataField == undefined) {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
selectedRecordsIDsInfo.push(Object.assign({ name, type: metadataField.dataType }, value));
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
});
|
|
207
163
|
}
|
|
208
|
-
|
|
209
|
-
return rmPrecisionPath;
|
|
164
|
+
return selectedRecordsIDsInfo;
|
|
210
165
|
}
|
|
211
166
|
getCleanOnCopyFields() {
|
|
212
167
|
var _a;
|
|
213
168
|
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);
|
|
214
169
|
}
|
|
215
|
-
fillFieldsWithRmp(payload) {
|
|
216
|
-
payload.fields.forEach((field) => {
|
|
217
|
-
var _a;
|
|
218
|
-
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rmp) && !this._fieldsWithRmp.includes(field.name)) {
|
|
219
|
-
this._fieldsWithRmp.push(field.name);
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
fillFieldsWithRmPrecision(payload) {
|
|
224
|
-
payload.fields.forEach((field) => {
|
|
225
|
-
var _a;
|
|
226
|
-
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !this._fieldsWithRmPrecision.includes(field.name)) {
|
|
227
|
-
this._fieldsWithRmPrecision.push(field.name);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
getCacheName(fieldName, metadataName, fieldValue) {
|
|
232
|
-
const cacheName = [fieldName, metadataName, fieldValue].join("_");
|
|
233
|
-
return cacheName;
|
|
234
|
-
}
|
|
235
|
-
updateDataStateRmp(newValue) {
|
|
236
|
-
const newRowMetadata = Object.assign({}, newValue);
|
|
237
|
-
this.dataState.rowMetadata = newRowMetadata;
|
|
238
|
-
}
|
|
239
|
-
saveCacheRmd(record) {
|
|
240
|
-
const rmd = record.__record__metadata__;
|
|
241
|
-
const keysRmd = Object.keys(rmd);
|
|
242
|
-
keysRmd.shift();
|
|
243
|
-
keysRmd.forEach((fieldName) => {
|
|
244
|
-
const fieldValue = getRecordValue(record, fieldName);
|
|
245
|
-
const cacheName = this.getCacheName(fieldName, rmd.provider, fieldValue);
|
|
246
|
-
this._rowMetadataCache.set(cacheName, Object.assign({}, rmd));
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
getMetadataByRow(payload) {
|
|
250
|
-
var _a;
|
|
251
|
-
if (!((_a = payload.records) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
252
|
-
return payload;
|
|
253
|
-
}
|
|
254
|
-
if (!this._fieldsWithRmp.length) {
|
|
255
|
-
const records = payload.records.map((record) => {
|
|
256
|
-
delete record.__record__metadata__;
|
|
257
|
-
return record;
|
|
258
|
-
});
|
|
259
|
-
return Object.assign(Object.assign({}, payload), { records });
|
|
260
|
-
}
|
|
261
|
-
const records = payload.records.map((record) => {
|
|
262
|
-
if (!record.__record__metadata__) {
|
|
263
|
-
return record;
|
|
264
|
-
}
|
|
265
|
-
this.saveCacheRmd(record);
|
|
266
|
-
const rowMetadata = Object.assign({}, record.__record__metadata__);
|
|
267
|
-
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
|
268
|
-
this._metadataByRow.set(record.__record__id__, rowMetadata);
|
|
269
|
-
delete record.__record__metadata__;
|
|
270
|
-
return record;
|
|
271
|
-
});
|
|
272
|
-
return Object.assign(Object.assign({}, payload), { records });
|
|
273
|
-
}
|
|
274
|
-
interceptRecordsAdded(action) {
|
|
275
|
-
if (!this.isAllowed("INSERT")) {
|
|
276
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
|
|
280
|
-
}
|
|
281
|
-
interceptRecordsCopied(action) {
|
|
282
|
-
if (!this.isAllowed("CLONE")) {
|
|
283
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
|
|
287
|
-
}
|
|
288
|
-
async interceptDataChange(action) {
|
|
289
|
-
if (this.isAllowed("UPDATE")) {
|
|
290
|
-
return action;
|
|
291
|
-
}
|
|
292
|
-
if (this._openedAlert) {
|
|
293
|
-
await this.dataUnit.cancelEdition();
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
this._openedAlert = true;
|
|
297
|
-
await this.dataUnit.cancelEdition();
|
|
298
|
-
await ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
|
299
|
-
this._openedAlert = false;
|
|
300
|
-
}
|
|
301
|
-
async interceptSavingData(action) {
|
|
302
|
-
if (!this.beforeSave) {
|
|
303
|
-
return action;
|
|
304
|
-
}
|
|
305
|
-
const continueAction = this.beforeSave(this.dataUnit);
|
|
306
|
-
if (continueAction instanceof Promise) {
|
|
307
|
-
const result = await continueAction;
|
|
308
|
-
return result ? action : undefined;
|
|
309
|
-
}
|
|
310
|
-
return continueAction ? action : undefined;
|
|
311
|
-
}
|
|
312
|
-
interceptDataSaved(action) {
|
|
313
|
-
if (this.afterSave) {
|
|
314
|
-
this.afterSave(this.dataUnit);
|
|
315
|
-
return;
|
|
316
|
-
}
|
|
317
|
-
return action;
|
|
318
|
-
}
|
|
319
|
-
async interceptEditionCanceled(action) {
|
|
320
|
-
var _a, _b;
|
|
321
|
-
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)) {
|
|
322
|
-
return action;
|
|
323
|
-
}
|
|
324
|
-
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
325
|
-
if (cancelConfirmation == undefined) {
|
|
326
|
-
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
327
|
-
return action;
|
|
328
|
-
}
|
|
329
|
-
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
330
|
-
const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
|
|
331
|
-
confirm && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
332
|
-
return confirm ? action : undefined;
|
|
333
|
-
}
|
|
334
|
-
async interceptRemovingRecords(action) {
|
|
335
|
-
var _a, _b, _c;
|
|
336
|
-
if (!this.isAllowed("REMOVE")) {
|
|
337
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
let multipleSelection = false;
|
|
341
|
-
let removeConfirmation = !((_a = action.payload) === null || _a === void 0 ? void 0 : _a.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
|
342
|
-
const selection = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getSelectionInfo();
|
|
343
|
-
if (!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
|
344
|
-
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
|
345
|
-
multipleSelection = true;
|
|
346
|
-
}
|
|
347
|
-
if (!removeConfirmation) {
|
|
348
|
-
return action;
|
|
349
|
-
}
|
|
350
|
-
const options = {
|
|
351
|
-
canClose: false,
|
|
352
|
-
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
|
353
|
-
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
|
354
|
-
btnConfirmDanger: false
|
|
355
|
-
};
|
|
356
|
-
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
357
|
-
const confirm = await ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options);
|
|
358
|
-
return confirm ? action : undefined;
|
|
359
|
-
}
|
|
360
|
-
interceptDataLoaded(action) {
|
|
361
|
-
const newPayload = this.getMetadataByRow(action.payload);
|
|
362
|
-
action = new DataUnitAction(Action.DATA_LOADED, newPayload);
|
|
363
|
-
return action;
|
|
364
|
-
}
|
|
365
|
-
interceptMetadataLoaded(action) {
|
|
366
|
-
this.fillFieldsWithRmp(action.payload);
|
|
367
|
-
this.fillFieldsWithRmPrecision(action.payload);
|
|
368
|
-
return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
|
|
369
|
-
}
|
|
370
170
|
async interceptAction(action) {
|
|
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
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
171
|
+
return new Promise(resolve => {
|
|
172
|
+
var _a, _b, _c, _d, _e;
|
|
173
|
+
switch (action.type) {
|
|
174
|
+
case Action.RECORDS_ADDED:
|
|
175
|
+
if (this.isAllowed("INSERT")) {
|
|
176
|
+
resolve(action);
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
case Action.RECORDS_COPIED:
|
|
183
|
+
if (this.isAllowed("CLONE")) {
|
|
184
|
+
const cleanFields = this.getCleanOnCopyFields();
|
|
185
|
+
if (cleanFields.length > 0) {
|
|
186
|
+
const records = action.payload;
|
|
187
|
+
action = new DataUnitAction(Action.RECORDS_COPIED, records.map(record => {
|
|
188
|
+
const newRecord = Object.assign({}, record);
|
|
189
|
+
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
190
|
+
return newRecord;
|
|
191
|
+
}));
|
|
192
|
+
}
|
|
193
|
+
resolve(action);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
case Action.DATA_CHANGED:
|
|
200
|
+
case Action.CHANGING_DATA:
|
|
201
|
+
if (this.isAllowed("UPDATE"))
|
|
202
|
+
return resolve(action);
|
|
203
|
+
if (this._openedAlert)
|
|
204
|
+
return this.dataUnit.cancelEdition();
|
|
205
|
+
this._openedAlert = true;
|
|
206
|
+
this.dataUnit.cancelEdition();
|
|
207
|
+
ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate")).then(() => {
|
|
208
|
+
this._openedAlert = false;
|
|
209
|
+
});
|
|
210
|
+
break;
|
|
211
|
+
case Action.SAVING_DATA:
|
|
212
|
+
if (this.beforeSave) {
|
|
213
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
|
214
|
+
if (continueAction instanceof Promise) {
|
|
215
|
+
continueAction.then(result => resolve(result ? action : undefined));
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
resolve(continueAction ? action : undefined);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
resolve(action);
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
225
|
+
case Action.DATA_SAVED:
|
|
226
|
+
if (this.afterSave) {
|
|
227
|
+
this.afterSave(this.dataUnit);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
resolve(action);
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case Action.EDITION_CANCELED:
|
|
234
|
+
if (!this.useCancelConfirm)
|
|
235
|
+
return resolve(action);
|
|
236
|
+
if (this.dataState.hasDirtyRecords) {
|
|
237
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
238
|
+
if (((_a = action.payload) === null || _a === void 0 ? void 0 : _a.fromParent) || ((_b = action.payload) === null || _b === void 0 ? void 0 : _b.silent)) {
|
|
239
|
+
resolve(action);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (cancelConfirmation == undefined) {
|
|
243
|
+
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
244
|
+
resolve(action);
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
248
|
+
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
|
249
|
+
.then((result) => {
|
|
250
|
+
result && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
251
|
+
resolve(result ? action : undefined);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
resolve(action);
|
|
257
|
+
}
|
|
258
|
+
break;
|
|
259
|
+
case Action.REMOVING_RECORDS:
|
|
260
|
+
if (this.isAllowed("REMOVE")) {
|
|
261
|
+
let multipleSelection = false;
|
|
262
|
+
let removeConfirmation = !((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
|
263
|
+
const selection = (_d = this.dataUnit) === null || _d === void 0 ? void 0 : _d.getSelectionInfo();
|
|
264
|
+
if (!((_e = action.payload) === null || _e === void 0 ? void 0 : _e.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
|
265
|
+
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
|
266
|
+
multipleSelection = true;
|
|
267
|
+
}
|
|
268
|
+
if (!removeConfirmation) {
|
|
269
|
+
resolve(action);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
const options = {
|
|
273
|
+
canClose: false,
|
|
274
|
+
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
|
275
|
+
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
|
276
|
+
btnConfirmDanger: false
|
|
277
|
+
};
|
|
278
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
279
|
+
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options)
|
|
280
|
+
.then((result) => resolve(result ? action : undefined));
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
285
|
+
}
|
|
286
|
+
break;
|
|
287
|
+
default:
|
|
288
|
+
resolve(action);
|
|
289
|
+
}
|
|
456
290
|
});
|
|
457
|
-
return newRecord;
|
|
458
|
-
}
|
|
459
|
-
handleCleanOnCopy(records) {
|
|
460
|
-
const cleanFields = this.getCleanOnCopyFields();
|
|
461
|
-
if (cleanFields.length > 0) {
|
|
462
|
-
records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
|
|
463
|
-
}
|
|
464
|
-
return records;
|
|
465
|
-
}
|
|
466
|
-
buildCopyWithCleanedFields(record, cleanFields) {
|
|
467
|
-
const newRecord = Object.assign({}, record);
|
|
468
|
-
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
469
|
-
return newRecord;
|
|
470
291
|
}
|
|
471
292
|
showSuccessMessage(message) {
|
|
472
293
|
ApplicationUtils.info(message, { iconName: "check" });
|
|
@@ -474,19 +295,9 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
474
295
|
isAllowed(flag) {
|
|
475
296
|
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
476
297
|
}
|
|
477
|
-
buildDataState(
|
|
478
|
-
var _a;
|
|
298
|
+
buildDataState() {
|
|
479
299
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
|
480
300
|
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
|
481
|
-
const selectedRecord = this.dataUnit.getSelectedRecord();
|
|
482
|
-
let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
|
|
483
|
-
const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
|
|
484
|
-
if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
|
|
485
|
-
rowMetadata = this.doGetRowMetadata(selectedRecord);
|
|
486
|
-
}
|
|
487
|
-
else if (rowMetadata) {
|
|
488
|
-
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
|
489
|
-
}
|
|
490
301
|
return new DataStateImpl({
|
|
491
302
|
insertionMode: this.dataUnit.hasNewRecord(),
|
|
492
303
|
isStartingInsertionMode,
|
|
@@ -497,62 +308,20 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
497
308
|
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
|
498
309
|
selectedRecords: undefined,
|
|
499
310
|
selectionInfo,
|
|
500
|
-
selectedRecord,
|
|
501
|
-
recordsIsEmpty: this.dataUnit.records.length === 0
|
|
502
|
-
metadataByRow: this._metadataByRow,
|
|
503
|
-
rowMetadata
|
|
311
|
+
selectedRecord: this.dataUnit.getSelectedRecord(),
|
|
312
|
+
recordsIsEmpty: this.dataUnit.records.length === 0
|
|
504
313
|
});
|
|
505
314
|
}
|
|
506
|
-
async handleDataSaved(action) {
|
|
507
|
-
const newRowMetadata = await this.handleLoadRowMetadata(action);
|
|
508
|
-
if (newRowMetadata) {
|
|
509
|
-
newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
|
|
510
|
-
}
|
|
511
|
-
const recordId = action.payload.records[0].__record__id__;
|
|
512
|
-
this._metadataByRow.set(recordId, newRowMetadata);
|
|
513
|
-
this.dataState = this.buildDataState();
|
|
514
|
-
if (this.ignoreSaveMessage) {
|
|
515
|
-
return;
|
|
516
|
-
}
|
|
517
|
-
const saveOperation = action.payload.changes[0]._operation.toLowerCase();
|
|
518
|
-
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0], saveOperation);
|
|
519
|
-
if (msg != undefined) {
|
|
520
|
-
this.showSuccessMessage(msg);
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
handleRecordsRemoved(action) {
|
|
524
|
-
var _a, _b;
|
|
525
|
-
const cachedRecords = action.payload.cachedRecords;
|
|
526
|
-
let removeFinishMsg;
|
|
527
|
-
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
|
528
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
532
|
-
}
|
|
533
|
-
if (removeFinishMsg != undefined) {
|
|
534
|
-
this.showSuccessMessage(removeFinishMsg);
|
|
535
|
-
}
|
|
536
|
-
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
537
|
-
const paginationInfo = this.dataUnit.getPaginationInfo();
|
|
538
|
-
if (paginationInfo) {
|
|
539
|
-
const page = recordsCount > 0 || paginationInfo.hasMore ? paginationInfo.currentPage : 0;
|
|
540
|
-
this.dataUnit.gotoPage(page);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
315
|
/**
|
|
544
316
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
545
317
|
* através de um pequeno modulo na estrutura da aplicação:
|
|
546
318
|
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
547
319
|
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
|
|
548
320
|
*/
|
|
549
|
-
getMessage(key, params = undefined
|
|
321
|
+
getMessage(key, params = undefined) {
|
|
550
322
|
if (!params) {
|
|
551
323
|
params = this.getMessageParams();
|
|
552
324
|
}
|
|
553
|
-
if (customOperation) {
|
|
554
|
-
this.messagesBuilder.currentOperation = customOperation;
|
|
555
|
-
}
|
|
556
325
|
return this.messagesBuilder.getMessage(key, params);
|
|
557
326
|
}
|
|
558
327
|
getMessageParams() {
|
|
@@ -583,8 +352,7 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
583
352
|
return await this._application.getDataUnit(this.entityName, cacheName, null, this.configName, this.resourceID);
|
|
584
353
|
}
|
|
585
354
|
}
|
|
586
|
-
async loadDataUnit(
|
|
587
|
-
var _a;
|
|
355
|
+
async loadDataUnit() {
|
|
588
356
|
if (this.dataUnit == null && this._application && this.entityName) {
|
|
589
357
|
this.dataUnit = await this.getDataUnitParentOrChild();
|
|
590
358
|
}
|
|
@@ -593,11 +361,6 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
593
361
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
594
362
|
this.dataUnit.addInterceptor(this);
|
|
595
363
|
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
596
|
-
if (forceMetadataLoad || !this.dataUnit.metadata)
|
|
597
|
-
await this.dataUnit.loadMetadata();
|
|
598
|
-
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
|
599
|
-
this.getMetadataByRow(this.dataUnit);
|
|
600
|
-
}
|
|
601
364
|
this.dataState = this.buildDataState();
|
|
602
365
|
let resolver;
|
|
603
366
|
while (resolver = this._onDataUnitResolve.pop()) {
|
|
@@ -616,40 +379,20 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
616
379
|
return;
|
|
617
380
|
}
|
|
618
381
|
handlerLinkFields() {
|
|
619
|
-
var _a, _b
|
|
620
|
-
const
|
|
621
|
-
if (!
|
|
382
|
+
var _a, _b;
|
|
383
|
+
const metadata = Object.assign({}, this.dataUnit.metadata);
|
|
384
|
+
if (!this._parentDataUnit)
|
|
622
385
|
return;
|
|
623
|
-
const
|
|
624
|
-
const child = parentDU.getChildInfo(childName);
|
|
386
|
+
const child = this._parentDataUnit.getChildInfo(this.entityName);
|
|
625
387
|
if (!child)
|
|
626
388
|
return;
|
|
627
|
-
const
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
handleDUWithLinks(fieldsToLink) {
|
|
631
|
-
this.fieldsToLink = fieldsToLink;
|
|
632
|
-
const metadata = Object.assign({}, this.dataUnit.metadata);
|
|
633
|
-
this.processLinks(metadata);
|
|
634
|
-
this.dataUnit.metadata = metadata;
|
|
635
|
-
this.dataUnitFieldsHidded.emit();
|
|
636
|
-
}
|
|
637
|
-
processLinks(metadata) {
|
|
638
|
-
var _a;
|
|
639
|
-
(_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
640
|
-
var _a;
|
|
641
|
-
if ((_a = this.fieldsToLink) === null || _a === void 0 ? void 0 : _a.includes(field.name)) {
|
|
389
|
+
const fieldsLink = (_a = child === null || child === void 0 ? void 0 : child.links) === null || _a === void 0 ? void 0 : _a.map(link => link.target);
|
|
390
|
+
(_b = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _b === void 0 ? void 0 : _b.forEach(field => {
|
|
391
|
+
if (fieldsLink === null || fieldsLink === void 0 ? void 0 : fieldsLink.includes(field.name)) {
|
|
642
392
|
field.visible = false;
|
|
643
393
|
}
|
|
644
394
|
});
|
|
645
|
-
|
|
646
|
-
getCleanDataUnitName() {
|
|
647
|
-
var _a;
|
|
648
|
-
const uri = this.dataUnit.name;
|
|
649
|
-
if (StringUtils.isEmpty(uri))
|
|
650
|
-
return uri;
|
|
651
|
-
const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
|
|
652
|
-
return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
|
|
395
|
+
this.dataUnit.metadata = metadata;
|
|
653
396
|
}
|
|
654
397
|
static getNearestInstance(element) {
|
|
655
398
|
let parent = element.parentElement;
|
|
@@ -660,13 +403,6 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
660
403
|
parent = parent.parentElement;
|
|
661
404
|
}
|
|
662
405
|
}
|
|
663
|
-
instanceMessagesBuilder() {
|
|
664
|
-
var _a;
|
|
665
|
-
if (this.messagesBuilder) {
|
|
666
|
-
return;
|
|
667
|
-
}
|
|
668
|
-
this.messagesBuilder = new SnkMessageBuilder((_a = this.domainMessagesBuilder) !== null && _a !== void 0 ? _a : this.entityName);
|
|
669
|
-
}
|
|
670
406
|
//---------------------------------------------
|
|
671
407
|
// Lifecycle web component
|
|
672
408
|
//---------------------------------------------
|
|
@@ -674,16 +410,17 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
674
410
|
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
675
411
|
this._application.getAllAccess(this.resourceID).then(access => this._permissions = access);
|
|
676
412
|
this._parentSnkDataUnit = this.getParentSnkDataUnit();
|
|
677
|
-
this.
|
|
413
|
+
if (this.messagesBuilder == undefined) {
|
|
414
|
+
this.messagesBuilder = new SnkMessageBuilder(this.entityName);
|
|
415
|
+
}
|
|
678
416
|
}
|
|
679
417
|
disconnectedCallback() {
|
|
680
418
|
if (this.dataUnit) {
|
|
681
419
|
this.dataUnit.releaseCallbacks();
|
|
682
420
|
}
|
|
683
421
|
}
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
this.handlerLinkFields();
|
|
422
|
+
componentDidLoad() {
|
|
423
|
+
this.loadDataUnit();
|
|
687
424
|
}
|
|
688
425
|
render() {
|
|
689
426
|
return (h(Host, null));
|
|
@@ -710,13 +447,8 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
710
447
|
"ignoreSaveMessage": [4, "ignore-save-message"],
|
|
711
448
|
"configName": [1, "config-name"],
|
|
712
449
|
"resourceID": [1, "resource-i-d"],
|
|
713
|
-
"domainMessagesBuilder": [1, "domain-messages-builder"],
|
|
714
|
-
"fieldsToLink": [32],
|
|
715
450
|
"getDataUnit": [64],
|
|
716
|
-
"getSelectedRecordsIDsInfo": [64]
|
|
717
|
-
"getFieldsWithRmp": [64],
|
|
718
|
-
"getFieldsWithRmPrecision": [64],
|
|
719
|
-
"getRowMetadata": [64]
|
|
451
|
+
"getSelectedRecordsIDsInfo": [64]
|
|
720
452
|
}]);
|
|
721
453
|
class DataStateImpl {
|
|
722
454
|
constructor(datastate) {
|
|
@@ -730,8 +462,6 @@ class DataStateImpl {
|
|
|
730
462
|
this.selectionInfo = datastate.selectionInfo;
|
|
731
463
|
this.selectedRecord = datastate.selectedRecord;
|
|
732
464
|
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
|
733
|
-
this.metadataByRow = datastate.metadataByRow;
|
|
734
|
-
this.rowMetadata = datastate.rowMetadata;
|
|
735
465
|
}
|
|
736
466
|
get selectedRecords() {
|
|
737
467
|
var _a;
|
|
@@ -756,4 +486,4 @@ function defineCustomElement() {
|
|
|
756
486
|
} });
|
|
757
487
|
}
|
|
758
488
|
|
|
759
|
-
export { SnkDataUnit as S, defineCustomElement as d
|
|
489
|
+
export { SnkDataUnit as S, defineCustomElement as d };
|