@sankhyalabs/sankhyablocks 1.3.34 → 1.4.0-beta.10
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/SnkMessageBuilder-6c2f7bcd.js +302 -0
- package/dist/cjs/_commonjsHelpers-537d719a.js +20 -0
- package/dist/cjs/configurableElementsStorage-93459c72.js +20 -0
- package/dist/cjs/constants-9056ca9e.js +84 -0
- package/dist/cjs/draggable.bundle-82a25c06.js +6886 -0
- package/dist/cjs/filter-item-type.enum-3daf58d3.js +16 -0
- package/dist/cjs/form-config-fetcher-2de7c16a.js +6895 -0
- package/dist/cjs/{index-1133bc2a.js → index-20e8b68a.js} +964 -209
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/sankhyablocks.cjs.js +3 -3
- package/dist/cjs/snk-application.cjs.entry.js +680 -6994
- package/dist/cjs/snk-config-modal.cjs.entry.js +62 -0
- package/dist/cjs/snk-config-options.cjs.entry.js +230 -0
- package/dist/cjs/snk-configurator_6.cjs.entry.js +1156 -0
- package/dist/cjs/snk-crud.cjs.entry.js +78 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +272 -0
- package/dist/cjs/snk-field-config_2.cjs.entry.js +135 -0
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +50 -0
- package/dist/cjs/snk-filter-detail.cjs.entry.js +106 -0
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +26 -0
- package/dist/cjs/snk-filter-number.cjs.entry.js +27 -0
- package/dist/cjs/snk-filter-period.cjs.entry.js +40 -0
- package/dist/cjs/snk-filter-personalized.cjs.entry.js +89 -0
- package/dist/cjs/snk-filter-search.cjs.entry.js +38 -0
- package/dist/cjs/snk-filter-text.cjs.entry.js +22 -0
- package/dist/cjs/snk-form-config.cjs.entry.js +957 -0
- package/dist/cjs/snk-form.cjs.entry.js +146 -0
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-tab-config.cjs.entry.js +321 -0
- package/dist/cjs/taskbar-elements-9a4b1e19.js +97 -0
- package/dist/cjs/taskbar-processor-6bd0d35c.js +47 -0
- package/dist/cjs/teste-pesquisa.cjs.entry.js +1 -1
- package/dist/collection/collection-manifest.json +45 -2
- package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +9 -2
- package/dist/collection/components/snk-application/snk-application.js +1346 -642
- package/dist/collection/components/snk-configurator/snk-configurator.js +261 -0
- package/dist/collection/components/snk-configurator/subcomponents/configModalProvider/configurableElementsStorage.js +16 -0
- package/dist/collection/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.css +122 -0
- package/dist/collection/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.js +137 -0
- package/dist/collection/components/snk-crud/snk-crud.css +6 -0
- package/dist/collection/components/snk-crud/snk-crud.js +232 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.css +6 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +517 -0
- package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +100 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +111 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +87 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +88 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +101 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +180 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +102 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +63 -0
- package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +12 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +178 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +289 -0
- package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +299 -0
- package/dist/collection/components/snk-filter-bar/filter-modal/snk-filter-modal.js +222 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +149 -0
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +462 -0
- package/dist/collection/components/snk-form/snk-form.css +38 -0
- package/dist/collection/components/snk-form/snk-form.js +336 -0
- package/dist/collection/components/snk-form/subcomponents/snk-config-options/snk-config-options.css +9 -0
- package/dist/collection/components/snk-form/subcomponents/snk-config-options/snk-config-options.js +315 -0
- package/dist/collection/components/snk-form/subcomponents/snk-field-config/snk-field-config.css +164 -0
- package/dist/collection/components/snk-form/subcomponents/snk-field-config/snk-field-config.js +140 -0
- package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.css +185 -0
- package/dist/collection/components/snk-form/subcomponents/snk-form-config/snk-form-config.js +1062 -0
- package/dist/collection/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.css +272 -0
- package/dist/collection/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.js +476 -0
- package/dist/collection/components/snk-grid/snk-grid.css +18 -0
- package/dist/collection/components/snk-grid/snk-grid.js +273 -0
- package/dist/collection/components/snk-pesquisa/snk-pesquisa.js +80 -79
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +90 -0
- package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +43 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.css +3 -0
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +339 -0
- package/dist/collection/components/teste-pesquisa/teste-pesquisa.js +12 -9
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +39 -14
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +87 -21
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +62 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +106 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/grid-config-fetcher.js +4 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/parameters-fecher.js +15 -15
- package/dist/collection/lib/http/data-fetcher/fetchers/resource-fetcher.js +9 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/totals-fetcher.js +47 -0
- package/dist/collection/lib/index.js +2 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +130 -0
- package/dist/collection/lib/message/resources/crud-utils.msg.js +4 -0
- package/dist/collection/lib/message/resources/snk-configurator.msg.js +11 -0
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +23 -0
- package/dist/collection/lib/message/resources/snk-filter-bar.msg.js +30 -0
- package/dist/collection/lib/message/resources/snk-form.msg.js +67 -0
- package/dist/collection/lib/message/resources/snk-taskbar.msg.js +17 -0
- package/dist/collection/lib/utils/CrudUtils.js +73 -0
- package/dist/collection/lib/utils/constants.js +72 -0
- package/dist/components/SnkMessageBuilder.js +280 -0
- package/dist/components/_commonjsHelpers.js +17 -0
- package/dist/components/constants.js +74 -0
- package/dist/components/filter-item-type.enum.js +14 -0
- package/dist/components/form-config-fetcher.js +6889 -0
- package/dist/components/index.d.ts +26 -5
- package/dist/components/index.js +26 -0
- package/dist/components/snk-application2.js +681 -6980
- package/dist/components/snk-config-modal.d.ts +11 -0
- package/dist/components/snk-config-modal.js +6 -0
- package/dist/components/snk-config-modal2.js +91 -0
- package/dist/components/snk-config-options.d.ts +11 -0
- package/dist/components/snk-config-options.js +6 -0
- package/dist/components/snk-config-options2.js +245 -0
- package/dist/components/snk-configurator.d.ts +11 -0
- package/dist/components/snk-configurator.js +6 -0
- package/dist/components/snk-configurator2.js +212 -0
- package/dist/components/snk-crud.d.ts +11 -0
- package/dist/components/snk-crud.js +183 -0
- package/dist/components/snk-data-unit.d.ts +11 -0
- package/dist/components/snk-data-unit.js +294 -0
- package/dist/components/snk-field-config.d.ts +11 -0
- package/dist/components/snk-field-config.js +6 -0
- package/dist/components/snk-field-config2.js +70 -0
- package/dist/components/snk-filter-bar.d.ts +11 -0
- package/dist/components/snk-filter-bar.js +6 -0
- package/dist/components/snk-filter-bar2.js +516 -0
- package/dist/components/snk-filter-binary-select.d.ts +11 -0
- package/dist/components/snk-filter-binary-select.js +67 -0
- package/dist/components/snk-filter-detail.d.ts +11 -0
- package/dist/components/snk-filter-detail.js +6 -0
- package/dist/components/snk-filter-detail2.js +120 -0
- package/dist/components/snk-filter-item.d.ts +11 -0
- package/dist/components/snk-filter-item.js +6 -0
- package/dist/components/snk-filter-item2.js +194 -0
- package/dist/components/snk-filter-list.d.ts +11 -0
- package/dist/components/snk-filter-list.js +6 -0
- package/dist/components/snk-filter-list2.js +149 -0
- package/dist/components/snk-filter-modal.d.ts +11 -0
- package/dist/components/snk-filter-modal.js +6 -0
- package/dist/components/snk-filter-modal2.js +84 -0
- package/dist/components/snk-filter-multi-select.d.ts +11 -0
- package/dist/components/snk-filter-multi-select.js +43 -0
- package/dist/components/snk-filter-number.d.ts +11 -0
- package/dist/components/snk-filter-number.js +44 -0
- package/dist/components/snk-filter-period.d.ts +11 -0
- package/dist/components/snk-filter-period.js +57 -0
- package/dist/components/snk-filter-personalized.d.ts +11 -0
- package/dist/components/snk-filter-personalized.js +108 -0
- package/dist/components/snk-filter-search.d.ts +11 -0
- package/dist/components/snk-filter-search.js +55 -0
- package/dist/components/snk-filter-text.d.ts +11 -0
- package/dist/components/snk-filter-text.js +38 -0
- package/dist/components/snk-form-config.d.ts +11 -0
- package/dist/components/snk-form-config.js +6 -0
- package/dist/components/snk-form-config2.js +996 -0
- package/dist/components/snk-form.d.ts +11 -0
- package/dist/components/snk-form.js +6 -0
- package/dist/components/snk-form2.js +209 -0
- package/dist/components/snk-grid.d.ts +11 -0
- package/dist/components/snk-grid.js +6 -0
- package/dist/components/snk-grid2.js +152 -0
- package/dist/components/snk-tab-config.d.ts +11 -0
- package/dist/components/snk-tab-config.js +6 -0
- package/dist/components/snk-tab-config2.js +7220 -0
- package/dist/components/snk-taskbar.d.ts +11 -0
- package/dist/components/snk-taskbar.js +6 -0
- package/dist/components/snk-taskbar2.js +282 -0
- package/dist/components/taskbar-processor.js +45 -0
- package/dist/esm/SnkMessageBuilder-5792c260.js +280 -0
- package/dist/esm/_commonjsHelpers-9943807e.js +17 -0
- package/dist/esm/configurableElementsStorage-cdc144b5.js +18 -0
- package/dist/esm/constants-c6039d3d.js +74 -0
- package/dist/esm/draggable.bundle-41d56f06.js +6884 -0
- package/dist/esm/filter-item-type.enum-a79b2fa8.js +14 -0
- package/dist/esm/form-config-fetcher-96c6c2dc.js +6889 -0
- package/dist/esm/{index-ffda6382.js → index-e4121713.js} +963 -210
- package/dist/esm/loader.js +3 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/esm/sankhyablocks.js +3 -3
- package/dist/esm/snk-application.entry.js +667 -6981
- package/dist/esm/snk-config-modal.entry.js +58 -0
- package/dist/esm/snk-config-options.entry.js +226 -0
- package/dist/esm/snk-configurator_6.entry.js +1147 -0
- package/dist/esm/snk-crud.entry.js +74 -0
- package/dist/esm/snk-data-unit.entry.js +268 -0
- package/dist/esm/snk-field-config_2.entry.js +130 -0
- package/dist/esm/snk-filter-binary-select.entry.js +46 -0
- package/dist/esm/snk-filter-detail.entry.js +102 -0
- package/dist/esm/snk-filter-multi-select.entry.js +22 -0
- package/dist/esm/snk-filter-number.entry.js +23 -0
- package/dist/esm/snk-filter-period.entry.js +36 -0
- package/dist/esm/snk-filter-personalized.entry.js +85 -0
- package/dist/esm/snk-filter-search.entry.js +34 -0
- package/dist/esm/snk-filter-text.entry.js +18 -0
- package/dist/esm/snk-form-config.entry.js +953 -0
- package/dist/esm/snk-form.entry.js +142 -0
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-tab-config.entry.js +317 -0
- package/dist/esm/taskbar-elements-e2ed0536.js +94 -0
- package/dist/esm/taskbar-processor-aa6772c9.js +45 -0
- package/dist/esm/teste-pesquisa.entry.js +1 -1
- package/dist/sankhyablocks/p-029ae4e4.entry.js +1 -0
- package/dist/sankhyablocks/p-03f9c407.js +1 -0
- package/dist/sankhyablocks/p-112455b1.js +1 -0
- package/dist/sankhyablocks/p-12ad2a19.entry.js +1 -0
- package/dist/sankhyablocks/p-1feabfc7.entry.js +1 -0
- package/dist/sankhyablocks/p-21c8929b.js +1 -0
- package/dist/sankhyablocks/p-2284c850.entry.js +1 -0
- package/dist/sankhyablocks/p-2b891c4a.entry.js +1 -0
- package/dist/sankhyablocks/p-2dc76d79.entry.js +1 -0
- package/dist/sankhyablocks/p-361299e8.js +26 -0
- package/dist/sankhyablocks/p-3a276f3d.entry.js +1 -0
- package/dist/sankhyablocks/p-400cc777.entry.js +1 -0
- package/dist/sankhyablocks/{p-2a7b4cb3.entry.js → p-44ce5b90.entry.js} +1 -1
- package/dist/sankhyablocks/p-521c96f0.entry.js +1 -0
- package/dist/sankhyablocks/{p-9520d78a.entry.js → p-6988f4a6.entry.js} +1 -1
- package/dist/sankhyablocks/p-776ff4d1.entry.js +1 -0
- package/dist/sankhyablocks/p-7b4a4a50.entry.js +1 -0
- package/dist/sankhyablocks/p-9ba3df4c.js +2 -0
- package/dist/sankhyablocks/p-9dc4426d.entry.js +1 -0
- package/dist/sankhyablocks/p-9dd2b8cb.js +1 -0
- package/dist/sankhyablocks/p-a17a4fca.entry.js +1 -0
- package/dist/sankhyablocks/p-a5b26df2.js +1 -0
- package/dist/sankhyablocks/p-b6d6b172.js +1 -0
- package/dist/sankhyablocks/p-cc4bef9f.entry.js +1 -0
- package/dist/sankhyablocks/p-d50651a3.js +1 -0
- package/dist/sankhyablocks/p-d690b6b5.entry.js +75 -0
- package/dist/sankhyablocks/p-d9fbb26f.js +1 -0
- package/dist/sankhyablocks/p-deb1f523.entry.js +1 -0
- package/dist/sankhyablocks/p-e871aa92.entry.js +1 -0
- package/dist/sankhyablocks/p-e9beab79.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/errorhandler/snk-error-handler.d.ts +1 -0
- package/dist/types/components/snk-application/snk-application.d.ts +178 -26
- package/dist/types/components/snk-configurator/snk-configurator.d.ts +46 -0
- package/dist/types/components/snk-configurator/subcomponents/configModalProvider/configurableElementsStorage.d.ts +8 -0
- package/dist/types/components/snk-configurator/subcomponents/snk-config-modal/snk-config-modal.d.ts +38 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +50 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +92 -0
- package/dist/types/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.d.ts +4 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.d.ts +13 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +9 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +9 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +15 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +24 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +11 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +8 -0
- package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +11 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +20 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +40 -0
- package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +45 -0
- package/dist/types/components/snk-filter-bar/filter-modal/snk-filter-modal.d.ts +26 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +65 -0
- package/dist/types/components/snk-form/snk-form.d.ts +71 -0
- package/dist/types/components/snk-form/subcomponents/snk-config-options/snk-config-options.d.ts +51 -0
- package/dist/types/components/snk-form/subcomponents/snk-field-config/snk-field-config.d.ts +32 -0
- package/dist/types/components/snk-form/subcomponents/snk-form-config/snk-form-config.d.ts +139 -0
- package/dist/types/components/snk-form/subcomponents/snk-tab-config/snk-tab-config.d.ts +97 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +59 -0
- package/dist/types/components/snk-taskbar/elements/taskbar-elements.d.ts +30 -0
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +12 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +92 -0
- package/dist/types/components.d.ts +1100 -12
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +7 -6
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +3 -0
- package/dist/types/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +21 -3
- package/dist/types/lib/http/data-fetcher/fetchers/grid-config-fetcher.d.ts +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/parameters-fecher.d.ts +7 -7
- package/dist/types/lib/http/data-fetcher/fetchers/resource-fetcher.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/totals-fetcher.d.ts +8 -0
- package/dist/types/lib/index.d.ts +2 -0
- package/dist/types/lib/message/SnkMessageBuilder.d.ts +42 -0
- package/dist/types/lib/message/resources/crud-utils.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-configurator.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-data-unit.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-filter-bar.msg.d.ts +2 -0
- package/dist/types/lib/message/resources/snk-form.msg.d.ts +5 -0
- package/dist/types/lib/message/resources/snk-taskbar.msg.d.ts +2 -0
- package/dist/types/lib/utils/CrudUtils.d.ts +6 -0
- package/dist/types/lib/utils/constants.d.ts +76 -0
- package/dist/types/lib/utils/pesquisa.d.ts +2 -1
- package/dist/types/stencil-public-runtime.d.ts +15 -4
- package/loader/package.json +1 -0
- package/package.json +6 -5
- package/react/components.d.ts +23 -0
- package/react/components.js +23 -0
- package/react/components.js.map +1 -1
- package/dist/sankhyablocks/p-98e8490d.entry.js +0 -69
- package/dist/sankhyablocks/p-edcb9d8e.js +0 -2
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
import { Host, h } from '@stencil/core';
|
|
2
|
+
import { Action, ApplicationContext } from '@sankhyalabs/core';
|
|
3
|
+
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
4
|
+
import { OperationMap } from '../../lib/message/SnkMessageBuilder';
|
|
5
|
+
export class SnkDataUnit {
|
|
6
|
+
constructor() {
|
|
7
|
+
this._onDataUnitResolve = [];
|
|
8
|
+
/**
|
|
9
|
+
* Determina quantas linhas são retornadas por página
|
|
10
|
+
*/
|
|
11
|
+
this.pageSize = 150;
|
|
12
|
+
this._dataUnitObserver = (action) => {
|
|
13
|
+
const duState = {
|
|
14
|
+
insertionMode: false,
|
|
15
|
+
hasNext: this.dataUnit.hasNext(),
|
|
16
|
+
hasPrevious: this.dataUnit.hasPrevious(),
|
|
17
|
+
copyMode: false,
|
|
18
|
+
isDirty: this.dataUnit.isDirty(),
|
|
19
|
+
hasDirtyRecords: this.dataUnit.hasDirtyRecords(),
|
|
20
|
+
selectedRecords: this.dataUnit.getSelectedRecords()
|
|
21
|
+
};
|
|
22
|
+
this.dataUnit.records.forEach(r => {
|
|
23
|
+
if (r.__record__id__.startsWith('NEW_')) {
|
|
24
|
+
duState.insertionMode = true;
|
|
25
|
+
duState.copyMode || (duState.copyMode = r['__record__source__id__'] != undefined);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
this.dataState = duState;
|
|
29
|
+
if (action.type === Action.DATA_SAVED) {
|
|
30
|
+
const msg = this.getMessage("snkDataUnit.saveInfo", action.payload.records[0]);
|
|
31
|
+
if (msg != undefined) {
|
|
32
|
+
this.showSuccessMessage(msg);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (action.type === Action.RECORDS_ADDED || action.type === Action.RECORDS_COPIED) {
|
|
36
|
+
this.insertionMode.emit();
|
|
37
|
+
}
|
|
38
|
+
if (action.type === Action.EDITION_CANCELED) {
|
|
39
|
+
this.cancelEdition.emit();
|
|
40
|
+
const cancelFinishMsg = this.getMessage("snkDataUnit.cancelInfo");
|
|
41
|
+
if (cancelFinishMsg != undefined) {
|
|
42
|
+
this.showSuccessMessage(cancelFinishMsg);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (action.type === Action.RECORDS_REMOVED) {
|
|
46
|
+
const removeFinishMsg = this.getMessage("snkDataUnit.removeInfo", action.payload.cachedRecords[0]);
|
|
47
|
+
if (removeFinishMsg != undefined) {
|
|
48
|
+
this.showSuccessMessage(removeFinishMsg);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
this._application.messagesBuilder.currentOperation = this.getMessageOperation();
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
observePageSize() {
|
|
55
|
+
if (this.dataUnit) {
|
|
56
|
+
this.dataUnit.pageSize = this.pageSize;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
observeDataUnitName(newValue, oldValue) {
|
|
60
|
+
if (oldValue != newValue) {
|
|
61
|
+
this.dataUnit = undefined;
|
|
62
|
+
this.dataUnitName = newValue;
|
|
63
|
+
this.loadDataUnit();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
observeEntityName(newValue, oldValue) {
|
|
67
|
+
if (oldValue != newValue) {
|
|
68
|
+
this.dataUnit = undefined;
|
|
69
|
+
this.entityName = newValue;
|
|
70
|
+
this.loadDataUnit();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
observeDataState(newValue, oldValue) {
|
|
74
|
+
if (oldValue != newValue) {
|
|
75
|
+
this.dataStateChange.emit(newValue);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
observeDataUnit() {
|
|
79
|
+
this.dataUnitReady.emit(this.dataUnit);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Pode-se obter o dataUnit através desse método. Outra forma, é ouvir o evento de
|
|
83
|
+
*
|
|
84
|
+
* @returns dataUnit
|
|
85
|
+
*/
|
|
86
|
+
async getDataUnit() {
|
|
87
|
+
return new Promise((resolve) => {
|
|
88
|
+
if (this.dataUnit) {
|
|
89
|
+
resolve(this.dataUnit);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this._onDataUnitResolve.push(resolve);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async interceptAction(action) {
|
|
97
|
+
return new Promise(resolve => {
|
|
98
|
+
switch (action.type) {
|
|
99
|
+
case Action.RECORDS_ADDED:
|
|
100
|
+
if (this.isAllowed("INSERT")) {
|
|
101
|
+
resolve(action);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenInsert"));
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case Action.RECORDS_COPIED:
|
|
108
|
+
if (this.isAllowed("CLONE")) {
|
|
109
|
+
resolve(action);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenClone"));
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
case Action.DATA_CHANGED:
|
|
116
|
+
case Action.CHANGING_DATA:
|
|
117
|
+
if (this.isAllowed("UPDATE")) {
|
|
118
|
+
resolve(action);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.dataUnit.cancelEdition();
|
|
122
|
+
ApplicationUtils.alert(this.getMessage("snkDataUnit.forbidden"), this.getMessage("snkDataUnit.forbiddenUpdate"));
|
|
123
|
+
}
|
|
124
|
+
break;
|
|
125
|
+
case Action.SAVING_DATA:
|
|
126
|
+
if (this.beforeSave) {
|
|
127
|
+
const continueAction = this.beforeSave(this.dataUnit);
|
|
128
|
+
if (continueAction instanceof Promise) {
|
|
129
|
+
continueAction.then(result => resolve(result ? action : undefined));
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
resolve(continueAction ? action : undefined);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
resolve(action);
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
case Action.DATA_SAVED:
|
|
140
|
+
if (this.afterSave) {
|
|
141
|
+
this.afterSave(this.dataUnit);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
resolve(action);
|
|
145
|
+
}
|
|
146
|
+
break;
|
|
147
|
+
case Action.EDITION_CANCELED:
|
|
148
|
+
if (this.dataState.hasDirtyRecords) {
|
|
149
|
+
const cancelConfirmation = this.getMessage("snkDataUnit.cancelConfirmation");
|
|
150
|
+
if (cancelConfirmation == undefined) {
|
|
151
|
+
resolve(action);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
const cancelConfirmationTitle = this.getMessage("snkDataUnit.cancelConfirmationTitle");
|
|
155
|
+
ApplicationUtils.confirm(cancelConfirmationTitle, cancelConfirmation)
|
|
156
|
+
.then((result) => resolve(result ? action : undefined));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
resolve(action);
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case Action.REMOVING_RECORDS:
|
|
164
|
+
if (this.isAllowed("REMOVE")) {
|
|
165
|
+
const removeConfirmation = this.getMessage("snkDataUnit.removeConfirmation");
|
|
166
|
+
if (removeConfirmation == undefined) {
|
|
167
|
+
resolve(action);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
const removeConfirmationTitle = this.getMessage("snkDataUnit.removeConfirmationTitle");
|
|
171
|
+
ApplicationUtils.confirm(removeConfirmationTitle, removeConfirmation, "delete", DialogType.WARN)
|
|
172
|
+
.then((result) => resolve(result ? action : undefined));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
ApplicationUtils.info(this.getMessage("snkDataUnit.forbiddenRemove"));
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
default:
|
|
180
|
+
resolve(action);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
showSuccessMessage(message) {
|
|
185
|
+
ApplicationUtils.info(message, { iconName: "check" });
|
|
186
|
+
}
|
|
187
|
+
isAllowed(flag) {
|
|
188
|
+
return this._permissions ? this._permissions.isSup || this._permissions[flag] : false;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
192
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
193
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
194
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-data-unit.msg.ts"
|
|
195
|
+
*/
|
|
196
|
+
getMessage(key, params = undefined) {
|
|
197
|
+
if (!params) {
|
|
198
|
+
params = this.getMessageParams();
|
|
199
|
+
}
|
|
200
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
201
|
+
}
|
|
202
|
+
getMessageParams() {
|
|
203
|
+
//TODO: Atualmente ainda não usamos o recurso de multiseleção do dataunit, mas no futuro
|
|
204
|
+
//precisaremos criar um mecanismo para oferecer todos os registros selecionados para a
|
|
205
|
+
//mensagem
|
|
206
|
+
return this.dataState.selectedRecords ? this.dataState.selectedRecords[0] : undefined;
|
|
207
|
+
}
|
|
208
|
+
getMessageOperation() {
|
|
209
|
+
if (this.dataState.copyMode) {
|
|
210
|
+
return OperationMap.CLONE;
|
|
211
|
+
}
|
|
212
|
+
if (this.dataState.insertionMode) {
|
|
213
|
+
return OperationMap.INSERT;
|
|
214
|
+
}
|
|
215
|
+
if (this.dataState.isDirty) {
|
|
216
|
+
return OperationMap.UPDATE;
|
|
217
|
+
}
|
|
218
|
+
return OperationMap.CLEAN;
|
|
219
|
+
}
|
|
220
|
+
async loadDataUnit() {
|
|
221
|
+
if (!this.dataUnit) {
|
|
222
|
+
if (this._application && this.entityName) {
|
|
223
|
+
const cacheName = this.dataUnitName ? this.dataUnitName : this.entityName;
|
|
224
|
+
this.dataUnit = await this._application.getDataUnit(this.entityName, cacheName);
|
|
225
|
+
this.dataUnit.pageSize = this.pageSize;
|
|
226
|
+
this.dataUnit.unsubscribe(this._dataUnitObserver);
|
|
227
|
+
this.dataUnit.addInterceptor(this);
|
|
228
|
+
this.dataUnit.subscribe(this._dataUnitObserver);
|
|
229
|
+
let resolver;
|
|
230
|
+
while (resolver = this._onDataUnitResolve.pop()) {
|
|
231
|
+
resolver(this.dataUnit);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
//---------------------------------------------
|
|
237
|
+
// Lifecycle web component
|
|
238
|
+
//---------------------------------------------
|
|
239
|
+
componentWillLoad() {
|
|
240
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
241
|
+
this._application.getAllAccess().then(access => this._permissions = access);
|
|
242
|
+
}
|
|
243
|
+
componentDidLoad() {
|
|
244
|
+
this.loadDataUnit();
|
|
245
|
+
}
|
|
246
|
+
render() {
|
|
247
|
+
return (h(Host, null));
|
|
248
|
+
}
|
|
249
|
+
static get is() { return "snk-data-unit"; }
|
|
250
|
+
static get encapsulation() { return "scoped"; }
|
|
251
|
+
static get originalStyleUrls() {
|
|
252
|
+
return {
|
|
253
|
+
"$": ["snk-data-unit.css"]
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
static get styleUrls() {
|
|
257
|
+
return {
|
|
258
|
+
"$": ["snk-data-unit.css"]
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
static get properties() {
|
|
262
|
+
return {
|
|
263
|
+
"dataState": {
|
|
264
|
+
"type": "unknown",
|
|
265
|
+
"mutable": true,
|
|
266
|
+
"complexType": {
|
|
267
|
+
"original": "DataState",
|
|
268
|
+
"resolved": "DataState",
|
|
269
|
+
"references": {
|
|
270
|
+
"DataState": {
|
|
271
|
+
"location": "local"
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
"required": false,
|
|
276
|
+
"optional": false,
|
|
277
|
+
"docs": {
|
|
278
|
+
"tags": [],
|
|
279
|
+
"text": "O estato atual dos dados, isto \u00E9 se h\u00E1 altera\u00E7\u00E3o, insers\u00E3o, as linhas selecionadas, etc."
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
"dataUnitName": {
|
|
283
|
+
"type": "string",
|
|
284
|
+
"mutable": false,
|
|
285
|
+
"complexType": {
|
|
286
|
+
"original": "string",
|
|
287
|
+
"resolved": "string",
|
|
288
|
+
"references": {}
|
|
289
|
+
},
|
|
290
|
+
"required": false,
|
|
291
|
+
"optional": false,
|
|
292
|
+
"docs": {
|
|
293
|
+
"tags": [],
|
|
294
|
+
"text": "Este atributo \u00E9 usado para criar o dataUnit uma \u00FAnica vez. Se omitido ser\u00E1 usado o pr\u00F3prio nome\nda entidade."
|
|
295
|
+
},
|
|
296
|
+
"attribute": "data-unit-name",
|
|
297
|
+
"reflect": false
|
|
298
|
+
},
|
|
299
|
+
"entityName": {
|
|
300
|
+
"type": "string",
|
|
301
|
+
"mutable": false,
|
|
302
|
+
"complexType": {
|
|
303
|
+
"original": "string",
|
|
304
|
+
"resolved": "string",
|
|
305
|
+
"references": {}
|
|
306
|
+
},
|
|
307
|
+
"required": false,
|
|
308
|
+
"optional": false,
|
|
309
|
+
"docs": {
|
|
310
|
+
"tags": [],
|
|
311
|
+
"text": "Determina qual a entidade representa os dados em quest\u00E3o."
|
|
312
|
+
},
|
|
313
|
+
"attribute": "entity-name",
|
|
314
|
+
"reflect": false
|
|
315
|
+
},
|
|
316
|
+
"pageSize": {
|
|
317
|
+
"type": "number",
|
|
318
|
+
"mutable": false,
|
|
319
|
+
"complexType": {
|
|
320
|
+
"original": "number",
|
|
321
|
+
"resolved": "number",
|
|
322
|
+
"references": {}
|
|
323
|
+
},
|
|
324
|
+
"required": false,
|
|
325
|
+
"optional": false,
|
|
326
|
+
"docs": {
|
|
327
|
+
"tags": [],
|
|
328
|
+
"text": "Determina quantas linhas s\u00E3o retornadas por p\u00E1gina"
|
|
329
|
+
},
|
|
330
|
+
"attribute": "page-size",
|
|
331
|
+
"reflect": false,
|
|
332
|
+
"defaultValue": "150"
|
|
333
|
+
},
|
|
334
|
+
"dataUnit": {
|
|
335
|
+
"type": "unknown",
|
|
336
|
+
"mutable": true,
|
|
337
|
+
"complexType": {
|
|
338
|
+
"original": "DataUnit",
|
|
339
|
+
"resolved": "DataUnit",
|
|
340
|
+
"references": {
|
|
341
|
+
"DataUnit": {
|
|
342
|
+
"location": "import",
|
|
343
|
+
"path": "@sankhyalabs/core"
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
"required": false,
|
|
348
|
+
"optional": false,
|
|
349
|
+
"docs": {
|
|
350
|
+
"tags": [],
|
|
351
|
+
"text": "Uma vez instanciado, pode-se obter o dataUnit por esta propriedade"
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
"beforeSave": {
|
|
355
|
+
"type": "unknown",
|
|
356
|
+
"mutable": false,
|
|
357
|
+
"complexType": {
|
|
358
|
+
"original": "(dataUnit: DataUnit) => boolean | Promise<boolean>",
|
|
359
|
+
"resolved": "(dataUnit: DataUnit) => boolean | Promise<boolean>",
|
|
360
|
+
"references": {
|
|
361
|
+
"DataUnit": {
|
|
362
|
+
"location": "import",
|
|
363
|
+
"path": "@sankhyalabs/core"
|
|
364
|
+
},
|
|
365
|
+
"Promise": {
|
|
366
|
+
"location": "global"
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
"required": false,
|
|
371
|
+
"optional": false,
|
|
372
|
+
"docs": {
|
|
373
|
+
"tags": [],
|
|
374
|
+
"text": "Executado imediatamente antes da a\u00E7\u00E3o de salvar as altera\u00E7\u00F5es. \u00DAtil no caso de valida\u00E7\u00F5es por exemplo.\nCaso retorne \"false\" (ou a promessa se resolva como false), cancela a a\u00E7\u00E3o."
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
"afterSave": {
|
|
378
|
+
"type": "unknown",
|
|
379
|
+
"mutable": false,
|
|
380
|
+
"complexType": {
|
|
381
|
+
"original": "(dataUnit: DataUnit) => void",
|
|
382
|
+
"resolved": "(dataUnit: DataUnit) => void",
|
|
383
|
+
"references": {
|
|
384
|
+
"DataUnit": {
|
|
385
|
+
"location": "import",
|
|
386
|
+
"path": "@sankhyalabs/core"
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
"required": false,
|
|
391
|
+
"optional": false,
|
|
392
|
+
"docs": {
|
|
393
|
+
"tags": [],
|
|
394
|
+
"text": "Executado ap\u00F3s a a\u00E7\u00E3o de salvar"
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
static get events() {
|
|
400
|
+
return [{
|
|
401
|
+
"method": "dataStateChange",
|
|
402
|
+
"name": "dataStateChange",
|
|
403
|
+
"bubbles": true,
|
|
404
|
+
"cancelable": true,
|
|
405
|
+
"composed": true,
|
|
406
|
+
"docs": {
|
|
407
|
+
"tags": [],
|
|
408
|
+
"text": "Disparado quando o h\u00E1 qualquer mudan\u00E7a de estado no DataUnit"
|
|
409
|
+
},
|
|
410
|
+
"complexType": {
|
|
411
|
+
"original": "DataState",
|
|
412
|
+
"resolved": "DataState",
|
|
413
|
+
"references": {
|
|
414
|
+
"DataState": {
|
|
415
|
+
"location": "local"
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}, {
|
|
420
|
+
"method": "dataUnitReady",
|
|
421
|
+
"name": "dataUnitReady",
|
|
422
|
+
"bubbles": true,
|
|
423
|
+
"cancelable": true,
|
|
424
|
+
"composed": true,
|
|
425
|
+
"docs": {
|
|
426
|
+
"tags": [],
|
|
427
|
+
"text": "Disparado quando o DataUnit est\u00E1 pronto"
|
|
428
|
+
},
|
|
429
|
+
"complexType": {
|
|
430
|
+
"original": "DataUnit",
|
|
431
|
+
"resolved": "DataUnit",
|
|
432
|
+
"references": {
|
|
433
|
+
"DataUnit": {
|
|
434
|
+
"location": "import",
|
|
435
|
+
"path": "@sankhyalabs/core"
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
}, {
|
|
440
|
+
"method": "insertionMode",
|
|
441
|
+
"name": "insertionMode",
|
|
442
|
+
"bubbles": true,
|
|
443
|
+
"cancelable": true,
|
|
444
|
+
"composed": true,
|
|
445
|
+
"docs": {
|
|
446
|
+
"tags": [],
|
|
447
|
+
"text": "Disparado quando um registro \u00E9 adicionado ou copiado"
|
|
448
|
+
},
|
|
449
|
+
"complexType": {
|
|
450
|
+
"original": "void",
|
|
451
|
+
"resolved": "void",
|
|
452
|
+
"references": {}
|
|
453
|
+
}
|
|
454
|
+
}, {
|
|
455
|
+
"method": "cancelEdition",
|
|
456
|
+
"name": "cancelEdition",
|
|
457
|
+
"bubbles": true,
|
|
458
|
+
"cancelable": true,
|
|
459
|
+
"composed": true,
|
|
460
|
+
"docs": {
|
|
461
|
+
"tags": [],
|
|
462
|
+
"text": "Disparado quando se cancela uma insers\u00E3o/c\u00F3pia"
|
|
463
|
+
},
|
|
464
|
+
"complexType": {
|
|
465
|
+
"original": "void",
|
|
466
|
+
"resolved": "void",
|
|
467
|
+
"references": {}
|
|
468
|
+
}
|
|
469
|
+
}];
|
|
470
|
+
}
|
|
471
|
+
static get methods() {
|
|
472
|
+
return {
|
|
473
|
+
"getDataUnit": {
|
|
474
|
+
"complexType": {
|
|
475
|
+
"signature": "() => Promise<DataUnit>",
|
|
476
|
+
"parameters": [],
|
|
477
|
+
"references": {
|
|
478
|
+
"Promise": {
|
|
479
|
+
"location": "global"
|
|
480
|
+
},
|
|
481
|
+
"DataUnit": {
|
|
482
|
+
"location": "import",
|
|
483
|
+
"path": "@sankhyalabs/core"
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
"return": "Promise<DataUnit>"
|
|
487
|
+
},
|
|
488
|
+
"docs": {
|
|
489
|
+
"text": "Pode-se obter o dataUnit atrav\u00E9s desse m\u00E9todo. Outra forma, \u00E9 ouvir o evento de",
|
|
490
|
+
"tags": [{
|
|
491
|
+
"name": "returns",
|
|
492
|
+
"text": "dataUnit"
|
|
493
|
+
}]
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
static get elementRef() { return "element"; }
|
|
499
|
+
static get watchers() {
|
|
500
|
+
return [{
|
|
501
|
+
"propName": "pageSize",
|
|
502
|
+
"methodName": "observePageSize"
|
|
503
|
+
}, {
|
|
504
|
+
"propName": "dataUnitName",
|
|
505
|
+
"methodName": "observeDataUnitName"
|
|
506
|
+
}, {
|
|
507
|
+
"propName": "entityName",
|
|
508
|
+
"methodName": "observeEntityName"
|
|
509
|
+
}, {
|
|
510
|
+
"propName": "dataState",
|
|
511
|
+
"methodName": "observeDataState"
|
|
512
|
+
}, {
|
|
513
|
+
"propName": "dataUnit",
|
|
514
|
+
"methodName": "observeDataUnit"
|
|
515
|
+
}];
|
|
516
|
+
}
|
|
517
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { DataType } from "@sankhyalabs/core";
|
|
2
|
+
import { toString } from "@sankhyalabs/core/dist/dataunit/metadata/DataType";
|
|
3
|
+
import FilterItemType from "../filter-item-type.enum";
|
|
4
|
+
const buildFilter = (item) => {
|
|
5
|
+
switch (item.type) {
|
|
6
|
+
case FilterItemType.DEFAULT_FILTER:
|
|
7
|
+
return buildDefault(item);
|
|
8
|
+
case FilterItemType.BINARY_SELECT:
|
|
9
|
+
return buildBinary(item);
|
|
10
|
+
case FilterItemType.MULTI_SELECT:
|
|
11
|
+
return buildMultSelect(item);
|
|
12
|
+
case FilterItemType.PERIOD:
|
|
13
|
+
return buildPeriod(item);
|
|
14
|
+
case FilterItemType.SEARCH:
|
|
15
|
+
return buildSearch(item);
|
|
16
|
+
case FilterItemType.TEXT:
|
|
17
|
+
return buildText(item);
|
|
18
|
+
case FilterItemType.NUMBER:
|
|
19
|
+
return buildNumber(item);
|
|
20
|
+
case FilterItemType.PERSONALIZED:
|
|
21
|
+
return buildPersonalized(item);
|
|
22
|
+
default:
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
export default buildFilter;
|
|
27
|
+
function buildDefault(item) {
|
|
28
|
+
return { name: item.id, expression: item.props.expression, params: [] };
|
|
29
|
+
}
|
|
30
|
+
function buildBinary(item) {
|
|
31
|
+
const { id, value, props } = item;
|
|
32
|
+
const options = props.options;
|
|
33
|
+
const selectedOption = options.find(opt => opt.name === value);
|
|
34
|
+
return { name: id, expression: selectedOption.expression, params: [] };
|
|
35
|
+
}
|
|
36
|
+
function buildMultSelect(item) {
|
|
37
|
+
const { id, value, props } = item;
|
|
38
|
+
return { name: id, expression: props.expression, params: [{ name: id, dataType: DataType.TEXT, value }] };
|
|
39
|
+
}
|
|
40
|
+
function buildPeriod(item) {
|
|
41
|
+
const { id, value, props } = item;
|
|
42
|
+
let { end, start } = value;
|
|
43
|
+
if (typeof end === "string") {
|
|
44
|
+
end = new Date(end);
|
|
45
|
+
}
|
|
46
|
+
if (typeof start === "string") {
|
|
47
|
+
start = new Date(start);
|
|
48
|
+
}
|
|
49
|
+
const params = [];
|
|
50
|
+
let expression;
|
|
51
|
+
if (end && start) {
|
|
52
|
+
expression = props.expression.fullfill;
|
|
53
|
+
params.push({ name: `${id}.START`, dataType: DataType.DATE, value: toString(DataType.DATE, start) }, { name: `${id}.END`, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if (start) {
|
|
57
|
+
expression = props.expression.onlystart;
|
|
58
|
+
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, start) });
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
expression = props.expression.onlyend;
|
|
62
|
+
params.push({ name: id, dataType: DataType.DATE, value: toString(DataType.DATE, end) });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return { name: id, expression, params };
|
|
66
|
+
}
|
|
67
|
+
function buildSearch(item) {
|
|
68
|
+
const { id, value, props } = item;
|
|
69
|
+
const expression = props.expression;
|
|
70
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value.value) }] };
|
|
71
|
+
}
|
|
72
|
+
function buildText(item) {
|
|
73
|
+
const { id, value, props } = item;
|
|
74
|
+
const expression = props.expression;
|
|
75
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.TEXT, value: toString(DataType.TEXT, value) }] };
|
|
76
|
+
}
|
|
77
|
+
function buildNumber(item) {
|
|
78
|
+
const { id, value, props } = item;
|
|
79
|
+
const expression = props.expression;
|
|
80
|
+
return { name: id, expression, params: [{ name: id, dataType: DataType.NUMBER, value: toString(DataType.NUMBER, value) }] };
|
|
81
|
+
}
|
|
82
|
+
function buildPersonalized(item) {
|
|
83
|
+
var _a;
|
|
84
|
+
const { id, value, props } = item;
|
|
85
|
+
const expression = props.expression;
|
|
86
|
+
return {
|
|
87
|
+
name: id, expression, params: (((_a = props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || []).map((param, index) => {
|
|
88
|
+
const valuesArray = Array.from(value);
|
|
89
|
+
const dataType = param.dataType;
|
|
90
|
+
let paramValue = (index >= 0 && index < valuesArray.length ? valuesArray[index] : null);
|
|
91
|
+
if (paramValue != undefined && typeof paramValue === "object" && "value" in paramValue) {
|
|
92
|
+
paramValue = paramValue["value"];
|
|
93
|
+
}
|
|
94
|
+
if (paramValue == undefined && dataType === DataType.BOOLEAN) {
|
|
95
|
+
paramValue = false;
|
|
96
|
+
}
|
|
97
|
+
return { name: param.name, dataType, value: typeof paramValue === "string" ? paramValue : toString(dataType, paramValue) };
|
|
98
|
+
})
|
|
99
|
+
};
|
|
100
|
+
}
|