@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,339 @@
|
|
|
1
|
+
import { ApplicationContext } from '@sankhyalabs/core';
|
|
2
|
+
import { h, Host } from '@stencil/core';
|
|
3
|
+
import { TaskbarElement, buildElem, AuthorizationElements, buildCustomButton, VisibleWhenForbidden } from './elements/taskbar-elements';
|
|
4
|
+
export class SnkTaskbar {
|
|
5
|
+
constructor() {
|
|
6
|
+
this._titleKeyByElement = {
|
|
7
|
+
[TaskbarElement.UPDATE]: "snkTaskbar.titleUpdate",
|
|
8
|
+
[TaskbarElement.PREVIOUS]: "snkTaskbar.titlePrevious",
|
|
9
|
+
[TaskbarElement.NEXT]: "snkTaskbar.titleNext",
|
|
10
|
+
[TaskbarElement.REFRESH]: "snkTaskbar.titleRefresh",
|
|
11
|
+
[TaskbarElement.CLONE]: "snkTaskbar.titleClone",
|
|
12
|
+
[TaskbarElement.REMOVE]: "snkTaskbar.titleRemove",
|
|
13
|
+
[TaskbarElement.MORE_OPTIONS]: "snkTaskbar.titleMoreOptions",
|
|
14
|
+
[TaskbarElement.INSERT]: "snkTaskbar.titleInsert",
|
|
15
|
+
[TaskbarElement.CANCEL]: "snkTaskbar.titleCancel",
|
|
16
|
+
[TaskbarElement.SAVE]: "snkTaskbar.titleSave",
|
|
17
|
+
[TaskbarElement.GRID_MODE]: "snkTaskbar.titleGridMode",
|
|
18
|
+
[TaskbarElement.FORM_MODE]: "snkTaskbar.titleFormMode",
|
|
19
|
+
[TaskbarElement.CONFIGURATOR]: "snkTaskbar.titleConfigurator"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
observeButtons() {
|
|
23
|
+
this._definitions = undefined;
|
|
24
|
+
}
|
|
25
|
+
// Internal methods
|
|
26
|
+
elementsFromString(strButtons) {
|
|
27
|
+
const elements = [];
|
|
28
|
+
if (strButtons) {
|
|
29
|
+
strButtons.split(",").forEach(buttonName => {
|
|
30
|
+
buttonName = buttonName.trim();
|
|
31
|
+
if (VisibleWhenForbidden[buttonName] || this.isAllowed(buttonName)) {
|
|
32
|
+
elements.push(buttonName.trim());
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return elements;
|
|
37
|
+
}
|
|
38
|
+
isAllowed(buttonName) {
|
|
39
|
+
if (AuthorizationElements[buttonName]) {
|
|
40
|
+
return this._permissions ? this._permissions.isSup || this._permissions[buttonName] : false;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
46
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
|
47
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
|
48
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-taskbar.msg.ts"
|
|
49
|
+
*/
|
|
50
|
+
getTitle(element) {
|
|
51
|
+
let key;
|
|
52
|
+
if (this.isAllowed(element)) {
|
|
53
|
+
key = this._titleKeyByElement[element];
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
key = "snkTaskbar.forbidden";
|
|
57
|
+
}
|
|
58
|
+
return key ? this._application.messagesBuilder.getMessage(key, {}) : "";
|
|
59
|
+
}
|
|
60
|
+
elementClick(elem) {
|
|
61
|
+
if (this.dataUnit) {
|
|
62
|
+
switch (elem) {
|
|
63
|
+
case TaskbarElement.PREVIOUS:
|
|
64
|
+
this.dataUnit.previousRecord();
|
|
65
|
+
break;
|
|
66
|
+
case TaskbarElement.NEXT:
|
|
67
|
+
this.dataUnit.nextRecord();
|
|
68
|
+
break;
|
|
69
|
+
case TaskbarElement.REFRESH:
|
|
70
|
+
this.dataUnit.loadData();
|
|
71
|
+
break;
|
|
72
|
+
case TaskbarElement.CLONE:
|
|
73
|
+
this.dataUnit.copySelected();
|
|
74
|
+
break;
|
|
75
|
+
case TaskbarElement.REMOVE:
|
|
76
|
+
this.dataUnit.removeSelectedRecords();
|
|
77
|
+
break;
|
|
78
|
+
case TaskbarElement.INSERT:
|
|
79
|
+
this.dataUnit.addRecord();
|
|
80
|
+
break;
|
|
81
|
+
case TaskbarElement.CANCEL:
|
|
82
|
+
this.dataUnit.cancelEdition();
|
|
83
|
+
break;
|
|
84
|
+
case TaskbarElement.SAVE:
|
|
85
|
+
this.dataUnit.saveData();
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
this.actionClick.emit(elem);
|
|
90
|
+
}
|
|
91
|
+
isEnabled(elem) {
|
|
92
|
+
if (!this.isAllowed(elem)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return !(this.disabledButtons && this.disabledButtons.includes(elem));
|
|
96
|
+
}
|
|
97
|
+
getElement(index, def) {
|
|
98
|
+
let className = def === this.primaryButton ? "ez-button--primary " : "";
|
|
99
|
+
if (index > 1) {
|
|
100
|
+
className += "ez-padding-left--medium";
|
|
101
|
+
}
|
|
102
|
+
if (TaskbarElement[def.toString()]) {
|
|
103
|
+
return buildElem(def, className, elem => this.getTitle(elem), elem => this.elementClick(elem), elem => this.isEnabled(elem), this.actionsList, this.configName);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
return buildCustomButton(def, className, elem => this.elementClick(elem), elem => this.isEnabled(elem));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// Lifecycle
|
|
110
|
+
componentWillLoad() {
|
|
111
|
+
this._application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
112
|
+
if (this._application) {
|
|
113
|
+
this._application.getAllAccess().then(access => this._permissions = access);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
this._permissions = {};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
componentWillRender() {
|
|
120
|
+
if (this._definitions == undefined && this._permissions) {
|
|
121
|
+
this._definitions = this.elementsFromString(this.buttons);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
render() {
|
|
125
|
+
if (this._definitions === undefined) {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
let index = 0;
|
|
129
|
+
return (h(Host, null, this._definitions.map((elem) => {
|
|
130
|
+
if (elem === TaskbarElement.DIVIDER) {
|
|
131
|
+
index = 0;
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
index++;
|
|
135
|
+
}
|
|
136
|
+
if (TaskbarElement[elem]) {
|
|
137
|
+
return this.getElement(index, TaskbarElement[elem]);
|
|
138
|
+
}
|
|
139
|
+
if (this.customButtons.has(elem)) {
|
|
140
|
+
return this.getElement(index, this.customButtons.get(elem));
|
|
141
|
+
}
|
|
142
|
+
return h("slot", { name: elem });
|
|
143
|
+
})));
|
|
144
|
+
}
|
|
145
|
+
static get is() { return "snk-taskbar"; }
|
|
146
|
+
static get encapsulation() { return "scoped"; }
|
|
147
|
+
static get originalStyleUrls() {
|
|
148
|
+
return {
|
|
149
|
+
"$": ["snk-taskbar.css"]
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
static get styleUrls() {
|
|
153
|
+
return {
|
|
154
|
+
"$": ["snk-taskbar.css"]
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
static get properties() {
|
|
158
|
+
return {
|
|
159
|
+
"configName": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"mutable": false,
|
|
162
|
+
"complexType": {
|
|
163
|
+
"original": "string",
|
|
164
|
+
"resolved": "string",
|
|
165
|
+
"references": {}
|
|
166
|
+
},
|
|
167
|
+
"required": false,
|
|
168
|
+
"optional": false,
|
|
169
|
+
"docs": {
|
|
170
|
+
"tags": [],
|
|
171
|
+
"text": "Nome usado para guardar/recuperar as configura\u00E7\u00F5es do formul\u00E1rio"
|
|
172
|
+
},
|
|
173
|
+
"attribute": "config-name",
|
|
174
|
+
"reflect": false
|
|
175
|
+
},
|
|
176
|
+
"buttons": {
|
|
177
|
+
"type": "string",
|
|
178
|
+
"mutable": false,
|
|
179
|
+
"complexType": {
|
|
180
|
+
"original": "string",
|
|
181
|
+
"resolved": "string",
|
|
182
|
+
"references": {}
|
|
183
|
+
},
|
|
184
|
+
"required": false,
|
|
185
|
+
"optional": false,
|
|
186
|
+
"docs": {
|
|
187
|
+
"tags": [],
|
|
188
|
+
"text": "Lista separada por virgula, contendo todos os elementos a serem criados"
|
|
189
|
+
},
|
|
190
|
+
"attribute": "buttons",
|
|
191
|
+
"reflect": false
|
|
192
|
+
},
|
|
193
|
+
"customButtons": {
|
|
194
|
+
"type": "unknown",
|
|
195
|
+
"mutable": false,
|
|
196
|
+
"complexType": {
|
|
197
|
+
"original": "Map<string, CustomButton>",
|
|
198
|
+
"resolved": "Map<string, CustomButton>",
|
|
199
|
+
"references": {
|
|
200
|
+
"Map": {
|
|
201
|
+
"location": "global"
|
|
202
|
+
},
|
|
203
|
+
"CustomButton": {
|
|
204
|
+
"location": "local"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
"required": false,
|
|
209
|
+
"optional": false,
|
|
210
|
+
"docs": {
|
|
211
|
+
"tags": [],
|
|
212
|
+
"text": "Mapa com defini\u00E7\u00E3o de bot\u00F5es personalizados. A chave do mapa deve ser \npassada na lista \"buttons\" no lugar onde o bot\u00E3o ir\u00E1 aparecer."
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"actionsList": {
|
|
216
|
+
"type": "unknown",
|
|
217
|
+
"mutable": false,
|
|
218
|
+
"complexType": {
|
|
219
|
+
"original": "Array<Action>",
|
|
220
|
+
"resolved": "Action[]",
|
|
221
|
+
"references": {
|
|
222
|
+
"Array": {
|
|
223
|
+
"location": "global"
|
|
224
|
+
},
|
|
225
|
+
"Action": {
|
|
226
|
+
"location": "local"
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
"required": false,
|
|
231
|
+
"optional": false,
|
|
232
|
+
"docs": {
|
|
233
|
+
"tags": [],
|
|
234
|
+
"text": "Lista de a\u00E7\u00F5es que devem ser usadas no bot\u00E3o \"Mais op\u00E7\u00F5es\""
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
"primaryButton": {
|
|
238
|
+
"type": "string",
|
|
239
|
+
"mutable": false,
|
|
240
|
+
"complexType": {
|
|
241
|
+
"original": "string",
|
|
242
|
+
"resolved": "string",
|
|
243
|
+
"references": {}
|
|
244
|
+
},
|
|
245
|
+
"required": false,
|
|
246
|
+
"optional": false,
|
|
247
|
+
"docs": {
|
|
248
|
+
"tags": [],
|
|
249
|
+
"text": "Qual bot\u00E3o deve ter apar\u00EAncia prim\u00E1ria"
|
|
250
|
+
},
|
|
251
|
+
"attribute": "primary-button",
|
|
252
|
+
"reflect": false
|
|
253
|
+
},
|
|
254
|
+
"disabledButtons": {
|
|
255
|
+
"type": "unknown",
|
|
256
|
+
"mutable": false,
|
|
257
|
+
"complexType": {
|
|
258
|
+
"original": "Array<string>",
|
|
259
|
+
"resolved": "string[]",
|
|
260
|
+
"references": {
|
|
261
|
+
"Array": {
|
|
262
|
+
"location": "global"
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
"required": false,
|
|
267
|
+
"optional": false,
|
|
268
|
+
"docs": {
|
|
269
|
+
"tags": [],
|
|
270
|
+
"text": "Array contendo todos os bot\u00F5es a serem desabilitados"
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
"dataUnit": {
|
|
274
|
+
"type": "unknown",
|
|
275
|
+
"mutable": false,
|
|
276
|
+
"complexType": {
|
|
277
|
+
"original": "DataUnit",
|
|
278
|
+
"resolved": "DataUnit",
|
|
279
|
+
"references": {
|
|
280
|
+
"DataUnit": {
|
|
281
|
+
"location": "import",
|
|
282
|
+
"path": "@sankhyalabs/core"
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
"required": false,
|
|
287
|
+
"optional": false,
|
|
288
|
+
"docs": {
|
|
289
|
+
"tags": [],
|
|
290
|
+
"text": "Inst\u00E2ncia do DataUnit"
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
static get states() {
|
|
296
|
+
return {
|
|
297
|
+
"_permissions": {}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
static get events() {
|
|
301
|
+
return [{
|
|
302
|
+
"method": "actionClick",
|
|
303
|
+
"name": "actionClick",
|
|
304
|
+
"bubbles": true,
|
|
305
|
+
"cancelable": true,
|
|
306
|
+
"composed": true,
|
|
307
|
+
"docs": {
|
|
308
|
+
"tags": [],
|
|
309
|
+
"text": "Emitido sempre que houver click de bot\u00E3o ou a\u00E7\u00E3o"
|
|
310
|
+
},
|
|
311
|
+
"complexType": {
|
|
312
|
+
"original": "string",
|
|
313
|
+
"resolved": "string",
|
|
314
|
+
"references": {}
|
|
315
|
+
}
|
|
316
|
+
}, {
|
|
317
|
+
"method": "actionChange",
|
|
318
|
+
"name": "actionChange",
|
|
319
|
+
"bubbles": true,
|
|
320
|
+
"cancelable": true,
|
|
321
|
+
"composed": true,
|
|
322
|
+
"docs": {
|
|
323
|
+
"tags": [],
|
|
324
|
+
"text": "Emitido sempre que houver altera\u00E7\u00E3o em algum elemento aberto pelo bot\u00E3o de a\u00E7\u00E3o"
|
|
325
|
+
},
|
|
326
|
+
"complexType": {
|
|
327
|
+
"original": "any",
|
|
328
|
+
"resolved": "any",
|
|
329
|
+
"references": {}
|
|
330
|
+
}
|
|
331
|
+
}];
|
|
332
|
+
}
|
|
333
|
+
static get watchers() {
|
|
334
|
+
return [{
|
|
335
|
+
"propName": "buttons",
|
|
336
|
+
"methodName": "observeButtons"
|
|
337
|
+
}];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataType, DataUnit, UserInterface } from '@sankhyalabs/core';
|
|
2
|
-
import {
|
|
2
|
+
import { h } from '@stencil/core';
|
|
3
3
|
export class TestePesquisa {
|
|
4
4
|
componentWillLoad() {
|
|
5
5
|
this.dataUnit = new DataUnit("testes_com_formulario");
|
|
@@ -19,15 +19,18 @@ export class TestePesquisa {
|
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
render() {
|
|
22
|
-
return (h("snk-application", null,
|
|
23
|
-
h("ez-form", { dataUnit: this.dataUnit })));
|
|
22
|
+
return (h("snk-application", null, h("ez-form", { dataUnit: this.dataUnit })));
|
|
24
23
|
}
|
|
25
24
|
static get is() { return "teste-pesquisa"; }
|
|
26
25
|
static get encapsulation() { return "shadow"; }
|
|
27
|
-
static get originalStyleUrls() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
static get originalStyleUrls() {
|
|
27
|
+
return {
|
|
28
|
+
"$": ["teste-pesquisa.css"]
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
static get styleUrls() {
|
|
32
|
+
return {
|
|
33
|
+
"$": ["teste-pesquisa.css"]
|
|
34
|
+
};
|
|
35
|
+
}
|
|
33
36
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorException } from '@sankhyalabs/core';
|
|
1
|
+
import { ErrorException, WarningException } from '@sankhyalabs/core';
|
|
2
2
|
import { batchRequests } from 'graphql-request';
|
|
3
3
|
import UrlUtils from "../../../lib/utils/urlutils";
|
|
4
4
|
import { StringUtils } from '@sankhyalabs/core';
|
|
@@ -33,6 +33,27 @@ export class DataFetcher {
|
|
|
33
33
|
DataFetcher.requestListener.splice(index, 1);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
processErrorInfo(errors) {
|
|
37
|
+
var _a, _b;
|
|
38
|
+
const POSITION_ERROR_INFO = 0;
|
|
39
|
+
const errorTitle = "Falha detectada";
|
|
40
|
+
const error = errors[POSITION_ERROR_INFO];
|
|
41
|
+
if (error.length > 0) { //As informações do erro vem no primeiro indice de um array
|
|
42
|
+
const errorInfo = error[POSITION_ERROR_INFO];
|
|
43
|
+
const errorMessage = (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.message) ? errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.message : "Não há mensagem de erro";
|
|
44
|
+
const errorLevel = ((_a = errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.extensions) === null || _a === void 0 ? void 0 : _a.level) ? errorInfo.extensions.level : "ERROR";
|
|
45
|
+
const errorCode = ((_b = errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.extensions) === null || _b === void 0 ? void 0 : _b.code) ? errorInfo.extensions.code : "";
|
|
46
|
+
switch (errorLevel) {
|
|
47
|
+
case "WARNING":
|
|
48
|
+
return new WarningException(errorTitle, errorMessage, errorCode);
|
|
49
|
+
default:
|
|
50
|
+
return new ErrorException(errorTitle, errorMessage, errorCode);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return new ErrorException(errorTitle, "Não há informações sobre o erro");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
36
57
|
async callGraphQL(req) {
|
|
37
58
|
var _a;
|
|
38
59
|
const reqKey = this.getReqKey(req);
|
|
@@ -43,7 +64,8 @@ export class DataFetcher {
|
|
|
43
64
|
let query = this.getQueryTemplate(req);
|
|
44
65
|
const res = await this.fecthGrapql([{ document: query, variables: req.values }]);
|
|
45
66
|
if (res.errors.length > 0) {
|
|
46
|
-
|
|
67
|
+
const error = this.processErrorInfo(res.errors);
|
|
68
|
+
reject(error);
|
|
47
69
|
}
|
|
48
70
|
else {
|
|
49
71
|
resolve(res.data[0][reqKey]);
|
|
@@ -60,23 +82,26 @@ export class DataFetcher {
|
|
|
60
82
|
resolveURL() {
|
|
61
83
|
return UrlUtils.getUrlBase();
|
|
62
84
|
}
|
|
63
|
-
getContext() {
|
|
85
|
+
getContext(module) {
|
|
86
|
+
var _a;
|
|
64
87
|
const urlParams = UrlUtils.getQueryParams(location.search);
|
|
65
88
|
return {
|
|
66
|
-
baseUrl: `${this.resolveURL()}/
|
|
89
|
+
baseUrl: `${this.resolveURL()}/${module}/service.sbr`,
|
|
67
90
|
appName: "SankhyaBlocks",
|
|
68
|
-
mgeSession: `${window['skw_session'] || urlParams.mgeSession}`,
|
|
91
|
+
mgeSession: `${window['skw_session'] || urlParams.get("mgeSession")}`,
|
|
69
92
|
globalID: "85C0093DFA240EAB699B4E47A10215BD",
|
|
70
|
-
resourceID: "
|
|
93
|
+
resourceID: (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID))
|
|
71
94
|
};
|
|
72
95
|
}
|
|
73
96
|
async callServiceBroker(serviceName, payload) {
|
|
74
97
|
return new Promise((accept, reject) => {
|
|
75
|
-
const
|
|
76
|
-
const
|
|
98
|
+
const parts = serviceName.split("@");
|
|
99
|
+
const [module, name] = parts.length === 2 ? parts : ['mge', serviceName];
|
|
100
|
+
const ctx = this.getContext(module);
|
|
101
|
+
const url = `${ctx.baseUrl}?serviceName=${name}&counter=21&application=${ctx.appName}&outputType=json&preventTransform=false&mgeSession=${ctx.mgeSession}&resourceID=${ctx.resourceID}&globalID=${ctx.globalID}&allowConcurrentCalls=true`;
|
|
77
102
|
document.cookie = `JSESSIONID=${ctx.mgeSession};`;
|
|
78
103
|
const http = new XMLHttpRequest();
|
|
79
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url }));
|
|
104
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url: url, requestBody: payload }));
|
|
80
105
|
http.open("POST", url, true);
|
|
81
106
|
http.withCredentials = true;
|
|
82
107
|
http.send(payload);
|
|
@@ -95,11 +120,11 @@ export class DataFetcher {
|
|
|
95
120
|
console.warn(`callServiceBroker error to parser response to JSON ${e}`);
|
|
96
121
|
reject(this.responseText);
|
|
97
122
|
}
|
|
98
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url }));
|
|
123
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
|
|
99
124
|
}
|
|
100
125
|
else if (this.readyState == 4 && this.status != 200) {
|
|
101
126
|
reject(this.responseText);
|
|
102
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url }));
|
|
127
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: payload }));
|
|
103
128
|
}
|
|
104
129
|
};
|
|
105
130
|
});
|
|
@@ -155,7 +180,7 @@ export class DataFetcher {
|
|
|
155
180
|
if (window['skw_session']) {
|
|
156
181
|
url += `?mgeSession=${window['skw_session']}`;
|
|
157
182
|
}
|
|
158
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url }));
|
|
183
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestStart({ url: url, requestBody: request }));
|
|
159
184
|
try {
|
|
160
185
|
res = await batchRequests(url, request, { 'Content-Type': `application/json; charset=${window['SERVER_ENCODING'] || 'UTF-8'}` });
|
|
161
186
|
res.forEach((resItem, index) => {
|
|
@@ -186,11 +211,11 @@ export class DataFetcher {
|
|
|
186
211
|
});
|
|
187
212
|
}
|
|
188
213
|
else {
|
|
189
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url }));
|
|
214
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: request }));
|
|
190
215
|
throw new ErrorException("Falha de comunicação", err.message);
|
|
191
216
|
}
|
|
192
217
|
}
|
|
193
|
-
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url }));
|
|
218
|
+
DataFetcher.requestListener.forEach(listener => listener.onRequestEnd({ url: url, requestBody: request }));
|
|
194
219
|
return { data: dataResponse, errors: errorsResponse };
|
|
195
220
|
}
|
|
196
221
|
isHttpError(err) {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DataFetcher } from "../DataFetcher";
|
|
1
|
+
import { ChangeOperation, DataType, DataUnit, StringUtils } from "@sankhyalabs/core";
|
|
3
2
|
import { gql } from "graphql-request";
|
|
3
|
+
import { DataFetcher } from "../DataFetcher";
|
|
4
4
|
export default class DataUnitFetcher {
|
|
5
5
|
constructor() {
|
|
6
6
|
this.templateByQuery = new Map();
|
|
7
|
+
this._loadDataTimeout = {};
|
|
7
8
|
this.buldTemplates();
|
|
8
9
|
}
|
|
9
10
|
buldTemplates() {
|
|
@@ -32,9 +33,9 @@ export default class DataUnitFetcher {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
}`);
|
|
35
|
-
this.templateByQuery.set("fetchData", gql `query($dataunit: String! $limit: Int $offset:Int $
|
|
36
|
+
this.templateByQuery.set("fetchData", gql `query($dataunit: String! $limit: Int $offset:Int $filters: [InputFilter!] $sort: [InputSort!]) {
|
|
36
37
|
$queryAlias$: fetchDataUnit(name: $dataunit){
|
|
37
|
-
data(limit: $limit offset: $offset filters: $
|
|
38
|
+
data(limit: $limit offset: $offset filters: $filters sort: $sort){
|
|
38
39
|
limit
|
|
39
40
|
offset
|
|
40
41
|
total
|
|
@@ -59,13 +60,25 @@ export default class DataUnitFetcher {
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
}`);
|
|
63
|
+
this.templateByQuery.set("fetchDataRecord", gql `query($dataunit: String! $recordID: [String!]) {
|
|
64
|
+
$queryAlias$: fetchDataUnit(name: $dataunit){
|
|
65
|
+
record(id: $recordID){
|
|
66
|
+
id
|
|
67
|
+
fields {
|
|
68
|
+
name
|
|
69
|
+
value
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}`);
|
|
62
74
|
}
|
|
63
75
|
getDataUnit(entityName, resourceID) {
|
|
64
76
|
const dataUnit = new DataUnit(`dd://${entityName}/${resourceID}`);
|
|
65
77
|
dataUnit.metadataLoader = (dataUnit) => this.loadMetadata(dataUnit);
|
|
66
|
-
dataUnit.dataLoader = (dataUnit,
|
|
78
|
+
dataUnit.dataLoader = (dataUnit, request) => this.loadData(dataUnit, request);
|
|
67
79
|
dataUnit.saveLoader = (dataUnit, changes) => this.saveData(dataUnit, changes);
|
|
68
80
|
dataUnit.removeLoader = (dataUnit, recordIds) => this.removeRecords(dataUnit, recordIds);
|
|
81
|
+
dataUnit.recordLoader = (dataUnit, recordIds) => this.loadRecord(dataUnit, recordIds);
|
|
69
82
|
return dataUnit;
|
|
70
83
|
}
|
|
71
84
|
loadMetadata(dataUnit) {
|
|
@@ -100,25 +113,39 @@ export default class DataUnitFetcher {
|
|
|
100
113
|
});
|
|
101
114
|
});
|
|
102
115
|
}
|
|
103
|
-
loadData(dataUnit,
|
|
116
|
+
loadData(dataUnit, request) {
|
|
117
|
+
const duName = dataUnit.name;
|
|
118
|
+
if (this._loadDataTimeout[duName]) {
|
|
119
|
+
clearTimeout(this._loadDataTimeout[duName]);
|
|
120
|
+
delete this._loadDataTimeout[duName];
|
|
121
|
+
}
|
|
104
122
|
return new Promise((resolve, reject) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
123
|
+
this._loadDataTimeout[duName] = setTimeout(() => {
|
|
124
|
+
delete this._loadDataTimeout[duName];
|
|
125
|
+
this.doLoadData(dataUnit, request)
|
|
126
|
+
.then(result => resolve(result))
|
|
127
|
+
.catch(reason => reject(reason));
|
|
128
|
+
}, 200);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
doLoadData(dataUnit, request) {
|
|
132
|
+
return new Promise((resolve, reject) => {
|
|
133
|
+
var _a;
|
|
134
|
+
const { sort, filters, limit, offset, quickFilter } = request;
|
|
135
|
+
const variables = { dataunit: dataUnit.name, sort, filters };
|
|
136
|
+
variables.limit = limit;
|
|
137
|
+
variables.offset = offset;
|
|
138
|
+
if (!StringUtils.isEmpty(quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.term)) {
|
|
112
139
|
if (variables.filter === undefined) {
|
|
113
140
|
variables.filter = [];
|
|
114
141
|
}
|
|
115
142
|
const quickFilterCriteria = {
|
|
116
143
|
name: "__QUICK_FILTER__",
|
|
117
144
|
expression: "__QUICK_FILTER__",
|
|
118
|
-
params: [{ name: "term", dataType: DataType.TEXT, value:
|
|
145
|
+
params: [{ name: "term", dataType: DataType.TEXT, value: quickFilter.term }]
|
|
119
146
|
};
|
|
120
|
-
if (((
|
|
121
|
-
quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value:
|
|
147
|
+
if (((_a = quickFilter === null || quickFilter === void 0 ? void 0 : quickFilter.fields) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
148
|
+
quickFilterCriteria.params.push({ name: "fields", dataType: DataType.OBJECT, value: quickFilter.fields });
|
|
122
149
|
}
|
|
123
150
|
variables.filter.push(quickFilterCriteria);
|
|
124
151
|
}
|
|
@@ -128,16 +155,32 @@ export default class DataUnitFetcher {
|
|
|
128
155
|
query: this.templateByQuery.get("fetchData"),
|
|
129
156
|
})
|
|
130
157
|
.then((resp) => {
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
158
|
+
const { limit, offset, total, hasMore, records } = resp.data;
|
|
159
|
+
let paginationInfo;
|
|
160
|
+
if (limit) {
|
|
161
|
+
const firstRecord = total == 0 ? 0 : offset + 1;
|
|
162
|
+
const lastRecord = offset + Math.min(records.length, limit);
|
|
163
|
+
const currentPage = offset / limit;
|
|
164
|
+
paginationInfo = {
|
|
165
|
+
firstRecord,
|
|
166
|
+
lastRecord,
|
|
167
|
+
total,
|
|
168
|
+
currentPage,
|
|
169
|
+
hasMore
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const processedRecords = [];
|
|
173
|
+
records.forEach((responseRecord) => {
|
|
134
174
|
const duRecord = { __record__id__: responseRecord.id };
|
|
135
175
|
responseRecord.fields.forEach(({ name, value }) => {
|
|
136
176
|
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
137
177
|
});
|
|
138
|
-
|
|
178
|
+
processedRecords.push(duRecord);
|
|
179
|
+
});
|
|
180
|
+
resolve({
|
|
181
|
+
paginationInfo,
|
|
182
|
+
records: processedRecords
|
|
139
183
|
});
|
|
140
|
-
resolve(Object.assign(Object.assign({}, pageResult), { records }));
|
|
141
184
|
})
|
|
142
185
|
.catch((error) => {
|
|
143
186
|
reject(error);
|
|
@@ -204,4 +247,27 @@ export default class DataUnitFetcher {
|
|
|
204
247
|
});
|
|
205
248
|
});
|
|
206
249
|
}
|
|
250
|
+
loadRecord(dataUnit, recordIds) {
|
|
251
|
+
return new Promise((resolve, reject) => {
|
|
252
|
+
DataFetcher.get()
|
|
253
|
+
.callGraphQL({
|
|
254
|
+
values: { recordID: recordIds, dataunit: dataUnit.name },
|
|
255
|
+
query: this.templateByQuery.get("fetchDataRecord"),
|
|
256
|
+
})
|
|
257
|
+
.then((response) => {
|
|
258
|
+
const dataUnitRecords = [];
|
|
259
|
+
response.record.forEach(responseRecord => {
|
|
260
|
+
const duRecord = { __record__id__: responseRecord.id };
|
|
261
|
+
responseRecord.fields.forEach(({ name, value }) => {
|
|
262
|
+
duRecord[name] = dataUnit.valueFromString(name, value);
|
|
263
|
+
});
|
|
264
|
+
dataUnitRecords.push(duRecord);
|
|
265
|
+
});
|
|
266
|
+
resolve(dataUnitRecords);
|
|
267
|
+
})
|
|
268
|
+
.catch((error) => {
|
|
269
|
+
reject(error);
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
}
|
|
207
273
|
}
|