@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-kb-67792.0 → 0.0.0-bugfix-dev-kb-67792.2
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-0a690675.js → ConfigStorage-e49214c6.js} +1 -0
- package/dist/cjs/{SnkMultiSelectionListDataSource-f79d220c.js → IExporterProvider-10b7fed5.js} +94 -4
- package/dist/cjs/RecordIDUtils-3735135c.js +43 -0
- package/dist/cjs/{SnkFormConfigManager-d6d5db6d.js → SnkFormConfigManager-beebf47a.js} +8 -7
- package/dist/cjs/{SnkMessageBuilder-96b0f549.js → SnkMessageBuilder-cceebbae.js} +9 -13
- package/dist/cjs/{pesquisa-fetcher-cba1b3d0.js → dataunit-fetcher-d4873076.js} +87 -180
- package/dist/cjs/{index-0922807b.js → index-1dfc7a6e.js} +5 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-fetcher-a1d0353f.js +166 -0
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +5 -3
- package/dist/cjs/snk-application.cjs.entry.js +35 -12
- package/dist/cjs/snk-attach.cjs.entry.js +71 -46
- package/dist/cjs/snk-crud.cjs.entry.js +101 -10
- package/dist/cjs/snk-data-exporter.cjs.entry.js +315 -85
- package/dist/cjs/snk-data-unit-f0221097.js +690 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +12 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +50 -10
- package/dist/cjs/snk-filter-bar.cjs.entry.js +6 -2
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-view.cjs.entry.js +67 -0
- package/dist/cjs/snk-form.cjs.entry.js +52 -7
- package/dist/cjs/snk-grid.cjs.entry.js +168 -111
- package/dist/cjs/{snk-guides-viewer-bfcad2d6.js → snk-guides-viewer-aafc3073.js} +43 -10
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -7
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +269 -40
- package/dist/cjs/snk-taskbar.cjs.entry.js +4 -3
- package/dist/cjs/{taskbar-elements-3ecd1278.js → taskbar-elements-9ad1f9c0.js} +3 -3
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/snk-application/snk-application.js +35 -11
- package/dist/collection/components/snk-attach/snk-attach.js +67 -44
- package/dist/collection/components/snk-crud/interfaces/PropsCustomEditor.js +1 -0
- package/dist/collection/components/snk-crud/interfaces/PropsCustomRender.js +1 -0
- package/dist/collection/components/snk-crud/snk-crud.js +305 -7
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +136 -2
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +161 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +134 -7
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +97 -0
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +74 -0
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +54 -1
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterStrategy.js +1 -0
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +58 -0
- package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +55 -0
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +59 -52
- package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +62 -0
- package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +88 -0
- package/dist/collection/components/snk-data-exporter/utils/ParserExport.js +20 -0
- package/dist/collection/components/snk-data-exporter/utils/RecordIDUtils.js +38 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +540 -219
- package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
- package/dist/collection/components/snk-data-unit/test/resources/parentMetadataMock.js +18 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +22 -1
- package/dist/collection/components/snk-form/snk-form.js +102 -5
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +7 -6
- package/dist/collection/components/snk-form-config/snk-form-config.js +1 -1
- package/dist/collection/components/snk-grid/snk-grid.css +2 -0
- package/dist/collection/components/snk-grid/snk-grid.js +242 -103
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +407 -20
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +2 -2
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +2 -1
- package/dist/collection/lib/@types/index.js +5 -0
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
- package/dist/collection/lib/configs/ConfigStorage.js +1 -0
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +7 -3
- package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
- package/dist/collection/lib/dataUnit/interfaces/InMemoryLoaderConfig.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +3 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +4 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +11 -13
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +53 -4
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +4 -4
- package/dist/collection/lib/message/SnkMessageBuilder.js +5 -12
- package/dist/collection/lib/message/resources/snk-data-exporter.msg.js +2 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +2 -1
- package/dist/components/ConfigStorage.js +1 -0
- package/dist/components/{field-search.js → IExporterProvider.js} +93 -6
- package/dist/components/ISave.js +47 -0
- package/dist/components/SnkFormConfigManager.js +7 -6
- package/dist/components/SnkMessageBuilder.js +9 -13
- package/dist/components/dataunit-fetcher.js +84 -182
- package/dist/components/index2.js +198 -33
- package/dist/components/pesquisa-fetcher.js +164 -0
- package/dist/components/snk-actions-button2.js +4 -11
- package/dist/components/snk-application2.js +31 -9
- package/dist/components/snk-attach2.js +65 -41
- package/dist/components/snk-crud.js +110 -11
- package/dist/components/snk-data-exporter2.js +309 -85
- package/dist/components/snk-data-unit2.js +487 -217
- package/dist/components/snk-detail-view2.js +96 -14
- package/dist/components/snk-expression-item2.js +1 -1
- package/dist/components/snk-filter-bar2.js +6 -1
- package/dist/components/snk-form-config2.js +1 -1
- package/dist/components/snk-form-view2.js +72 -1
- package/dist/components/snk-form.js +53 -6
- package/dist/components/snk-grid2.js +171 -109
- package/dist/components/snk-personalized-filter2.js +1 -1
- package/dist/components/snk-simple-crud2.js +264 -25
- package/dist/components/snk-taskbar2.js +6 -5
- package/dist/esm/{ConfigStorage-8c2ddac8.js → ConfigStorage-e476378d.js} +1 -0
- package/dist/esm/{SnkMultiSelectionListDataSource-a4805051.js → IExporterProvider-d597f27d.js} +93 -5
- package/dist/esm/RecordIDUtils-87d02110.js +41 -0
- package/dist/esm/{SnkFormConfigManager-c01b9d9d.js → SnkFormConfigManager-298cd647.js} +8 -7
- package/dist/esm/{SnkMessageBuilder-72423074.js → SnkMessageBuilder-ae87b754.js} +9 -13
- package/dist/esm/{pesquisa-fetcher-34a8b8be.js → dataunit-fetcher-3d2ec959.js} +83 -181
- package/dist/esm/{index-0ece87a6.js → index-3aa4977a.js} +6 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-fetcher-a87445a0.js +164 -0
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +5 -3
- package/dist/esm/snk-application.entry.js +34 -11
- package/dist/esm/snk-attach.entry.js +66 -41
- package/dist/esm/snk-crud.entry.js +101 -10
- package/dist/esm/snk-data-exporter.entry.js +316 -86
- package/dist/esm/snk-data-unit-1ef94aef.js +688 -0
- package/dist/esm/snk-data-unit.entry.js +12 -2
- package/dist/esm/snk-detail-view.entry.js +50 -10
- package/dist/esm/snk-filter-bar.entry.js +6 -2
- package/dist/esm/snk-filter-modal-item.entry.js +1 -1
- package/dist/esm/snk-form-config.entry.js +1 -1
- package/dist/esm/snk-form-view.entry.js +67 -0
- package/dist/esm/snk-form.entry.js +52 -7
- package/dist/esm/snk-grid.entry.js +166 -109
- package/dist/esm/{snk-guides-viewer-edeac29f.js → snk-guides-viewer-62124f3d.js} +43 -10
- package/dist/esm/snk-guides-viewer.entry.js +9 -7
- package/dist/esm/snk-personalized-filter.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +257 -28
- package/dist/esm/snk-taskbar.entry.js +4 -3
- package/dist/esm/{taskbar-elements-2473c8ac.js → taskbar-elements-d59867f1.js} +3 -3
- package/dist/sankhyablocks/p-08c28ddd.entry.js +1 -0
- package/dist/sankhyablocks/p-091ce761.js +60 -0
- package/dist/sankhyablocks/p-094eebf6.entry.js +1 -0
- package/dist/sankhyablocks/p-0c68f40f.entry.js +1 -0
- package/dist/sankhyablocks/p-162b9a59.entry.js +11 -0
- package/dist/sankhyablocks/p-1db45d26.entry.js +1 -0
- package/dist/sankhyablocks/p-25f1fc39.js +6 -0
- package/dist/sankhyablocks/p-2e9c764c.entry.js +1 -0
- package/dist/sankhyablocks/p-30cf616e.js +1 -0
- package/dist/sankhyablocks/{p-96621231.js → p-3287a6cc.js} +1 -1
- package/dist/sankhyablocks/p-421bec84.entry.js +1 -0
- package/dist/sankhyablocks/p-42f7b05d.entry.js +1 -0
- package/dist/sankhyablocks/p-51999ab5.entry.js +1 -0
- package/dist/sankhyablocks/p-5f016aed.js +1 -0
- package/dist/sankhyablocks/p-6c364d25.entry.js +1 -0
- package/dist/sankhyablocks/p-70001ac1.js +1 -0
- package/dist/sankhyablocks/p-74c665d5.entry.js +1 -0
- package/dist/sankhyablocks/p-76a65660.js +1 -0
- package/dist/sankhyablocks/p-7c4aabe2.js +1 -0
- package/dist/sankhyablocks/{p-ae4fc9a9.js → p-7e7a7473.js} +1 -1
- package/dist/sankhyablocks/p-8c1ff936.entry.js +1 -0
- package/dist/sankhyablocks/p-939e15d3.entry.js +1 -0
- package/dist/sankhyablocks/p-9863d682.js +1 -0
- package/dist/sankhyablocks/{p-41c2c191.entry.js → p-9dfda04a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-c2ae0fab.entry.js → p-bd008859.entry.js} +1 -1
- package/dist/sankhyablocks/p-c273d6ee.js +1 -0
- package/dist/sankhyablocks/p-d65d98ed.entry.js +1 -0
- package/dist/sankhyablocks/p-f2809746.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +7 -3
- package/dist/types/components/snk-attach/snk-attach.d.ts +11 -9
- package/dist/types/components/snk-crud/interfaces/PropsCustomEditor.d.ts +4 -0
- package/dist/types/components/snk-crud/interfaces/PropsCustomRender.d.ts +4 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +45 -1
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +23 -0
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +28 -3
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +24 -0
- package/dist/types/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.d.ts +14 -0
- package/dist/types/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.d.ts +12 -0
- package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +24 -4
- package/dist/types/components/snk-data-exporter/interfaces/IExporterStrategy.d.ts +5 -0
- package/dist/types/components/snk-data-exporter/providers/ClientSideExporterProvider.d.ts +17 -0
- package/dist/types/components/snk-data-exporter/providers/ServerSideExporterProvider.d.ts +17 -0
- package/dist/types/components/snk-data-exporter/snk-data-exporter.d.ts +4 -1
- package/dist/types/components/snk-data-exporter/structure/ItemBuilder.d.ts +21 -0
- package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +77 -0
- package/dist/types/components/snk-data-exporter/utils/ParserExport.d.ts +4 -0
- package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +3 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +67 -3
- package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
- package/dist/types/components/snk-data-unit/test/resources/parentMetadataMock.d.ts +3 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +4 -0
- package/dist/types/components/snk-form/snk-form.d.ts +14 -0
- package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +2 -2
- package/dist/types/components/snk-grid/snk-grid.d.ts +46 -6
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +62 -4
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +1 -1
- package/dist/types/components.d.ts +261 -4
- package/dist/types/lib/@types/index.d.ts +5 -0
- package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +2 -1
- package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
- package/dist/types/lib/dataUnit/interfaces/InMemoryLoaderConfig.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/snk-data-unit-559ac55c.js +0 -462
- package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +0 -34
- package/dist/components/index3.js +0 -199
- package/dist/esm/snk-data-unit-44215df7.js +0 -460
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
- package/dist/sankhyablocks/p-176c3491.entry.js +0 -1
- package/dist/sankhyablocks/p-37e5d563.js +0 -65
- package/dist/sankhyablocks/p-38289a55.js +0 -1
- package/dist/sankhyablocks/p-46e55a95.entry.js +0 -1
- package/dist/sankhyablocks/p-4e728357.entry.js +0 -1
- package/dist/sankhyablocks/p-5571bdfe.js +0 -1
- package/dist/sankhyablocks/p-5630574e.js +0 -1
- package/dist/sankhyablocks/p-5f8c0426.entry.js +0 -1
- package/dist/sankhyablocks/p-80c64add.entry.js +0 -1
- package/dist/sankhyablocks/p-86af4cc2.js +0 -1
- package/dist/sankhyablocks/p-8b690717.js +0 -1
- package/dist/sankhyablocks/p-a1832166.entry.js +0 -1
- package/dist/sankhyablocks/p-a809d944.entry.js +0 -1
- package/dist/sankhyablocks/p-a97226f6.entry.js +0 -1
- package/dist/sankhyablocks/p-add17f6a.entry.js +0 -1
- package/dist/sankhyablocks/p-c5a9a5d9.entry.js +0 -1
- package/dist/sankhyablocks/p-c5aa7d70.entry.js +0 -11
- package/dist/sankhyablocks/p-cb0147ab.entry.js +0 -1
- package/dist/sankhyablocks/p-f0145e3b.js +0 -1
- package/dist/sankhyablocks/p-f03e4199.entry.js +0 -1
- package/dist/sankhyablocks/p-f607db63.entry.js +0 -1
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/index.d.ts +0 -3
|
@@ -1,29 +1,87 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-a7d3d3f1.js';
|
|
2
|
-
import { StringUtils, ApplicationContext, ObjectUtils, DataType,
|
|
2
|
+
import { UserInterface, StringUtils, ApplicationContext, ObjectUtils, DataType, JSUtils, FloatingManager, ElementIDUtils } from '@sankhyalabs/core';
|
|
3
3
|
import { CSSVarsUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
4
|
import { d as VIEW_MODE, S as SIMPLE_CRUD_MODE } from './constants-8457af36.js';
|
|
5
|
-
import { T as TaskbarElement } from './taskbar-elements-
|
|
5
|
+
import { T as TaskbarElement } from './taskbar-elements-d59867f1.js';
|
|
6
6
|
import './DataFetcher-773a3e4b.js';
|
|
7
|
-
import
|
|
8
|
-
import { S as SnkMultiSelectionListDataSource,
|
|
9
|
-
import { P as PresentationMode } from './index-
|
|
7
|
+
import './pesquisa-fetcher-a87445a0.js';
|
|
8
|
+
import { C as CommonsExporter, S as SnkMultiSelectionListDataSource, R as RmPrecisionCustomValueFormatter, a as CrudUtils } from './IExporterProvider-d597f27d.js';
|
|
9
|
+
import { D as DataExporterOption, P as PresentationMode } from './index-3aa4977a.js';
|
|
10
10
|
import './ISave-d8c8bc59.js';
|
|
11
11
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
12
12
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
13
|
+
import { I as InMemoryLoader } from './dataunit-fetcher-3d2ec959.js';
|
|
13
14
|
import './filter-item-type.enum-d45e026f.js';
|
|
14
15
|
import { F as FormConfigFetcher } from './form-config-fetcher-e0382e5a.js';
|
|
15
16
|
import { T as TaskbarProcessor, b as buildFieldSearch, o as openFieldSearch } from './field-search-efbe307f.js';
|
|
16
|
-
import { C as ConfigStorage } from './ConfigStorage-
|
|
17
|
-
import { S as SnkFormConfigManager } from './SnkFormConfigManager-
|
|
18
|
-
import './
|
|
17
|
+
import { C as ConfigStorage } from './ConfigStorage-e476378d.js';
|
|
18
|
+
import { S as SnkFormConfigManager } from './SnkFormConfigManager-298cd647.js';
|
|
19
|
+
import { g as getSelectedIDs } from './RecordIDUtils-87d02110.js';
|
|
20
|
+
import { s as store } from './index-bdf75557.js';
|
|
19
21
|
import './PrintUtils-3e4ff0f5.js';
|
|
22
|
+
import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
|
|
20
23
|
import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
|
24
|
+
import '@sankhyalabs/core/dist/utils/SortingUtils';
|
|
21
25
|
import './ResourceIDUtils-a114189a.js';
|
|
22
|
-
import '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
|
|
23
26
|
|
|
24
27
|
const REGULAR_DEFAULT_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "MORE_OPTIONS"];
|
|
25
28
|
const REGULAR_SELECTED_BTNS = ["INSERT", "REFRESH", "PREVIOUS", "NEXT", "DIVIDER", "CLONE", "REMOVE", "DIVIDER", "MORE_OPTIONS"];
|
|
26
29
|
|
|
30
|
+
class ClientSideExporterProvider extends CommonsExporter {
|
|
31
|
+
getSelectedNumber() {
|
|
32
|
+
return this.dataUnit.getSelectionInfo().length;
|
|
33
|
+
}
|
|
34
|
+
getTotalRecords() {
|
|
35
|
+
var _a, _b, _c;
|
|
36
|
+
const { total } = ((_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getPaginationInfo()) || {};
|
|
37
|
+
return total !== null && total !== void 0 ? total : (_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.records) === null || _c === void 0 ? void 0 : _c.length;
|
|
38
|
+
}
|
|
39
|
+
getSelectedIDs() {
|
|
40
|
+
return getSelectedIDs(this.dataUnit);
|
|
41
|
+
}
|
|
42
|
+
getRecordID() {
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
return (_c = (_b = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.records) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.__record__id__;
|
|
45
|
+
}
|
|
46
|
+
async getRecords() {
|
|
47
|
+
if (this.dataUnit.records.length === 0) {
|
|
48
|
+
return Promise.resolve([]);
|
|
49
|
+
}
|
|
50
|
+
const selectionInfo = this.dataUnit.getSelectionInfo();
|
|
51
|
+
const records = selectionInfo.isEmpty() || selectionInfo.isAllRecords() ? await selectionInfo.getAllRecords() : selectionInfo.records;
|
|
52
|
+
return Promise.resolve(records == undefined ? [] : records);
|
|
53
|
+
}
|
|
54
|
+
getHiddenOptions() {
|
|
55
|
+
return [
|
|
56
|
+
DataExporterOption.EXPORT_BY_EMAIL,
|
|
57
|
+
DataExporterOption.EXPORT_PDF_TO_EMAIL,
|
|
58
|
+
DataExporterOption.EXPORT_XLS_TO_EMAIL,
|
|
59
|
+
DataExporterOption.EXPORT_PAGE_TO_PDF,
|
|
60
|
+
DataExporterOption.EXPORT_PAGE_TO_XLS
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
formatValue(record, column) {
|
|
64
|
+
const { id, descriptionFrom } = column;
|
|
65
|
+
const value = record[descriptionFrom || id];
|
|
66
|
+
if (value == undefined) {
|
|
67
|
+
return "";
|
|
68
|
+
}
|
|
69
|
+
if (descriptionFrom != undefined) {
|
|
70
|
+
return value.label;
|
|
71
|
+
}
|
|
72
|
+
const fieldDescriptor = this.dataUnit.getField(id);
|
|
73
|
+
if (fieldDescriptor.userInterface === UserInterface.SEARCH) {
|
|
74
|
+
return value.value;
|
|
75
|
+
}
|
|
76
|
+
if (column.customFormatter) {
|
|
77
|
+
const ezGridColumn = this.getColumnsState().find(columnState => column.id === columnState.name);
|
|
78
|
+
const formattedValue = column.customFormatter.format(value, ezGridColumn, record.__record__id__);
|
|
79
|
+
return formattedValue;
|
|
80
|
+
}
|
|
81
|
+
return this.dataUnit.getFormattedValue(id, value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
27
85
|
const snkSimpleCrudCss = ".sc-snk-simple-crud-h{display:flex;height:100%;width:100%;--snk-simple-crud-grid--min-height:300px}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto 1fr;row-gap:12px;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}.simple-crud__form--hidden.sc-snk-simple-crud{display:none}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;--ez-grid--min-height:var(--snk-simple-crud-grid--min-height)}ez-form.sc-snk-simple-crud{min-height:300px}";
|
|
28
86
|
|
|
29
87
|
const SnkSimpleCrud = class {
|
|
@@ -38,11 +96,13 @@ const SnkSimpleCrud = class {
|
|
|
38
96
|
this._multiSelectionListDataSource = new SnkMultiSelectionListDataSource();
|
|
39
97
|
this._keyDownHandler = (event) => this.keyDownListener(event);
|
|
40
98
|
this._formConfigFetcher = new FormConfigFetcher();
|
|
99
|
+
this._customEditors = new Map();
|
|
100
|
+
this._customRenders = new Map();
|
|
41
101
|
this._taskbarProcessor = new TaskbarProcessor({
|
|
42
|
-
"snkSimpleCrudTaskbar.form_regular": this.getButtons(false, TaskbarElement.GRID_MODE),
|
|
43
|
-
"snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, TaskbarElement.FORM_MODE),
|
|
44
|
-
"snkSimpleCrudTaskbar.form_selected": this.getButtons(true, TaskbarElement.GRID_MODE),
|
|
45
|
-
"snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, TaskbarElement.FORM_MODE),
|
|
102
|
+
"snkSimpleCrudTaskbar.form_regular": this.getButtons(false, [TaskbarElement.GRID_MODE]),
|
|
103
|
+
"snkSimpleCrudTaskbar.grid_regular": this.getButtons(false, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
|
|
104
|
+
"snkSimpleCrudTaskbar.form_selected": this.getButtons(true, [TaskbarElement.GRID_MODE]),
|
|
105
|
+
"snkSimpleCrudTaskbar.grid_selected": this.getButtons(true, [TaskbarElement.DATA_EXPORTER, TaskbarElement.FORM_MODE]),
|
|
46
106
|
"snkSimpleCrudTaskbar.finish_edition": ["CANCEL", "SAVE"]
|
|
47
107
|
});
|
|
48
108
|
this._showPopUpGridConfig = false;
|
|
@@ -53,12 +113,15 @@ const SnkSimpleCrud = class {
|
|
|
53
113
|
this._customContainerId = `SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${StringUtils.generateUUID()}`;
|
|
54
114
|
this.dataState = undefined;
|
|
55
115
|
this.dataUnit = undefined;
|
|
116
|
+
this.entityName = undefined;
|
|
56
117
|
this.mode = SIMPLE_CRUD_MODE.SERVER;
|
|
57
118
|
this.gridConfig = undefined;
|
|
58
119
|
this.formConfig = undefined;
|
|
59
120
|
this._formFields = [];
|
|
121
|
+
this._fieldsProps = new Map();
|
|
60
122
|
this.multipleSelection = undefined;
|
|
61
123
|
this.useCancelConfirm = true;
|
|
124
|
+
this.pageSize = 150;
|
|
62
125
|
this.resourceID = undefined;
|
|
63
126
|
this.taskbarManager = undefined;
|
|
64
127
|
this.messagesBuilder = undefined;
|
|
@@ -69,6 +132,34 @@ const SnkSimpleCrud = class {
|
|
|
69
132
|
this.gridLegacyConfigName = undefined;
|
|
70
133
|
this.formLegacyConfigName = undefined;
|
|
71
134
|
this.ignoreReadOnlyFormFields = false;
|
|
135
|
+
this.autoFocus = true;
|
|
136
|
+
this.domainMessagesBuilder = undefined;
|
|
137
|
+
this.autoLoad = undefined;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Registra um editor customizado para campos da grade e formulário.
|
|
141
|
+
*/
|
|
142
|
+
async addCustomEditor(fieldName, customEditor) {
|
|
143
|
+
if (this._grid && this._form) {
|
|
144
|
+
this._grid.addCustomEditor(fieldName, customEditor);
|
|
145
|
+
this._form.addCustomEditor(fieldName, customEditor);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const newCustomEditors = new Map(this._customEditors);
|
|
149
|
+
newCustomEditors.set(fieldName, customEditor);
|
|
150
|
+
this._customEditors = newCustomEditors;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Registra um render customizado para colunas da grid.
|
|
154
|
+
*/
|
|
155
|
+
async addGridCustomRender(fieldName, customRender) {
|
|
156
|
+
if (this._grid) {
|
|
157
|
+
this._grid.addGridCustomRender(fieldName, customRender);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const newCustomRenders = new Map(this._customRenders);
|
|
161
|
+
newCustomRenders.set(fieldName, customRender);
|
|
162
|
+
this._customRenders = newCustomRenders;
|
|
72
163
|
}
|
|
73
164
|
handleResourceIDChanged(newValue, oldValue) {
|
|
74
165
|
if (StringUtils.isEmpty(newValue)) {
|
|
@@ -80,9 +171,30 @@ const SnkSimpleCrud = class {
|
|
|
80
171
|
this.loadFormConfig(true);
|
|
81
172
|
this.loadGridConfig(true);
|
|
82
173
|
}
|
|
83
|
-
|
|
174
|
+
/**
|
|
175
|
+
* Registra um formatador de valores para uma coluna da grid.
|
|
176
|
+
*/
|
|
177
|
+
async addCustomValueFormatter(columnName, customFormatter) {
|
|
178
|
+
this._grid.addCustomValueFormatter(columnName, customFormatter);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Remove o formatador de valores de uma coluna da grid.
|
|
182
|
+
*/
|
|
183
|
+
async removeCustomValueFormatter(columnName) {
|
|
184
|
+
this._grid.removeCustomValueFormatter(columnName);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Altera/adiciona uma propriedade nos metadados do campo.
|
|
188
|
+
*/
|
|
189
|
+
async setFieldProp(fieldName, propName, value) {
|
|
190
|
+
const newCustomFieldProps = new Map(this._fieldsProps);
|
|
191
|
+
const currentProps = this._fieldsProps.get(fieldName);
|
|
192
|
+
newCustomFieldProps.set(fieldName, Object.assign(Object.assign({}, currentProps), { [propName]: value }));
|
|
193
|
+
this._fieldsProps = newCustomFieldProps;
|
|
194
|
+
}
|
|
195
|
+
getButtons(selected, extraButtons) {
|
|
84
196
|
return this.addConfigButton(this.resolveInMemoryBtns(selected ? REGULAR_SELECTED_BTNS : REGULAR_DEFAULT_BTNS)
|
|
85
|
-
.concat(
|
|
197
|
+
.concat(extraButtons));
|
|
86
198
|
}
|
|
87
199
|
addConfigButton(buttons) {
|
|
88
200
|
if (this.configName === undefined) {
|
|
@@ -122,15 +234,19 @@ const SnkSimpleCrud = class {
|
|
|
122
234
|
}
|
|
123
235
|
evt.stopPropagation();
|
|
124
236
|
}
|
|
237
|
+
async onChangeEntityName(newValue) {
|
|
238
|
+
if (this.dataUnit)
|
|
239
|
+
return;
|
|
240
|
+
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
241
|
+
this.dataUnit = await application.getDataUnit(newValue, null, null, this.configName);
|
|
242
|
+
}
|
|
125
243
|
onModeChange() {
|
|
126
244
|
if (this.mode == SIMPLE_CRUD_MODE.IN_MEMORY) {
|
|
127
245
|
this.initInMemoryDataUnit();
|
|
128
246
|
}
|
|
129
247
|
}
|
|
130
248
|
observeDataState(newValue, oldValue) {
|
|
131
|
-
|
|
132
|
-
this.dataStateChange.emit(newValue);
|
|
133
|
-
}
|
|
249
|
+
this.handleDataStateChange(newValue, oldValue);
|
|
134
250
|
}
|
|
135
251
|
async observeFormLegacy(newValue, oldValue) {
|
|
136
252
|
await this.handleUpdateFormLegacyConfig(newValue, oldValue);
|
|
@@ -138,6 +254,28 @@ const SnkSimpleCrud = class {
|
|
|
138
254
|
async observeGridLegacy(newValue, oldValue) {
|
|
139
255
|
await this.handleUpdateGridLegacyConfig(newValue, oldValue);
|
|
140
256
|
}
|
|
257
|
+
async handleDataStateChange(newValue, oldValue) {
|
|
258
|
+
if (ObjectUtils.objectToString(oldValue) != ObjectUtils.objectToString(newValue)) {
|
|
259
|
+
this.dataStateChange.emit(newValue);
|
|
260
|
+
}
|
|
261
|
+
await this.processRmPrecision();
|
|
262
|
+
}
|
|
263
|
+
async processRmPrecision() {
|
|
264
|
+
var _a, _b;
|
|
265
|
+
const fieldsWithRmPrecision = await this._snkDataUnit.getFieldsWithRmPrecision();
|
|
266
|
+
for (const field of fieldsWithRmPrecision || []) {
|
|
267
|
+
if (!field) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
const rmPrecision = (_b = (_a = this.dataState) === null || _a === void 0 ? void 0 : _a.rowMetadata) === null || _b === void 0 ? void 0 : _b.getProp('rm_precision', field);
|
|
271
|
+
if (!rmPrecision && rmPrecision !== 0) {
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
await this.setFieldProp(field, 'precision', rmPrecision);
|
|
275
|
+
await this.setFieldProp(field, 'prettyPrecision', rmPrecision);
|
|
276
|
+
}
|
|
277
|
+
this._rmPrecisionCustomValueFormatter.setDataState(this.dataState);
|
|
278
|
+
}
|
|
141
279
|
async handleUpdateGridLegacyConfig(newValue, oldValue) {
|
|
142
280
|
if (newValue == undefined || newValue == oldValue) {
|
|
143
281
|
return;
|
|
@@ -234,6 +372,7 @@ const SnkSimpleCrud = class {
|
|
|
234
372
|
}
|
|
235
373
|
async componentWillRender() {
|
|
236
374
|
this._resourceID = await this.application.getResourceID();
|
|
375
|
+
this.dataExporterProviderStore();
|
|
237
376
|
this._taskbarProcessor.process(this.getTaskBarId(), this.taskbarManager, this.dataState, this.getTaskBarDisabledButtons());
|
|
238
377
|
if (this.configName === undefined) {
|
|
239
378
|
return;
|
|
@@ -245,32 +384,70 @@ const SnkSimpleCrud = class {
|
|
|
245
384
|
this.loadGridConfig();
|
|
246
385
|
this.loadFormConfig();
|
|
247
386
|
}
|
|
387
|
+
componentDidRender() {
|
|
388
|
+
this._rmPrecisionCustomValueFormatter.setGrid(this._grid);
|
|
389
|
+
this.addGridCustomValueFormattters();
|
|
390
|
+
this.setFieldsProps();
|
|
391
|
+
this.setCustomRenders();
|
|
392
|
+
this.setCustomEditors();
|
|
393
|
+
}
|
|
248
394
|
componentWillLoad() {
|
|
249
395
|
this.processMetadata();
|
|
250
396
|
this.onModeChange();
|
|
251
397
|
this.configDatasource();
|
|
398
|
+
this._rmPrecisionCustomValueFormatter = new RmPrecisionCustomValueFormatter();
|
|
252
399
|
}
|
|
253
400
|
componentDidLoad() {
|
|
254
401
|
CSSVarsUtils.applyVarsGrid(this._element, this._grid);
|
|
255
402
|
}
|
|
403
|
+
setCustomRenders() {
|
|
404
|
+
if (!this._grid) {
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
for (const [fieldName, customRender] of this._customRenders) {
|
|
408
|
+
this._grid.addGridCustomRender(fieldName, customRender);
|
|
409
|
+
this._customRenders.delete(fieldName);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
setCustomEditors() {
|
|
413
|
+
if (!this._grid || !this._form) {
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
for (const [fieldName, customEditor] of this._customEditors) {
|
|
417
|
+
this._grid.addCustomEditor(fieldName, customEditor);
|
|
418
|
+
this._form.addCustomEditor(fieldName, customEditor);
|
|
419
|
+
this._customEditors.delete(fieldName);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
256
422
|
configDatasource() {
|
|
257
423
|
this._multiSelectionListDataSource.setApplication(this.application);
|
|
258
424
|
this._multiSelectionListDataSource.setDataUnit(this.dataUnit);
|
|
259
425
|
}
|
|
426
|
+
setFieldsProps() {
|
|
427
|
+
if (!this._form) {
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
for (const [fieldName, props] of this._fieldsProps) {
|
|
431
|
+
for (const prop in props) {
|
|
432
|
+
this._form.setFieldProp(fieldName, prop, props[prop]);
|
|
433
|
+
}
|
|
434
|
+
this._fieldsProps.delete(fieldName);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
260
437
|
getTaskBarId() {
|
|
261
|
-
var _a, _b
|
|
438
|
+
var _a, _b;
|
|
262
439
|
if ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) {
|
|
263
440
|
return "snkSimpleCrudTaskbar.finish_edition";
|
|
264
441
|
}
|
|
265
442
|
if (((_b = this.dataState) === null || _b === void 0 ? void 0 : _b.selectionInfo) &&
|
|
266
443
|
!this.dataState.selectionInfo.isAllRecords() &&
|
|
267
|
-
|
|
444
|
+
this.dataState.selectionInfo.length > 0) {
|
|
268
445
|
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_selected" : "snkSimpleCrudTaskbar.form_selected";
|
|
269
446
|
}
|
|
270
447
|
return this._currentViewMode === VIEW_MODE.GRID ? "snkSimpleCrudTaskbar.grid_regular" : "snkSimpleCrudTaskbar.form_regular";
|
|
271
448
|
}
|
|
272
449
|
initInMemoryDataUnit() {
|
|
273
|
-
this._inMemoryLoader = new InMemoryLoader(this._metadata);
|
|
450
|
+
this._inMemoryLoader = new InMemoryLoader(this._metadata, undefined, { autoLoad: this.autoLoad });
|
|
274
451
|
this.dataUnit = this._inMemoryLoader.dataUnit;
|
|
275
452
|
this.dataUnitReady.emit(this.dataUnit);
|
|
276
453
|
}
|
|
@@ -309,12 +486,11 @@ const SnkSimpleCrud = class {
|
|
|
309
486
|
var _a;
|
|
310
487
|
(_a = this._snkConfigurator) === null || _a === void 0 ? void 0 : _a.close();
|
|
311
488
|
}
|
|
312
|
-
updateConfig() {
|
|
489
|
+
async updateConfig() {
|
|
313
490
|
if (this._formConfigManager == undefined) {
|
|
314
491
|
this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
|
|
315
492
|
}
|
|
316
493
|
this._formConfigManager.setConfig(this.formConfig);
|
|
317
|
-
return;
|
|
318
494
|
}
|
|
319
495
|
processMetadata() {
|
|
320
496
|
const fieldsMetadataElem = this._element.querySelectorAll("snk-field-metadata");
|
|
@@ -346,11 +522,28 @@ const SnkSimpleCrud = class {
|
|
|
346
522
|
};
|
|
347
523
|
}
|
|
348
524
|
}
|
|
525
|
+
addGridCustomValueFormattters() {
|
|
526
|
+
var _a, _b, _c;
|
|
527
|
+
const metadataFields = ((_a = this._metadata) === null || _a === void 0 ? void 0 : _a.fields) || ((_c = (_b = this.dataUnit) === null || _b === void 0 ? void 0 : _b.metadata) === null || _c === void 0 ? void 0 : _c.fields);
|
|
528
|
+
if (!metadataFields) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
const fieldsWithRmPrecision = [];
|
|
532
|
+
metadataFields.forEach((field) => {
|
|
533
|
+
var _a;
|
|
534
|
+
if (((_a = field.properties) === null || _a === void 0 ? void 0 : _a.rm_precision) && !fieldsWithRmPrecision.includes(field.name)) {
|
|
535
|
+
fieldsWithRmPrecision.push(field.name);
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
fieldsWithRmPrecision.forEach(field => {
|
|
539
|
+
this.addCustomValueFormatter(field, this._rmPrecisionCustomValueFormatter);
|
|
540
|
+
});
|
|
541
|
+
}
|
|
349
542
|
onDataStateChange(evt) {
|
|
350
543
|
this.dataState = Object.assign({}, evt.detail);
|
|
351
544
|
}
|
|
352
545
|
getTaskBarDisabledButtons() {
|
|
353
|
-
var _a, _b, _c, _d;
|
|
546
|
+
var _a, _b, _c, _d, _e, _f;
|
|
354
547
|
const disabledButtons = [];
|
|
355
548
|
if (!((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.hasNext)) {
|
|
356
549
|
disabledButtons.push(TaskbarElement.NEXT);
|
|
@@ -361,6 +554,9 @@ const SnkSimpleCrud = class {
|
|
|
361
554
|
if ((_d = (_c = this.dataState) === null || _c === void 0 ? void 0 : _c.selectionInfo) === null || _d === void 0 ? void 0 : _d.isEmpty()) {
|
|
362
555
|
disabledButtons.push(TaskbarElement.FORM_MODE);
|
|
363
556
|
}
|
|
557
|
+
if (((_f = (_e = this.dataState) === null || _e === void 0 ? void 0 : _e.selectionInfo) === null || _f === void 0 ? void 0 : _f.length) > 1) {
|
|
558
|
+
disabledButtons.push(TaskbarElement.CLONE);
|
|
559
|
+
}
|
|
364
560
|
return disabledButtons;
|
|
365
561
|
}
|
|
366
562
|
handleCancelEdit() {
|
|
@@ -504,9 +700,23 @@ const SnkSimpleCrud = class {
|
|
|
504
700
|
.then(() => {
|
|
505
701
|
this.setGridConfig(config);
|
|
506
702
|
this.closeGridConfig();
|
|
703
|
+
this.dataExporterProviderStore();
|
|
507
704
|
});
|
|
508
705
|
evt.stopPropagation();
|
|
509
706
|
}
|
|
707
|
+
async dataExporterProviderStore() {
|
|
708
|
+
if (this.dataUnit == undefined) {
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
if (this._grid == undefined) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
const dataExporterProvider = new ClientSideExporterProvider(this.dataUnit, this._grid);
|
|
715
|
+
store.set("exporterProviders", Object.assign(Object.assign({}, store.get("exporterProviders")), { [this.getDataExporterStoreKey()]: dataExporterProvider }));
|
|
716
|
+
}
|
|
717
|
+
getDataExporterStoreKey() {
|
|
718
|
+
return `SnkSimpleCrudDataExporter:${this.configName == undefined ? this.dataUnit.name : this.configName}`;
|
|
719
|
+
}
|
|
510
720
|
setGridConfig(config) {
|
|
511
721
|
this.gridConfig = config;
|
|
512
722
|
CrudUtils.assertDefaultSorting(this.gridConfig, this.dataUnit);
|
|
@@ -522,6 +732,15 @@ const SnkSimpleCrud = class {
|
|
|
522
732
|
closeFormConfig() {
|
|
523
733
|
this._showFormConfig = false;
|
|
524
734
|
}
|
|
735
|
+
getPageSize() {
|
|
736
|
+
if (this.mode === SIMPLE_CRUD_MODE.IN_MEMORY) {
|
|
737
|
+
return 0;
|
|
738
|
+
}
|
|
739
|
+
if (this.pageSize == undefined) {
|
|
740
|
+
return 150;
|
|
741
|
+
}
|
|
742
|
+
return this.pageSize;
|
|
743
|
+
}
|
|
525
744
|
//No momento não daremos suporte para configuração de formulário quando houver formLegacyConfigName
|
|
526
745
|
handleShowFormConfig() {
|
|
527
746
|
return this._showFormConfig && !this.formLegacyConfigName;
|
|
@@ -530,26 +749,36 @@ const SnkSimpleCrud = class {
|
|
|
530
749
|
return StringUtils.isEmpty(this.resourceID) ? this._resourceID : this.resourceID;
|
|
531
750
|
}
|
|
532
751
|
getFormConfig() {
|
|
533
|
-
var _a
|
|
534
|
-
const configFromManager = (_a = this._formConfigManager) === null || _a === void 0 ? void 0 : _a.getConfig(
|
|
752
|
+
var _a;
|
|
753
|
+
const configFromManager = (_a = this._formConfigManager) === null || _a === void 0 ? void 0 : _a.getConfig(this.dataUnit, this.ignoreReadOnlyFormFields);
|
|
535
754
|
if (!this.configName && !configFromManager) {
|
|
536
755
|
return this.formConfig;
|
|
537
756
|
}
|
|
538
757
|
return configFromManager;
|
|
539
758
|
}
|
|
759
|
+
updateFormConfig() {
|
|
760
|
+
const newConfig = Object.assign(Object.assign({}, this.formConfig), { fields: this.dataUnit.metadata.fields });
|
|
761
|
+
this.setFormConfig(newConfig, true);
|
|
762
|
+
if (this._formConfigManager == undefined) {
|
|
763
|
+
this._formConfigManager = new SnkFormConfigManager(this.configName, this.resolveResourceID());
|
|
764
|
+
}
|
|
765
|
+
this._formConfigManager.setConfig(this.formConfig);
|
|
766
|
+
}
|
|
540
767
|
/* istanbul ignore next */
|
|
541
768
|
render() {
|
|
542
769
|
var _a;
|
|
543
770
|
if (this.dataUnit == undefined) {
|
|
544
771
|
return;
|
|
545
772
|
}
|
|
546
|
-
|
|
773
|
+
const taskbarContent = (h("snk-taskbar", { class: this._currentViewMode === VIEW_MODE.FORM && "ez-box ez-box--shadow ez-padding--medium", dataUnit: this.dataUnit, primaryButton: ((_a = this.dataState) === null || _a === void 0 ? void 0 : _a.isDirty) ? "SAVE" : "INSERT", "data-element-id": "grid_left", messagesBuilder: this.messagesBuilder, buttons: this._taskbarProcessor.buttons, actionsList: this.getActionsList(), disabledButtons: this._taskbarProcessor.disabledButtons, customButtons: this._taskbarProcessor.customButtons, "data-exporter-store-key": this.getDataExporterStoreKey(), slot: "leftButtons", presentationMode: PresentationMode.SECONDARY }, h("slot", { name: "TASKBAR_CUSTOM_ELEMENTS" })));
|
|
774
|
+
return (h("snk-data-unit", { ref: ref => this._snkDataUnit = ref, class: "simple-crud__container", dataUnit: this.dataUnit, useCancelConfirm: this.useCancelConfirm, onDataStateChange: evt => this.onDataStateChange(evt), onCancelEdition: this.handleCancelEdit.bind(this), pageSize: this.getPageSize(), onInsertionMode: () => this.goToView(VIEW_MODE.FORM), onDataUnitReady: (evt) => this.dataUnitReady.emit(evt.detail), ignoreSaveMessage: this._currentViewMode === VIEW_MODE.GRID, onMessagesBuilderUpdated: evt => this.messagesBuilder = evt.detail, onDataUnitFieldsHidded: this.updateFormConfig.bind(this), domainMessagesBuilder: this.domainMessagesBuilder }, h("header", null, h("slot", { name: "snkSimpleCrudHeader" })), h("section", { class: "ez-box ez-box--shadow simple-crud__container-section" }, this._currentViewMode === VIEW_MODE.FORM && taskbarContent, h("ez-view-stack", { ref: (ref) => this._viewStack = ref, "data-element-id": "simple-crud" }, h("stack-item", null, h("ez-grid", { class: "ez-margin-bottom--large", ref: ref => this._grid = ref, dataUnit: this.dataUnit, config: this.gridConfig, "no-header": true, multipleSelection: this.multipleSelection, onEzDoubleClick: () => this.goToView(VIEW_MODE.FORM), onConfigChange: evt => this.gridConfigChangeHandler(evt), columnfilterDataSource: this.dataUnit.name && this.dataUnit.name.includes(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME)
|
|
547
775
|
? undefined
|
|
548
|
-
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab }, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
|
|
776
|
+
: this._multiSelectionListDataSource, useEnterLikeTab: this.useEnterLikeTab, autoFocus: this.autoFocus }, this._currentViewMode === VIEW_MODE.GRID && taskbarContent, h("div", { slot: "footer" }, h("slot", { name: "snkSimpleCrudFooter" })))), h("stack-item", null, h("ez-form", { ref: (ref) => this._form = ref, class: `ez-margin-top--large ${this.handleShowFormConfig() ? "simple-crud__form--hidden" : ""}`, dataUnit: this.dataUnit, config: this.getFormConfig(), fieldToFocus: this._fieldToGetFocus, onEzFormSetFields: (evt) => this.handleFormSetFields(evt.detail), onEzFormRequestClearFieldToFocus: this.clearFieldToFocusHandler.bind(this) }), this.handleShowFormConfig() && h("snk-form-config", { messagesBuilder: this.messagesBuilder, dataUnit: this.dataUnit, configManager: this._formConfigManager, onConfigClose: () => this.closeFormConfig() })), this.messagesBuilder && h("snk-configurator", { ref: (ref) => this._snkConfigurator = ref, viewMode: this._currentViewMode, messagesBuilder: this.messagesBuilder, onConfigSelected: (evt) => this.goToView(evt.detail), onOpenConfig: (evt) => this.openConfig(evt.detail), showActionButtons: this.showConfiguratorButtons, onSave: evt => this.handleConfiguratorEvent(evt, 'SAVE'), onCancel: evt => this.handleConfiguratorEvent(evt, 'CANCEL'), resourceID: this.resolveResourceID(), customContainerId: this._customContainerId })), h("div", { id: `${this._customContainerId}` }, h("slot", { name: "SnkConfigContainerSlot" }))), h("ez-modal", { modalSize: "small", closeEsc: false, closeOutsideClick: false, opened: this._showPopUpGridConfig, onEzCloseModal: () => this.closeGridConfig() }, h("snk-grid-config", { ref: ref => this._snkGridConfig = ref, config: this.gridConfig, "data-element-id": this._element.getAttribute(ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME), selectedIndex: 0, configName: this.configName, onConfigChange: (evt) => this.modalConfigChangeHandler(evt), onConfigCancel: () => this.closeGridConfig(), resourceID: this.resolveResourceID() }))));
|
|
549
777
|
}
|
|
550
778
|
get _element() { return getElement(this); }
|
|
551
779
|
static get watchers() { return {
|
|
552
780
|
"resourceID": ["handleResourceIDChanged"],
|
|
781
|
+
"entityName": ["onChangeEntityName"],
|
|
553
782
|
"mode": ["onModeChange"],
|
|
554
783
|
"dataState": ["observeDataState"],
|
|
555
784
|
"formLegacyConfigName": ["observeFormLegacy"],
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-a7d3d3f1.js';
|
|
2
2
|
import { Action, StringUtils, ApplicationContext, OVERFLOWED_CLASS_NAME, OverflowWatcher, OverflowDirection, ElementIDUtils } from '@sankhyalabs/core';
|
|
3
3
|
import { A as AuthorizationConfig } from './AuthorizationConfig-dcbd207a.js';
|
|
4
|
-
import { T as TaskbarElement, V as VisibleWhenForbidden, A as AuthorizationElements, b as buildElem, a as buildCustomButton } from './taskbar-elements-
|
|
5
|
-
import { P as PresentationMode } from './index-
|
|
4
|
+
import { T as TaskbarElement, V as VisibleWhenForbidden, A as AuthorizationElements, b as buildElem, a as buildCustomButton } from './taskbar-elements-d59867f1.js';
|
|
5
|
+
import { P as PresentationMode } from './index-3aa4977a.js';
|
|
6
6
|
import './index-bdf75557.js';
|
|
7
7
|
|
|
8
8
|
const snkTaskbarCss = ".sc-snk-taskbar-h{display:flex;flex-wrap:wrap}.no-wrap.sc-snk-taskbar-h{flex-wrap:nowrap}.full-width.sc-snk-taskbar-h{width:100%}.align-right.sc-snk-taskbar-h{justify-content:flex-end}.overflowed.sc-snk-taskbar{display:none}";
|
|
@@ -189,8 +189,9 @@ const SnkTaskbar = class {
|
|
|
189
189
|
className += "ez-padding-left--medium";
|
|
190
190
|
}
|
|
191
191
|
const taskbarElement = TaskbarElement[def.toString()];
|
|
192
|
+
const dataExporterStoreKey = this._element.dataset.exporterStoreKey || this.configName;
|
|
192
193
|
if (taskbarElement) {
|
|
193
|
-
return buildElem(def, className, this.getIdElemBtnNative(def), elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.buildDynamicActionsList(),
|
|
194
|
+
return buildElem(def, className, this.getIdElemBtnNative(def), elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.buildDynamicActionsList(), dataExporterStoreKey, this.presentationMode);
|
|
194
195
|
}
|
|
195
196
|
else {
|
|
196
197
|
return buildCustomButton(def, className, this.getIdElemBtnCustom(def), elem => this.elementClick(elem), elem => this.isEnabled(elem));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { h } from './index-a7d3d3f1.js';
|
|
2
|
-
import { P as PresentationMode } from './index-
|
|
2
|
+
import { P as PresentationMode } from './index-3aa4977a.js';
|
|
3
3
|
import { s as store } from './index-bdf75557.js';
|
|
4
4
|
|
|
5
5
|
var TaskbarElement;
|
|
@@ -48,7 +48,7 @@ const buildCustomButton = (def, className, dataElementId, action, isEnabled) =>
|
|
|
48
48
|
return textButton(def.name, className, dataElementId, text, hint, action, isEnabled);
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
|
-
const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions,
|
|
51
|
+
const buildElem = (element, className, dataElementId, getTitle, action, isEnabled, actions, dataExporterStoreKey, presentationMode) => {
|
|
52
52
|
var _a;
|
|
53
53
|
const title = getTitle(element);
|
|
54
54
|
switch (element) {
|
|
@@ -91,7 +91,7 @@ const buildElem = (element, className, dataElementId, getTitle, action, isEnable
|
|
|
91
91
|
case TaskbarElement.DIVIDER:
|
|
92
92
|
return h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin--none ez-margin-left--medium", "data-taskbar-divider": true });
|
|
93
93
|
case TaskbarElement.DATA_EXPORTER:
|
|
94
|
-
const provider = (_a = store.get("exporterProviders")) === null || _a === void 0 ? void 0 : _a[
|
|
94
|
+
const provider = (_a = store.get("exporterProviders")) === null || _a === void 0 ? void 0 : _a[dataExporterStoreKey];
|
|
95
95
|
return h("snk-data-exporter", { class: className, provider: provider, "data-element-id": dataElementId, "data-taskbar-element": element });
|
|
96
96
|
case TaskbarElement.ATTACH:
|
|
97
97
|
return iconButton("anexo", element, className, dataElementId, title, action, isEnabled);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as i,c as t,h as s,g as e}from"./p-d2d301a6.js";import{UserInterface as o,StringUtils as n,ApplicationContext as h,ObjectUtils as a,DataType as r,JSUtils as d,FloatingManager as l,ElementIDUtils as u}from"@sankhyalabs/core";import{CSSVarsUtils as c}from"@sankhyalabs/ezui/dist/collection/utils";import{d as m,S as v}from"./p-b0ef4383.js";import{T as f}from"./p-7e7a7473.js";import"./p-594bc21d.js";import"./p-25f1fc39.js";import{C as p,S as g,R as C,a as S}from"./p-76a65660.js";import{D as k,P as b}from"./p-30cf616e.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{I as y}from"./p-091ce761.js";import"./p-ff1990ad.js";import{F as w}from"./p-181975f1.js";import{T as E,b as _,o as T}from"./p-c2495304.js";import{C as I}from"./p-3287a6cc.js";import{S as F}from"./p-5f016aed.js";import{g as R}from"./p-9863d682.js";import{s as D}from"./p-6dc031de.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"@sankhyalabs/core/dist/utils/SortingUtils";import"./p-688dcb4c.js";const z=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","MORE_OPTIONS"],O=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER","MORE_OPTIONS"];class M extends p{getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var i,t,s;const{total:e}=(null===(i=this.dataUnit)||void 0===i?void 0:i.getPaginationInfo())||{};return null!=e?e:null===(s=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===s?void 0:s.length}getSelectedIDs(){return R(this.dataUnit)}getRecordID(){var i,t,s;return null===(s=null===(t=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===t?void 0:t[0])||void 0===s?void 0:s.__record__id__}async getRecords(){if(0===this.dataUnit.records.length)return Promise.resolve([]);const i=this.dataUnit.getSelectionInfo(),t=i.isEmpty()||i.isAllRecords()?await i.getAllRecords():i.records;return Promise.resolve(null==t?[]:t)}getHiddenOptions(){return[k.EXPORT_BY_EMAIL,k.EXPORT_PDF_TO_EMAIL,k.EXPORT_XLS_TO_EMAIL,k.EXPORT_PAGE_TO_PDF,k.EXPORT_PAGE_TO_XLS]}formatValue(i,t){const{id:s,descriptionFrom:e}=t,n=i[e||s];if(null==n)return"";if(null!=e)return n.label;if(this.dataUnit.getField(s).userInterface===o.SEARCH)return n.value;if(t.customFormatter){const s=this.getColumnsState().find((i=>t.id===i.name));return t.customFormatter.format(n,s,i.__record__id__)}return this.dataUnit.getFormattedValue(s,n)}}const P=class{constructor(s){i(this,s),this.dataStateChange=t(this,"dataStateChange",3),this.dataUnitReady=t(this,"dataUnitReady",3),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this.configuratorSave=t(this,"configuratorSave",7),this.configuratorCancel=t(this,"configuratorCancel",7),this._multiSelectionListDataSource=new g,this._keyDownHandler=i=>this.keyDownListener(i),this._formConfigFetcher=new w,this._customEditors=new Map,this._customRenders=new Map,this._taskbarProcessor=new E({"snkSimpleCrudTaskbar.form_regular":this.getButtons(!1,[f.GRID_MODE]),"snkSimpleCrudTaskbar.grid_regular":this.getButtons(!1,[f.DATA_EXPORTER,f.FORM_MODE]),"snkSimpleCrudTaskbar.form_selected":this.getButtons(!0,[f.GRID_MODE]),"snkSimpleCrudTaskbar.grid_selected":this.getButtons(!0,[f.DATA_EXPORTER,f.FORM_MODE]),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._showPopUpGridConfig=!1,this._showFormConfig=!1,this._currentViewMode=m.GRID,this._config=void 0,this._fieldToGetFocus=void 0,this._customContainerId=`SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${n.generateUUID()}`,this.dataState=void 0,this.dataUnit=void 0,this.entityName=void 0,this.mode=v.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this._formFields=[],this._fieldsProps=new Map,this.multipleSelection=void 0,this.useCancelConfirm=!0,this.pageSize=150,this.resourceID=void 0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.actionsList=void 0,this.configName=void 0,this.showConfiguratorButtons=void 0,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0,this.ignoreReadOnlyFormFields=!1,this.autoFocus=!0,this.domainMessagesBuilder=void 0,this.autoLoad=void 0}async addCustomEditor(i,t){if(this._grid&&this._form)return this._grid.addCustomEditor(i,t),void this._form.addCustomEditor(i,t);const s=new Map(this._customEditors);s.set(i,t),this._customEditors=s}async addGridCustomRender(i,t){if(this._grid)return void this._grid.addGridCustomRender(i,t);const s=new Map(this._customRenders);s.set(i,t),this._customRenders=s}handleResourceIDChanged(i,t){n.isEmpty(i)||i!==t&&(this.loadFormConfig(!0),this.loadGridConfig(!0))}async addCustomValueFormatter(i,t){this._grid.addCustomValueFormatter(i,t)}async removeCustomValueFormatter(i){this._grid.removeCustomValueFormatter(i)}async setFieldProp(i,t,s){const e=new Map(this._fieldsProps),o=this._fieldsProps.get(i);e.set(i,Object.assign(Object.assign({},o),{[t]:s})),this._fieldsProps=e}getButtons(i,t){return this.addConfigButton(this.resolveInMemoryBtns(i?O:z).concat(t))}addConfigButton(i){return void 0===this.configName?i:i.concat(f.CONFIGURATOR)}get application(){return h.getContextValue("__SNK__APPLICATION__")}resolveInMemoryBtns(i){const t=[...i];return this.mode===v.IN_MEMORY&&t.splice(1,1),t}async goToView(i){this._currentViewMode=i,this._viewStack&&this._viewStack.show(i)}actionClickListener(i){const t=i.detail;t===f.CONFIGURATOR?this._snkConfigurator.open():t===f.GRID_MODE?this.goToView(m.GRID):t===f.FORM_MODE&&this.goToView(m.FORM),i.stopPropagation()}async onChangeEntityName(i){if(this.dataUnit)return;const t=h.getContextValue("__SNK__APPLICATION__");this.dataUnit=await t.getDataUnit(i,null,null,this.configName)}onModeChange(){this.mode==v.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(i,t){this.handleDataStateChange(i,t)}async observeFormLegacy(i,t){await this.handleUpdateFormLegacyConfig(i,t)}async observeGridLegacy(i,t){await this.handleUpdateGridLegacyConfig(i,t)}async handleDataStateChange(i,t){a.objectToString(t)!=a.objectToString(i)&&this.dataStateChange.emit(i),await this.processRmPrecision()}async processRmPrecision(){var i,t;const s=await this._snkDataUnit.getFieldsWithRmPrecision();for(const e of s||[]){if(!e)continue;const s=null===(t=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata)||void 0===t?void 0:t.getProp("rm_precision",e);(s||0===s)&&(await this.setFieldProp(e,"precision",s),await this.setFieldProp(e,"prettyPrecision",s))}this._rmPrecisionCustomValueFormatter.setDataState(this.dataState)}async handleUpdateGridLegacyConfig(i,t){null!=i&&i!=t&&this._gridConfigAlreadyLoaded&&await this.loadGridConfig(!0)}async handleUpdateFormLegacyConfig(i,t){null!=i&&i!=t&&this._formConfigAlreadyLoaded&&this.loadFormConfig(!0)}openConfig(i){this._snkConfigurator.close(),i===m.GRID?this.openGridConfig():i===m.FORM&&this.openFormConfig()}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._showPopUpGridConfig=!0}))}async openFormConfig(){var i,t;if(this.formLegacyConfigName){const s=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkSimpleCrud.formConfigUnavaliable.title",void 0),e=null===(t=this.messagesBuilder)||void 0===t?void 0:t.getMessage("snkSimpleCrud.formConfigUnavaliable.message",void 0);await this.application.alert(s,e)}else this._showFormConfig=!0}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&I.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}loadGridConfig(i){if(void 0!==this.configName&&(null==this.gridConfig&&!this._gridConfigAlreadyLoaded||i))return this.addGridLegacyConfigName(),this._gridConfigAlreadyLoaded=!0,new Promise(((i,t)=>{I.loadGridConfig(this.configName,this.resolveResourceID()).then((t=>{this.setGridConfig(t),i()})).catch((i=>{t(i)}))}))}formConfigIsLoaded(){return null!=this.formConfig||this._formConfigAlreadyLoaded}async loadFormConfig(i=!1){if(void 0===this.configName)return;if(null==this._formConfigManager&&(this._formConfigManager=new F(this.configName,this.resolveResourceID()),this._formConfigManager.setConfig(this.formConfig)),this.formConfigIsLoaded()&&!i)return;this._formConfigAlreadyLoaded=!0;let t=await this._formConfigFetcher.fetchLegacyConfigurableForm(this.formLegacyConfigName);if(null!=t)return this._formConfigManager.setConfig(t),void this.setFormConfig(t);this.setFormConfig(await this._formConfigManager.loadConfig())}async componentWillRender(){this._resourceID=await this.application.getResourceID(),this.dataExporterProviderStore(),this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons()),void 0!==this.configName&&(null!=this.gridConfig||this._gridConfigAlreadyLoaded||(await this.addGridLegacyConfigName(),this.loadGridConfig(),this.loadFormConfig()))}componentDidRender(){this._rmPrecisionCustomValueFormatter.setGrid(this._grid),this.addGridCustomValueFormattters(),this.setFieldsProps(),this.setCustomRenders(),this.setCustomEditors()}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource(),this._rmPrecisionCustomValueFormatter=new C}componentDidLoad(){c.applyVarsGrid(this._element,this._grid)}setCustomRenders(){if(this._grid)for(const[i,t]of this._customRenders)this._grid.addGridCustomRender(i,t),this._customRenders.delete(i)}setCustomEditors(){if(this._grid&&this._form)for(const[i,t]of this._customEditors)this._grid.addCustomEditor(i,t),this._form.addCustomEditor(i,t),this._customEditors.delete(i)}configDatasource(){this._multiSelectionListDataSource.setApplication(this.application),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}setFieldsProps(){if(this._form)for(const[i,t]of this._fieldsProps){for(const s in t)this._form.setFieldProp(i,s,t[s]);this._fieldsProps.delete(i)}}getTaskBarId(){var i,t;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(t=this.dataState)||void 0===t?void 0:t.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&this.dataState.selectionInfo.length>0?this._currentViewMode===m.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===m.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new y(this._metadata,void 0,{autoLoad:this.autoLoad}),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(i){return this._inMemoryLoader?this._inMemoryLoader.metadata=i:this.dataUnit&&(this.dataUnit.metadata=i),Promise.resolve()}setRecords(i){return this._inMemoryLoader?this._inMemoryLoader.records=i:this.dataUnit&&(this.dataUnit.records=i),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}async openConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.open()}async closeConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.close()}async updateConfig(){null==this._formConfigManager&&(this._formConfigManager=new F(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}processMetadata(){const i=this._element.querySelectorAll("snk-field-metadata"),t=[],s={fields:[],emptyConfig:!1};i.forEach((i=>{const e={name:i.getAttribute("name")||i.getAttribute("label"),label:i.getAttribute("label"),dataType:r[i.getAttribute("dataType")]||r.TEXT,userInterface:o[i.getAttribute("userInterface")]||o.SHORTTEXT,readOnly:"true"==i.getAttribute("readOnly"),required:"true"==i.getAttribute("required"),tab:i.getAttribute("tab")||void 0,visible:"false"!=i.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),t.push(e)})),t.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:t})}addGridCustomValueFormattters(){var i,t,s;const e=(null===(i=this._metadata)||void 0===i?void 0:i.fields)||(null===(s=null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)||void 0===s?void 0:s.fields);if(!e)return;const o=[];e.forEach((i=>{var t;(null===(t=i.properties)||void 0===t?void 0:t.rm_precision)&&!o.includes(i.name)&&o.push(i.name)})),o.forEach((i=>{this.addCustomValueFormatter(i,this._rmPrecisionCustomValueFormatter)}))}onDataStateChange(i){this.dataState=Object.assign({},i.detail)}getTaskBarDisabledButtons(){var i,t,s,e,o,n;const h=[];return(null===(i=this.dataState)||void 0===i?void 0:i.hasNext)||h.push(f.NEXT),(null===(t=this.dataState)||void 0===t?void 0:t.hasPrevious)||h.push(f.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&h.push(f.FORM_MODE),(null===(n=null===(o=this.dataState)||void 0===o?void 0:o.selectionInfo)||void 0===n?void 0:n.length)>1&&h.push(f.CLONE),h}handleCancelEdit(){var i;(null===(i=this.dataState)||void 0===i?void 0:i.recordsIsEmpty)&&(this.goToView(m.GRID),this.dataUnit.clearSelection())}handleConfiguratorEvent(i,t){i.stopImmediatePropagation(),"SAVE"!==t?this.configuratorCancel.emit():this.configuratorSave.emit()}getColumnSearch(i,t){return null!=this._columnSearch||(this._moreOptions=i,this._columnSearch=_(t,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(t=>{var s;null!=t&&(this._grid.locateColumn(t.value),null===(s=i.hideActions)||void 0===s||s.call(i))}))),this._columnSearch}onSelectField(i,t){null!=i&&(this._fieldToGetFocus=i.value,t.hideActions())}getFieldSearch(i,t){return null!=this._fieldSearch||(this._moreOptions=i,i.addEventListener("ezPopoverOpen",(()=>this.findField())),this._fieldSearch=_(t,(({argument:i})=>this.fieldsOptionLoader(i)),(t=>this.onSelectField(t,i)))),this._fieldSearch}getFormFields(){var i,t;return null!==(t=null===(i=this.formConfig)||void 0===i?void 0:i.fields)&&void 0!==t?t:this._formFields}handleFormSetFields(i){a.equals(this._formFields,i)||(this._formFields=null!=i?i:[])}fieldsOptionLoader(i){const t=null==i?void 0:i.toLowerCase(),s=this.getFormFields().map((i=>{var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.getField(i.name)})).filter((i=>{var s,e;return(null===(s=i.name)||void 0===s?void 0:s.toLowerCase().includes(t))||(null===(e=i.label)||void 0===e?void 0:e.toLowerCase().includes(t))})).map((i=>({value:i.name,label:i.label})));return Promise.resolve(s)}getActionsList(){var i,t;const s=[{value:n.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkSimpleCrud.findColumn",void 0))&&void 0!==t?t:"Buscar",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this._currentViewMode===m.GRID?this.getColumnSearch(i,t):this.getFieldSearch(i,t)}];if(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const i=this.getTopTaskBarId();return s.concat(this.taskbarManager.getMoreOptions(i,this.configName,this.dataState,this.actionsList))}return s.concat(this.actionsList)}getTopTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?`snkGridTopTaskbar.finish_edition${b.PRIMARY}`:`snkGridTopTaskbar.regular${b.PRIMARY}`}async keyDownListener(i){i.ctrlKey&&null!=i.key&&"F"===i.key.toUpperCase()&&null!=this._element&&(d.isHiddenElement(this._element)||(l.closeAll(),this._currentViewMode===m.GRID?await this.findColumn():await this.findField(),i.preventDefault()))}async findField(){await this.openSeach(this._fieldSearch)}async findColumn(){await this.openSeach(this._columnSearch)}async openSeach(i){await T(this._moreOptions,i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}connectedCallback(){window.addEventListener("keydown",this._keyDownHandler,{capture:!0})}disconnectedCallback(){window.removeEventListener("keydown",this._keyDownHandler)}gridConfigChangeHandler(i){I.saveGridConfig(i.detail,this.configName,this.resolveResourceID()),i.stopPropagation()}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}async dataExporterProviderStore(){if(null==this.dataUnit)return;if(null==this._grid)return;const i=new M(this.dataUnit,this._grid);D.set("exporterProviders",Object.assign(Object.assign({},D.get("exporterProviders")),{[this.getDataExporterStoreKey()]:i}))}getDataExporterStoreKey(){return`SnkSimpleCrudDataExporter:${null==this.configName?this.dataUnit.name:this.configName}`}setGridConfig(i){this.gridConfig=i,S.assertDefaultSorting(this.gridConfig,this.dataUnit)}setFormConfig(i,t){this.formConfig&&!t||(this.formConfig=i)}closeGridConfig(){this._showPopUpGridConfig=!1}closeFormConfig(){this._showFormConfig=!1}getPageSize(){return this.mode===v.IN_MEMORY?0:null==this.pageSize?150:this.pageSize}handleShowFormConfig(){return this._showFormConfig&&!this.formLegacyConfigName}resolveResourceID(){return n.isEmpty(this.resourceID)?this._resourceID:this.resourceID}getFormConfig(){var i;const t=null===(i=this._formConfigManager)||void 0===i?void 0:i.getConfig(this.dataUnit,this.ignoreReadOnlyFormFields);return this.configName||t?t:this.formConfig}updateFormConfig(){const i=Object.assign(Object.assign({},this.formConfig),{fields:this.dataUnit.metadata.fields});this.setFormConfig(i,!0),null==this._formConfigManager&&(this._formConfigManager=new F(this.configName,this.resolveResourceID())),this._formConfigManager.setConfig(this.formConfig)}render(){var i;if(null==this.dataUnit)return;const t=s("snk-taskbar",{class:this._currentViewMode===m.FORM&&"ez-box ez-box--shadow ez-padding--medium",dataUnit:this.dataUnit,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,actionsList:this.getActionsList(),disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,"data-exporter-store-key":this.getDataExporterStoreKey(),slot:"leftButtons",presentationMode:b.SECONDARY},s("slot",{name:"TASKBAR_CUSTOM_ELEMENTS"}));return s("snk-data-unit",{ref:i=>this._snkDataUnit=i,class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:i=>this.onDataStateChange(i),onCancelEdition:this.handleCancelEdit.bind(this),pageSize:this.getPageSize(),onInsertionMode:()=>this.goToView(m.FORM),onDataUnitReady:i=>this.dataUnitReady.emit(i.detail),ignoreSaveMessage:this._currentViewMode===m.GRID,onMessagesBuilderUpdated:i=>this.messagesBuilder=i.detail,onDataUnitFieldsHidded:this.updateFormConfig.bind(this),domainMessagesBuilder:this.domainMessagesBuilder},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:"ez-box ez-box--shadow simple-crud__container-section"},this._currentViewMode===m.FORM&&t,s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{class:"ez-margin-bottom--large",ref:i=>this._grid=i,dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(m.FORM),onConfigChange:i=>this.gridConfigChangeHandler(i),columnfilterDataSource:this.dataUnit.name&&this.dataUnit.name.includes(y.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab,autoFocus:this.autoFocus},this._currentViewMode===m.GRID&&t,s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,s("ez-form",{ref:i=>this._form=i,class:"ez-margin-top--large "+(this.handleShowFormConfig()?"simple-crud__form--hidden":""),dataUnit:this.dataUnit,config:this.getFormConfig(),fieldToFocus:this._fieldToGetFocus,onEzFormSetFields:i=>this.handleFormSetFields(i.detail),onEzFormRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this)}),this.handleShowFormConfig()&&s("snk-form-config",{messagesBuilder:this.messagesBuilder,dataUnit:this.dataUnit,configManager:this._formConfigManager,onConfigClose:()=>this.closeFormConfig()})),this.messagesBuilder&&s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:i=>this.goToView(i.detail),onOpenConfig:i=>this.openConfig(i.detail),showActionButtons:this.showConfiguratorButtons,onSave:i=>this.handleConfiguratorEvent(i,"SAVE"),onCancel:i=>this.handleConfiguratorEvent(i,"CANCEL"),resourceID:this.resolveResourceID(),customContainerId:this._customContainerId})),s("div",{id:`${this._customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}))),s("ez-modal",{modalSize:"small",closeEsc:!1,closeOutsideClick:!1,opened:this._showPopUpGridConfig,onEzCloseModal:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this.gridConfig,"data-element-id":this._element.getAttribute(u.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resolveResourceID()})))}get _element(){return e(this)}static get watchers(){return{resourceID:["handleResourceIDChanged"],entityName:["onChangeEntityName"],mode:["onModeChange"],dataState:["observeDataState"],formLegacyConfigName:["observeFormLegacy"],gridLegacyConfigName:["observeGridLegacy"]}}};P.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%;--snk-simple-crud-grid--min-height:300px}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:auto 1fr;row-gap:12px;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}.simple-crud__form--hidden.sc-snk-simple-crud{display:none}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;--ez-grid--min-height:var(--snk-simple-crud-grid--min-height)}ez-form.sc-snk-simple-crud{min-height:300px}";export{P as snk_simple_crud}
|