@sankhyalabs/sankhyablocks 1.4.0-beta.1 → 1.4.0-beta.11
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-7717f1e4.js → SnkMessageBuilder-6c2f7bcd.js} +107 -131
- 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-e2e1bc5b.js → filter-item-type.enum-3daf58d3.js} +2 -0
- package/dist/cjs/form-config-fetcher-2de7c16a.js +6895 -0
- package/dist/cjs/{index-b0b676c5.js → index-20e8b68a.js} +165 -1473
- package/dist/cjs/loader.cjs.js +2 -18
- package/dist/cjs/sankhyablocks.cjs.js +4 -116
- package/dist/cjs/snk-application.cjs.entry.js +330 -7196
- 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 +21 -13
- package/dist/cjs/snk-data-unit.cjs.entry.js +24 -32
- package/dist/cjs/snk-field-config_2.cjs.entry.js +135 -0
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +5 -2
- package/dist/cjs/snk-filter-detail.cjs.entry.js +62 -5
- package/dist/cjs/snk-filter-multi-select.cjs.entry.js +6 -3
- package/dist/cjs/snk-filter-number.cjs.entry.js +6 -3
- package/dist/cjs/snk-filter-period.cjs.entry.js +5 -2
- package/dist/cjs/snk-filter-personalized.cjs.entry.js +89 -0
- package/dist/cjs/snk-filter-search.cjs.entry.js +7 -13
- package/dist/cjs/snk-filter-text.cjs.entry.js +2 -2
- package/dist/cjs/snk-form-config.cjs.entry.js +957 -0
- package/dist/cjs/snk-form.cjs.entry.js +41 -28
- package/dist/cjs/snk-pesquisa.cjs.entry.js +5 -5
- package/dist/cjs/snk-tab-config.cjs.entry.js +321 -0
- package/dist/cjs/{taskbar-elements-283c737e.js → taskbar-elements-9a4b1e19.js} +10 -6
- package/dist/cjs/teste-pesquisa.cjs.entry.js +5 -5
- package/dist/collection/collection-manifest.json +29 -1
- package/dist/collection/components/snk-application/errorhandler/snk-error-handler.js +1 -1
- package/dist/collection/components/snk-application/snk-application.js +236 -37
- 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.js +46 -17
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +1 -28
- 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 +23 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.js +24 -1
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-number.js +24 -1
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-period.js +23 -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 +22 -38
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-text.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-item/filter-item-type.enum.js +2 -0
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +80 -20
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +65 -31
- package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +85 -19
- 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 +39 -4
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +250 -141
- package/dist/collection/components/snk-form/snk-form.css +4 -0
- package/dist/collection/components/snk-form/snk-form.js +108 -30
- 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.js +94 -26
- package/dist/collection/components/snk-taskbar/elements/taskbar-elements.js +9 -5
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +35 -3
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +3 -3
- package/dist/collection/lib/http/data-fetcher/fetchers/dataunit-fetcher.js +35 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/filter-bar-config-fetcher.js +18 -10
- package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +106 -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/index.js +1 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +11 -2
- 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-filter-bar.msg.js +14 -2
- package/dist/collection/lib/message/resources/snk-form.msg.js +59 -2
- package/dist/collection/lib/message/resources/snk-taskbar.msg.js +1 -1
- package/dist/collection/lib/utils/CrudUtils.js +73 -0
- package/dist/collection/lib/utils/constants.js +72 -0
- package/dist/components/SnkMessageBuilder.js +108 -131
- package/dist/components/_commonjsHelpers.js +17 -0
- package/dist/components/constants.js +74 -0
- package/dist/components/filter-item-type.enum.js +2 -0
- package/dist/{sankhyablocks/snk-application.entry.js → components/form-config-fetcher.js} +88 -1347
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.js +8 -4
- package/dist/components/snk-application2.js +313 -7173
- 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.js +76 -26
- package/dist/components/snk-data-unit.js +4 -13
- 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-bar2.js +354 -148
- package/dist/components/snk-filter-binary-select.js +5 -1
- package/dist/components/snk-filter-detail2.js +62 -5
- package/dist/components/snk-filter-item2.js +52 -33
- package/dist/components/snk-filter-list2.js +60 -22
- 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.js +6 -2
- package/dist/components/snk-filter-number.js +6 -2
- package/dist/components/snk-filter-period.js +5 -1
- 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.js +5 -12
- package/dist/components/snk-filter-text.js +1 -1
- 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-form2.js +79 -29
- package/dist/components/snk-grid2.js +57 -32
- package/dist/components/snk-pesquisa2.js +1 -1
- 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-taskbar2.js +28 -10
- package/dist/components/teste-pesquisa.js +1 -1
- package/dist/{sankhyablocks/SnkMessageBuilder-a7da466b.js → esm/SnkMessageBuilder-5792c260.js} +108 -131
- 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-61fbf80a.js → filter-item-type.enum-a79b2fa8.js} +2 -0
- package/dist/esm/form-config-fetcher-96c6c2dc.js +6889 -0
- package/dist/{sankhyablocks/index-2b4d2d14.js → esm/index-e4121713.js} +165 -1466
- package/dist/esm/loader.js +2 -18
- package/dist/esm/sankhyablocks.js +4 -116
- package/dist/esm/snk-application.entry.js +308 -7174
- 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 +20 -12
- package/dist/esm/snk-data-unit.entry.js +5 -13
- package/dist/esm/snk-field-config_2.entry.js +130 -0
- package/dist/esm/snk-filter-binary-select.entry.js +5 -2
- package/dist/esm/snk-filter-detail.entry.js +62 -5
- package/dist/esm/snk-filter-multi-select.entry.js +6 -3
- package/dist/esm/snk-filter-number.entry.js +6 -3
- package/dist/esm/snk-filter-period.entry.js +5 -2
- package/dist/esm/snk-filter-personalized.entry.js +85 -0
- package/dist/esm/snk-filter-search.entry.js +6 -12
- package/dist/esm/snk-filter-text.entry.js +2 -2
- package/dist/esm/snk-form-config.entry.js +953 -0
- package/dist/esm/snk-form.entry.js +40 -27
- package/dist/esm/snk-pesquisa.entry.js +2 -2
- package/dist/esm/snk-tab-config.entry.js +317 -0
- package/dist/{sankhyablocks/taskbar-elements-35d64ff9.js → esm/taskbar-elements-e2ed0536.js} +10 -6
- package/dist/esm/teste-pesquisa.entry.js +2 -2
- package/dist/sankhyablocks/index.esm.js +0 -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-21c8929b.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-44ce5b90.entry.js +1 -0
- package/dist/sankhyablocks/p-521c96f0.entry.js +1 -0
- package/dist/sankhyablocks/p-60eef7cd.entry.js +1 -0
- package/dist/sankhyablocks/p-6988f4a6.entry.js +1 -0
- package/dist/sankhyablocks/p-6a4162bd.entry.js +1 -0
- package/dist/sankhyablocks/p-776ff4d1.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/p-f37cdeb5.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -129
- package/dist/types/components/snk-application/snk-application.d.ts +38 -16
- 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 +1 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-multi-select.d.ts +2 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-number.d.ts +2 -0
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-period.d.ts +1 -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 +4 -5
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-text.d.ts +1 -0
- package/dist/types/components/snk-filter-bar/filter-item/filter-item-type.enum.d.ts +3 -1
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +7 -1
- 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 +8 -3
- 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 +31 -17
- 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 +6 -5
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +11 -3
- package/dist/types/components.d.ts +424 -24
- package/dist/types/lib/http/data-fetcher/fetchers/dataunit-fetcher.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +21 -3
- 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/index.d.ts +1 -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-form.msg.d.ts +5 -2
- 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/package.json +4 -3
- package/react/components.d.ts +25 -0
- package/react/components.js +25 -0
- package/react/components.js.map +1 -1
- package/dist/cjs/app-globals-3a1e7e63.js +0 -5
- package/dist/cjs/css-shim-b8158822.js +0 -6
- package/dist/cjs/dom-36862b77.js +0 -75
- package/dist/cjs/index-02201bc9.js +0 -2397
- package/dist/cjs/shadow-css-346c0795.js +0 -389
- package/dist/cjs/snk-filter-bar.cjs.entry.js +0 -278
- package/dist/cjs/snk-filter-item.cjs.entry.js +0 -154
- package/dist/cjs/snk-filter-list.cjs.entry.js +0 -91
- package/dist/cjs/snk-grid.cjs.entry.js +0 -79
- package/dist/cjs/snk-taskbar.cjs.entry.js +0 -160
- package/dist/components/index2.js +0 -2384
- package/dist/esm/SnkMessageBuilder-a7da466b.js +0 -303
- package/dist/esm/app-globals-0f993ce5.js +0 -3
- package/dist/esm/css-shim-b3f2ee8d.js +0 -4
- package/dist/esm/dom-665d6011.js +0 -73
- package/dist/esm/index-2b4d2d14.js +0 -3262
- package/dist/esm/index-f1d3e4da.js +0 -2384
- package/dist/esm/shadow-css-b18e99d7.js +0 -387
- package/dist/esm/snk-filter-bar.entry.js +0 -274
- package/dist/esm/snk-filter-item.entry.js +0 -150
- package/dist/esm/snk-filter-list.entry.js +0 -87
- package/dist/esm/snk-grid.entry.js +0 -75
- package/dist/esm/snk-taskbar.entry.js +0 -156
- package/dist/esm/taskbar-elements-35d64ff9.js +0 -90
- package/dist/sankhyablocks/app-globals-0f993ce5.js +0 -3
- package/dist/sankhyablocks/css-shim-b3f2ee8d.js +0 -4
- package/dist/sankhyablocks/dom-665d6011.js +0 -73
- package/dist/sankhyablocks/filter-item-type.enum-61fbf80a.js +0 -12
- package/dist/sankhyablocks/index-f1d3e4da.js +0 -2384
- package/dist/sankhyablocks/shadow-css-b18e99d7.js +0 -387
- package/dist/sankhyablocks/snk-crud.entry.js +0 -66
- package/dist/sankhyablocks/snk-data-unit.entry.js +0 -276
- package/dist/sankhyablocks/snk-filter-bar.entry.js +0 -274
- package/dist/sankhyablocks/snk-filter-binary-select.entry.js +0 -43
- package/dist/sankhyablocks/snk-filter-detail.entry.js +0 -45
- package/dist/sankhyablocks/snk-filter-item.entry.js +0 -150
- package/dist/sankhyablocks/snk-filter-list.entry.js +0 -87
- package/dist/sankhyablocks/snk-filter-multi-select.entry.js +0 -19
- package/dist/sankhyablocks/snk-filter-number.entry.js +0 -20
- package/dist/sankhyablocks/snk-filter-period.entry.js +0 -33
- package/dist/sankhyablocks/snk-filter-search.entry.js +0 -40
- package/dist/sankhyablocks/snk-filter-text.entry.js +0 -18
- package/dist/sankhyablocks/snk-form.entry.js +0 -129
- package/dist/sankhyablocks/snk-grid.entry.js +0 -75
- package/dist/sankhyablocks/snk-pesquisa.entry.js +0 -311
- package/dist/sankhyablocks/snk-taskbar.entry.js +0 -156
- package/dist/sankhyablocks/taskbar-processor-aa6772c9.js +0 -45
- package/dist/sankhyablocks/teste-pesquisa.entry.js +0 -33
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { a as draggable_bundle, d as defineCustomElement$1 } from './snk-tab-config2.js';
|
|
3
|
+
import { ObjectUtils, ArrayUtils, ApplicationContext } from '@sankhyalabs/core';
|
|
4
|
+
import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
5
|
+
import { C as CONFIG_EVENTS, b as TAB_NAMES, A as ACTION_CONFIG } from './constants.js';
|
|
6
|
+
import { a as UserConfigType } from './form-config-fetcher.js';
|
|
7
|
+
import { d as defineCustomElement$3 } from './snk-config-options2.js';
|
|
8
|
+
import { d as defineCustomElement$2 } from './snk-field-config2.js';
|
|
9
|
+
|
|
10
|
+
const snkFormConfigCss = ".sc-snk-form-config-h{--snk-form-config__title--font-pattern:var(--font-pattern, \"Roboto\");--snk-form-config__title--weight--large:var(--text-weight--large, 600);display:flex;flex-direction:column;position:absolute;top:0;left:0;width:100%;height:100%;z-index:var(--more-visible, 2);background-color:var(--background--xlight)}.form-config__title.sc-snk-form-config{display:flex;margin:0;line-height:1.3;font-family:var(--snk-form-config__title--font-pattern);font-weight:var(--snk-form-config__title--weight--large)}.form-config__header-container.sc-snk-form-config{display:flex}.form-config__field-container.sc-snk-form-config{width:32%;padding:6px}.form-config__hide-content.sc-snk-form-config{display:none}ez-icon.sc-snk-form-config .left-icon.sc-snk-form-config{--ez-icon--color:var(--text--disable)}.ez-box__label-counter.sc-snk-form-config{font-weight:var(--text-weight--extra-small);margin-top:-7px}.form-config__btn-options.sc-snk-form-config{--ez-button--min-width:300px;--ez-button--background-color:#FFFFFF}[data-draggable-parent].sc-snk-form-config{position:relative}.form-config__field-config--selected.sc-snk-form-config{position:static}.form-config__field-config--dragged.sc-snk-form-config .draggable-mirror.sc-snk-form-config{z-index:var(--more-visible, 2)}.form-config__config-options.sc-snk-form-config{position:relative;margin-top:-3px;min-width:100%;z-index:1}.form-config__tab-container.sc-snk-form-config,.form-config__fields-available.sc-snk-form-config{position:relative;height:100%;max-height:calc(100vh - 92px)}.form-config__tab-container.sc-snk-form-config .ez-box__container.sc-snk-form-config,.form-config__fields-available.sc-snk-form-config .ez-box__container.sc-snk-form-config{align-content:flex-start;height:100%}.form-config__fields-available.sc-snk-form-config [data-draggable-parent].sc-snk-form-config{align-content:flex-start;overflow-y:auto;height:100%;max-height:calc(100% - 122px)}.form-config__tab-content.sc-snk-form-config{align-content:flex-start;overflow-y:auto;height:auto;max-height:calc(100% - 128px)}[data-draggable-element].sc-snk-form-config{cursor:grab}.form-config__actions-button.sc-snk-form-config{--ez-actions-button__btn-action--min-width:250px}.form-config__add-group.sc-snk-form-config{position:relative;min-height:120px;margin-bottom:10px}.form-config__add-group-container.sc-snk-form-config{position:absolute;display:flex;flex-wrap:wrap;width:100%;box-sizing:border-box;border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #d2dce9);padding:var(--space--small, 6px)}.form-config__add-group-content.sc-snk-form-config{width:100%;display:flex;flex-wrap:wrap;justify-content:center;align-items:center;box-sizing:border-box;border:2px dashed var(--color-strokes, #DCE0E8);border-radius:var(--border--radius-small, 6px)}.form-config__add-group-label.sc-snk-form-config{display:flex;justify-content:center;box-sizing:border-box;padding:var(--space--large, 24px)}.form-config__btn-add-group.sc-snk-form-config{position:relative;padding:var(--space--large, 24px) var(--space--medium, 12px) 0}.form-config__btn-add-group-container.sc-snk-form-config{padding:var(--space--medium, 12px);border-radius:var(--border--radius-medium, 12px);border:2px solid var(--color-strokes, #DCE0E8);background-color:var(--background--body, #fafcff)}.form-config__left-icon--eye-off.sc-snk-form-config{padding-top:var(--space--medium, 8px)}ez-collapsible-box.draggable-mirror.sc-snk-form-config{display:table;background-color:#FFFFFF}ez-collapsible-box.sc-snk-form-config{margin-bottom:10px}@media screen and (min-width: 480px){.form-config__field-config--selected.sc-snk-form-config .ez-flex.form-config__config-options.sc-snk-form-config{min-width:calc(300% + 12px)}.form-config__field-config--selected.sc-snk-form-config:nth-child(3n+2) .ez-flex.form-config__config-options.sc-snk-form-config{transform:translate(calc(100% / 3 * -1))}.form-config__field-config--selected.sc-snk-form-config:nth-child(3n+3) .ez-flex.form-config__config-options.sc-snk-form-config{transform:translate(calc(100% / 3 * -2))}}";
|
|
11
|
+
|
|
12
|
+
const CONTAINER_ID = {
|
|
13
|
+
collapsibleBox: "EZ-COLLAPSIBLE-BOX",
|
|
14
|
+
withoutGroup: "fieldsWithoutGroupContainer",
|
|
15
|
+
fieldsAvailable: "fieldsAvailableContainer",
|
|
16
|
+
addNewGroup: "addNewGroupContainer"
|
|
17
|
+
};
|
|
18
|
+
const SnkFormConfig = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
this.__registerHost();
|
|
22
|
+
this.configChange = createEvent(this, "configChange", 7);
|
|
23
|
+
this._listEnabledFields = [];
|
|
24
|
+
this._renderTimer = 500;
|
|
25
|
+
this._sortableTimer = 100;
|
|
26
|
+
this._tabSelected = 1;
|
|
27
|
+
this._labelNewGroup = "Novo grupo";
|
|
28
|
+
this._mouseOnFieldConfig = false;
|
|
29
|
+
this._mouseOnConfigOptions = false;
|
|
30
|
+
this._editingTitleGroup = false;
|
|
31
|
+
this._newGroupBoxes = [];
|
|
32
|
+
this._currentGroupBoxes = [];
|
|
33
|
+
this._formFieldsStyle = "ez-col ez-col--sd-12 ez-col--tb-4 ez-padding-right--small ez-padding-bottom--medium sc-snk-form-config";
|
|
34
|
+
this._fieldsAvailableStyle = "ez-col ez-col--sd-12 ez-col--tb-12 ez-margin-bottom--medium ez-margin-right--medium sc-snk-form-config";
|
|
35
|
+
this._fieldFloatingStyle = "form-config__field-config--dragged";
|
|
36
|
+
this._formConfigOptions = [];
|
|
37
|
+
this._formConfig = {};
|
|
38
|
+
this._formConfigChanged = false;
|
|
39
|
+
this._optionFormConfigChanged = false;
|
|
40
|
+
this._tempGroups = [];
|
|
41
|
+
/**
|
|
42
|
+
* Campos de configuração de formulário.
|
|
43
|
+
*/
|
|
44
|
+
this.formConfig = {};
|
|
45
|
+
}
|
|
46
|
+
observeFormConfig() {
|
|
47
|
+
this.loadConfig(this._sortableTimer);
|
|
48
|
+
}
|
|
49
|
+
loadFields(updateTimer = 0) {
|
|
50
|
+
this._layoutFormConfig = [];
|
|
51
|
+
// this._layoutFormConfig ? this._layoutFormConfig.length = 0 : this._layoutFormConfig = [];
|
|
52
|
+
/*
|
|
53
|
+
TODO: Validar a possibilidade de fazer diretamente this._layoutFormConfig.length = 0
|
|
54
|
+
sem a necessidade do ternario abaixo, para isso definir um default para o this._layoutFormConfig
|
|
55
|
+
na declaração da variavel
|
|
56
|
+
- Impactou:
|
|
57
|
+
- Inserir um field, alterar a tab de lugar e inserir um novo campo
|
|
58
|
+
- Ocultar/Deletar sequencialmente mais de uma aba
|
|
59
|
+
*/
|
|
60
|
+
if (updateTimer > 0) {
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
this.buildFields();
|
|
63
|
+
}, updateTimer);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.buildFields();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
buildFields() {
|
|
70
|
+
this.buildFormConfig();
|
|
71
|
+
this.buildAvailableFields();
|
|
72
|
+
}
|
|
73
|
+
loadFormConfig(updateTimer) {
|
|
74
|
+
var _a;
|
|
75
|
+
this._formConfig = ObjectUtils.copy(this.formConfig);
|
|
76
|
+
this.loadFields(updateTimer);
|
|
77
|
+
this.controlFieldConfig();
|
|
78
|
+
if (((_a = this._filterFieldsAvailable) === null || _a === void 0 ? void 0 : _a.value) != undefined) {
|
|
79
|
+
this._filterFieldsAvailable.value = "";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
cancelChangeConfig() {
|
|
83
|
+
if (this._formConfigChanged === true) {
|
|
84
|
+
this.openConfirmDialog(this.getMessage("snkFormConfig.confirm.cancel")).then((canCancel) => {
|
|
85
|
+
if (canCancel) {
|
|
86
|
+
this._formConfigChanged = false;
|
|
87
|
+
this.resetChangeConfig();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
this.resetChangeConfig();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
cancelChangeOptionConfig() {
|
|
96
|
+
if (this._optionFormConfigChanged === true) {
|
|
97
|
+
this.openConfirmDialog(this.getMessage("snkFormConfig.confirm.cancel")).then((canCancel) => {
|
|
98
|
+
if (canCancel) {
|
|
99
|
+
this._optionFormConfigChanged = false;
|
|
100
|
+
this.resetChangeOptionConfig();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this.resetChangeOptionConfig();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
resetChangeConfig() {
|
|
109
|
+
this.loadFormConfig(this._sortableTimer);
|
|
110
|
+
this.clearTempGroups();
|
|
111
|
+
}
|
|
112
|
+
resetChangeOptionConfig() {
|
|
113
|
+
this._formConfigChanged = false;
|
|
114
|
+
this.loadConfig(this._sortableTimer);
|
|
115
|
+
this.clearTempGroups();
|
|
116
|
+
}
|
|
117
|
+
getTabsToSave() {
|
|
118
|
+
return this._layoutFormConfig
|
|
119
|
+
.map((layoutConfig, index) => {
|
|
120
|
+
return {
|
|
121
|
+
label: layoutConfig.tab,
|
|
122
|
+
order: index,
|
|
123
|
+
visible: layoutConfig.visible
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
getFieldsToSave() {
|
|
128
|
+
const fields = [];
|
|
129
|
+
const snkFieldConfigs = this._formContainer.querySelectorAll('snk-field-config');
|
|
130
|
+
snkFieldConfigs.forEach((snkField) => {
|
|
131
|
+
const fieldConfig = snkField.fieldConfig;
|
|
132
|
+
if (fieldConfig) {
|
|
133
|
+
const fieldToSave = {
|
|
134
|
+
cleanOnCopy: fieldConfig.cleanOnCopy || false,
|
|
135
|
+
group: fieldConfig.group,
|
|
136
|
+
label: fieldConfig.label,
|
|
137
|
+
name: fieldConfig.name,
|
|
138
|
+
required: fieldConfig.required,
|
|
139
|
+
readOnly: fieldConfig.readOnly,
|
|
140
|
+
tab: fieldConfig.tab,
|
|
141
|
+
defaultValue: fieldConfig.defaultValue
|
|
142
|
+
};
|
|
143
|
+
fields.push(fieldToSave);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
return fields;
|
|
147
|
+
}
|
|
148
|
+
isDefaultConfiguration() {
|
|
149
|
+
var _a;
|
|
150
|
+
const optionSelected = (_a = this._optionFormConfigSelected) === null || _a === void 0 ? void 0 : _a.origin;
|
|
151
|
+
return optionSelected === UserConfigType.DEFAULT
|
|
152
|
+
&& this._optionFormConfigChanged === true
|
|
153
|
+
&& this._formConfigChanged === false;
|
|
154
|
+
}
|
|
155
|
+
saveConfig() {
|
|
156
|
+
var _a;
|
|
157
|
+
if (((_a = this._tempGroups) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
158
|
+
ApplicationUtils.alert(this.getMessage("snkFormConfig.confirm.title"), this.getMessage("snkFormConfig.confirm.group"));
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const isDefault = this.isDefaultConfiguration();
|
|
162
|
+
let formConfig = {};
|
|
163
|
+
if (isDefault) {
|
|
164
|
+
formConfig = ObjectUtils.copy(this.formConfig);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
formConfig = ObjectUtils.copy(this._formConfig);
|
|
168
|
+
}
|
|
169
|
+
if (isDefault === false) {
|
|
170
|
+
const tabs = this.getTabsToSave();
|
|
171
|
+
if ((tabs === null || tabs === void 0 ? void 0 : tabs.length) > 0) {
|
|
172
|
+
formConfig.tabs = tabs;
|
|
173
|
+
}
|
|
174
|
+
const fields = this.getFieldsToSave();
|
|
175
|
+
if ((fields === null || fields === void 0 ? void 0 : fields.length) > 0) {
|
|
176
|
+
formConfig.fields = fields;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
formConfig.defaultConfiguration = isDefault;
|
|
180
|
+
this.configChange.emit(formConfig);
|
|
181
|
+
this._formConfigChanged = false;
|
|
182
|
+
this._optionFormConfigChanged = false;
|
|
183
|
+
}
|
|
184
|
+
applyOptionConfig() {
|
|
185
|
+
if (this._optionFormConfigChanged === true && this._optionFormConfigSelected != undefined) {
|
|
186
|
+
const name = this._optionFormConfigSelected.name || "configuração selecionada";
|
|
187
|
+
const origin = this._optionFormConfigSelected.origin === UserConfigType.DEFAULT ? "pessoal" : "padrão";
|
|
188
|
+
const msg = this.getMessage("snkFormConfig.confirm.apply").replace('{0}', name).replace('{1}', origin);
|
|
189
|
+
this.openConfirmDialog(msg).then((canCancel) => {
|
|
190
|
+
if (canCancel) {
|
|
191
|
+
this.saveConfig();
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
this.saveConfig();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
controlFieldConfig(fieldConfig = undefined) {
|
|
200
|
+
var _a;
|
|
201
|
+
if (fieldConfig == undefined) {
|
|
202
|
+
this._fieldConfigSelected = undefined;
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (((_a = this._fieldConfigSelected) === null || _a === void 0 ? void 0 : _a.name) === (fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.name)) {
|
|
206
|
+
this._fieldConfigSelected = undefined;
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
this._fieldConfigSelected = fieldConfig;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
getFieldConfigStyle(fieldConfig) {
|
|
213
|
+
var _a;
|
|
214
|
+
return this._formFieldsStyle +
|
|
215
|
+
(((_a = this._fieldConfigSelected) === null || _a === void 0 ? void 0 : _a.name) === fieldConfig.name ? " form-config__field-config--selected" : "");
|
|
216
|
+
}
|
|
217
|
+
getFieldsByGroup(group) {
|
|
218
|
+
var _a;
|
|
219
|
+
return ((_a = group.fields) === null || _a === void 0 ? void 0 : _a.length) ? group.fields.map((field) => {
|
|
220
|
+
var _a, _b;
|
|
221
|
+
return h("div", { key: field.name, class: this.getFieldConfigStyle(field), "data-draggable-element": "field", onMouseDown: (evt) => this.controlMoveField(evt) }, h("snk-field-config", { onEzClickIcon: (evt) => { this.handleFieldConfigChange(evt); }, modeInsertion: false, fieldConfig: field, isConfigActive: ((_a = this._fieldConfigSelected) === null || _a === void 0 ? void 0 : _a.name) === field.name }), ((_b = this._fieldConfigSelected) === null || _b === void 0 ? void 0 : _b.name) === field.name &&
|
|
222
|
+
h("div", { class: "ez-flex form-config__config-options" }, h("snk-config-options", { idConfig: field.name, dataUnit: this.dataUnit, fieldConfig: this._fieldConfigSelected, onConfigOptionsChanged: (ev) => this.handleconfigOptionsChanged(ev.detail) })));
|
|
223
|
+
}) : h("div", { class: "form-config__add-group-container" }, h("div", { class: "form-config__add-group-content" }, h("div", { class: "form-config__add-group-label" }, h("label", { class: "ez-text ez-text--center ez-text--medium ez-text--primary ez-text--bold" }, this.getMessage("snkFormConfig.form.labelDropField")))));
|
|
224
|
+
}
|
|
225
|
+
handleconfigOptionsChanged(fieldEdited) {
|
|
226
|
+
var _a;
|
|
227
|
+
(_a = this._formConfig.fields) === null || _a === void 0 ? void 0 : _a.forEach(field => {
|
|
228
|
+
});
|
|
229
|
+
this._formConfigChanged = true;
|
|
230
|
+
}
|
|
231
|
+
closeFormConfig() {
|
|
232
|
+
if (this._formConfigChanged === true || this._optionFormConfigChanged === true) {
|
|
233
|
+
this.openConfirmDialog(this.getMessage("snkFormConfig.confirm.exit")).then((canClose) => {
|
|
234
|
+
if (canClose) {
|
|
235
|
+
this._formConfigChanged = false;
|
|
236
|
+
this.setShowFormConfig(false);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
this.setShowFormConfig(false);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
openConfirmDialog(msg = "", title = this.getMessage("snkFormConfig.confirm.title")) {
|
|
245
|
+
return ApplicationUtils.confirm(title, msg);
|
|
246
|
+
}
|
|
247
|
+
controlMoveField(evt) {
|
|
248
|
+
const element = evt === null || evt === void 0 ? void 0 : evt.target;
|
|
249
|
+
if ((element === null || element === void 0 ? void 0 : element.closest('[data-draggable-element="field"]')) != undefined) {
|
|
250
|
+
this._mouseOnFieldConfig = true;
|
|
251
|
+
if ((element === null || element === void 0 ? void 0 : element.closest(".form-config__config-options")) != undefined || (element === null || element === void 0 ? void 0 : element.closest('.field-config__options')) != undefined) {
|
|
252
|
+
this._mouseOnConfigOptions = true;
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
const iconList = ['minus', 'settings-inverted', 'chevron-up'];
|
|
256
|
+
const iconName = element === null || element === void 0 ? void 0 : element.iconName;
|
|
257
|
+
if (iconList.includes(iconName) === false) {
|
|
258
|
+
this.controlFieldConfig();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
controlStartDraggingField(evt) {
|
|
264
|
+
var _a, _b, _c;
|
|
265
|
+
if (this._mouseOnConfigOptions) {
|
|
266
|
+
evt === null || evt === void 0 ? void 0 : evt.cancel();
|
|
267
|
+
this._mouseOnConfigOptions = false;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
const sourceContainer = (_c = (_b = (_a = evt === null || evt === void 0 ? void 0 : evt.data) === null || _a === void 0 ? void 0 : _a.dragEvent) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.sourceContainer;
|
|
271
|
+
if (sourceContainer != undefined) {
|
|
272
|
+
sourceContainer.classList.add(this._fieldFloatingStyle);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
controlSortedDraggingField(evt) {
|
|
277
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
278
|
+
const oldContainer = (_a = evt === null || evt === void 0 ? void 0 : evt.data) === null || _a === void 0 ? void 0 : _a.oldContainer;
|
|
279
|
+
const newContainer = (_b = evt === null || evt === void 0 ? void 0 : evt.data) === null || _b === void 0 ? void 0 : _b.newContainer;
|
|
280
|
+
const draggingElement = (_e = (_d = (_c = evt === null || evt === void 0 ? void 0 : evt.data) === null || _c === void 0 ? void 0 : _c.dragEvent) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.source;
|
|
281
|
+
const originalElement = (_h = (_g = (_f = evt === null || evt === void 0 ? void 0 : evt.data) === null || _f === void 0 ? void 0 : _f.dragEvent) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.originalSource;
|
|
282
|
+
if (oldContainer != undefined && newContainer != undefined && draggingElement != undefined && originalElement != undefined) {
|
|
283
|
+
if ((newContainer.tagName === CONTAINER_ID.collapsibleBox
|
|
284
|
+
|| newContainer.id === CONTAINER_ID.withoutGroup)
|
|
285
|
+
&& oldContainer.id === CONTAINER_ID.fieldsAvailable) {
|
|
286
|
+
draggingElement.className = this._formFieldsStyle;
|
|
287
|
+
draggingElement.querySelector('snk-field-config').modeInsertion = false;
|
|
288
|
+
originalElement.className = this._formFieldsStyle;
|
|
289
|
+
originalElement.querySelector('snk-field-config').modeInsertion = false;
|
|
290
|
+
}
|
|
291
|
+
else if ((oldContainer.tagName === CONTAINER_ID.collapsibleBox
|
|
292
|
+
|| oldContainer.id === CONTAINER_ID.withoutGroup)
|
|
293
|
+
&& newContainer.id === CONTAINER_ID.fieldsAvailable) {
|
|
294
|
+
draggingElement.className = this._fieldsAvailableStyle;
|
|
295
|
+
draggingElement.querySelector('snk-field-config').modeInsertion = true;
|
|
296
|
+
originalElement.className = this._fieldsAvailableStyle;
|
|
297
|
+
originalElement.querySelector('snk-field-config').modeInsertion = true;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
isCancelDragAvailableField(newContainer, oldContainer, evt) {
|
|
302
|
+
var _a, _b;
|
|
303
|
+
if (newContainer == undefined || oldContainer == undefined || evt == undefined) {
|
|
304
|
+
return false;
|
|
305
|
+
}
|
|
306
|
+
if (((_a = evt.data) === null || _a === void 0 ? void 0 : _a.newIndex) !== ((_b = evt.data) === null || _b === void 0 ? void 0 : _b.oldIndex)
|
|
307
|
+
&& newContainer.id === CONTAINER_ID.fieldsAvailable
|
|
308
|
+
&& oldContainer.id === newContainer.id) {
|
|
309
|
+
evt.cancel();
|
|
310
|
+
this._fieldsAvailable = [];
|
|
311
|
+
setTimeout(() => {
|
|
312
|
+
this.buildAvailableFields();
|
|
313
|
+
}, this._sortableTimer);
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
isRemoveField(newContainer, oldContainer, fieldConfig) {
|
|
319
|
+
if (newContainer == undefined || oldContainer == undefined || fieldConfig == undefined) {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
if ((oldContainer.tagName === CONTAINER_ID.collapsibleBox
|
|
323
|
+
|| oldContainer.id === CONTAINER_ID.withoutGroup)
|
|
324
|
+
&& newContainer.id === CONTAINER_ID.fieldsAvailable) {
|
|
325
|
+
const eventDetail = {
|
|
326
|
+
detail: {
|
|
327
|
+
field: fieldConfig,
|
|
328
|
+
type: ACTION_CONFIG.remove
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
setTimeout(() => {
|
|
332
|
+
this.handleFieldConfigChange(eventDetail, this._sortableTimer);
|
|
333
|
+
}, this._renderTimer);
|
|
334
|
+
return true;
|
|
335
|
+
}
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
isAddOrMoveField(newContainer, oldContainer, fieldConfig, data) {
|
|
339
|
+
var _a;
|
|
340
|
+
if (newContainer == undefined || oldContainer == undefined || fieldConfig == undefined || data == undefined) {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
if (data.newIndex !== data.oldIndex
|
|
344
|
+
|| oldContainer.dataset.groupName !== newContainer.dataset.groupName
|
|
345
|
+
|| (newContainer.id === CONTAINER_ID.withoutGroup
|
|
346
|
+
&& oldContainer.id === CONTAINER_ID.fieldsAvailable)) {
|
|
347
|
+
if (this.isFieldAvailable(newContainer, oldContainer)) {
|
|
348
|
+
fieldConfig.tab = (_a = this._tabConfig) === null || _a === void 0 ? void 0 : _a.selectedTab;
|
|
349
|
+
}
|
|
350
|
+
fieldConfig.group = newContainer.dataset.groupName;
|
|
351
|
+
setTimeout(() => {
|
|
352
|
+
const isNewGroup = newContainer.id.includes(CONTAINER_ID.addNewGroup);
|
|
353
|
+
if (isNewGroup) {
|
|
354
|
+
this.clearTempGroups(true);
|
|
355
|
+
}
|
|
356
|
+
const sortableTimer = oldContainer.dataset.groupName !== newContainer.dataset.groupName
|
|
357
|
+
|| (newContainer.id === CONTAINER_ID.withoutGroup && oldContainer.id === CONTAINER_ID.fieldsAvailable)
|
|
358
|
+
? this._sortableTimer
|
|
359
|
+
: 0;
|
|
360
|
+
this.updateFieldsToSave(sortableTimer);
|
|
361
|
+
}, this._renderTimer);
|
|
362
|
+
return true;
|
|
363
|
+
}
|
|
364
|
+
return false;
|
|
365
|
+
}
|
|
366
|
+
isFieldAvailable(newContainer, oldContainer) {
|
|
367
|
+
if (newContainer == undefined || oldContainer == undefined) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
return (newContainer.tagName === CONTAINER_ID.collapsibleBox
|
|
371
|
+
|| newContainer.id === CONTAINER_ID.withoutGroup)
|
|
372
|
+
&& oldContainer.id === CONTAINER_ID.fieldsAvailable;
|
|
373
|
+
}
|
|
374
|
+
controlStopDraggingField(evt) {
|
|
375
|
+
var _a, _b, _c, _d, _e, _f;
|
|
376
|
+
const oldContainer = (_a = evt === null || evt === void 0 ? void 0 : evt.data) === null || _a === void 0 ? void 0 : _a.oldContainer;
|
|
377
|
+
const newContainer = (_b = evt === null || evt === void 0 ? void 0 : evt.data) === null || _b === void 0 ? void 0 : _b.newContainer;
|
|
378
|
+
if (this.isCancelDragAvailableField(newContainer, oldContainer, evt)) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
const originalElement = (_e = (_d = (_c = evt === null || evt === void 0 ? void 0 : evt.data) === null || _c === void 0 ? void 0 : _c.dragEvent) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.originalSource;
|
|
382
|
+
const fieldConfig = (_f = originalElement === null || originalElement === void 0 ? void 0 : originalElement.querySelector('snk-field-config')) === null || _f === void 0 ? void 0 : _f.fieldConfig;
|
|
383
|
+
if (this.isRemoveField(newContainer, oldContainer, fieldConfig)) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
if (this.isAddOrMoveField(newContainer, oldContainer, fieldConfig, evt === null || evt === void 0 ? void 0 : evt.data)) {
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
updateFieldsToSave(updateTimer = 0) {
|
|
391
|
+
const fields = this.getFieldsToSave();
|
|
392
|
+
if ((fields === null || fields === void 0 ? void 0 : fields.length) > 0) {
|
|
393
|
+
this._formConfig.fields = fields;
|
|
394
|
+
}
|
|
395
|
+
this.loadFields(updateTimer);
|
|
396
|
+
this._formConfigChanged = true;
|
|
397
|
+
}
|
|
398
|
+
controlSortableField() {
|
|
399
|
+
if (this._sortableContainer == undefined) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
if (this._sortableField) {
|
|
403
|
+
this._sortableField.destroy();
|
|
404
|
+
}
|
|
405
|
+
this._sortableField = new draggable_bundle.Sortable(this._sortableContainer.querySelectorAll('[data-draggable-parent="field"]'), {
|
|
406
|
+
draggable: '[data-draggable-element="field"]',
|
|
407
|
+
mirror: {
|
|
408
|
+
constrainDimensions: true
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
this._sortableField.on(CONFIG_EVENTS.dragStart, (evt) => this.controlStartDraggingField(evt));
|
|
412
|
+
this._sortableField.on(CONFIG_EVENTS.dragSorted, (evt) => this.controlSortedDraggingField(evt));
|
|
413
|
+
this._sortableField.on(CONFIG_EVENTS.dragStop, (evt) => this.controlStopDraggingField(evt));
|
|
414
|
+
}
|
|
415
|
+
controlStartDraggingGroup(evt) {
|
|
416
|
+
if (this._mouseOnFieldConfig || this._editingTitleGroup) {
|
|
417
|
+
evt === null || evt === void 0 ? void 0 : evt.cancel();
|
|
418
|
+
this._mouseOnFieldConfig = false;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
controlStopDraggingGroup(evt) {
|
|
422
|
+
if (evt.data.newIndex !== evt.data.oldIndex) {
|
|
423
|
+
setTimeout(() => {
|
|
424
|
+
this.updateFieldsToSave(this._sortableTimer);
|
|
425
|
+
}, this._renderTimer);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
controlSortableGroup() {
|
|
429
|
+
if (this._sortableContainer == undefined) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
if (this._sortableGroup) {
|
|
433
|
+
this._sortableGroup.destroy();
|
|
434
|
+
}
|
|
435
|
+
this._sortableGroup = new draggable_bundle.Sortable(this._sortableContainer.querySelectorAll('[data-draggable-parent="group"]'), {
|
|
436
|
+
draggable: '[data-draggable-element="group"]',
|
|
437
|
+
mirror: {
|
|
438
|
+
constrainDimensions: true
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
this._sortableGroup.on(CONFIG_EVENTS.dragStart, (evt) => this.controlStartDraggingGroup(evt));
|
|
442
|
+
this._sortableGroup.on(CONFIG_EVENTS.dragStop, (evt) => this.controlStopDraggingGroup(evt));
|
|
443
|
+
}
|
|
444
|
+
loadUserConfig() {
|
|
445
|
+
var _a;
|
|
446
|
+
if (this._application != undefined) {
|
|
447
|
+
this._application.fetchUserAvailableConfigs((_a = this.parentForm) === null || _a === void 0 ? void 0 : _a.configName)
|
|
448
|
+
.then((userConfig) => {
|
|
449
|
+
this._formConfigOptions = userConfig;
|
|
450
|
+
let isDefault = this._formConfig != undefined ? this._formConfig.defaultConfiguration : true;
|
|
451
|
+
const selectedOption = userConfig
|
|
452
|
+
.find((config) => {
|
|
453
|
+
return config.origin === (isDefault ? UserConfigType.DEFAULT : UserConfigType.USER);
|
|
454
|
+
});
|
|
455
|
+
this.setFormConfig(selectedOption);
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
setFormConfig(config) {
|
|
460
|
+
this._optionFormConfigSelected = config;
|
|
461
|
+
}
|
|
462
|
+
controlSelectFormConfig(evt) {
|
|
463
|
+
const action = evt === null || evt === void 0 ? void 0 : evt.detail;
|
|
464
|
+
const selectedOption = this._formConfigOptions
|
|
465
|
+
.find((config) => {
|
|
466
|
+
return config.origin === (action === null || action === void 0 ? void 0 : action.value);
|
|
467
|
+
});
|
|
468
|
+
this.setFormConfig(selectedOption);
|
|
469
|
+
this._optionFormConfigChanged = true;
|
|
470
|
+
this.loadConfigByUser();
|
|
471
|
+
}
|
|
472
|
+
changeTabOrder(newIndex) {
|
|
473
|
+
const tabs = [];
|
|
474
|
+
const tabConfigs = this._tabConfig.querySelectorAll('.tab-config__tab');
|
|
475
|
+
this._tabSelected = newIndex;
|
|
476
|
+
tabConfigs.forEach((tabConfig, index) => {
|
|
477
|
+
var _a;
|
|
478
|
+
if (index) {
|
|
479
|
+
const label = (_a = tabConfig.querySelector('.tab-config__tab-label')) === null || _a === void 0 ? void 0 : _a.getAttribute('title');
|
|
480
|
+
tabs.push({
|
|
481
|
+
label,
|
|
482
|
+
order: (index - 1)
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
this._layoutFormConfig.map((tabLayout) => {
|
|
487
|
+
tabs.forEach((tab) => {
|
|
488
|
+
tab.label === tabLayout.tab && (tab.visible = tabLayout.visible);
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
if (tabs.length > 0) {
|
|
492
|
+
this._formConfig.tabs = tabs;
|
|
493
|
+
this.loadFields(this._sortableTimer);
|
|
494
|
+
this.controlFieldConfig();
|
|
495
|
+
this._formConfigChanged = true;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
loadConfigByUser() {
|
|
499
|
+
var _a;
|
|
500
|
+
if (this._application != undefined) {
|
|
501
|
+
const option = this._optionFormConfigSelected;
|
|
502
|
+
const fetchActionName = (option === null || option === void 0 ? void 0 : option.origin) === UserConfigType.DEFAULT ? "fetchDefaultConfig" :
|
|
503
|
+
(option === null || option === void 0 ? void 0 : option.origin) === UserConfigType.USER ? "fetchLegacyConfig" :
|
|
504
|
+
undefined;
|
|
505
|
+
if (fetchActionName != undefined) {
|
|
506
|
+
this._application[fetchActionName]((_a = this.parentForm) === null || _a === void 0 ? void 0 : _a.configName)
|
|
507
|
+
.then((formConfig) => {
|
|
508
|
+
if (formConfig != undefined) {
|
|
509
|
+
this._formConfig = formConfig;
|
|
510
|
+
this._tabSelected = 1;
|
|
511
|
+
this.loadFields(this._sortableTimer);
|
|
512
|
+
this.controlFieldConfig();
|
|
513
|
+
this.clearTempGroups();
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
loadConfig(updateTimer = 0) {
|
|
520
|
+
this.loadFormConfig(updateTimer);
|
|
521
|
+
this.loadUserConfig();
|
|
522
|
+
}
|
|
523
|
+
addNewGroup() {
|
|
524
|
+
var _a, _b;
|
|
525
|
+
const tab = (_a = this._tabConfig) === null || _a === void 0 ? void 0 : _a.selectedTab;
|
|
526
|
+
const hasGroup = (_b = this._tempGroups) === null || _b === void 0 ? void 0 : _b.find((tempGroup) => {
|
|
527
|
+
return tempGroup.tab === tab && tempGroup.group.includes(this._labelNewGroup);
|
|
528
|
+
});
|
|
529
|
+
if (hasGroup == undefined) {
|
|
530
|
+
this._tempGroups.push({
|
|
531
|
+
tab,
|
|
532
|
+
group: this.handleDuplicateGroups(this._labelNewGroup, this._tabConfig.selectedTab)
|
|
533
|
+
});
|
|
534
|
+
this.loadFields();
|
|
535
|
+
this.controlFieldConfig();
|
|
536
|
+
this._formConfigChanged = true;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
clearTempGroups(clearInTab = false) {
|
|
540
|
+
var _a;
|
|
541
|
+
if (((_a = this._tempGroups) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
542
|
+
if (clearInTab) {
|
|
543
|
+
this._tempGroups = this._tempGroups.filter((tempGroup) => {
|
|
544
|
+
return tempGroup.tab !== this._tabConfig.selectedTab;
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
else {
|
|
548
|
+
this._tempGroups = [];
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
removeGroup(indexTempGroup = undefined) {
|
|
553
|
+
if (indexTempGroup != undefined) {
|
|
554
|
+
this._tempGroups = this._tempGroups.filter((tempGroup, index) => {
|
|
555
|
+
return (index !== indexTempGroup
|
|
556
|
+
&& tempGroup.tab === this._tabConfig.selectedTab)
|
|
557
|
+
|| tempGroup.tab !== this._tabConfig.selectedTab;
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
else {
|
|
561
|
+
this.updateFieldsToSave(this._sortableTimer);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
checkGroupExists(newLabel, indexGroup, isTempGroup = false) {
|
|
565
|
+
var _a, _b, _c;
|
|
566
|
+
const tabName = (_a = this._tabConfig) === null || _a === void 0 ? void 0 : _a.selectedTab;
|
|
567
|
+
const currentTab = (_b = this._layoutFormConfig) === null || _b === void 0 ? void 0 : _b.find(tab => tab.tab === tabName);
|
|
568
|
+
const tabGroupsNames = (_c = currentTab === null || currentTab === void 0 ? void 0 : currentTab.groups) === null || _c === void 0 ? void 0 : _c.map(tab => { var _a; return (_a = tab.group) === null || _a === void 0 ? void 0 : _a.toLowerCase(); });
|
|
569
|
+
if (tabGroupsNames === null || tabGroupsNames === void 0 ? void 0 : tabGroupsNames.includes(newLabel === null || newLabel === void 0 ? void 0 : newLabel.toLowerCase())) {
|
|
570
|
+
const title = this.getMessage("snkFormConfig.confirm.title");
|
|
571
|
+
const message = `
|
|
572
|
+
${this.getMessage("snkFormConfig.alert.titleGroupExists")}
|
|
573
|
+
<b>${newLabel}</b>
|
|
574
|
+
${this.getMessage("snkFormConfig.alert.inTab")}
|
|
575
|
+
<b>${tabName === TAB_NAMES.main ? this.getMessage("snkFormConfig.form.mainArea") : tabName}</b>.
|
|
576
|
+
<br/><br/>
|
|
577
|
+
${this.getMessage("snkFormConfig.alert.infoValidTitle")}
|
|
578
|
+
`;
|
|
579
|
+
ApplicationUtils.alert(title, message)
|
|
580
|
+
.then(() => {
|
|
581
|
+
var _a, _b;
|
|
582
|
+
if (isTempGroup) {
|
|
583
|
+
(_a = this._newGroupBoxes[indexGroup]) === null || _a === void 0 ? void 0 : _a.applyFocusTextEdit();
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
(_b = this._currentGroupBoxes[tabName][indexGroup]) === null || _b === void 0 ? void 0 : _b.applyFocusTextEdit();
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
return false;
|
|
590
|
+
}
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
saveEditLabelTempGroup(editDetails, index) {
|
|
594
|
+
const { newValue: newLabel } = editDetails.detail;
|
|
595
|
+
if (this._newGroupBoxes != undefined && this._newGroupBoxes[index] != undefined) {
|
|
596
|
+
this._newGroupBoxes[index].dataset.groupName = newLabel;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
saveEditLabelGroup(editDetails) {
|
|
600
|
+
var _a;
|
|
601
|
+
const { value: oldLabel, newValue: newLabel } = editDetails.detail;
|
|
602
|
+
(_a = this._formConfig.fields) === null || _a === void 0 ? void 0 : _a.forEach((field) => {
|
|
603
|
+
if (field.group === oldLabel) {
|
|
604
|
+
field.group = newLabel;
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
this.loadFields(this._sortableTimer);
|
|
608
|
+
this.controlFieldConfig();
|
|
609
|
+
this._formConfigChanged = true;
|
|
610
|
+
}
|
|
611
|
+
renderTempGroupByTab(tabName) {
|
|
612
|
+
return this._tempGroups.map((tempGroup, indexGroup) => {
|
|
613
|
+
if (tempGroup.tab === tabName) {
|
|
614
|
+
return h("ez-collapsible-box", { ref: ref => this._newGroupBoxes[indexGroup] = ref, id: `${CONTAINER_ID.addNewGroup}-${indexGroup}`, editable: true, removable: true, "header-size": "large", label: tempGroup.group, "icon-placement": "left", "data-group-name": tempGroup.group, "data-draggable-parent": "field", class: "form-config__add-group", onEzRemove: () => this.removeGroup(indexGroup), onEzSaveEditLabel: (evt) => this.saveEditLabelTempGroup(evt, indexGroup), onEzEditLabelMode: (evt) => this._editingTitleGroup = evt.detail, conditionalSave: (newLabel) => this.checkGroupExists(newLabel, indexGroup, true) }, this.getFieldsByGroup(tempGroup));
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
handleDuplicateGroups(titleNewGroup, currentTab) {
|
|
619
|
+
var _a;
|
|
620
|
+
const selectedTabGroups = this._layoutFormConfig[this._tabConfig.selectedIndex].groups.map(tab => tab.group);
|
|
621
|
+
if (selectedTabGroups != undefined) {
|
|
622
|
+
(_a = this._layoutFormConfig) === null || _a === void 0 ? void 0 : _a.map(tab => {
|
|
623
|
+
if (tab.tab === currentTab) {
|
|
624
|
+
if (tab.groups.some(groups => groups.group === titleNewGroup)) {
|
|
625
|
+
titleNewGroup += `${this.captureHighestValueTitle(selectedTabGroups)}`;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
return titleNewGroup;
|
|
631
|
+
}
|
|
632
|
+
captureHighestValueTitle(groupsTemp) {
|
|
633
|
+
let valuesNumericTitle = [];
|
|
634
|
+
groupsTemp === null || groupsTemp === void 0 ? void 0 : groupsTemp.map(group => {
|
|
635
|
+
if (group != undefined) {
|
|
636
|
+
valuesNumericTitle.push(group.replace(/[^0-9]/g, ''));
|
|
637
|
+
}
|
|
638
|
+
});
|
|
639
|
+
if (Math.max.apply(null, valuesNumericTitle) > 0) {
|
|
640
|
+
return ` (${Math.max.apply(null, valuesNumericTitle) + 1})`;
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
return ' (1)';
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
getLayoutFormConfig() {
|
|
647
|
+
var _a, _b;
|
|
648
|
+
if (((_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.fields) == undefined) {
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
let layoutFormConfig = [];
|
|
652
|
+
let fields = [];
|
|
653
|
+
for (const field of this._formConfig.fields) {
|
|
654
|
+
const hasField = fields.find((fieldTemp) => {
|
|
655
|
+
return field.name === fieldTemp.name && field.tab === fieldTemp.tab;
|
|
656
|
+
});
|
|
657
|
+
if (hasField == undefined) {
|
|
658
|
+
fields.push(field);
|
|
659
|
+
const fieldMD = this.dataUnit.getField(field.name);
|
|
660
|
+
if (fieldMD === null || fieldMD === void 0 ? void 0 : fieldMD.visible) {
|
|
661
|
+
if (field.label == undefined || field.label === "") {
|
|
662
|
+
field.label = fieldMD.label;
|
|
663
|
+
}
|
|
664
|
+
let tab = layoutFormConfig.find(value => value.tab === field.tab);
|
|
665
|
+
if (tab == undefined) {
|
|
666
|
+
let visible = null;
|
|
667
|
+
if (this._formConfig.tabs != undefined) {
|
|
668
|
+
const configTabs = this._formConfig.tabs.filter(configTab => configTab.label === field.tab);
|
|
669
|
+
if (configTabs.length > 0) {
|
|
670
|
+
visible = configTabs[0].visible;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
const tabLabel = ((_b = field.tab) === null || _b === void 0 ? void 0 : _b.label) || field.tab;
|
|
674
|
+
if (visible !== null) {
|
|
675
|
+
tab = { tab: tabLabel, groups: [], visible };
|
|
676
|
+
}
|
|
677
|
+
else {
|
|
678
|
+
tab = { tab: tabLabel, groups: [], visible: true };
|
|
679
|
+
}
|
|
680
|
+
layoutFormConfig.push(tab);
|
|
681
|
+
}
|
|
682
|
+
const group = tab.groups.find(value => value.group === field.group);
|
|
683
|
+
if (group) {
|
|
684
|
+
group.fields.push(field);
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
const newGroup = { group: field.group, fields: [field] };
|
|
688
|
+
if (field.group === undefined) {
|
|
689
|
+
tab.groups.unshift(newGroup);
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
tab.groups.push(newGroup);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return layoutFormConfig;
|
|
699
|
+
}
|
|
700
|
+
configureTabs(layoutFormConfig) {
|
|
701
|
+
var _a;
|
|
702
|
+
if (((_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.tabs) == undefined) {
|
|
703
|
+
return layoutFormConfig;
|
|
704
|
+
}
|
|
705
|
+
if (layoutFormConfig == undefined) {
|
|
706
|
+
layoutFormConfig = [];
|
|
707
|
+
}
|
|
708
|
+
return this._formConfig.tabs.map((tab) => {
|
|
709
|
+
return layoutFormConfig.find(config => { var _a, _b; return ((_a = tab.label) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === ((_b = config.tab) === null || _b === void 0 ? void 0 : _b.toLowerCase()); })
|
|
710
|
+
|| { tab: tab.label, groups: [], visible: tab.visible };
|
|
711
|
+
}).filter((layoutConfig) => {
|
|
712
|
+
return (layoutConfig === null || layoutConfig === void 0 ? void 0 : layoutConfig.tab) != undefined;
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
configureTabMain(layoutFormConfig) {
|
|
716
|
+
if (layoutFormConfig == undefined) {
|
|
717
|
+
layoutFormConfig = [];
|
|
718
|
+
}
|
|
719
|
+
const hasTabMain = layoutFormConfig.find((layoutTab) => {
|
|
720
|
+
return layoutTab.tab === TAB_NAMES.main;
|
|
721
|
+
});
|
|
722
|
+
if (hasTabMain == undefined) {
|
|
723
|
+
layoutFormConfig.unshift({ tab: TAB_NAMES.main, groups: [], visible: true });
|
|
724
|
+
}
|
|
725
|
+
return layoutFormConfig;
|
|
726
|
+
}
|
|
727
|
+
updateTabs() {
|
|
728
|
+
const tabs = this.getTabsToSave();
|
|
729
|
+
if ((tabs === null || tabs === void 0 ? void 0 : tabs.length) > 0) {
|
|
730
|
+
this._formConfig.tabs = tabs;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
buildFormConfig() {
|
|
734
|
+
var _a;
|
|
735
|
+
if (((_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.fields) == undefined) {
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
let layoutFormConfig = this.getLayoutFormConfig();
|
|
739
|
+
layoutFormConfig = this.configureTabs(layoutFormConfig);
|
|
740
|
+
layoutFormConfig = this.configureTabMain(layoutFormConfig);
|
|
741
|
+
this._layoutFormConfig = layoutFormConfig;
|
|
742
|
+
this.updateTabs();
|
|
743
|
+
}
|
|
744
|
+
buildAvailableFields() {
|
|
745
|
+
var _a, _b;
|
|
746
|
+
if (((_a = this._formConfig) === null || _a === void 0 ? void 0 : _a.fields) == undefined) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
let fieldsFormConfig = [];
|
|
750
|
+
let fieldsMetadata = this.dataUnit.metadata.fields;
|
|
751
|
+
for (const field of this._formConfig.fields) {
|
|
752
|
+
fieldsFormConfig.push(field);
|
|
753
|
+
}
|
|
754
|
+
const listFieldsAvailable = fieldsMetadata.filter(({ name: _nameFieldMetadado, visible: _visibleMetadado }) => _visibleMetadado === true
|
|
755
|
+
&& fieldsFormConfig.some(({ name: _nameFieldForm }) => _nameFieldForm === _nameFieldMetadado) === false);
|
|
756
|
+
this._fieldsAvailable = listFieldsAvailable;
|
|
757
|
+
this._listEnabledFields = listFieldsAvailable;
|
|
758
|
+
if (((_b = this._filterFieldsAvailable) === null || _b === void 0 ? void 0 : _b.value) != undefined) {
|
|
759
|
+
const filterValue = this._filterFieldsAvailable.value;
|
|
760
|
+
this.onFilterChange(filterValue);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
setShowFormConfig(value) {
|
|
764
|
+
this.parentForm.setShowFormConfig(value);
|
|
765
|
+
}
|
|
766
|
+
changeTabSelected(tabSelected) {
|
|
767
|
+
this._tabSelected = tabSelected.index;
|
|
768
|
+
const selectorTab = this._formContainer.querySelector("div#tab" + tabSelected.index);
|
|
769
|
+
this._formContainer.querySelectorAll(".form-config__tab-content").forEach(container => container.className = "form-config__hide-content sc-snk-form-config");
|
|
770
|
+
if (selectorTab) {
|
|
771
|
+
selectorTab.className = "form-config__tab-content ez-flex ez-flex--column ez-size-width--full ez-padding--medium sc-snk-form-config";
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
onFilterChange(value) {
|
|
775
|
+
this._fieldsAvailable = ArrayUtils.applyStringFilter(value, this._listEnabledFields, true, "label");
|
|
776
|
+
}
|
|
777
|
+
orderFieldsAvailable(fields) {
|
|
778
|
+
return ArrayUtils.sortAlphabetically(fields);
|
|
779
|
+
}
|
|
780
|
+
handleLabelCounter(sizeList) {
|
|
781
|
+
const labels = [this.getMessage("snkFormConfig.availableFields.labelNoFields"), this.getMessage("snkFormConfig.availableFields.labelOneField")];
|
|
782
|
+
return sizeList > 1 ? `${sizeList} ${this.getMessage("snkFormConfig.availableFields.labelAvailableFields")}` : labels[sizeList];
|
|
783
|
+
}
|
|
784
|
+
controlAddFieldConfig(fieldConfig) {
|
|
785
|
+
var _a;
|
|
786
|
+
this._formConfigChanged = false;
|
|
787
|
+
if (fieldConfig == undefined) {
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
if (this._formConfig.fields == undefined) {
|
|
791
|
+
this._formConfig.fields = [];
|
|
792
|
+
}
|
|
793
|
+
const fieldFinded = this._formConfig.fields.filter((field) => {
|
|
794
|
+
return field.name === fieldConfig.name && field.tab && fieldConfig.tab;
|
|
795
|
+
});
|
|
796
|
+
if (fieldFinded.length > 0) {
|
|
797
|
+
fieldFinded.forEach((field) => {
|
|
798
|
+
field.name = fieldConfig.name;
|
|
799
|
+
field.label = fieldConfig.label;
|
|
800
|
+
field.required = fieldConfig.required;
|
|
801
|
+
field.readOnly = fieldConfig.readOnly;
|
|
802
|
+
field.group = fieldConfig.group;
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
else {
|
|
806
|
+
this._formConfig.fields.push({
|
|
807
|
+
name: fieldConfig.name,
|
|
808
|
+
label: fieldConfig.label,
|
|
809
|
+
required: fieldConfig.required,
|
|
810
|
+
readOnly: fieldConfig.readOnly,
|
|
811
|
+
group: fieldConfig.group,
|
|
812
|
+
tab: (_a = this._tabConfig) === null || _a === void 0 ? void 0 : _a.selectedTab
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
this.loadFields();
|
|
816
|
+
this.controlFieldConfig();
|
|
817
|
+
this._formConfigChanged = true;
|
|
818
|
+
this.resetSortables();
|
|
819
|
+
}
|
|
820
|
+
controlRemoveFieldConfig(fieldConfig, updateTimer) {
|
|
821
|
+
var _a;
|
|
822
|
+
this._formConfigChanged = false;
|
|
823
|
+
if (fieldConfig == undefined) {
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
this._formConfig.fields = (_a = this._formConfig.fields) === null || _a === void 0 ? void 0 : _a.filter((field) => field.name !== fieldConfig.name);
|
|
827
|
+
this.loadFields(updateTimer);
|
|
828
|
+
this.controlFieldConfig();
|
|
829
|
+
this._formConfigChanged = true;
|
|
830
|
+
this.resetSortables();
|
|
831
|
+
}
|
|
832
|
+
resetSortables() {
|
|
833
|
+
this.controlSortableField();
|
|
834
|
+
this.controlSortableGroup();
|
|
835
|
+
}
|
|
836
|
+
handleFieldConfigChange(evt, updateTimer = 0) {
|
|
837
|
+
const { field: fieldConfig, type: actionType } = evt.detail;
|
|
838
|
+
if (actionType === ACTION_CONFIG.configuration) {
|
|
839
|
+
this.controlFieldConfig(fieldConfig);
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
if (actionType === ACTION_CONFIG.remove) {
|
|
843
|
+
this.controlRemoveFieldConfig(fieldConfig, updateTimer);
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
if (actionType === ACTION_CONFIG.add) {
|
|
847
|
+
this.controlAddFieldConfig(fieldConfig);
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
changeTabLabel(editDetails) {
|
|
852
|
+
var _a, _b;
|
|
853
|
+
const { value: oldLabel, newValue: newLabel } = editDetails.detail.detail;
|
|
854
|
+
(_a = this._formConfig.fields) === null || _a === void 0 ? void 0 : _a.forEach((field) => {
|
|
855
|
+
if (field.tab === oldLabel) {
|
|
856
|
+
field.tab = newLabel;
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
(_b = this._formConfig.tabs) === null || _b === void 0 ? void 0 : _b.forEach((tab) => {
|
|
860
|
+
if (tab.label === oldLabel) {
|
|
861
|
+
tab.label = newLabel;
|
|
862
|
+
}
|
|
863
|
+
});
|
|
864
|
+
this.loadFields(this._sortableTimer);
|
|
865
|
+
this.controlFieldConfig();
|
|
866
|
+
this._formConfigChanged = true;
|
|
867
|
+
}
|
|
868
|
+
handleDeleteTab(tabSelected) {
|
|
869
|
+
let options = {
|
|
870
|
+
canClose: false,
|
|
871
|
+
labelCancel: this.getMessage("snkFormConfig.confirm.labelNo"),
|
|
872
|
+
labelConfirm: this.getMessage("snkFormConfig.confirm.labelYes"),
|
|
873
|
+
btnConfirmDanger: false
|
|
874
|
+
};
|
|
875
|
+
const title = this.getMessage("snkFormConfig.confirm.title");
|
|
876
|
+
const deleteTab = this.getMessage("snkFormConfig.confirm.deleteTab");
|
|
877
|
+
ApplicationUtils.confirm(title, `${deleteTab} <b>${tabSelected.detail.label}</b>?`, "delete", DialogType.WARN, options)
|
|
878
|
+
.then(response => {
|
|
879
|
+
var _a;
|
|
880
|
+
if (response) {
|
|
881
|
+
this._formConfig.tabs = (_a = this._formConfig.tabs) === null || _a === void 0 ? void 0 : _a.filter((tab) => {
|
|
882
|
+
return tab.label !== tabSelected.detail.label;
|
|
883
|
+
});
|
|
884
|
+
this.loadFields(this._sortableTimer);
|
|
885
|
+
this.controlFieldConfig();
|
|
886
|
+
this._formConfigChanged = true;
|
|
887
|
+
}
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
changeHideTab(tabSelected) {
|
|
891
|
+
var _a;
|
|
892
|
+
(_a = this._formConfig.tabs) === null || _a === void 0 ? void 0 : _a.forEach((tab) => {
|
|
893
|
+
if (tab.label === tabSelected.detail.label) {
|
|
894
|
+
tab.visible = !tab.visible;
|
|
895
|
+
}
|
|
896
|
+
});
|
|
897
|
+
this.loadFields(this._sortableTimer);
|
|
898
|
+
this.controlFieldConfig();
|
|
899
|
+
this._formConfigChanged = true;
|
|
900
|
+
}
|
|
901
|
+
handleCanStartDragTab() {
|
|
902
|
+
var _a, _b;
|
|
903
|
+
const tabs = this._layoutFormConfig.map(tab => tab.tab);
|
|
904
|
+
for (const tab of tabs) {
|
|
905
|
+
(_a = this._currentGroupBoxes[tab]) === null || _a === void 0 ? void 0 : _a.map(collapsibleBox => collapsibleBox === null || collapsibleBox === void 0 ? void 0 : collapsibleBox.cancelEdition());
|
|
906
|
+
}
|
|
907
|
+
(_b = this._newGroupBoxes) === null || _b === void 0 ? void 0 : _b.map(collapsibleBox => collapsibleBox === null || collapsibleBox === void 0 ? void 0 : collapsibleBox.cancelEdition());
|
|
908
|
+
}
|
|
909
|
+
/**
|
|
910
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
911
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
912
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
913
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-form.msg.ts"
|
|
914
|
+
*/
|
|
915
|
+
getMessage(key, params) {
|
|
916
|
+
return this._application.messagesBuilder.getMessage(key, params);
|
|
917
|
+
}
|
|
918
|
+
componentDidRender() {
|
|
919
|
+
this.controlSortableField();
|
|
920
|
+
this.controlSortableGroup();
|
|
921
|
+
}
|
|
922
|
+
componentWillLoad() {
|
|
923
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
924
|
+
this.loadConfig();
|
|
925
|
+
}
|
|
926
|
+
render() {
|
|
927
|
+
var _a, _b, _c, _d;
|
|
928
|
+
const configOptions = this._formConfigOptions.map((option) => {
|
|
929
|
+
return { value: option.origin, label: option.name };
|
|
930
|
+
});
|
|
931
|
+
return (h(Host, null, h("div", { class: "ez-row ez-padding--medium" }, h("div", { class: "ez-col ez-col--sd-7 ez-col--tb-9 ez-align--middle" }, h("ez-button", { mode: "icon", iconName: "arrow_back", class: "ez-padding--small", size: "small", onClick: () => this.closeFormConfig() }), h("h1", { class: "ez-title ez-title--extra-large ez-padding--small" }, this.getMessage("snkFormConfig.title")), h("ez-actions-button", { class: "form-config__actions-button ez-margin-left--medium", value: (_a = this._optionFormConfigSelected) === null || _a === void 0 ? void 0 : _a.origin, showLabel: true, iconName: "chevron-down", checkOption: true, size: "small", actions: configOptions, onEzAction: (evt) => this.controlSelectFormConfig(evt) })), h("div", { class: "ez-col ez-col--sd-5 ez-col--tb-3 ez-align--middle ez-align--right" }, this._formConfigChanged === true && this._optionFormConfigChanged === false &&
|
|
932
|
+
h("div", { class: "ez-row ez-align--middle ez-align--right" }, h("ez-button", { label: "Cancelar", class: "ez-padding-left--medium", size: "small", onClick: () => this.cancelChangeConfig() }), h("ez-button", { label: "Salvar", class: "ez-button--primary ez-padding-left--medium", size: "small", onClick: () => this.saveConfig() }, h("ez-icon", { class: "ez-margin-right--small", slot: "leftIcon", iconName: "save" }))), this._optionFormConfigChanged === true &&
|
|
933
|
+
h("div", { class: "ez-row ez-align--middle ez-align--right" }, h("ez-button", { label: "Cancelar", class: "ez-padding-left--medium", size: "small", onClick: () => this.cancelChangeOptionConfig() }), h("ez-button", { label: this.getMessage("snkFormConfig.applyConfig"), class: "ez-button--primary ez-padding-left--medium", size: "small", onClick: () => this.applyOptionConfig() })))), h("div", { class: "ez-row ez-padding--medium", ref: ref => this._sortableContainer = ref }, h("div", { class: "form-config__tab-container ez-col ez-col--sd-9 ez-col--tb-9 ez-padding-right--medium" }, ((_b = this._layoutFormConfig) === null || _b === void 0 ? void 0 : _b.length) > 0 &&
|
|
934
|
+
h("section", { class: "ez-box__container", ref: ref => this._formContainer = ref }, h("snk-tab-config", { ref: ref => this._tabConfig = ref, selectedIndex: this._tabSelected, onEzTabChange: (ev) => this.changeTabSelected(ev.detail), onEzOrderChange: (ev) => this.changeTabOrder(ev.detail), onEditionTitleTab: (ev) => this.changeTabLabel(ev), onDeleteTab: (ev) => this.handleDeleteTab(ev), onHideTab: (ev) => this.changeHideTab(ev), onCanStartDrag: () => this.handleCanStartDragTab() }, this._layoutFormConfig.map((tab) => h("snk-tab", { tabKey: tab.tab || "Geral", label: tab.tab || this.getMessage("snkFormConfig.form.tabGeneral"), visible: tab.visible }))), this._layoutFormConfig.map((tab, indexTab) => h("div", { id: "tab" + indexTab, "data-draggable-parent": "group", class: this._tabSelected === indexTab
|
|
935
|
+
? "form-config__tab-content ez-flex ez-flex--column ez-size-width--full ez-padding--medium"
|
|
936
|
+
: "form-config__hide-content" }, tab.groups.map((group, indexGroup) => {
|
|
937
|
+
if (group.group) {
|
|
938
|
+
if (this._currentGroupBoxes[tab.tab] == undefined) {
|
|
939
|
+
this._currentGroupBoxes[tab.tab] = [];
|
|
940
|
+
}
|
|
941
|
+
return h("ez-collapsible-box", { ref: ref => this._currentGroupBoxes[tab.tab][indexGroup] = ref, editable: true, removable: true, "header-size": "large", label: group.group, "icon-placement": "left", "data-group-name": group.group, "data-draggable-parent": "field", "data-draggable-element": "group", onEzRemove: () => this.removeGroup(), onEzSaveEditLabel: (evt) => this.saveEditLabelGroup(evt), onEzEditLabelMode: (evt) => this._editingTitleGroup = evt.detail, conditionalSave: (newLabel) => this.checkGroupExists(newLabel, indexGroup) }, this.getFieldsByGroup(group));
|
|
942
|
+
}
|
|
943
|
+
else {
|
|
944
|
+
return h("div", { class: "ez-flex ez-flex--column ez-size-width--full" }, h("label", { class: "ez-text ez-text--secondary ez-margin-vertical--small" }, this.getMessage("snkFormConfig.form.subTitleInfo")), h("div", { id: CONTAINER_ID.withoutGroup, class: "ez-row", "data-draggable-parent": "field" }, this.getFieldsByGroup(group)), h("hr", { class: "ez-divider-horizontal ez-margin-vertical--medium" }));
|
|
945
|
+
}
|
|
946
|
+
}), this.renderTempGroupByTab(tab.tab))), h("div", { class: "form-config__btn-add-group ez-row" }, h("div", { class: "form-config__btn-add-group-container ez-col ez-col--sd-12 ez-col--tb-12 ez-align--center" }, h("ez-button", { label: this.getMessage("snkFormConfig.form.labelNewGroup"), class: "ez-padding-horizontal--small ez-button--primary", size: "small", onClick: () => this.addNewGroup() }, h("ez-icon", { class: "ez-margin-right--small", slot: "leftIcon", iconName: "plus" })))))), h("div", { class: "form-config__fields-available ez-col ez-col--sd-3 ez-col--tb-3" }, h("section", { class: "ez-box__container ez-col ez-col--pn-12" }, h("h1", { class: "ez-title ez-title--large ez-title--primary ez-padding-bottom--medium" }, this.getMessage("snkFormConfig.availableFields.title")), h("ez-filter-input", { ref: ref => this._filterFieldsAvailable = ref, label: this.getMessage("snkFormConfig.availableFields.labelSearchField"), onEzChange: evt => this.onFilterChange(evt.detail) }), h("span", { class: "ez-box__label-counter ez-text ez-text--medium ez-text--primary ez-margin-bottom--medium" }, this.handleLabelCounter((_c = this._fieldsAvailable) === null || _c === void 0 ? void 0 : _c.length)), ((_d = this._layoutFormConfig) === null || _d === void 0 ? void 0 : _d.length) > 0 &&
|
|
947
|
+
h("div", { id: CONTAINER_ID.fieldsAvailable, class: "ez-row", "data-draggable-parent": "field" }, this.orderFieldsAvailable(this._fieldsAvailable).map((field) => h("div", { key: field.name, class: this._fieldsAvailableStyle, "data-draggable-element": "field", onMouseDown: (evt) => this.controlMoveField(evt) }, h("snk-field-config", { onEzClickIcon: (evt) => { this.handleFieldConfigChange(evt); }, fieldConfig: field })))))))));
|
|
948
|
+
}
|
|
949
|
+
static get watchers() { return {
|
|
950
|
+
"formConfig": ["observeFormConfig"]
|
|
951
|
+
}; }
|
|
952
|
+
static get style() { return snkFormConfigCss; }
|
|
953
|
+
}, [2, "snk-form-config", {
|
|
954
|
+
"dataUnit": [16],
|
|
955
|
+
"formConfig": [16],
|
|
956
|
+
"parentForm": [16],
|
|
957
|
+
"_formConfigOptions": [32],
|
|
958
|
+
"_fieldConfigSelected": [32],
|
|
959
|
+
"_layoutFormConfig": [32],
|
|
960
|
+
"_fieldsAvailable": [32],
|
|
961
|
+
"_formConfig": [32],
|
|
962
|
+
"_formConfigChanged": [32],
|
|
963
|
+
"_optionFormConfigSelected": [32],
|
|
964
|
+
"_optionFormConfigChanged": [32],
|
|
965
|
+
"_tempGroups": [32]
|
|
966
|
+
}]);
|
|
967
|
+
function defineCustomElement() {
|
|
968
|
+
if (typeof customElements === "undefined") {
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
const components = ["snk-form-config", "snk-config-options", "snk-field-config", "snk-tab-config"];
|
|
972
|
+
components.forEach(tagName => { switch (tagName) {
|
|
973
|
+
case "snk-form-config":
|
|
974
|
+
if (!customElements.get(tagName)) {
|
|
975
|
+
customElements.define(tagName, SnkFormConfig);
|
|
976
|
+
}
|
|
977
|
+
break;
|
|
978
|
+
case "snk-config-options":
|
|
979
|
+
if (!customElements.get(tagName)) {
|
|
980
|
+
defineCustomElement$3();
|
|
981
|
+
}
|
|
982
|
+
break;
|
|
983
|
+
case "snk-field-config":
|
|
984
|
+
if (!customElements.get(tagName)) {
|
|
985
|
+
defineCustomElement$2();
|
|
986
|
+
}
|
|
987
|
+
break;
|
|
988
|
+
case "snk-tab-config":
|
|
989
|
+
if (!customElements.get(tagName)) {
|
|
990
|
+
defineCustomElement$1();
|
|
991
|
+
}
|
|
992
|
+
break;
|
|
993
|
+
} });
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
export { SnkFormConfig as S, defineCustomElement as d };
|