@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-11997.0 → 0.0.0-bugfix-dev-KB-99999.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-0e4275f5.js → ConfigStorage-8009ecb2.js} +20 -4
- package/dist/cjs/{DataFetcher-bd3d53a8.js → DataFetcher-ba94ed5b.js} +142 -102
- package/dist/cjs/{PersonalizedFilterUtils-1aeb625d.js → PersonalizedFilterUtils-0184ffbb.js} +11 -4
- package/dist/cjs/PreloadManager-84466da6.js +224 -0
- package/dist/cjs/{SnkFormConfigManager-5b485cd4.js → SnkFormConfigManager-7d850fbc.js} +23 -6
- package/dist/cjs/{SnkMessageBuilder-d0abb63d.js → SnkMessageBuilder-7293d0ad.js} +29 -8
- package/dist/cjs/{SnkMultiSelectionListDataSource-804ff4c7.js → SnkMultiSelectionListDataSource-ba5838c2.js} +15 -0
- package/dist/cjs/Sortable-fb1c4cbb.js +2853 -0
- package/dist/cjs/{auth-fetcher-1583fe43.js → auth-fetcher-c8467c07.js} +1 -1
- package/dist/cjs/{constants-d187e03e.js → constants-35ddd366.js} +4 -0
- package/dist/cjs/dataunit-fetcher-de65b9fc.js +725 -0
- package/dist/cjs/{taskbar-processor-bce3f499.js → field-search-f56aa7d6.js} +35 -0
- package/dist/cjs/{filter-item-type.enum-aa823a00.js → filter-item-type.enum-a7ffdaa6.js} +1 -0
- package/dist/cjs/filterNumberVariation-d65332da.js +7 -0
- package/dist/cjs/{form-config-fetcher-f6cb55e6.js → form-config-fetcher-df043d3d.js} +1 -1
- package/dist/cjs/{index-0e663819.js → index-0922807b.js} +1 -0
- package/dist/cjs/index-f9e81701.js +10 -6
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-3356b3df.js → pesquisa-fetcher-ef050a47.js} +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/{snk-actions-button.cjs.entry.js → snk-actions-button_2.cjs.entry.js} +214 -91
- package/dist/cjs/snk-application.cjs.entry.js +474 -140
- package/dist/cjs/snk-attach.cjs.entry.js +27 -11
- package/dist/cjs/snk-config-options.cjs.entry.js +1 -1
- package/dist/cjs/snk-configurator.cjs.entry.js +17 -2
- package/dist/cjs/snk-crud.cjs.entry.js +127 -17
- package/dist/cjs/snk-custom-slot-elements.cjs.entry.js +20 -0
- package/dist/cjs/snk-data-exporter.cjs.entry.js +12 -11
- package/dist/cjs/{snk-data-unit-7cc1846d.js → snk-data-unit-1bc69073.js} +15 -5
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +34 -14
- package/dist/cjs/snk-field-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-advanced-mode_2.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-bar.cjs.entry.js +163 -17
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +52 -0
- package/dist/cjs/snk-filter-detail.cjs.entry.js +9 -2
- package/dist/cjs/snk-filter-field-search_2.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-item.cjs.entry.js +39 -15
- package/dist/cjs/snk-filter-list.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +9 -9
- package/dist/cjs/snk-filter-modal.cjs.entry.js +38 -7
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-number.cjs.entry.js +42 -3
- package/dist/cjs/snk-filter-period.cjs.entry.js +3 -3
- package/dist/cjs/snk-filter-search.cjs.entry.js +1 -1
- package/dist/cjs/snk-form-config.cjs.entry.js +16 -15
- package/dist/cjs/snk-form-view.cjs.entry.js +14 -0
- package/dist/cjs/snk-form.cjs.entry.js +6 -7
- package/dist/cjs/snk-grid-config.cjs.entry.js +6 -7
- package/dist/cjs/snk-grid.cjs.entry.js +131 -40
- package/dist/cjs/{snk-guides-viewer-5e22097d.js → snk-guides-viewer-7f9b6d94.js} +161 -22
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +16 -13
- package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +1 -1
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +24 -13
- package/dist/cjs/snk-select-box.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +127 -103
- package/dist/cjs/snk-tab-config.cjs.entry.js +12 -11
- package/dist/cjs/snk-taskbar.cjs.entry.js +3 -3
- package/dist/cjs/{taskbar-elements-39949c7a.js → taskbar-elements-01b85b99.js} +4 -4
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/snk-actions-button/actions/executor/java.executor.js +2 -2
- package/dist/collection/components/snk-actions-button/actions/executor/javascript.executor.js +2 -2
- package/dist/collection/components/snk-actions-button/actions/executor/procedure.executor.js +2 -2
- package/dist/collection/components/snk-actions-button/clientEvent/index.js +81 -76
- package/dist/collection/components/snk-actions-button/snk-actions-button.css +4 -11
- package/dist/collection/components/snk-actions-button/snk-actions-button.js +2 -2
- package/dist/collection/components/snk-application/snk-application.js +485 -84
- package/dist/collection/components/snk-attach/snk-attach.css +6 -0
- package/dist/collection/components/snk-attach/snk-attach.js +15 -3
- package/dist/collection/components/snk-attach/structure/data-unit-builder.js +4 -1
- package/dist/collection/components/snk-configurator/snk-configurator.js +33 -1
- package/dist/collection/components/snk-crud/snk-crud.js +136 -10
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +21 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +45 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +178 -22
- package/dist/collection/components/snk-custom-slot-elements/snk-custom-slot-elements.css +3 -0
- package/dist/collection/components/{snk-taskbar/snk-taskbar-custom-elements.js → snk-custom-slot-elements/snk-custom-slot-elements.js} +10 -10
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.css +1 -9
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +1 -1
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +15 -12
- package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +69 -2
- package/dist/collection/components/snk-filter-bar/filter-item/editors/enum/filterNumberVariation.js +5 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.js +95 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +93 -8
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +2 -2
- package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +1 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +7 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +38 -14
- package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +87 -6
- package/dist/collection/components/snk-filter-bar/filter-modal/subcomponents/snk-filter-modal-item.js +4 -3
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +5 -6
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +218 -7
- package/dist/collection/components/snk-filter-bar/utils/SnkFilterModalFactory.js +3 -1
- package/dist/collection/components/snk-form/SnkFormConfigManager.js +22 -5
- package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +10 -8
- package/dist/collection/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.js +10 -8
- package/dist/collection/components/snk-grid/filtercolumn/SnkMultiSelectionListDataSource.js +11 -0
- package/dist/collection/components/snk-grid/snk-grid.css +7 -2
- package/dist/collection/components/snk-grid/snk-grid.js +166 -39
- package/dist/collection/components/snk-personalized-filter/snk-personalized-filter.js +32 -6
- package/dist/collection/components/snk-personalized-filter/subcomponents/snk-filter-param-config/utils/PersonalizedFilterUtils.js +13 -4
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.css +8 -2
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +115 -6
- package/dist/collection/components/snk-taskbar/elements/taskbar-actions-button/taskbar-actions-button.css +6 -0
- package/dist/collection/components/snk-taskbar/elements/taskbar-actions-button/taskbar-actions-button.js +310 -0
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +3 -3
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +0 -4
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +1 -1
- package/dist/collection/components/snk-taskbar/subcomponents/field-search.js +31 -0
- package/dist/collection/lib/@types/index.js +1 -0
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +74 -15
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +61 -43
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +118 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +80 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +139 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/{dataunit-fetcher.js → data-unit/dataunit-fetcher.js} +49 -100
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadDataResult.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadDataStrategy.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadingInfo.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRecordField.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IResponseRecord.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DataUnitStrategy.js +68 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +162 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/index.js +3 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/fetchDataExporter/personalized-reports-fetcher.js +3 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +14 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.js +3 -0
- package/dist/collection/lib/index.js +1 -1
- package/dist/collection/lib/message/SnkMessageBuilder.js +9 -3
- package/dist/collection/lib/message/resources/snk-application.msg.js +9 -0
- package/dist/collection/lib/message/resources/snk-crud.msg.js +1 -0
- package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +5 -4
- package/dist/collection/lib/message/resources/snk-grid.msg.js +3 -1
- package/dist/collection/lib/message/resources/snk-simple-crud.msg.js +4 -0
- package/dist/collection/lib/utils/constants.js +3 -0
- package/dist/collection/lib/utils/urlutils.js +10 -4
- package/dist/collection/lib/workspace/workspace.js +27 -0
- package/dist/components/ConfigStorage.js +17 -1
- package/dist/components/DataFetcher.js +101 -61
- package/dist/components/PersonalizedFilterUtils.js +10 -3
- package/dist/components/SnkFormConfigManager.js +22 -5
- package/dist/components/SnkMessageBuilder.js +29 -8
- package/dist/components/constants.js +4 -1
- package/dist/components/dataunit-fetcher.js +846 -100
- package/dist/components/{SnkMultiSelectionListDataSource.js → field-search.js} +44 -1
- package/dist/components/filter-item-type.enum.js +1 -0
- package/dist/components/filterNumberVariation.js +7 -0
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/components/index2.js +1 -0
- package/dist/components/snk-actions-button2.js +91 -86
- package/dist/components/snk-application2.js +392 -55
- package/dist/components/snk-attach2.js +39 -19
- package/dist/components/snk-configurator2.js +18 -2
- package/dist/components/snk-crud.js +184 -70
- package/dist/components/snk-custom-slot-elements.d.ts +11 -0
- package/dist/components/snk-custom-slot-elements.js +35 -0
- package/dist/components/snk-data-exporter2.js +7 -5
- package/dist/components/snk-data-unit2.js +15 -5
- package/dist/components/snk-detail-view2.js +264 -96
- package/dist/components/snk-filter-bar2.js +164 -13
- package/dist/components/snk-filter-checkbox-list.d.ts +11 -0
- package/dist/components/snk-filter-checkbox-list.js +68 -0
- package/dist/components/snk-filter-detail2.js +7 -0
- package/dist/components/snk-filter-item2.js +38 -14
- package/dist/components/snk-filter-list.js +1 -1
- package/dist/components/snk-filter-modal-item2.js +4 -3
- package/dist/components/snk-filter-modal.js +40 -7
- package/dist/components/snk-filter-number.js +43 -2
- package/dist/components/snk-filter-period.js +2 -2
- package/dist/components/snk-form-config2.js +13 -11
- package/dist/components/snk-form-view2.js +15 -0
- package/dist/components/snk-grid2.js +166 -68
- package/dist/components/snk-personalized-filter2.js +18 -6
- package/dist/components/snk-simple-crud2.js +132 -104
- package/dist/components/snk-tab-config2.js +2203 -6233
- package/dist/components/snk-taskbar2.js +16 -10
- package/dist/components/taskbar-actions-button.d.ts +11 -0
- package/dist/components/taskbar-actions-button.js +6 -0
- package/dist/components/taskbar-actions-button2.js +140 -0
- package/dist/esm/{ConfigStorage-f359573c.js → ConfigStorage-1244b8b0.js} +20 -4
- package/dist/esm/{DataFetcher-8daff9ad.js → DataFetcher-aa159c5a.js} +101 -61
- package/dist/esm/{PersonalizedFilterUtils-75fb0106.js → PersonalizedFilterUtils-e2b38ef7.js} +11 -4
- package/dist/esm/PreloadManager-c1c2f2b4.js +222 -0
- package/dist/esm/{SnkFormConfigManager-35876bad.js → SnkFormConfigManager-9be0e7d4.js} +24 -7
- package/dist/esm/{SnkMessageBuilder-68c1c25a.js → SnkMessageBuilder-ca843d1b.js} +29 -8
- package/dist/esm/{SnkMultiSelectionListDataSource-892f37f9.js → SnkMultiSelectionListDataSource-44494b0e.js} +11 -0
- package/dist/esm/Sortable-83960219.js +2851 -0
- package/dist/esm/{auth-fetcher-299fed55.js → auth-fetcher-c05dc474.js} +1 -1
- package/dist/esm/{constants-3644f1b6.js → constants-8457af36.js} +4 -1
- package/dist/esm/dataunit-fetcher-e218c6d2.js +722 -0
- package/dist/esm/{taskbar-processor-94402e6e.js → field-search-efbe307f.js} +34 -1
- package/dist/esm/{filter-item-type.enum-5028ed3f.js → filter-item-type.enum-d45e026f.js} +1 -0
- package/dist/esm/filterNumberVariation-8cee02ea.js +7 -0
- package/dist/esm/{form-config-fetcher-8ef7be16.js → form-config-fetcher-36219cd3.js} +1 -1
- package/dist/esm/{index-1564817d.js → index-0ece87a6.js} +1 -0
- package/dist/esm/index-a7d3d3f1.js +10 -6
- package/dist/esm/loader.js +1 -1
- package/dist/{components/pesquisa-fetcher.js → esm/pesquisa-fetcher-dd3ca0a5.js} +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/{snk-actions-button.entry.js → snk-actions-button_2.entry.js} +215 -93
- package/dist/esm/snk-application.entry.js +475 -141
- package/dist/esm/snk-attach.entry.js +27 -11
- package/dist/esm/snk-config-options.entry.js +1 -1
- package/dist/esm/snk-configurator.entry.js +18 -3
- package/dist/esm/snk-crud.entry.js +128 -18
- package/dist/esm/snk-custom-slot-elements.entry.js +16 -0
- package/dist/esm/snk-data-exporter.entry.js +13 -12
- package/dist/esm/{snk-data-unit-1715d2f1.js → snk-data-unit-6208ebf0.js} +16 -6
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +34 -14
- package/dist/esm/snk-field-config.entry.js +1 -1
- package/dist/esm/snk-filter-advanced-mode_2.entry.js +2 -2
- package/dist/esm/snk-filter-bar.entry.js +165 -19
- package/dist/esm/snk-filter-binary-select.entry.js +1 -1
- package/dist/esm/snk-filter-checkbox-list.entry.js +48 -0
- package/dist/esm/snk-filter-detail.entry.js +9 -2
- package/dist/esm/snk-filter-field-search_2.entry.js +2 -2
- package/dist/esm/snk-filter-item.entry.js +39 -15
- package/dist/esm/snk-filter-list.entry.js +1 -1
- package/dist/esm/snk-filter-modal-item.entry.js +9 -9
- package/dist/esm/snk-filter-modal.entry.js +38 -7
- package/dist/esm/snk-filter-multi-select.entry.js +1 -1
- package/dist/esm/snk-filter-number.entry.js +42 -3
- package/dist/esm/snk-filter-period.entry.js +3 -3
- package/dist/esm/snk-filter-search.entry.js +1 -1
- package/dist/esm/snk-form-config.entry.js +16 -15
- package/dist/esm/snk-form-view.entry.js +14 -0
- package/dist/esm/snk-form.entry.js +6 -7
- package/dist/esm/snk-grid-config.entry.js +6 -7
- package/dist/esm/snk-grid.entry.js +132 -41
- package/dist/esm/{snk-guides-viewer-b0e32a7d.js → snk-guides-viewer-9d5e073f.js} +161 -22
- package/dist/esm/snk-guides-viewer.entry.js +16 -13
- package/dist/esm/snk-personalized-filter-editor.entry.js +1 -1
- package/dist/esm/snk-personalized-filter.entry.js +24 -13
- package/dist/esm/snk-select-box.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +126 -102
- package/dist/esm/snk-tab-config.entry.js +12 -11
- package/dist/esm/snk-taskbar.entry.js +3 -3
- package/dist/esm/{taskbar-elements-0a6b8b95.js → taskbar-elements-d4d0b424.js} +4 -4
- package/dist/sankhyablocks/p-01ba23cd.entry.js +1 -0
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +1 -0
- package/dist/sankhyablocks/{p-5c1aacc7.js → p-057fad05.js} +1 -1
- package/dist/sankhyablocks/p-0874adb5.entry.js +1 -0
- package/dist/sankhyablocks/p-094c30cb.js +1 -0
- package/dist/sankhyablocks/p-0d084a0f.entry.js +1 -0
- package/dist/sankhyablocks/{p-c870b530.js → p-0d7863ed.js} +1 -1
- package/dist/sankhyablocks/p-11081798.entry.js +1 -0
- package/dist/sankhyablocks/p-143425c0.entry.js +1 -0
- package/dist/sankhyablocks/{p-cb37982f.entry.js → p-20726710.entry.js} +1 -1
- package/dist/sankhyablocks/p-32f0935f.js +1 -0
- package/dist/sankhyablocks/p-3520c088.entry.js +1 -0
- package/dist/sankhyablocks/p-374d03f6.js +1 -0
- package/dist/sankhyablocks/p-38289a55.js +1 -0
- package/dist/sankhyablocks/{p-25c5428f.entry.js → p-3ab6df3d.entry.js} +1 -1
- package/dist/sankhyablocks/p-3b60db06.entry.js +1 -0
- package/dist/sankhyablocks/{p-eb636e15.entry.js → p-41f8bfa3.entry.js} +1 -1
- package/dist/sankhyablocks/p-4775a293.entry.js +1 -0
- package/dist/sankhyablocks/p-4b0938f6.entry.js +1 -0
- package/dist/sankhyablocks/p-585294ee.js +56 -0
- package/dist/sankhyablocks/p-5f74c859.entry.js +1 -0
- package/dist/sankhyablocks/p-69754d94.entry.js +1 -0
- package/dist/sankhyablocks/p-6977a26c.entry.js +1 -0
- package/dist/sankhyablocks/{p-648a7c72.entry.js → p-69efa80d.entry.js} +1 -1
- package/dist/sankhyablocks/p-70589af8.entry.js +1 -0
- package/dist/sankhyablocks/p-776ee8e3.js +1 -0
- package/dist/sankhyablocks/{p-959e0835.entry.js → p-7e2ded86.entry.js} +1 -1
- package/dist/sankhyablocks/p-7f9d6b5d.entry.js +11 -0
- package/dist/sankhyablocks/{p-0885ed3c.entry.js → p-8002dcd0.entry.js} +1 -1
- package/dist/sankhyablocks/p-809f367d.entry.js +1 -0
- package/dist/sankhyablocks/p-8437508f.js +1 -0
- package/dist/sankhyablocks/p-8eb67fa4.entry.js +1 -0
- package/dist/sankhyablocks/{p-f30526a7.entry.js → p-95df461f.entry.js} +1 -1
- package/dist/sankhyablocks/p-9695f78b.js +1 -0
- package/dist/sankhyablocks/{p-838f8234.entry.js → p-98674137.entry.js} +1 -1
- package/dist/sankhyablocks/p-a87229cd.entry.js +1 -0
- package/dist/sankhyablocks/p-a9e5b094.entry.js +1 -0
- package/dist/sankhyablocks/p-aaa3ee68.entry.js +1 -0
- package/dist/sankhyablocks/p-b0ef4383.js +1 -0
- package/dist/sankhyablocks/p-ba627e85.js +60 -0
- package/dist/sankhyablocks/p-c22c1d8e.js +1 -0
- package/dist/sankhyablocks/p-c2495304.js +1 -0
- package/dist/sankhyablocks/{p-26ad62b9.entry.js → p-c758265f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-fe49067d.entry.js → p-c8622597.entry.js} +1 -1
- package/dist/sankhyablocks/p-cb7419e0.entry.js +1 -0
- package/dist/sankhyablocks/p-d1007720.entry.js +1 -0
- package/dist/sankhyablocks/{p-a1e1b305.entry.js → p-d3f53df2.entry.js} +1 -1
- package/dist/sankhyablocks/p-d6317851.entry.js +1 -0
- package/dist/sankhyablocks/{p-b13cb8b5.js → p-d9bb09b3.js} +2 -2
- package/dist/sankhyablocks/p-e3132789.entry.js +1 -0
- package/dist/sankhyablocks/p-e6380c60.js +1 -0
- package/dist/sankhyablocks/p-f514913b.entry.js +1 -0
- package/dist/sankhyablocks/p-fa80e546.js +1 -0
- package/dist/sankhyablocks/p-fa816fb2.js +1 -0
- package/dist/sankhyablocks/p-fd8814b9.entry.js +1 -0
- package/dist/sankhyablocks/{p-584d7212.js → p-ff1990ad.js} +1 -1
- package/dist/sankhyablocks/p-ff6064e7.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/clientEvent/index.d.ts +1 -1
- package/dist/types/components/snk-actions-button/subcomponents/snk-actions-form.d.ts +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +90 -15
- package/dist/types/components/snk-attach/snk-attach.d.ts +1 -0
- package/dist/types/components/snk-configurator/snk-configurator.d.ts +6 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +13 -0
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +3 -0
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +10 -1
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +49 -12
- package/dist/types/components/snk-custom-slot-elements/snk-custom-slot-elements.d.ts +7 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +1 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/enum/filterNumberVariation.d.ts +4 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.d.ts +27 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +24 -2
- package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +2 -1
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +2 -0
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +15 -1
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +30 -0
- package/dist/types/components/snk-filter-bar/utils/SnkFilterModalFactory.d.ts +5 -1
- package/dist/types/components/snk-form/SnkFormConfigManager.d.ts +6 -1
- package/dist/types/components/snk-grid/filtercolumn/SnkMultiSelectionListDataSource.d.ts +2 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +20 -6
- package/dist/types/components/snk-personalized-filter/snk-personalized-filter.d.ts +4 -1
- package/dist/types/components/snk-personalized-filter/subcomponents/snk-filter-param-config/utils/PersonalizedFilterUtils.d.ts +1 -1
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +24 -2
- package/dist/types/components/snk-taskbar/elements/taskbar-actions-button/taskbar-actions-button.d.ts +59 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +18 -2
- package/dist/types/components/snk-taskbar/subcomponents/field-search.d.ts +4 -0
- package/dist/types/components.d.ts +256 -32
- package/dist/types/lib/@types/index.d.ts +2 -1
- package/dist/types/lib/dataUnit/InMemoryLoader.d.ts +5 -1
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +8 -4
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.d.ts +13 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.d.ts +19 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +22 -0
- package/dist/types/lib/http/data-fetcher/fetchers/{dataunit-fetcher.d.ts → data-unit/dataunit-fetcher.d.ts} +5 -3
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadDataResult.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadDataStrategy.d.ts +7 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadingInfo.d.ts +10 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRecordField.d.ts +4 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IResponseRecord.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DataUnitStrategy.d.ts +9 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +16 -0
- package/dist/types/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.d.ts +1 -1
- package/dist/types/lib/index.d.ts +1 -1
- package/dist/types/lib/message/resources/snk-application.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-simple-crud.msg.d.ts +2 -0
- package/dist/types/lib/utils/constants.d.ts +3 -4
- package/dist/types/lib/workspace/workspace.d.ts +6 -0
- package/package.json +4 -4
- package/react/components.d.ts +3 -1
- package/react/components.js +3 -1
- package/react/components.js.map +1 -1
- package/dist/cjs/_commonjsHelpers-537d719a.js +0 -20
- package/dist/cjs/dataunit-fetcher-910be4ce.js +0 -356
- package/dist/cjs/draggable.bundle-82a25c06.js +0 -6886
- package/dist/cjs/snk-taskbar-custom-elements.cjs.entry.js +0 -20
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +0 -6
- package/dist/components/_commonjsHelpers.js +0 -17
- package/dist/components/snk-taskbar-custom-elements.d.ts +0 -11
- package/dist/components/snk-taskbar-custom-elements.js +0 -35
- package/dist/esm/_commonjsHelpers-9943807e.js +0 -17
- package/dist/esm/dataunit-fetcher-bd8f9572.js +0 -354
- package/dist/esm/draggable.bundle-41d56f06.js +0 -6884
- package/dist/esm/pesquisa-fetcher-27819123.js +0 -165
- package/dist/esm/snk-taskbar-custom-elements.entry.js +0 -16
- package/dist/sankhyablocks/p-0df2ead8.entry.js +0 -11
- package/dist/sankhyablocks/p-112455b1.js +0 -1
- package/dist/sankhyablocks/p-324ce41e.entry.js +0 -1
- package/dist/sankhyablocks/p-34604220.entry.js +0 -1
- package/dist/sankhyablocks/p-4a78e118.js +0 -1
- package/dist/sankhyablocks/p-5534e08c.js +0 -1
- package/dist/sankhyablocks/p-5d04ae42.entry.js +0 -1
- package/dist/sankhyablocks/p-6a38bda5.entry.js +0 -1
- package/dist/sankhyablocks/p-7bcd2f89.js +0 -56
- package/dist/sankhyablocks/p-7bd5aea7.js +0 -1
- package/dist/sankhyablocks/p-8014cc25.entry.js +0 -1
- package/dist/sankhyablocks/p-928efcaa.entry.js +0 -1
- package/dist/sankhyablocks/p-989937ee.entry.js +0 -1
- package/dist/sankhyablocks/p-9a270401.entry.js +0 -1
- package/dist/sankhyablocks/p-a7ee0e6f.entry.js +0 -1
- package/dist/sankhyablocks/p-ac0556a3.js +0 -1
- package/dist/sankhyablocks/p-ae6aff81.js +0 -1
- package/dist/sankhyablocks/p-b244640b.js +0 -1
- package/dist/sankhyablocks/p-b6d6b172.js +0 -1
- package/dist/sankhyablocks/p-bba91710.entry.js +0 -1
- package/dist/sankhyablocks/p-bd628455.entry.js +0 -1
- package/dist/sankhyablocks/p-c2beb95c.js +0 -1
- package/dist/sankhyablocks/p-c555075c.entry.js +0 -1
- package/dist/sankhyablocks/p-c9841939.js +0 -1
- package/dist/sankhyablocks/p-d3ec3586.entry.js +0 -1
- package/dist/sankhyablocks/p-d708b4ab.entry.js +0 -1
- package/dist/sankhyablocks/p-d84bc5c1.js +0 -1
- package/dist/sankhyablocks/p-de76b8a8.js +0 -76
- package/dist/sankhyablocks/p-e19014a9.entry.js +0 -1
- package/dist/sankhyablocks/p-e1cb1f0b.js +0 -1
- package/dist/sankhyablocks/p-e3a82e1c.entry.js +0 -1
- package/dist/sankhyablocks/p-e9b53a9a.entry.js +0 -1
- package/dist/sankhyablocks/p-ebf8c5df.entry.js +0 -1
- package/dist/sankhyablocks/p-ed5f1204.entry.js +0 -1
- package/dist/sankhyablocks/p-f9395c20.entry.js +0 -1
- package/dist/sankhyablocks/p-f94b999e.entry.js +0 -1
- package/dist/sankhyablocks/p-fa9d3f73.js +0 -1
- package/dist/sankhyablocks/p-fb1ecd0b.entry.js +0 -1
- package/dist/sankhyablocks/p-fcd09423.entry.js +0 -1
- package/dist/sankhyablocks/p-fd15aaac.entry.js +0 -1
- package/dist/types/components/snk-taskbar/snk-taskbar-custom-elements.d.ts +0 -7
|
@@ -1,7 +1,807 @@
|
|
|
1
|
-
import { DataUnit, StringUtils,
|
|
1
|
+
import { DataType, FieldComparator, SortMode, DataUnit, DateUtils, StringUtils, ChangeOperation, ApplicationContext, UserInterface, DataUnitStorage } from '@sankhyalabs/core';
|
|
2
2
|
import { d as dist, D as DataFetcher } from './DataFetcher.js';
|
|
3
3
|
import { DISTINCT_FILTER_NAME_PREFIX } from '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
4
4
|
import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
5
|
+
import { ColumnFilterManager } from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
|
6
|
+
import { R as ResourceIDUtils } from './ResourceIDUtils.js';
|
|
7
|
+
|
|
8
|
+
class PesquisaFetcher {
|
|
9
|
+
constructor() {
|
|
10
|
+
this._defaultPageSize = 100;
|
|
11
|
+
this._templateByQuery = new Map();
|
|
12
|
+
this._searchListenersByDataUnit = new Map();
|
|
13
|
+
this.buldTemplates();
|
|
14
|
+
}
|
|
15
|
+
buldTemplates() {
|
|
16
|
+
this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
|
17
|
+
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
|
18
|
+
value
|
|
19
|
+
label
|
|
20
|
+
}
|
|
21
|
+
}`);
|
|
22
|
+
}
|
|
23
|
+
loadSearchOptions(entityName, argument, criteria, options) {
|
|
24
|
+
var _a;
|
|
25
|
+
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
|
26
|
+
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
|
27
|
+
criteria === null || criteria === void 0 ? void 0 : criteria.params.forEach(param => {
|
|
28
|
+
if (param.dataType === DataType.OBJECT) {
|
|
29
|
+
param.value = JSON.stringify(param.value);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
|
33
|
+
const values = {
|
|
34
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
|
35
|
+
entityName,
|
|
36
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
|
37
|
+
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
|
38
|
+
};
|
|
39
|
+
if (values.options) {
|
|
40
|
+
(_a = values.options) === null || _a === void 0 ? true : delete _a.dataUnitId;
|
|
41
|
+
}
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
DataFetcher.get()
|
|
44
|
+
.callGraphQL({
|
|
45
|
+
values,
|
|
46
|
+
query: this._templateByQuery.get("search"),
|
|
47
|
+
})
|
|
48
|
+
.then((result) => {
|
|
49
|
+
resolve(result);
|
|
50
|
+
})
|
|
51
|
+
.catch((error) => {
|
|
52
|
+
reject(error);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
|
57
|
+
var _a, _b, _c;
|
|
58
|
+
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
|
59
|
+
const values = {
|
|
60
|
+
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
|
61
|
+
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
|
62
|
+
searchOptions: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || searchOptions,
|
|
63
|
+
};
|
|
64
|
+
const serviceName = "PesquisaSP.getSuggestion";
|
|
65
|
+
const externalCriteria = {
|
|
66
|
+
query: {
|
|
67
|
+
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if (((_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params.length) > 0) {
|
|
71
|
+
externalCriteria.params = {
|
|
72
|
+
param: values.criteria.params.map(param => {
|
|
73
|
+
let value = param.value;
|
|
74
|
+
let type = param.dataType;
|
|
75
|
+
if (type === DataType.OBJECT) {
|
|
76
|
+
value = value.value;
|
|
77
|
+
type = "S";
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
type = convertParamType(param.dataType);
|
|
81
|
+
}
|
|
82
|
+
return { $: value, type };
|
|
83
|
+
})
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const options = searchOptions != undefined
|
|
87
|
+
? {
|
|
88
|
+
"pkFieldName": searchOptions.codeFieldName,
|
|
89
|
+
"label": searchOptions.descriptionFieldName,
|
|
90
|
+
"fieldName": searchOptions.codeFieldName,
|
|
91
|
+
"useDescriptionOptions": false,
|
|
92
|
+
"enableRowsCounter": true
|
|
93
|
+
}
|
|
94
|
+
: undefined;
|
|
95
|
+
const reqBody = {
|
|
96
|
+
"serviceName": serviceName,
|
|
97
|
+
"requestBody": {
|
|
98
|
+
"criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_c = values.searchOptions) === null || _c === void 0 ? void 0 : _c.rootEntity }, { options }),
|
|
99
|
+
"clientEventList": {
|
|
100
|
+
"clientEvent": []
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return new Promise((resolve, reject) => {
|
|
105
|
+
DataFetcher.get()
|
|
106
|
+
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
|
107
|
+
.then(result => resolve(result))
|
|
108
|
+
.catch(error => reject(error));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
addSearchListener(entityName, dataUnitID, listener) {
|
|
112
|
+
var _a;
|
|
113
|
+
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
|
114
|
+
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
|
115
|
+
if (!entityListener) {
|
|
116
|
+
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
for (const type of Object.keys(listener)) {
|
|
120
|
+
if (type in entityListener.listener) {
|
|
121
|
+
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
|
122
|
+
if (listenerFunctionIsEquals)
|
|
123
|
+
continue;
|
|
124
|
+
entityListener.listener[type] = listener[type];
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return () => {
|
|
129
|
+
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
|
130
|
+
if (!newListeners.length) {
|
|
131
|
+
this._searchListenersByDataUnit.delete(dataUnitID);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
|
138
|
+
var _a;
|
|
139
|
+
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
|
140
|
+
if (!dataUnitId)
|
|
141
|
+
return;
|
|
142
|
+
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
|
143
|
+
if (!entityListener)
|
|
144
|
+
return;
|
|
145
|
+
const { listener } = entityListener;
|
|
146
|
+
if (!(listenerType in listener))
|
|
147
|
+
return;
|
|
148
|
+
return listener[listenerType]({ argument, criteria, searchOptions });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function convertParamType(dataType) {
|
|
152
|
+
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
|
153
|
+
//atual da pesquisa... em geral, somente inteiros,
|
|
154
|
+
//data (com ou sem hora) e string são realmente relevantes
|
|
155
|
+
switch (dataType) {
|
|
156
|
+
case DataType.NUMBER:
|
|
157
|
+
return "I";
|
|
158
|
+
case DataType.DATE:
|
|
159
|
+
return "D";
|
|
160
|
+
default:
|
|
161
|
+
return "S";
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
var SearchListenerType;
|
|
165
|
+
(function (SearchListenerType) {
|
|
166
|
+
SearchListenerType["beforeSearch"] = "beforeSearch";
|
|
167
|
+
})(SearchListenerType || (SearchListenerType = {}));
|
|
168
|
+
|
|
169
|
+
class ArrayRepository {
|
|
170
|
+
constructor(equalsFunction) {
|
|
171
|
+
this._list = [];
|
|
172
|
+
this._equalsFunction = equalsFunction;
|
|
173
|
+
}
|
|
174
|
+
async load(filterFunction, sortingFunction, offset, limit) {
|
|
175
|
+
let result = [].concat(this._list);
|
|
176
|
+
if (filterFunction != undefined) {
|
|
177
|
+
result = this._list.filter(item => filterFunction(item));
|
|
178
|
+
}
|
|
179
|
+
if (sortingFunction != undefined) {
|
|
180
|
+
result = result.sort(sortingFunction);
|
|
181
|
+
}
|
|
182
|
+
const count = result.length;
|
|
183
|
+
if (limit != undefined) {
|
|
184
|
+
const start = offset || 0;
|
|
185
|
+
const end = limit ? start + limit : result.length;
|
|
186
|
+
result = result.slice(start, end);
|
|
187
|
+
}
|
|
188
|
+
return Promise.resolve({ result, count });
|
|
189
|
+
}
|
|
190
|
+
async distict(itemProcessor) {
|
|
191
|
+
const processedItems = [];
|
|
192
|
+
let hasEmpty = false;
|
|
193
|
+
for (const item of this._list) {
|
|
194
|
+
const processedItem = itemProcessor(item);
|
|
195
|
+
if (processedItem == undefined) {
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (processedItem.value == undefined) {
|
|
199
|
+
hasEmpty = true;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
processedItems.push(processedItem);
|
|
203
|
+
}
|
|
204
|
+
if (hasEmpty) {
|
|
205
|
+
processedItems.push({ key: "", value: null });
|
|
206
|
+
}
|
|
207
|
+
return Promise.resolve(new Map(processedItems.map(item => [item.key, item.value])));
|
|
208
|
+
}
|
|
209
|
+
async push(items) {
|
|
210
|
+
this._list.push(...items);
|
|
211
|
+
}
|
|
212
|
+
async clear() {
|
|
213
|
+
this._list = [];
|
|
214
|
+
}
|
|
215
|
+
async delete(items) {
|
|
216
|
+
this._list = this._list.filter(item => {
|
|
217
|
+
for (const removed of items) {
|
|
218
|
+
if (this._equalsFunction(item, removed)) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return true;
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
async update(items) {
|
|
226
|
+
this._list = this._list.map(existingItem => {
|
|
227
|
+
const newItem = items.find(newItem => this._equalsFunction(existingItem, newItem));
|
|
228
|
+
return newItem == undefined ? existingItem : newItem;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
async insert(itemReference, items) {
|
|
232
|
+
const itemPosition = this._list.indexOf(itemReference);
|
|
233
|
+
if (itemPosition == -1) {
|
|
234
|
+
this._list.push(...items);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
this._list = this._list.slice(0, itemPosition).concat(items).concat(this._list.slice(itemPosition));
|
|
238
|
+
}
|
|
239
|
+
isOperating() {
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
242
|
+
async isEmpty() {
|
|
243
|
+
return Promise.resolve(this._list.length === 0);
|
|
244
|
+
}
|
|
245
|
+
async count() {
|
|
246
|
+
return Promise.resolve(this._list.length);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
class PreloadManager {
|
|
251
|
+
static setLoadingStatus(dataUnit, loadingInProgress) {
|
|
252
|
+
this._loadingStatus.set(dataUnit.name, loadingInProgress);
|
|
253
|
+
}
|
|
254
|
+
static isCacheEnabled(_dataUnit) {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
static cacheRecords(dataUnit, records, resetDatabase, loadingInProgress) {
|
|
258
|
+
PreloadManager.setLoadingStatus(dataUnit, loadingInProgress);
|
|
259
|
+
if (PreloadManager.isCacheEnabled(dataUnit)) {
|
|
260
|
+
this.getRepository(dataUnit).push(records);
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
if (resetDatabase) {
|
|
264
|
+
this._repositories.delete(dataUnit.name);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
static getSortingFunction(dataUnit, sorting) {
|
|
269
|
+
if (sorting == undefined || sorting.length == 0) {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
return (recordA, recordB) => {
|
|
273
|
+
for (const sort of sorting) {
|
|
274
|
+
const result = FieldComparator.compare(dataUnit.getField(sort.field), recordA, recordB, sort.mode === SortMode.ASC);
|
|
275
|
+
if (result != 0) {
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
static async getDistinct(dataUnit, fieldName) {
|
|
282
|
+
if (!PreloadManager.isCacheEnabled(dataUnit)) {
|
|
283
|
+
return Promise.resolve(ColumnFilterManager.compileDistinct(fieldName, dataUnit));
|
|
284
|
+
}
|
|
285
|
+
let filterFunction;
|
|
286
|
+
const request = dataUnit.getLastLoadRequest();
|
|
287
|
+
if (request != undefined) {
|
|
288
|
+
const columnFilters = ColumnFilterManager.getColumnFilters(request.filters, fieldName);
|
|
289
|
+
filterFunction = ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
|
|
290
|
+
}
|
|
291
|
+
return new Promise((accept, reject) => {
|
|
292
|
+
PreloadManager.getRepository(dataUnit).distict(record => {
|
|
293
|
+
if (filterFunction != undefined && !filterFunction(record)) {
|
|
294
|
+
return undefined;
|
|
295
|
+
}
|
|
296
|
+
const fieldValue = record[fieldName];
|
|
297
|
+
if (fieldValue == undefined) {
|
|
298
|
+
return { key: null, value: null };
|
|
299
|
+
}
|
|
300
|
+
const value = fieldValue.value != undefined ? fieldValue.value : fieldValue;
|
|
301
|
+
return { key: dataUnit.getFormattedValue(fieldName, fieldValue), value };
|
|
302
|
+
})
|
|
303
|
+
.then(result => {
|
|
304
|
+
if (result == undefined) {
|
|
305
|
+
accept(undefined);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
accept(Array.from(result.entries()).map(([label, value]) => ({ label, value, check: true })));
|
|
309
|
+
})
|
|
310
|
+
.catch(reason => reject(reason));
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
static async loadData(dataUnit, request, loadFromServer) {
|
|
314
|
+
try {
|
|
315
|
+
if (PreloadManager.isCacheEnabled(dataUnit)) {
|
|
316
|
+
let useCache = request.source === "EZ_GRID_LOADING_SOURCE" || request.source === DataUnit.CHANGING_PAGE_LOADING_SOURCE;
|
|
317
|
+
if (useCache) {
|
|
318
|
+
const isCacheEmpty = await PreloadManager.getRepository(dataUnit).isEmpty();
|
|
319
|
+
if (!isCacheEmpty) {
|
|
320
|
+
return PreloadManager.loadFromCache(dataUnit, request);
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
//Como não vamos aproveitar o cache, ele precisa ser limpo.
|
|
324
|
+
PreloadManager.getRepository(dataUnit).clear().catch(() => { });
|
|
325
|
+
}
|
|
326
|
+
return loadFromServer(dataUnit, request);
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
console.error(error);
|
|
330
|
+
return Promise.reject(error);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
static insertRecords(dataUnit, reference, records) {
|
|
334
|
+
if (PreloadManager.isCacheEnabled(dataUnit)) {
|
|
335
|
+
PreloadManager.getRepository(dataUnit).insert(reference, records);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
static updateRecords(dataUnit, records) {
|
|
339
|
+
if (PreloadManager.isCacheEnabled(dataUnit)) {
|
|
340
|
+
PreloadManager.getRepository(dataUnit).update(records);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
static removeRecords(dataUnit, records) {
|
|
344
|
+
if (PreloadManager.isCacheEnabled(dataUnit)) {
|
|
345
|
+
PreloadManager.getRepository(dataUnit).delete(records);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
static async countRecords(dataUnit) {
|
|
349
|
+
if (PreloadManager.isCacheEnabled(dataUnit)) {
|
|
350
|
+
return PreloadManager.getRepository(dataUnit).count();
|
|
351
|
+
}
|
|
352
|
+
return Promise.resolve(0);
|
|
353
|
+
}
|
|
354
|
+
static getRepository(dataUnit) {
|
|
355
|
+
const name = dataUnit.name;
|
|
356
|
+
if (!PreloadManager._repositories.has(name)) {
|
|
357
|
+
PreloadManager._repositories.set(name, new ArrayRepository((recordA, recordB) => recordA.__record__id__ === recordB.__record__id__));
|
|
358
|
+
}
|
|
359
|
+
return PreloadManager._repositories.get(name);
|
|
360
|
+
}
|
|
361
|
+
static async loadFromCache(dataUnit, request) {
|
|
362
|
+
return new Promise((accept, reject) => {
|
|
363
|
+
const columnFilters = ColumnFilterManager.getColumnFilters(request.filters, "");
|
|
364
|
+
const { limit, offset, sort } = request;
|
|
365
|
+
PreloadManager.getRepository(dataUnit)
|
|
366
|
+
.load(ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values())), PreloadManager.getSortingFunction(dataUnit, sort), offset, limit)
|
|
367
|
+
.then(loadResult => {
|
|
368
|
+
const stillLoading = PreloadManager._loadingStatus.get(dataUnit.name);
|
|
369
|
+
const { count, result: records } = loadResult;
|
|
370
|
+
const firstRecord = count == 0 ? 0 : offset + 1;
|
|
371
|
+
const lastRecord = offset + Math.min(records.length, limit);
|
|
372
|
+
const currentPage = offset / limit;
|
|
373
|
+
const paginationInfo = {
|
|
374
|
+
count, currentPage, firstRecord, lastRecord,
|
|
375
|
+
hasMore: stillLoading || (lastRecord < count),
|
|
376
|
+
total: stillLoading ? undefined : count
|
|
377
|
+
};
|
|
378
|
+
accept({ records, paginationInfo });
|
|
379
|
+
})
|
|
380
|
+
.catch(reason => reject(reason));
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
PreloadManager._repositories = new Map();
|
|
385
|
+
PreloadManager._loadingStatus = new Map();
|
|
386
|
+
|
|
387
|
+
class InMemoryLoader {
|
|
388
|
+
constructor(metadata, records) {
|
|
389
|
+
this.metadata = metadata;
|
|
390
|
+
this.records = records;
|
|
391
|
+
this._dataUnit = new DataUnit(InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME);
|
|
392
|
+
this._dataUnit.metadataLoader = () => this.metadaLoader();
|
|
393
|
+
this._dataUnit.dataLoader = (dataUnit, request) => this.inMemoryLoader(dataUnit, request, this.getRecordsToLoad());
|
|
394
|
+
this._dataUnit.saveLoader = (_dataUnit, changes) => this.saveLoader(_dataUnit, changes);
|
|
395
|
+
this._dataUnit.removeLoader = (_dataUnit, recordIds) => this.removeLoader(_dataUnit, recordIds);
|
|
396
|
+
this.dataUnit.loadMetadata().then(() => this.dataUnit.loadData());
|
|
397
|
+
}
|
|
398
|
+
getRecordsToLoad() {
|
|
399
|
+
if (this._initialRecords == undefined && this.dataUnit.records.length > 0) {
|
|
400
|
+
this._initialRecords = this.dataUnit.records;
|
|
401
|
+
}
|
|
402
|
+
return this._initialRecords;
|
|
403
|
+
}
|
|
404
|
+
get dataUnit() {
|
|
405
|
+
return this._dataUnit;
|
|
406
|
+
}
|
|
407
|
+
get records() {
|
|
408
|
+
return this.dataUnit.records;
|
|
409
|
+
}
|
|
410
|
+
static getConvertedValue(descriptor, strValue) {
|
|
411
|
+
if (descriptor.dataType === DataType.BOOLEAN) {
|
|
412
|
+
return strValue === "S";
|
|
413
|
+
}
|
|
414
|
+
if (descriptor.dataType === DataType.NUMBER) {
|
|
415
|
+
return Number(strValue);
|
|
416
|
+
}
|
|
417
|
+
if (descriptor.dataType === DataType.DATE) {
|
|
418
|
+
return DateUtils.strToDate(strValue, true);
|
|
419
|
+
}
|
|
420
|
+
if (descriptor.dataType === DataType.OBJECT) {
|
|
421
|
+
return JSON.parse(strValue);
|
|
422
|
+
}
|
|
423
|
+
return strValue;
|
|
424
|
+
}
|
|
425
|
+
set records(records) {
|
|
426
|
+
const columns = this._metadata ? new Map(this._metadata.fields.map(descriptor => [descriptor.name, descriptor])) : undefined;
|
|
427
|
+
const newRecords = records === null || records === void 0 ? void 0 : records.map(record => {
|
|
428
|
+
if (!record["__record__id__"]) {
|
|
429
|
+
record["__record__id__"] = this.generateUniqueId();
|
|
430
|
+
}
|
|
431
|
+
if (columns != undefined) {
|
|
432
|
+
for (const name in record) {
|
|
433
|
+
const value = record[name];
|
|
434
|
+
if (typeof value === "string" && columns.has(name)) {
|
|
435
|
+
record[name] = InMemoryLoader.getConvertedValue(columns.get(name), value);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
return record;
|
|
440
|
+
});
|
|
441
|
+
this._initialRecords = newRecords;
|
|
442
|
+
if (this._dataUnit) {
|
|
443
|
+
//Isso força o refresh internamente no datunit
|
|
444
|
+
this._dataUnit.gotoPage(0);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
get metadata() {
|
|
448
|
+
return this._metadata;
|
|
449
|
+
}
|
|
450
|
+
set metadata(metadata) {
|
|
451
|
+
this._metadata = metadata;
|
|
452
|
+
if (this._dataUnit) {
|
|
453
|
+
this._dataUnit.metadata = this._metadata;
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
generateUniqueId() {
|
|
457
|
+
return StringUtils.generateUUID();
|
|
458
|
+
}
|
|
459
|
+
inMemoryLoader(dataUnit, request, recordsIn) {
|
|
460
|
+
let records = this.applyFilter(recordsIn, dataUnit, request.filters);
|
|
461
|
+
records = this.applySorting(records, dataUnit, request.sort);
|
|
462
|
+
return Promise.resolve({ records, paginationInfo: buildPaginationInfo(request, records) });
|
|
463
|
+
}
|
|
464
|
+
applyFilter(records, dataUnit, filters) {
|
|
465
|
+
const columnFilters = ColumnFilterManager.getColumnFilters(filters, "");
|
|
466
|
+
if (columnFilters == undefined || columnFilters.size == 0) {
|
|
467
|
+
return records;
|
|
468
|
+
}
|
|
469
|
+
const filterFunciton = ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
|
|
470
|
+
if (filterFunciton == undefined) {
|
|
471
|
+
return records;
|
|
472
|
+
}
|
|
473
|
+
return records.filter(filterFunciton);
|
|
474
|
+
}
|
|
475
|
+
applySorting(records, dataUnit, sorting) {
|
|
476
|
+
if (sorting == undefined || sorting.length == 0) {
|
|
477
|
+
return records;
|
|
478
|
+
}
|
|
479
|
+
const sortingFunction = PreloadManager.getSortingFunction(dataUnit, sorting);
|
|
480
|
+
if (sortingFunction == undefined) {
|
|
481
|
+
return records;
|
|
482
|
+
}
|
|
483
|
+
return records.sort(sortingFunction);
|
|
484
|
+
}
|
|
485
|
+
metadaLoader() {
|
|
486
|
+
return Promise.resolve(this._metadata);
|
|
487
|
+
}
|
|
488
|
+
saveLoader(_dataUnit, changes) {
|
|
489
|
+
return new Promise((resolve) => {
|
|
490
|
+
let dataUnitRecords = [];
|
|
491
|
+
changes.forEach(change => {
|
|
492
|
+
let { record, updatingFields, operation } = change;
|
|
493
|
+
const changedRecord = Object.assign(Object.assign({}, record), updatingFields);
|
|
494
|
+
if (operation === ChangeOperation.INSERT ||
|
|
495
|
+
operation === ChangeOperation.COPY) {
|
|
496
|
+
changedRecord["__old__id__"] = record["__record__id__"];
|
|
497
|
+
changedRecord["__record__id__"] = this.generateUniqueId();
|
|
498
|
+
this.records.push(changedRecord);
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
const recordIndex = this.records.findIndex(r => r["__record__id__"] == changedRecord["__record__id__"]);
|
|
502
|
+
this.records[recordIndex] = changedRecord;
|
|
503
|
+
}
|
|
504
|
+
dataUnitRecords.push(changedRecord);
|
|
505
|
+
});
|
|
506
|
+
resolve(dataUnitRecords);
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
removeLoader(_dataUnit, recordIds) {
|
|
510
|
+
return new Promise((resolve) => {
|
|
511
|
+
resolve(recordIds);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = "InMemoryDataUnit";
|
|
516
|
+
function buildPaginationInfo({ offset, limit }, records) {
|
|
517
|
+
if (offset === undefined || limit === undefined) {
|
|
518
|
+
return undefined;
|
|
519
|
+
}
|
|
520
|
+
const lastRecord = Math.min(offset + limit, records.length);
|
|
521
|
+
return {
|
|
522
|
+
currentPage: Math.ceil(offset / limit),
|
|
523
|
+
firstRecord: offset,
|
|
524
|
+
lastRecord: lastRecord,
|
|
525
|
+
total: records.length,
|
|
526
|
+
hasMore: !!(records.length - lastRecord),
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
class DatasetStrategy {
|
|
531
|
+
canSlice() {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
async load(dataUnit, request, loadingInfo) {
|
|
535
|
+
if (dataUnit.metadata == undefined) {
|
|
536
|
+
return Promise.resolve({ records: [], loadingInfo });
|
|
537
|
+
}
|
|
538
|
+
try {
|
|
539
|
+
const localSorting = [];
|
|
540
|
+
const serverSorting = [];
|
|
541
|
+
if (request.sort != undefined) {
|
|
542
|
+
for (const sort of request.sort) {
|
|
543
|
+
const descriptor = dataUnit.getField(sort.field);
|
|
544
|
+
const local = descriptor != undefined
|
|
545
|
+
&& descriptor.properties != undefined
|
|
546
|
+
&& descriptor.properties.calculated === "true";
|
|
547
|
+
if (local) {
|
|
548
|
+
localSorting.push(sort);
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
serverSorting.push(sort);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
const fields = this.getFieldsList(dataUnit);
|
|
556
|
+
const serviceName = "DatasetSP.loadRecords";
|
|
557
|
+
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting);
|
|
558
|
+
const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
|
|
559
|
+
const { result: responseRecords, pagerID: pagerId } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
|
560
|
+
const records = this.processRecords(dataUnit, fields, responseRecords);
|
|
561
|
+
const loadingInProgress = pagerId != undefined;
|
|
562
|
+
const count = loadingInfo.count + records.length;
|
|
563
|
+
const needReload = !loadingInProgress && localSorting.length > 0;
|
|
564
|
+
return Promise.resolve({
|
|
565
|
+
records,
|
|
566
|
+
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
|
567
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count,
|
|
568
|
+
needReload })
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
catch (error) {
|
|
572
|
+
console.error(error);
|
|
573
|
+
return Promise.reject(error);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
getFieldsList(dataUnit) {
|
|
577
|
+
let fields = ["__record__id__", "__record__label__"];
|
|
578
|
+
dataUnit.metadata.fields.forEach((descriptor) => {
|
|
579
|
+
if (descriptor.standAlone) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
fields = fields.concat(this.getFieldNames(descriptor));
|
|
583
|
+
});
|
|
584
|
+
return fields;
|
|
585
|
+
}
|
|
586
|
+
getFieldNames(descriptor) {
|
|
587
|
+
const descriptionField = this.getSearchDescriptionField(descriptor);
|
|
588
|
+
if (descriptionField == undefined) {
|
|
589
|
+
return descriptor.name;
|
|
590
|
+
}
|
|
591
|
+
return [descriptor.name, descriptionField];
|
|
592
|
+
}
|
|
593
|
+
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, sorting) {
|
|
594
|
+
const dataSetID = dataUnit.dataUnitId;
|
|
595
|
+
const dataUnitName = dataUnit.name;
|
|
596
|
+
const entityName = DataUnitFetcher.parseDataUnitName(dataUnitName).entityName;
|
|
597
|
+
const useParallelLoader = !!(request.limit || request.offset);
|
|
598
|
+
const requestBody = {
|
|
599
|
+
serviceName,
|
|
600
|
+
requestBody: {
|
|
601
|
+
dataSetID,
|
|
602
|
+
fields,
|
|
603
|
+
entityName,
|
|
604
|
+
pageNumber: loadingInfo.pageNumber,
|
|
605
|
+
totalRecordsCount: loadingInfo.count,
|
|
606
|
+
pagerID: loadingInfo.pagerId,
|
|
607
|
+
standAlone: false,
|
|
608
|
+
standAloneFieldsMD: {
|
|
609
|
+
__record__id__: { "fieldType": "S", "userType": "P" },
|
|
610
|
+
__record__label__: { "fieldType": "S", "userType": "P" }
|
|
611
|
+
},
|
|
612
|
+
tryJoinedFields: true,
|
|
613
|
+
parallelLoader: useParallelLoader,
|
|
614
|
+
crudListener: `br.com.sankhya.bff.${this.getModuleName()}.BFFDataUnitDatasetAdapter`,
|
|
615
|
+
txProperties: this.getTxProperties(dataUnitName, request, sorting),
|
|
616
|
+
useDefaultRowsLimit: false
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
return JSON.stringify(requestBody);
|
|
620
|
+
}
|
|
621
|
+
getModuleName() {
|
|
622
|
+
const app = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
623
|
+
const moduleName = app.getModuleName();
|
|
624
|
+
return moduleName.replace("-bff", "");
|
|
625
|
+
}
|
|
626
|
+
getTxProperties(dataUnitName, request, sorting) {
|
|
627
|
+
var _a, _b;
|
|
628
|
+
const txProperties = {
|
|
629
|
+
"__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnitName
|
|
630
|
+
};
|
|
631
|
+
const serverSideFilters = (_b = (_a = request.filters) === null || _a === void 0 ? void 0 : _a.filter(filter => !filter.name.startsWith("FILTRO_COLUNA_"))) !== null && _b !== void 0 ? _b : [];
|
|
632
|
+
if (serverSideFilters.length !== 0) {
|
|
633
|
+
txProperties["__DATA_UNIT_ADAPTER__[criteria]"] = JSON.stringify(serverSideFilters);
|
|
634
|
+
}
|
|
635
|
+
if (sorting != undefined && sorting.length !== 0) {
|
|
636
|
+
txProperties["__DATA_UNIT_ADAPTER__[sorting]"] = JSON.stringify(sorting);
|
|
637
|
+
}
|
|
638
|
+
if (request.parentRecordId != undefined) {
|
|
639
|
+
txProperties["__DATA_UNIT_ADAPTER__[parentRecordId]"] = request.parentRecordId;
|
|
640
|
+
}
|
|
641
|
+
return txProperties;
|
|
642
|
+
}
|
|
643
|
+
processRecords(dataUnit, fields, responseRecords) {
|
|
644
|
+
return responseRecords.map((dataFrame) => {
|
|
645
|
+
const duRecord = {
|
|
646
|
+
__record__id__: dataFrame[0],
|
|
647
|
+
__record__label__: dataFrame[1]
|
|
648
|
+
};
|
|
649
|
+
dataUnit.metadata.fields.forEach(fieldDescriptor => {
|
|
650
|
+
duRecord[fieldDescriptor.name] = this.buildFieldValue(fieldDescriptor, fields, dataFrame);
|
|
651
|
+
});
|
|
652
|
+
return duRecord;
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
buildFieldValue(descriptor, allFields, dataFrame) {
|
|
656
|
+
const fieldIndex = allFields.indexOf(descriptor.name);
|
|
657
|
+
if (fieldIndex < 0) {
|
|
658
|
+
return null;
|
|
659
|
+
}
|
|
660
|
+
const strValue = dataFrame[fieldIndex];
|
|
661
|
+
if (StringUtils.isEmpty(strValue)) {
|
|
662
|
+
return null;
|
|
663
|
+
}
|
|
664
|
+
const descriptionField = this.getSearchDescriptionField(descriptor);
|
|
665
|
+
if (descriptionField != undefined) {
|
|
666
|
+
const descriptionFieldIndex = allFields.indexOf(descriptionField);
|
|
667
|
+
if (descriptionFieldIndex >= 0) {
|
|
668
|
+
return { value: strValue, label: dataFrame[descriptionFieldIndex] };
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
if (descriptor.userInterface === UserInterface.SEARCH) {
|
|
672
|
+
//Se não tem um campo de descrição (código acima)
|
|
673
|
+
//Mas é um search, tentamos parsear um numero...
|
|
674
|
+
return isNaN(Number(strValue)) ? strValue : Number(strValue);
|
|
675
|
+
}
|
|
676
|
+
return InMemoryLoader.getConvertedValue(descriptor, strValue);
|
|
677
|
+
}
|
|
678
|
+
getSearchDescriptionField(descriptor) {
|
|
679
|
+
if (descriptor.userInterface === UserInterface.SEARCH) {
|
|
680
|
+
const { ENTITYNAME, mergedFrom, DESCRIPTIONFIELD } = descriptor.properties;
|
|
681
|
+
if (!StringUtils.isEmpty(DESCRIPTIONFIELD)) {
|
|
682
|
+
return mergedFrom != undefined ? `${mergedFrom}.${ENTITYNAME}.${DESCRIPTIONFIELD}` : `${ENTITYNAME}.${DESCRIPTIONFIELD}`;
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
return undefined;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
class DataUnitDataLoader {
|
|
690
|
+
static async debounce(dataUnit, callBack) {
|
|
691
|
+
const duName = dataUnit.name;
|
|
692
|
+
if (DataUnitDataLoader._debouncingTimeouts[duName]) {
|
|
693
|
+
clearTimeout(DataUnitDataLoader._debouncingTimeouts[duName]);
|
|
694
|
+
delete DataUnitDataLoader._debouncingTimeouts[duName];
|
|
695
|
+
}
|
|
696
|
+
DataUnitDataLoader._debouncingTimeouts[duName] = setTimeout(() => {
|
|
697
|
+
delete DataUnitDataLoader._debouncingTimeouts[duName];
|
|
698
|
+
callBack();
|
|
699
|
+
}, 100);
|
|
700
|
+
}
|
|
701
|
+
static async loadData(dataUnit, request) {
|
|
702
|
+
return new Promise((resolve, reject) => {
|
|
703
|
+
DataUnitDataLoader.debounce(dataUnit, () => {
|
|
704
|
+
PreloadManager.loadData(dataUnit, request, this.loadFromServer)
|
|
705
|
+
.then(resp => resolve(resp))
|
|
706
|
+
.catch(reason => reject(reason));
|
|
707
|
+
});
|
|
708
|
+
});
|
|
709
|
+
}
|
|
710
|
+
static async loadFromServer(dataUnit, request, loadingInfo) {
|
|
711
|
+
try {
|
|
712
|
+
//Registramos a request com as informações de carga para determinarmos a última.
|
|
713
|
+
//Caso o usuário inicie outro refresh antes de terminar, devemos ignorar o resultado.
|
|
714
|
+
loadingInfo = DataUnitDataLoader.registryLoading(dataUnit, loadingInfo);
|
|
715
|
+
const loadResult = await DataUnitDataLoader.callLoader(dataUnit, request, loadingInfo);
|
|
716
|
+
if (loadResult == undefined) {
|
|
717
|
+
//Essa request foi originada de refresh antigo. Será ignorada;
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
const loadedRecords = loadResult.records;
|
|
721
|
+
const paginationInfo = DataUnitDataLoader.buildPaginationInfo(loadedRecords.length, request, loadResult.loadingInfo);
|
|
722
|
+
const records = paginationInfo == undefined ? loadedRecords : loadedRecords.slice(0, paginationInfo.lastRecord);
|
|
723
|
+
return Promise.resolve({ records, paginationInfo });
|
|
724
|
+
}
|
|
725
|
+
catch (error) {
|
|
726
|
+
console.error(error);
|
|
727
|
+
return Promise.reject(error);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
static async callLoader(dataUnit, request, requestLoadingInfo, dataLoader) {
|
|
731
|
+
if (dataLoader == undefined) {
|
|
732
|
+
//dataLoader = new DataUnitStrategy();
|
|
733
|
+
dataLoader = new DatasetStrategy();
|
|
734
|
+
}
|
|
735
|
+
const result = await dataLoader.load(dataUnit, request, requestLoadingInfo);
|
|
736
|
+
const { records, loadingInfo: responseLoadingInfo } = result;
|
|
737
|
+
if (DataUnitDataLoader.isOldRequest(dataUnit, responseLoadingInfo)) {
|
|
738
|
+
return Promise.resolve(undefined);
|
|
739
|
+
}
|
|
740
|
+
const recreateCache = !dataLoader.canSlice() || responseLoadingInfo.count === 0;
|
|
741
|
+
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
|
742
|
+
if (PreloadManager.isCacheEnabled(dataUnit) && responseLoadingInfo.loadingInProgress) {
|
|
743
|
+
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
|
744
|
+
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
|
|
745
|
+
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
|
746
|
+
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
|
747
|
+
.catch(reason => console.error(reason));
|
|
748
|
+
}
|
|
749
|
+
return Promise.resolve(result);
|
|
750
|
+
}
|
|
751
|
+
static afterLoadingPage(dataUnit, loadingInfo) {
|
|
752
|
+
PreloadManager.setLoadingStatus(dataUnit, loadingInfo.loadingInProgress);
|
|
753
|
+
const dataUnitPagination = dataUnit.getPaginationInfo();
|
|
754
|
+
if (dataUnitPagination == undefined) {
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
const count = loadingInfo.count;
|
|
758
|
+
if (loadingInfo.loadingInProgress) {
|
|
759
|
+
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { count }));
|
|
760
|
+
return;
|
|
761
|
+
}
|
|
762
|
+
if (loadingInfo.needReload) {
|
|
763
|
+
//Ir para a primeira página, faz com que o loadData seja chamado novamente
|
|
764
|
+
dataUnit.gotoPage(0);
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { total: count, count }));
|
|
768
|
+
}
|
|
769
|
+
static registryLoading(dataUnit, loadingInfo) {
|
|
770
|
+
if (loadingInfo == undefined) {
|
|
771
|
+
loadingInfo = { requestTime: new Date().getTime(), count: 0 };
|
|
772
|
+
}
|
|
773
|
+
DataUnitDataLoader._requestTimeByDataUnit.set(dataUnit.name, loadingInfo.requestTime);
|
|
774
|
+
return loadingInfo;
|
|
775
|
+
}
|
|
776
|
+
static isOldRequest(dataUnit, loadingInfo) {
|
|
777
|
+
return DataUnitDataLoader._requestTimeByDataUnit.get(dataUnit.name) > loadingInfo.requestTime;
|
|
778
|
+
}
|
|
779
|
+
static buildPaginationInfo(pageSize, request, loadingInfo) {
|
|
780
|
+
let { limit, offset } = request;
|
|
781
|
+
if (!limit) {
|
|
782
|
+
return undefined;
|
|
783
|
+
}
|
|
784
|
+
if (loadingInfo.pageNumber === 1) {
|
|
785
|
+
// Quando o loader não é capaz de fatiar os registros
|
|
786
|
+
// ele pode decidir por uma carga completa, o que faz o
|
|
787
|
+
// controle de paginação voltar pra primeira página.
|
|
788
|
+
offset = 0;
|
|
789
|
+
}
|
|
790
|
+
const { total, count, loadingInProgress } = loadingInfo;
|
|
791
|
+
const firstRecord = (count === 0 || pageSize === 0) ? 0 : offset + 1;
|
|
792
|
+
const lastRecord = offset + Math.min(pageSize, limit);
|
|
793
|
+
return {
|
|
794
|
+
total,
|
|
795
|
+
count,
|
|
796
|
+
lastRecord,
|
|
797
|
+
firstRecord,
|
|
798
|
+
currentPage: offset / limit,
|
|
799
|
+
hasMore: lastRecord < count || loadingInProgress
|
|
800
|
+
};
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
DataUnitDataLoader._requestTimeByDataUnit = new Map();
|
|
804
|
+
DataUnitDataLoader._debouncingTimeouts = {};
|
|
5
805
|
|
|
6
806
|
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
7
807
|
var t = {};
|
|
@@ -14,10 +814,10 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
14
814
|
}
|
|
15
815
|
return t;
|
|
16
816
|
};
|
|
817
|
+
const DATA_UNIT_NAME_PARSER = /dd:\/\/([^/]+)\/([^/?]+)/;
|
|
17
818
|
class DataUnitFetcher {
|
|
18
819
|
constructor() {
|
|
19
820
|
this.templateByQuery = new Map();
|
|
20
|
-
this._loadDataTimeout = {};
|
|
21
821
|
this.buldTemplates();
|
|
22
822
|
}
|
|
23
823
|
buldTemplates() {
|
|
@@ -29,6 +829,7 @@ class DataUnitFetcher {
|
|
|
29
829
|
defaultValue
|
|
30
830
|
label
|
|
31
831
|
visible
|
|
832
|
+
standAlone
|
|
32
833
|
readOnly
|
|
33
834
|
required
|
|
34
835
|
dataType
|
|
@@ -56,24 +857,6 @@ class DataUnitFetcher {
|
|
|
56
857
|
}
|
|
57
858
|
}
|
|
58
859
|
}`);
|
|
59
|
-
this.templateByQuery.set("fetchData", dist.gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!] $parentRecordId: String) {
|
|
60
|
-
$queryAlias$: fetchDataUnit(name: $dataunit){
|
|
61
|
-
data(limit: $limit offset: $offset filters: $filters sort: $sort parentRecordId: $parentRecordId){
|
|
62
|
-
limit
|
|
63
|
-
offset
|
|
64
|
-
total
|
|
65
|
-
hasMore
|
|
66
|
-
records{
|
|
67
|
-
id
|
|
68
|
-
label
|
|
69
|
-
fields {
|
|
70
|
-
name
|
|
71
|
-
value
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}`);
|
|
77
860
|
this.templateByQuery.set("saveData", dist.gql `mutation($changes: [InputBatchChange!]!) {
|
|
78
861
|
$queryAlias$: batchOperationDataUnit(changes: $changes){
|
|
79
862
|
oldId
|
|
@@ -102,11 +885,25 @@ class DataUnitFetcher {
|
|
|
102
885
|
$queryAlias$: selectDistinct(dataUnit: $dataUnit, fieldName: $fieldName, argument: $argument, filters: $filters, parentRecordId: $parentRecordId)
|
|
103
886
|
}`);
|
|
104
887
|
}
|
|
888
|
+
static parseDataUnitName(name) {
|
|
889
|
+
if (name == undefined) {
|
|
890
|
+
return undefined;
|
|
891
|
+
}
|
|
892
|
+
const parts = DATA_UNIT_NAME_PARSER.exec(name);
|
|
893
|
+
if (!parts) {
|
|
894
|
+
return undefined;
|
|
895
|
+
}
|
|
896
|
+
return { entityName: parts[1], resourceID: parts[2] };
|
|
897
|
+
}
|
|
105
898
|
getDataUnit(entityName, resourceID, parentDataUnit, configName) {
|
|
899
|
+
if (PreloadManager.applicationResourceID == undefined) {
|
|
900
|
+
//Por falta de um lugar melhor pra iniciar essa variável, fazemos isso aqui.
|
|
901
|
+
ResourceIDUtils.getResourceID().then(resourceID => PreloadManager.applicationResourceID = resourceID);
|
|
902
|
+
}
|
|
106
903
|
const duName = `dd://${entityName}/${resourceID}${configName ? "/" + configName : ""}`;
|
|
107
904
|
const dataUnit = parentDataUnit != undefined ? parentDataUnit.getChildDataunit(duName) : new DataUnit(duName);
|
|
108
905
|
dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
|
|
109
|
-
dataUnit.dataLoader = (dataUnit, request) =>
|
|
906
|
+
dataUnit.dataLoader = (dataUnit, request) => DataUnitDataLoader.loadData(dataUnit, request);
|
|
110
907
|
dataUnit.saveLoader = (_dataUnit, changes) => this.saveData(dataUnit, changes);
|
|
111
908
|
dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
|
|
112
909
|
dataUnit.recordLoader = (dataUnit, recordIds) => this.loadRecord(dataUnit, recordIds);
|
|
@@ -146,24 +943,6 @@ class DataUnitFetcher {
|
|
|
146
943
|
});
|
|
147
944
|
});
|
|
148
945
|
}
|
|
149
|
-
async loadData(dataUnit, request) {
|
|
150
|
-
try {
|
|
151
|
-
const duName = dataUnit.name;
|
|
152
|
-
if (this._loadDataTimeout[duName]) {
|
|
153
|
-
clearTimeout(this._loadDataTimeout[duName]);
|
|
154
|
-
delete this._loadDataTimeout[duName];
|
|
155
|
-
}
|
|
156
|
-
const result = await this.doLoadData(dataUnit, request);
|
|
157
|
-
delete this._loadDataTimeout[duName];
|
|
158
|
-
await new Promise(resolve => {
|
|
159
|
-
this._loadDataTimeout[duName] = setTimeout(resolve, 200);
|
|
160
|
-
});
|
|
161
|
-
return Promise.resolve(result);
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
return Promise.reject(error);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
946
|
loadSelectDistinct(dataUnit, fieldName, argument) {
|
|
168
947
|
const { parentRecordId, filters } = dataUnit.getLastLoadRequest() || {};
|
|
169
948
|
const filteredFilters = filters.filter(f => f.name !== `${DISTINCT_FILTER_NAME_PREFIX}${fieldName}`);
|
|
@@ -188,67 +967,9 @@ class DataUnitFetcher {
|
|
|
188
967
|
});
|
|
189
968
|
});
|
|
190
969
|
}
|
|
191
|
-
doLoadData(dataUnit, request) {
|
|
192
|
-
return new Promise((resolve, reject) => {
|
|
193
|
-
var _a;
|
|
194
|
-
const { sort, filters, limit, offset, quickFilter } = request;
|
|
195
|
-
const variables = { dataunit: dataUnit.name, sort, filters };
|
|
196
|
-
variables.limit = limit;
|
|
197
|
-
variables.offset = offset;
|
|
198
|
-
variables.parentRecordId = request.parentRecordId;
|
|
199
|
-
if (!StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
|
|
200
|
-
if (variables.filter === undefined) {
|
|
201
|
-
variables.filter = [];
|
|
202
|
-
}
|
|
203
|
-
const quickFilterCriteria = {
|
|
204
|
-
name: "__QUICK_FILTER__",
|
|
205
|
-
expression: "__QUICK_FILTER__",
|
|
206
|
-
params: [{ name: "term", dataType: DataType.TEXT, value: quickFilter.term }]
|
|
207
|
-
};
|
|
208
|
-
if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
209
|
-
quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: quickFilter.fields });
|
|
210
|
-
}
|
|
211
|
-
variables.filter.push(quickFilterCriteria);
|
|
212
|
-
}
|
|
213
|
-
DataFetcher.get()
|
|
214
|
-
.callGraphQL({
|
|
215
|
-
values: variables,
|
|
216
|
-
query: this.templateByQuery.get("fetchData"),
|
|
217
|
-
})
|
|
218
|
-
.then((resp) => {
|
|
219
|
-
const { limit, offset, total, hasMore, records } = resp.data;
|
|
220
|
-
let paginationInfo;
|
|
221
|
-
if (limit) {
|
|
222
|
-
const firstRecord = total == 0 ? 0 : offset + 1;
|
|
223
|
-
const lastRecord = offset + Math.min(records.length, limit);
|
|
224
|
-
const currentPage = offset / limit;
|
|
225
|
-
paginationInfo = {
|
|
226
|
-
firstRecord,
|
|
227
|
-
lastRecord,
|
|
228
|
-
total,
|
|
229
|
-
currentPage,
|
|
230
|
-
hasMore
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
const processedRecords = [];
|
|
234
|
-
records.forEach((responseRecord) => {
|
|
235
|
-
const duRecord = { __record__id__: responseRecord.id, __record__label__: responseRecord.label };
|
|
236
|
-
responseRecord.fields.forEach(({ name, value }) => {
|
|
237
|
-
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
238
|
-
});
|
|
239
|
-
processedRecords.push(duRecord);
|
|
240
|
-
});
|
|
241
|
-
resolve({
|
|
242
|
-
paginationInfo,
|
|
243
|
-
records: processedRecords
|
|
244
|
-
});
|
|
245
|
-
})
|
|
246
|
-
.catch((error) => {
|
|
247
|
-
reject(error);
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
970
|
saveData(dataUnit, duChanges) {
|
|
971
|
+
const updatedRecordsIds = [];
|
|
972
|
+
const addedRecordsIds = [];
|
|
252
973
|
const changes = duChanges.map((change) => {
|
|
253
974
|
const { dataUnit: changeDU, record, updatingFields, operation } = change;
|
|
254
975
|
const dataUnitInstance = DataUnitStorage.get(changeDU);
|
|
@@ -260,6 +981,14 @@ class DataUnitFetcher {
|
|
|
260
981
|
return { fieldName, dataType, value: dataUnitInstance.valueToString(fieldName, value) };
|
|
261
982
|
});
|
|
262
983
|
}
|
|
984
|
+
if (changeDU === dataUnit.name) {
|
|
985
|
+
if (operation === ChangeOperation.INSERT || operation === ChangeOperation.COPY) {
|
|
986
|
+
addedRecordsIds.push(record.__record__id__);
|
|
987
|
+
}
|
|
988
|
+
else {
|
|
989
|
+
updatedRecordsIds.push(record.__record__id__);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
263
992
|
const reqChange = { dataUnit: changeDU, fields: parsedUpdatingFields, operation, recordId: record.__record__id__ };
|
|
264
993
|
if (change.sourceId) {
|
|
265
994
|
reqChange.sourceId = change.sourceId;
|
|
@@ -297,6 +1026,7 @@ class DataUnitFetcher {
|
|
|
297
1026
|
});
|
|
298
1027
|
dataUnitRecords.push(duRecord);
|
|
299
1028
|
});
|
|
1029
|
+
this.updateCache(dataUnit, dataUnitRecords, updatedRecordsIds, addedRecordsIds);
|
|
300
1030
|
resolve(dataUnitRecords);
|
|
301
1031
|
})
|
|
302
1032
|
.catch((error) => {
|
|
@@ -304,6 +1034,20 @@ class DataUnitFetcher {
|
|
|
304
1034
|
});
|
|
305
1035
|
});
|
|
306
1036
|
}
|
|
1037
|
+
updateCache(dataUnit, savedRecords, toUpdate, toInsert) {
|
|
1038
|
+
const recordsById = new Map(savedRecords.map(record => [record.__old__id__ || record.__record__id__, record]));
|
|
1039
|
+
const addedRecords = toInsert.map(recordId => {
|
|
1040
|
+
const copy = Object.assign({}, recordsById.get(recordId));
|
|
1041
|
+
delete copy.__old__id__;
|
|
1042
|
+
return copy;
|
|
1043
|
+
});
|
|
1044
|
+
if (addedRecords.length > 0) {
|
|
1045
|
+
const firstRecord = dataUnit.records[0];
|
|
1046
|
+
PreloadManager.insertRecords(dataUnit, firstRecord, addedRecords);
|
|
1047
|
+
}
|
|
1048
|
+
const updatedRecords = toUpdate.map(recordId => (Object.assign({}, recordsById.get(recordId))));
|
|
1049
|
+
PreloadManager.updateRecords(dataUnit, updatedRecords);
|
|
1050
|
+
}
|
|
307
1051
|
getTransientInfo(dataUnit, recordID) {
|
|
308
1052
|
const { records } = dataUnit.getSelectionInfo();
|
|
309
1053
|
return Object.entries(records.filter(record => record.__record__id__ == recordID)[0]).filter(([key]) => key.startsWith(DataUnitTransient.DATA_UNIT_TRANSIENT_PREFIX_NAME)).map(([name, value]) => ({ fieldName: name, value, dataType: DataType.TEXT }));
|
|
@@ -319,6 +1063,7 @@ class DataUnitFetcher {
|
|
|
319
1063
|
query: this.templateByQuery.get("saveData"),
|
|
320
1064
|
})
|
|
321
1065
|
.then((_resp) => {
|
|
1066
|
+
PreloadManager.removeRecords(dataUnit, dataUnit.records.filter(record => recordIds.includes(record.__record__id__)));
|
|
322
1067
|
resolve(recordIds);
|
|
323
1068
|
})
|
|
324
1069
|
.catch((error) => {
|
|
@@ -342,6 +1087,7 @@ class DataUnitFetcher {
|
|
|
342
1087
|
});
|
|
343
1088
|
dataUnitRecords.push(duRecord);
|
|
344
1089
|
});
|
|
1090
|
+
//TODO: Chamar o worker para persistir a nova versão do registro
|
|
345
1091
|
resolve(dataUnitRecords);
|
|
346
1092
|
})
|
|
347
1093
|
.catch((error) => {
|
|
@@ -351,4 +1097,4 @@ class DataUnitFetcher {
|
|
|
351
1097
|
}
|
|
352
1098
|
}
|
|
353
1099
|
|
|
354
|
-
export { DataUnitFetcher as D };
|
|
1100
|
+
export { DataUnitFetcher as D, InMemoryLoader as I, PesquisaFetcher as P, PreloadManager as a };
|