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