@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-38445.1 → 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-942ce74b.js → ConfigStorage-0a690675.js} +2 -2
- package/dist/cjs/{DataFetcher-313debd8.js → DataFetcher-77729a93.js} +7 -2
- package/dist/cjs/{SnkFormConfigManager-1b13bacd.js → SnkFormConfigManager-d6d5db6d.js} +5 -8
- package/dist/cjs/{SnkMessageBuilder-722b104e.js → SnkMessageBuilder-96b0f549.js} +13 -9
- package/dist/cjs/{IExporterProvider-597949f9.js → SnkMultiSelectionListDataSource-f79d220c.js} +6 -96
- package/dist/cjs/{auth-fetcher-54f5ff9d.js → auth-fetcher-29bb791c.js} +1 -1
- package/dist/cjs/{form-config-fetcher-2dd00e5b.js → form-config-fetcher-feb08214.js} +1 -1
- package/dist/cjs/{index-1dfc7a6e.js → index-0922807b.js} +0 -5
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{dataunit-fetcher-688d3f05.js → pesquisa-fetcher-cba1b3d0.js} +181 -88
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -7
- package/dist/cjs/snk-application.cjs.entry.js +15 -38
- package/dist/cjs/snk-attach.cjs.entry.js +49 -74
- package/dist/cjs/snk-crud.cjs.entry.js +13 -99
- package/dist/cjs/snk-data-exporter.cjs.entry.js +88 -318
- 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 -51
- package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-bar.cjs.entry.js +14 -9
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
- package/dist/cjs/snk-form-config.cjs.entry.js +2 -2
- package/dist/cjs/snk-form-view.cjs.entry.js +0 -67
- package/dist/cjs/snk-form.cjs.entry.js +9 -54
- package/dist/cjs/snk-grid.cjs.entry.js +112 -169
- package/dist/cjs/{snk-guides-viewer-67605336.js → snk-guides-viewer-bfcad2d6.js} +10 -38
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -11
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
- package/dist/cjs/snk-simple-crud.cjs.entry.js +40 -267
- 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 -249
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +0 -135
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +0 -161
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +5 -112
- package/dist/collection/components/snk-data-exporter/exporter-email-sender/options-step.js +1 -1
- 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 +2 -64
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +214 -507
- 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 +3 -6
- 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 +18 -386
- 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/dataUnit/InMemoryLoader.js +3 -7
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +8 -3
- 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 +0 -1
- package/dist/collection/lib/message/resources/snk-exporter.msg.js +1 -1
- package/dist/components/DataFetcher.js +8 -3
- package/dist/components/SnkFormConfigManager.js +3 -6
- 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 -103
- package/dist/components/snk-data-exporter2.js +87 -311
- package/dist/components/snk-data-unit2.js +212 -470
- package/dist/components/snk-detail-view2.js +10 -87
- package/dist/components/snk-exporter-email-sender2.js +1 -1
- package/dist/components/snk-expression-item2.js +1 -1
- package/dist/components/snk-filter-bar2.js +11 -7
- 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 +23 -259
- package/dist/components/snk-taskbar2.js +5 -6
- package/dist/esm/{ConfigStorage-86187da3.js → ConfigStorage-8c2ddac8.js} +2 -2
- package/dist/esm/{DataFetcher-c1baf61d.js → DataFetcher-773a3e4b.js} +8 -3
- package/dist/esm/{SnkFormConfigManager-d4554df9.js → SnkFormConfigManager-c01b9d9d.js} +5 -8
- package/dist/esm/{SnkMessageBuilder-89925609.js → SnkMessageBuilder-72423074.js} +13 -9
- package/dist/esm/{IExporterProvider-63a188b6.js → SnkMultiSelectionListDataSource-a4805051.js} +7 -95
- package/dist/esm/{auth-fetcher-039abba3.js → auth-fetcher-a411f73c.js} +1 -1
- package/dist/esm/{form-config-fetcher-30fb808f.js → form-config-fetcher-e0382e5a.js} +1 -1
- package/dist/esm/{index-3aa4977a.js → index-0ece87a6.js} +1 -6
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{dataunit-fetcher-264191b2.js → pesquisa-fetcher-34a8b8be.js} +182 -84
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +5 -7
- package/dist/esm/snk-application.entry.js +14 -37
- package/dist/esm/snk-attach.entry.js +44 -69
- package/dist/esm/snk-crud.entry.js +13 -99
- package/dist/esm/snk-data-exporter.entry.js +89 -319
- 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 -51
- package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
- package/dist/esm/snk-filter-bar.entry.js +14 -9
- package/dist/esm/snk-filter-modal-item.entry.js +3 -3
- package/dist/esm/snk-form-config.entry.js +2 -2
- package/dist/esm/snk-form-view.entry.js +0 -67
- package/dist/esm/snk-form.entry.js +9 -54
- package/dist/esm/snk-grid.entry.js +110 -167
- package/dist/esm/{snk-guides-viewer-151f6091.js → snk-guides-viewer-edeac29f.js} +10 -38
- package/dist/esm/snk-guides-viewer.entry.js +9 -11
- package/dist/esm/snk-personalized-filter.entry.js +3 -3
- package/dist/esm/snk-simple-crud.entry.js +28 -255
- 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-913a9979.js → p-0cd3c0a9.js} +1 -1
- package/dist/sankhyablocks/p-16a1dd18.entry.js +1 -0
- package/dist/sankhyablocks/p-176c3491.entry.js +1 -0
- package/dist/sankhyablocks/{p-df5451c7.js → p-181975f1.js} +1 -1
- package/dist/sankhyablocks/p-37e5d563.js +65 -0
- package/dist/sankhyablocks/p-38289a55.js +1 -0
- package/dist/sankhyablocks/{p-a1d72395.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-594bc21d.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-aff76a53.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-eae7a817.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-14a08904.entry.js → p-f03e4199.entry.js} +1 -1
- 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 -36
- 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 -19
- 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 +2 -61
- 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-grid/snk-grid.d.ts +6 -46
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +4 -58
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
- package/dist/types/components.d.ts +4 -220
- 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-680e198f.js +0 -166
- package/dist/cjs/snk-data-unit-685272e7.js +0 -679
- 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-03c8f919.js +0 -164
- package/dist/esm/snk-data-unit-63f83504.js +0 -677
- package/dist/sankhyablocks/p-14b9f964.entry.js +0 -1
- package/dist/sankhyablocks/p-19c18d06.entry.js +0 -1
- package/dist/sankhyablocks/p-1db45d26.entry.js +0 -1
- package/dist/sankhyablocks/p-219f888d.entry.js +0 -1
- package/dist/sankhyablocks/p-30cf616e.js +0 -1
- package/dist/sankhyablocks/p-3a212712.js +0 -1
- package/dist/sankhyablocks/p-47b60deb.entry.js +0 -1
- package/dist/sankhyablocks/p-7505da04.entry.js +0 -1
- package/dist/sankhyablocks/p-75f83d1d.entry.js +0 -1
- package/dist/sankhyablocks/p-7a337364.js +0 -1
- package/dist/sankhyablocks/p-829d4045.js +0 -1
- package/dist/sankhyablocks/p-82a0bfb0.entry.js +0 -11
- package/dist/sankhyablocks/p-8fc470e5.entry.js +0 -1
- package/dist/sankhyablocks/p-941bf3ef.entry.js +0 -1
- package/dist/sankhyablocks/p-9863d682.js +0 -1
- package/dist/sankhyablocks/p-af8efd95.js +0 -6
- package/dist/sankhyablocks/p-b4b21558.entry.js +0 -1
- package/dist/sankhyablocks/p-bad55caa.entry.js +0 -1
- package/dist/sankhyablocks/p-c053256c.entry.js +0 -1
- package/dist/sankhyablocks/p-c5268346.entry.js +0 -1
- package/dist/sankhyablocks/p-cefba299.js +0 -1
- package/dist/sankhyablocks/p-dc7c9047.js +0 -1
- package/dist/sankhyablocks/p-f2809746.entry.js +0 -1
- package/dist/sankhyablocks/p-fcac4dfc.js +0 -1
- package/dist/sankhyablocks/p-fe79f83a.js +0 -60
- 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
|
-
break;
|
|
81
|
-
case Action.METADATA_LOADED:
|
|
82
|
-
this.fillFieldsWithRmp(this.dataUnit.metadata);
|
|
83
|
-
this.fillFieldsWithRmPrecision(this.dataUnit.metadata);
|
|
84
|
-
break;
|
|
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();
|
|
85
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
|
+
}
|
|
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;
|
|
@@ -152,320 +125,169 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
152
125
|
* @returns Retorna a lista de IDs dos registros selecionados.
|
|
153
126
|
*/
|
|
154
127
|
async getSelectedRecordsIDsInfo() {
|
|
155
|
-
|
|
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
|
-
return (propPath, fieldName) => {
|
|
191
|
-
if (propPath === "rm_precision") {
|
|
192
|
-
propPath = this.resolvePrecisionFromMetadata(fieldName);
|
|
193
|
-
}
|
|
194
|
-
return ObjectUtils.getProp(rowMetadata, propPath);
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
resolvePrecisionFromMetadata(fieldName) {
|
|
198
|
-
var _a, _b;
|
|
199
|
-
if (!fieldName) {
|
|
200
|
-
ApplicationUtils.error(this.getMessage("snkDataUnit.fieldNameRequired"));
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
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;
|
|
204
|
-
if (!rmPrecision) {
|
|
205
|
-
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
|
+
});
|
|
206
163
|
}
|
|
207
|
-
|
|
208
|
-
return rmPrecisionPath;
|
|
164
|
+
return selectedRecordsIDsInfo;
|
|
209
165
|
}
|
|
210
166
|
getCleanOnCopyFields() {
|
|
211
167
|
var _a;
|
|
212
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);
|
|
213
169
|
}
|
|
214
|
-
fillFieldsWithRmp(payload) {
|
|
215
|
-
payload.fields.forEach((field) => {
|
|
216
|
-
var _a;
|
|
217
|
-
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rmp) && !this._fieldsWithRmp.includes(field.name)) {
|
|
218
|
-
this._fieldsWithRmp.push(field.name);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
fillFieldsWithRmPrecision(payload) {
|
|
223
|
-
payload.fields.forEach((field) => {
|
|
224
|
-
var _a;
|
|
225
|
-
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !this._fieldsWithRmPrecision.includes(field.name)) {
|
|
226
|
-
this._fieldsWithRmPrecision.push(field.name);
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
getCacheName(fieldName, metadataName, fieldValue) {
|
|
231
|
-
const cacheName = [fieldName, metadataName, fieldValue].join("_");
|
|
232
|
-
return cacheName;
|
|
233
|
-
}
|
|
234
|
-
updateDataStateRmp(newValue) {
|
|
235
|
-
const newRowMetadata = Object.assign({}, newValue);
|
|
236
|
-
this.dataState.rowMetadata = newRowMetadata;
|
|
237
|
-
}
|
|
238
|
-
saveCacheRmd(record) {
|
|
239
|
-
const rmd = record.__record__metadata__;
|
|
240
|
-
const keysRmd = Object.keys(rmd);
|
|
241
|
-
keysRmd.shift();
|
|
242
|
-
keysRmd.forEach((fieldName) => {
|
|
243
|
-
const fieldValue = getRecordValue(record, fieldName);
|
|
244
|
-
const cacheName = this.getCacheName(fieldName, rmd.provider, fieldValue);
|
|
245
|
-
this._rowMetadataCache.set(cacheName, Object.assign({}, rmd));
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
getMetadataByRow(payload) {
|
|
249
|
-
var _a;
|
|
250
|
-
if (!((_a = payload.records) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
251
|
-
return payload;
|
|
252
|
-
}
|
|
253
|
-
if (!this._fieldsWithRmp.length) {
|
|
254
|
-
const records = payload.records.map((record) => {
|
|
255
|
-
delete record.__record__metadata__;
|
|
256
|
-
return record;
|
|
257
|
-
});
|
|
258
|
-
return Object.assign(Object.assign({}, payload), { records });
|
|
259
|
-
}
|
|
260
|
-
const records = payload.records.map((record) => {
|
|
261
|
-
if (!record.__record__metadata__) {
|
|
262
|
-
return record;
|
|
263
|
-
}
|
|
264
|
-
this.saveCacheRmd(record);
|
|
265
|
-
const rowMetadata = Object.assign({}, record.__record__metadata__);
|
|
266
|
-
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
|
267
|
-
this._metadataByRow.set(record.__record__id__, rowMetadata);
|
|
268
|
-
delete record.__record__metadata__;
|
|
269
|
-
return record;
|
|
270
|
-
});
|
|
271
|
-
return Object.assign(Object.assign({}, payload), { records });
|
|
272
|
-
}
|
|
273
|
-
interceptRecordsAdded(action) {
|
|
274
|
-
if (!this.isAllowed("INSERT")) {
|
|
275
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
return new DataUnitAction(Action.RECORDS_ADDED, this.handleLinksWithParent(action.payload));
|
|
279
|
-
}
|
|
280
|
-
interceptRecordsCopied(action) {
|
|
281
|
-
if (!this.isAllowed("CLONE")) {
|
|
282
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
285
|
-
return new DataUnitAction(Action.RECORDS_COPIED, this.handleRecordsCopied(action.payload));
|
|
286
|
-
}
|
|
287
|
-
async interceptDataChange(action) {
|
|
288
|
-
if (this.isAllowed("UPDATE")) {
|
|
289
|
-
return action;
|
|
290
|
-
}
|
|
291
|
-
if (this._openedAlert) {
|
|
292
|
-
await this.dataUnit.cancelEdition();
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
this._openedAlert = true;
|
|
296
|
-
await this.dataUnit.cancelEdition();
|
|
297
|
-
await ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
|
298
|
-
this._openedAlert = false;
|
|
299
|
-
}
|
|
300
|
-
async interceptSavingData(action) {
|
|
301
|
-
if (!this.beforeSave) {
|
|
302
|
-
return action;
|
|
303
|
-
}
|
|
304
|
-
const continueAction = this.beforeSave(this.dataUnit);
|
|
305
|
-
if (continueAction instanceof Promise) {
|
|
306
|
-
const result = await continueAction;
|
|
307
|
-
return result ? action : undefined;
|
|
308
|
-
}
|
|
309
|
-
return continueAction ? action : undefined;
|
|
310
|
-
}
|
|
311
|
-
interceptDataSaved(action) {
|
|
312
|
-
if (this.afterSave) {
|
|
313
|
-
this.afterSave(this.dataUnit);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
return action;
|
|
317
|
-
}
|
|
318
|
-
async interceptEditionCanceled(action) {
|
|
319
|
-
var _a, _b;
|
|
320
|
-
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)) {
|
|
321
|
-
return action;
|
|
322
|
-
}
|
|
323
|
-
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
324
|
-
if (cancelConfirmation == undefined) {
|
|
325
|
-
this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
326
|
-
return action;
|
|
327
|
-
}
|
|
328
|
-
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
329
|
-
const confirm = await ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation);
|
|
330
|
-
confirm && this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo"));
|
|
331
|
-
return confirm ? action : undefined;
|
|
332
|
-
}
|
|
333
|
-
async interceptRemovingRecords(action) {
|
|
334
|
-
var _a, _b, _c;
|
|
335
|
-
if (!this.isAllowed("REMOVE")) {
|
|
336
|
-
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
let multipleSelection = false;
|
|
340
|
-
let removeConfirmation = !((_a = action.payload) === null || _a === void 0 ? void 0 : _a.silent) && this.getMessage("snkDataUnit.removeConfirmation");
|
|
341
|
-
const selection = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.getSelectionInfo();
|
|
342
|
-
if (!((_c = action.payload) === null || _c === void 0 ? void 0 : _c.silent) && (selection === null || selection === void 0 ? void 0 : selection.length) > 1) {
|
|
343
|
-
removeConfirmation = this.getMessage("snkDataUnit.removeAllConfirmation", { size: selection.length });
|
|
344
|
-
multipleSelection = true;
|
|
345
|
-
}
|
|
346
|
-
if (!removeConfirmation) {
|
|
347
|
-
return action;
|
|
348
|
-
}
|
|
349
|
-
const options = {
|
|
350
|
-
canClose: false,
|
|
351
|
-
labelCancel: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "no" : "cancel"}`),
|
|
352
|
-
labelConfirm: this.getMessage(`snkDataUnit.confirm.${multipleSelection ? "yes" : "delete"}`),
|
|
353
|
-
btnConfirmDanger: false
|
|
354
|
-
};
|
|
355
|
-
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
356
|
-
const confirm = await ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, null, DialogType.WARN, options);
|
|
357
|
-
return confirm ? action : undefined;
|
|
358
|
-
}
|
|
359
|
-
interceptDataLoaded(action) {
|
|
360
|
-
const newPayload = this.getMetadataByRow(action.payload);
|
|
361
|
-
action = new DataUnitAction(Action.DATA_LOADED, newPayload);
|
|
362
|
-
return action;
|
|
363
|
-
}
|
|
364
|
-
interceptMetadataLoaded(action) {
|
|
365
|
-
this.fillFieldsWithRmp(action.payload);
|
|
366
|
-
this.fillFieldsWithRmPrecision(action.payload);
|
|
367
|
-
return new DataUnitAction(Action.METADATA_LOADED, this.handleDULinksOnMetadataLoaded(action.payload));
|
|
368
|
-
}
|
|
369
170
|
async interceptAction(action) {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
}
|
|
455
290
|
});
|
|
456
|
-
return newRecord;
|
|
457
|
-
}
|
|
458
|
-
handleCleanOnCopy(records) {
|
|
459
|
-
const cleanFields = this.getCleanOnCopyFields();
|
|
460
|
-
if (cleanFields.length > 0) {
|
|
461
|
-
records = records.map(record => this.buildCopyWithCleanedFields(record, cleanFields));
|
|
462
|
-
}
|
|
463
|
-
return records;
|
|
464
|
-
}
|
|
465
|
-
buildCopyWithCleanedFields(record, cleanFields) {
|
|
466
|
-
const newRecord = Object.assign({}, record);
|
|
467
|
-
cleanFields.forEach(fieldName => delete newRecord[fieldName]);
|
|
468
|
-
return newRecord;
|
|
469
291
|
}
|
|
470
292
|
showSuccessMessage(message) {
|
|
471
293
|
ApplicationUtils.info(message, { iconName: "check" });
|
|
@@ -473,19 +295,9 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
473
295
|
isAllowed(flag) {
|
|
474
296
|
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
475
297
|
}
|
|
476
|
-
buildDataState(
|
|
477
|
-
var _a;
|
|
298
|
+
buildDataState() {
|
|
478
299
|
const selectionInfo = this.dataUnit.getSelectionInfo();
|
|
479
300
|
const isStartingInsertionMode = (this.dataUnit.hasDirtyRecords() || this.dataUnit.hasWaitingChanges()) && (selectionInfo === null || selectionInfo === void 0 ? void 0 : selectionInfo.isEmpty());
|
|
480
|
-
const selectedRecord = this.dataUnit.getSelectedRecord();
|
|
481
|
-
let rowMetadata = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata;
|
|
482
|
-
const allowedOverwrite = [Action.SELECTION_CHANGED, Action.EDITION_CANCELED, Action.NEXT_SELECTED, Action.PREVIOUS_SELECTED];
|
|
483
|
-
if (selectedRecord && (!rowMetadata || allowedOverwrite.includes(actionType))) {
|
|
484
|
-
rowMetadata = this.doGetRowMetadata(selectedRecord);
|
|
485
|
-
}
|
|
486
|
-
else if (rowMetadata) {
|
|
487
|
-
rowMetadata.getProp = this.buildGetPropRowMetadata(rowMetadata);
|
|
488
|
-
}
|
|
489
301
|
return new DataStateImpl({
|
|
490
302
|
insertionMode: this.dataUnit.hasNewRecord(),
|
|
491
303
|
isStartingInsertionMode,
|
|
@@ -496,48 +308,10 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
496
308
|
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
|
497
309
|
selectedRecords: undefined,
|
|
498
310
|
selectionInfo,
|
|
499
|
-
selectedRecord,
|
|
500
|
-
recordsIsEmpty: this.dataUnit.records.length === 0
|
|
501
|
-
metadataByRow: this._metadataByRow,
|
|
502
|
-
rowMetadata
|
|
311
|
+
selectedRecord: this.dataUnit.getSelectedRecord(),
|
|
312
|
+
recordsIsEmpty: this.dataUnit.records.length === 0
|
|
503
313
|
});
|
|
504
314
|
}
|
|
505
|
-
async handleDataSaved(action) {
|
|
506
|
-
const newRowMetadata = await this.handleLoadRowMetadata(action);
|
|
507
|
-
if (newRowMetadata) {
|
|
508
|
-
newRowMetadata.getProp = this.buildGetPropRowMetadata(newRowMetadata);
|
|
509
|
-
}
|
|
510
|
-
const recordId = action.payload.records[0].__record__id__;
|
|
511
|
-
this._metadataByRow.set(recordId, newRowMetadata);
|
|
512
|
-
this.dataState = this.buildDataState();
|
|
513
|
-
if (this.ignoreSaveMessage) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
517
|
-
if (msg != undefined) {
|
|
518
|
-
this.showSuccessMessage(msg);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
handleRecordsRemoved(action) {
|
|
522
|
-
var _a, _b;
|
|
523
|
-
const cachedRecords = action.payload.cachedRecords;
|
|
524
|
-
let removeFinishMsg;
|
|
525
|
-
if ((cachedRecords === null || cachedRecords === void 0 ? void 0 : cachedRecords.length) > 1) {
|
|
526
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeAllInfo", { size: cachedRecords.length });
|
|
527
|
-
}
|
|
528
|
-
else {
|
|
529
|
-
removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
530
|
-
}
|
|
531
|
-
if (removeFinishMsg != undefined) {
|
|
532
|
-
this.showSuccessMessage(removeFinishMsg);
|
|
533
|
-
}
|
|
534
|
-
const recordsCount = (_b = (_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
535
|
-
const paginationInfo = this.dataUnit.getPaginationInfo();
|
|
536
|
-
if (paginationInfo) {
|
|
537
|
-
const page = recordsCount > 0 || paginationInfo.hasMore ? paginationInfo.currentPage : 0;
|
|
538
|
-
this.dataUnit.gotoPage(page);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
315
|
/**
|
|
542
316
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
543
317
|
* através de um pequeno modulo na estrutura da aplicação:
|
|
@@ -579,7 +353,6 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
579
353
|
}
|
|
580
354
|
}
|
|
581
355
|
async loadDataUnit() {
|
|
582
|
-
var _a;
|
|
583
356
|
if (this.dataUnit == null && this._application && this.entityName) {
|
|
584
357
|
this.dataUnit = await this.getDataUnitParentOrChild();
|
|
585
358
|
}
|
|
@@ -588,10 +361,6 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
588
361
|
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
589
362
|
this.dataUnit.addInterceptor(this);
|
|
590
363
|
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
591
|
-
await this.dataUnit.loadMetadata();
|
|
592
|
-
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
|
593
|
-
this.getMetadataByRow(this.dataUnit);
|
|
594
|
-
}
|
|
595
364
|
this.dataState = this.buildDataState();
|
|
596
365
|
let resolver;
|
|
597
366
|
while (resolver = this._onDataUnitResolve.pop()) {
|
|
@@ -610,40 +379,20 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
610
379
|
return;
|
|
611
380
|
}
|
|
612
381
|
handlerLinkFields() {
|
|
613
|
-
var _a, _b
|
|
614
|
-
const
|
|
615
|
-
if (!
|
|
382
|
+
var _a, _b;
|
|
383
|
+
const metadata = Object.assign({}, this.dataUnit.metadata);
|
|
384
|
+
if (!this._parentDataUnit)
|
|
616
385
|
return;
|
|
617
|
-
const
|
|
618
|
-
const child = parentDU.getChildInfo(childName);
|
|
386
|
+
const child = this._parentDataUnit.getChildInfo(this.entityName);
|
|
619
387
|
if (!child)
|
|
620
388
|
return;
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
handleDUWithLinks(fieldsToLink) {
|
|
625
|
-
this.fieldsToLink = fieldsToLink;
|
|
626
|
-
const metadata = Object.assign({}, this.dataUnit.metadata);
|
|
627
|
-
this.processLinks(metadata);
|
|
628
|
-
this.dataUnit.metadata = metadata;
|
|
629
|
-
this.dataUnitFieldsHidded.emit();
|
|
630
|
-
}
|
|
631
|
-
processLinks(metadata) {
|
|
632
|
-
var _a;
|
|
633
|
-
(_a = metadata === null || metadata === void 0 ? void 0 : metadata.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
634
|
-
var _a;
|
|
635
|
-
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)) {
|
|
636
392
|
field.visible = false;
|
|
637
393
|
}
|
|
638
394
|
});
|
|
639
|
-
|
|
640
|
-
getCleanDataUnitName() {
|
|
641
|
-
var _a;
|
|
642
|
-
const uri = this.dataUnit.name;
|
|
643
|
-
if (StringUtils.isEmpty(uri))
|
|
644
|
-
return uri;
|
|
645
|
-
const matcher = this.REGEX_DATAUNIT_NAME.exec(uri);
|
|
646
|
-
return (_a = matcher === null || matcher === void 0 ? void 0 : matcher[1]) !== null && _a !== void 0 ? _a : uri;
|
|
395
|
+
this.dataUnit.metadata = metadata;
|
|
647
396
|
}
|
|
648
397
|
static getNearestInstance(element) {
|
|
649
398
|
let parent = element.parentElement;
|
|
@@ -670,9 +419,8 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
670
419
|
this.dataUnit.releaseCallbacks();
|
|
671
420
|
}
|
|
672
421
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
this.handlerLinkFields();
|
|
422
|
+
componentDidLoad() {
|
|
423
|
+
this.loadDataUnit();
|
|
676
424
|
}
|
|
677
425
|
render() {
|
|
678
426
|
return (h(Host, null));
|
|
@@ -699,12 +447,8 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
699
447
|
"ignoreSaveMessage": [4, "ignore-save-message"],
|
|
700
448
|
"configName": [1, "config-name"],
|
|
701
449
|
"resourceID": [1, "resource-i-d"],
|
|
702
|
-
"fieldsToLink": [32],
|
|
703
450
|
"getDataUnit": [64],
|
|
704
|
-
"getSelectedRecordsIDsInfo": [64]
|
|
705
|
-
"getFieldsWithRmp": [64],
|
|
706
|
-
"getFieldsWithRmPrecision": [64],
|
|
707
|
-
"getRowMetadata": [64]
|
|
451
|
+
"getSelectedRecordsIDsInfo": [64]
|
|
708
452
|
}]);
|
|
709
453
|
class DataStateImpl {
|
|
710
454
|
constructor(datastate) {
|
|
@@ -718,8 +462,6 @@ class DataStateImpl {
|
|
|
718
462
|
this.selectionInfo = datastate.selectionInfo;
|
|
719
463
|
this.selectedRecord = datastate.selectedRecord;
|
|
720
464
|
this.recordsIsEmpty = datastate.recordsIsEmpty;
|
|
721
|
-
this.metadataByRow = datastate.metadataByRow;
|
|
722
|
-
this.rowMetadata = datastate.rowMetadata;
|
|
723
465
|
}
|
|
724
466
|
get selectedRecords() {
|
|
725
467
|
var _a;
|
|
@@ -744,4 +486,4 @@ function defineCustomElement() {
|
|
|
744
486
|
} });
|
|
745
487
|
}
|
|
746
488
|
|
|
747
|
-
export { SnkDataUnit as S, defineCustomElement as d
|
|
489
|
+
export { SnkDataUnit as S, defineCustomElement as d };
|