ui-soxo-bootstrap-core 2.4.25-dev.41 → 2.4.25-dev.44
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/.babelrc +8 -8
- package/.github/workflows/npm-publish.yml +52 -55
- package/.husky/pre-commit +11 -11
- package/.prettierrc.json +10 -10
- package/babel.config.js +2 -2
- package/core/components/component-loader/component-loader.js +125 -125
- package/core/components/component-wrapper/component-wrapper.js +121 -121
- package/core/components/external-window/external-window.js +236 -236
- package/core/components/external-window/external-window.test.js +80 -80
- package/core/components/extra-info/extra-info-details.js +155 -155
- package/core/components/extra-info/extra-info-details.scss +26 -26
- package/core/components/extra-info/extra-info.js +134 -134
- package/core/components/index.js +20 -20
- package/core/components/landing-api/landing-api.js +492 -492
- package/core/components/landing-api/landing-api.scss +19 -19
- package/core/components/menu-template-api/menu-template-api.js +321 -321
- package/core/components/root-application-api/root-application-api.js +174 -174
- package/core/index.js +13 -13
- package/core/lib/Store.js +365 -365
- package/core/lib/components/application-bootstrap/application-bootstrap.js +115 -115
- package/core/lib/components/approval-form/approval-form.js +280 -280
- package/core/lib/components/approval-form/approval-form.scss +183 -183
- package/core/lib/components/approval-list/approval-list.js +143 -143
- package/core/lib/components/approval-list/approval-list.scss +2 -2
- package/core/lib/components/approval-list/components/request-card/request-card.js +42 -42
- package/core/lib/components/approval-list/components/request-card/request-card.scss +30 -30
- package/core/lib/components/camera/camera.js +230 -230
- package/core/lib/components/camera/camera.scss +86 -86
- package/core/lib/components/comment-block/comment-block.js +138 -138
- package/core/lib/components/comment-block/comment-block.scss +3 -3
- package/core/lib/components/confirm-modal/confirm-modal.js +82 -82
- package/core/lib/components/confirm-modal/confirm-modal.scss +2 -2
- package/core/lib/components/consent/consent.js +67 -67
- package/core/lib/components/consent/pdf-signature.js +299 -299
- package/core/lib/components/consent/signature-pad.js +90 -90
- package/core/lib/components/consent/signature-pad.scss +14 -14
- package/core/lib/components/file-upload/file-upload.js +133 -133
- package/core/lib/components/finger-print-reader/finger-print-reader.js +295 -295
- package/core/lib/components/finger-print-reader/finger-print-reader.scss +47 -47
- package/core/lib/components/finger-print-search/finger-print-search.js +200 -200
- package/core/lib/components/finger-print-search/finger-print-search.scss +47 -47
- package/core/lib/components/global-header/animations.js +18 -18
- package/core/lib/components/global-header/global-header.js +412 -412
- package/core/lib/components/global-header/global-header.scss +369 -369
- package/core/lib/components/header/generic-header.js +76 -76
- package/core/lib/components/header/generic-header.scss +99 -99
- package/core/lib/components/image-preview/image-preview.js +33 -33
- package/core/lib/components/image-wrapper/image-wrapper.js +108 -108
- package/core/lib/components/image-wrapper/image-wrapper.scss +12 -12
- package/core/lib/components/index.js +206 -206
- package/core/lib/components/landing/landing.js +403 -403
- package/core/lib/components/language-switcher/language-switcher.js +49 -49
- package/core/lib/components/menu-context/menu-context.js +69 -69
- package/core/lib/components/menu-template/menu-template.js +249 -249
- package/core/lib/components/menu-template/menu-template.scss +9 -9
- package/core/lib/components/modal-search/modal-search.js +153 -153
- package/core/lib/components/modal-search/modal-search.scss +78 -78
- package/core/lib/components/modal-wrapper/modal-manager.js +15 -15
- package/core/lib/components/modal-wrapper/modal-wrapper.js +108 -108
- package/core/lib/components/modal-wrapper/modal-wrapper.scss +13 -13
- package/core/lib/components/notice-board/notice-board.js +132 -132
- package/core/lib/components/notice-board/notice-board.scss +65 -65
- package/core/lib/components/page-container/page-container.js +55 -55
- package/core/lib/components/page-container/page-container.scss +8 -8
- package/core/lib/components/page-header/page-header.js +23 -23
- package/core/lib/components/page-header/page-header.scss +17 -17
- package/core/lib/components/pdf-viewer/pdf-viewer.js +56 -56
- package/core/lib/components/portlet-table/components/table-actions/table-actions.js +58 -58
- package/core/lib/components/portlet-table/components/table-actions/table-actions.scss +1 -1
- package/core/lib/components/portlet-table/components/table-data/table-data.js +106 -106
- package/core/lib/components/portlet-table/portlet-table.js +63 -63
- package/core/lib/components/portlet-table/portlet-table.scss +90 -90
- package/core/lib/components/progress-bar/progress-bar.js +58 -58
- package/core/lib/components/progress-bar/progress-bar.scss +15 -15
- package/core/lib/components/request-form/request-form.js +110 -110
- package/core/lib/components/root-application/root-application.js +70 -70
- package/core/lib/components/rupee/rupee.js +14 -14
- package/core/lib/components/script-input/script-input.js +169 -169
- package/core/lib/components/script-input/script-input.scss +8 -8
- package/core/lib/components/sidemenu/animations.js +51 -51
- package/core/lib/components/sidemenu/sidemenu.js +572 -572
- package/core/lib/components/sidemenu/sidemenu.scss +277 -277
- package/core/lib/components/spotlight-search/spotlight-search.component.js +635 -635
- package/core/lib/components/spotlight-search/spotlight-search.component.scss +78 -78
- package/core/lib/components/table-wrapper/table-wrapper.js +135 -135
- package/core/lib/components/table-wrapper/table-wrapper.scss +72 -72
- package/core/lib/components/ui_elements/Loader.js +12 -12
- package/core/lib/components/ui_elements/Notify.js +12 -12
- package/core/lib/components/ui_elements/PlaceHolder.js +33 -33
- package/core/lib/components/web-camera/web-camera.js +161 -161
- package/core/lib/components/web-camera/web-camera.scss +28 -28
- package/core/lib/core.md +9 -9
- package/core/lib/elements/Elements.md +2 -2
- package/core/lib/elements/basic/LoggedUserRedirect.js +21 -21
- package/core/lib/elements/basic/PrivateRoute.js +16 -16
- package/core/lib/elements/basic/button/Button.md +43 -43
- package/core/lib/elements/basic/button/button.js +170 -170
- package/core/lib/elements/basic/card/Card.md +15 -15
- package/core/lib/elements/basic/card/card.js +40 -40
- package/core/lib/elements/basic/card/card.scss +13 -13
- package/core/lib/elements/basic/checkbox/checkbox.js +23 -23
- package/core/lib/elements/basic/col/col.js +15 -15
- package/core/lib/elements/basic/copy-to-clipboard/Readme.md +40 -40
- package/core/lib/elements/basic/copy-to-clipboard/copy-to-clipboard.js +61 -61
- package/core/lib/elements/basic/country-phone-input/Readme.md +98 -98
- package/core/lib/elements/basic/country-phone-input/country-phone-input.js +106 -106
- package/core/lib/elements/basic/country-phone-input/phone-input.scss +61 -61
- package/core/lib/elements/basic/datepicker/datepicker.js +33 -33
- package/core/lib/elements/basic/dragabble-wrapper/draggable-wrapper.js +136 -136
- package/core/lib/elements/basic/empty/empty.js +14 -14
- package/core/lib/elements/basic/fingerprint-protrected/fingerprint-protected.js +118 -118
- package/core/lib/elements/basic/fingerprint-protrected/fingerprint-protected.scss +10 -10
- package/core/lib/elements/basic/form/form.js +70 -70
- package/core/lib/elements/basic/form/form.scss +3 -3
- package/core/lib/elements/basic/image/image.js +45 -45
- package/core/lib/elements/basic/image/image.scss +17 -17
- package/core/lib/elements/basic/image/readme.md +26 -26
- package/core/lib/elements/basic/image-viewer/image-viewer.js +108 -108
- package/core/lib/elements/basic/image-viewer/image-viewer.scss +7 -7
- package/core/lib/elements/basic/input/input.js +81 -81
- package/core/lib/elements/basic/input/readme.md +77 -77
- package/core/lib/elements/basic/json-input/json-input.js +51 -51
- package/core/lib/elements/basic/menu-dashboard/menu-dashboard.js +216 -216
- package/core/lib/elements/basic/menu-dashboard/menu-dashboard.scss +28 -28
- package/core/lib/elements/basic/menu-tree/menu-tree.js +114 -114
- package/core/lib/elements/basic/modal/modal.js +64 -64
- package/core/lib/elements/basic/modal/readme.md +62 -62
- package/core/lib/elements/basic/popconfirm/popconfirm.js +17 -17
- package/core/lib/elements/basic/popover/popover.js +12 -12
- package/core/lib/elements/basic/radio/radio.js +18 -18
- package/core/lib/elements/basic/rangepicker/rangepicker.js +141 -141
- package/core/lib/elements/basic/rangepicker/rangepicker.scss +24 -24
- package/core/lib/elements/basic/rangepicker/readme.md +81 -81
- package/core/lib/elements/basic/reference-select/readme.md +18 -18
- package/core/lib/elements/basic/reference-select/reference-select.js +337 -337
- package/core/lib/elements/basic/row/row.js +15 -15
- package/core/lib/elements/basic/select/select.js +46 -46
- package/core/lib/elements/basic/select-box/readme.md +52 -52
- package/core/lib/elements/basic/select-box/select-box.js +63 -63
- package/core/lib/elements/basic/skeleton/readme.md +35 -35
- package/core/lib/elements/basic/skeleton/skeleton.js +35 -35
- package/core/lib/elements/basic/skeleton/skeleton.scss +53 -53
- package/core/lib/elements/basic/space/space.js +12 -12
- package/core/lib/elements/basic/switch/readme.md +29 -29
- package/core/lib/elements/basic/switch/switch.js +67 -67
- package/core/lib/elements/basic/tab/tab.js +14 -14
- package/core/lib/elements/basic/table/readme.md +8 -8
- package/core/lib/elements/basic/table/table.js +100 -100
- package/core/lib/elements/basic/tag/tag.js +63 -63
- package/core/lib/elements/basic/tag/tag.scss +2 -2
- package/core/lib/elements/basic/timeline/timeline.js +13 -13
- package/core/lib/elements/basic/title/readme.md +20 -20
- package/core/lib/elements/basic/title/title.js +37 -37
- package/core/lib/elements/basic/user-search/user-search.js +192 -192
- package/core/lib/elements/complex/barcode/barcode.js +27 -27
- package/core/lib/elements/complex/bargraph/bar-graph.js +262 -262
- package/core/lib/elements/complex/basic-table/basic-table.js +110 -110
- package/core/lib/elements/complex/basic-table/basic-table.scss +4 -4
- package/core/lib/elements/complex/date-display/date-display.js +37 -37
- package/core/lib/elements/complex/error-boundary/error-boundary.js +29 -29
- package/core/lib/elements/complex/google-location-input/map-container-library-load.js +92 -92
- package/core/lib/elements/complex/google-map/google-map.js +230 -230
- package/core/lib/elements/complex/google-map/google-map.scss +13 -13
- package/core/lib/elements/complex/line-graph/line-graph.js +108 -108
- package/core/lib/elements/complex/location-search-input/location-search-input.js +100 -100
- package/core/lib/elements/complex/pie-chart/pie-chart.js +202 -202
- package/core/lib/elements/complex/qr-code/qr-code.js +27 -27
- package/core/lib/elements/complex/qrscanner/qrscanner.js +57 -57
- package/core/lib/elements/complex/search-debounce/search-debounce.js +37 -37
- package/core/lib/elements/complex/statistic-card/dashboard-statistic-card.js +75 -75
- package/core/lib/elements/complex/statistic-card/statistic-card.js +28 -28
- package/core/lib/elements/index.js +226 -226
- package/core/lib/hooks/device-detect.js +25 -25
- package/core/lib/hooks/index.js +9 -9
- package/core/lib/hooks/use-location.js +33 -33
- package/core/lib/hooks/use-otp-timer.js +80 -80
- package/core/lib/hooks/use-window-size.js +34 -34
- package/core/lib/i18n.js +69 -69
- package/core/lib/index.js +106 -106
- package/core/lib/introduction.md +73 -73
- package/core/lib/js-styleguide.md +4112 -4112
- package/core/lib/models/actions/actions.js +127 -127
- package/core/lib/models/actions/components/action-detail/action-detail.js +190 -190
- package/core/lib/models/actions/components/custom-actions/custom-actions.js +185 -185
- package/core/lib/models/attachments/attachments.js +231 -231
- package/core/lib/models/base-loader.js +99 -99
- package/core/lib/models/base.js +716 -716
- package/core/lib/models/branches/branches.js +125 -125
- package/core/lib/models/checklists/checklists.js +114 -114
- package/core/lib/models/columns/columns.js +169 -169
- package/core/lib/models/columns/components/columns-add/columns-add.js +171 -171
- package/core/lib/models/comments/comments.js +213 -213
- package/core/lib/models/departments/departments.js +107 -107
- package/core/lib/models/financial-years/financial_years.js +127 -127
- package/core/lib/models/forms/components/form-creator/form-creator.js +590 -590
- package/core/lib/models/forms/components/form-creator/form-creator.scss +29 -29
- package/core/lib/models/forms/components/form-detail/form-detail.js +224 -224
- package/core/lib/models/forms/forms.js +121 -121
- package/core/lib/models/index.js +203 -203
- package/core/lib/models/invoice-numbers/invoice_numbers.js +204 -204
- package/core/lib/models/lookup-types/components/lookup-detail/lookup-detail.js +145 -145
- package/core/lib/models/lookup-types/lookup-types.js +113 -113
- package/core/lib/models/lookup-values/components/lookup-values-add/lookup-values-add.js +126 -126
- package/core/lib/models/lookup-values/lookup-values.js +107 -107
- package/core/lib/models/menu-roles/menu-roles.js +127 -127
- package/core/lib/models/menus/components/menu-add/menu-add.js +228 -228
- package/core/lib/models/menus/components/menu-detail/menu-detail.js +170 -170
- package/core/lib/models/menus/components/menu-list/menu-list.js +593 -593
- package/core/lib/models/menus/components/menu-list/menu-list.scss +5 -5
- package/core/lib/models/menus/components/menu-roles-add/menu-roles-add.js +183 -183
- package/core/lib/models/menus/menus.js +499 -499
- package/core/lib/models/models/components/model-detail/model-detail.js +137 -137
- package/core/lib/models/models/components/models.js +128 -128
- package/core/lib/models/modules/modules.js +204 -204
- package/core/lib/models/outbox/outbox.js +73 -73
- package/core/lib/models/pages/pages.js +107 -107
- package/core/lib/models/permissions/permissions.js +71 -71
- package/core/lib/models/process/components/process-add/process-add.js +181 -181
- package/core/lib/models/process/components/process-dashboard/process-dashboard.js +601 -601
- package/core/lib/models/process/components/process-dashboard/process-dashboard.scss +62 -62
- package/core/lib/models/process/components/process-detail/process-detail.js +140 -140
- package/core/lib/models/process/components/process-timeline/process-timeline.js +139 -139
- package/core/lib/models/process/components/task-detail/task-detail.js +240 -240
- package/core/lib/models/process/components/task-detail/task-detail.scss +27 -27
- package/core/lib/models/process/components/task-form/task-form.js +528 -528
- package/core/lib/models/process/components/task-form/task-form.scss +7 -7
- package/core/lib/models/process/components/task-list/task-list.js +221 -221
- package/core/lib/models/process/components/task-list/task-list.scss +14 -14
- package/core/lib/models/process/components/task-overview/task-overview.js +299 -299
- package/core/lib/models/process/components/task-overview-legacy/task-overview-legacy.js +192 -192
- package/core/lib/models/process/components/task-routes/task-routes.js +45 -45
- package/core/lib/models/process/components/task-status/task-status.js +175 -175
- package/core/lib/models/process/components/task-status/task-status.scss +11 -11
- package/core/lib/models/process/process.js +780 -780
- package/core/lib/models/process-transactions/process-transactions.js +123 -123
- package/core/lib/models/roles/roles.js +106 -106
- package/core/lib/models/scripts/scripts.js +111 -111
- package/core/lib/models/step-transactions/step-transcations.js +147 -147
- package/core/lib/models/steps/components/step-add/step-add.js +261 -261
- package/core/lib/models/steps/components/step-detail/step-detail.js +157 -157
- package/core/lib/models/steps/steps.js +356 -356
- package/core/lib/models/user-preferences/user-preferences.js +83 -83
- package/core/lib/models/users/components/user-add/user-add.js +226 -226
- package/core/lib/models/users/users.js +119 -119
- package/core/lib/modules/business/launch-page/launch-page.js +29 -29
- package/core/lib/modules/business/launch-page/launch-page.scss +5 -5
- package/core/lib/modules/business/slots/slots.js +231 -231
- package/core/lib/modules/business/slots/slots.scss +108 -108
- package/core/lib/modules/forms/components/field-customizer/field-customizer.js +138 -138
- package/core/lib/modules/forms/components/field-selector/field-selector.js +157 -157
- package/core/lib/modules/forms/components/field-selector/field-selector.scss +25 -25
- package/core/lib/modules/forms/components/form-display/form-display.js +203 -203
- package/core/lib/modules/forms/components/form-display/form-display.scss +9 -9
- package/core/lib/modules/forms/components/tab-customizer/tab-customizer.js +124 -124
- package/core/lib/modules/generic/generic-add/generic-add.js +213 -213
- package/core/lib/modules/generic/generic-detail/generic-detail.js +199 -199
- package/core/lib/modules/generic/generic-edit/generic-edit.js +120 -120
- package/core/lib/modules/generic/generic-list/ExportReactCSV.js +62 -62
- package/core/lib/modules/generic/generic-list/generic-list.js +705 -705
- package/core/lib/modules/generic/generic-list/generic-list.scss +34 -34
- package/core/lib/modules/generic/generic-upload/generic-upload.js +483 -483
- package/core/lib/modules/generic/table-settings/table-settings.js +226 -226
- package/core/lib/modules/generic/table-settings/table-settings.scss +37 -37
- package/core/lib/modules/index.js +52 -52
- package/core/lib/modules/modules-routes/module-routes.js +35 -35
- package/core/lib/pages/change-password/change-password.js +211 -211
- package/core/lib/pages/change-password/change-password.scss +76 -76
- package/core/lib/pages/homepage/homepage.js +53 -53
- package/core/lib/pages/index.js +19 -19
- package/core/lib/pages/login/login.js +735 -735
- package/core/lib/pages/login/login.scss +458 -458
- package/core/lib/pages/manage-users/manage-users.js +429 -429
- package/core/lib/pages/manage-users/manage-users.scss +25 -25
- package/core/lib/pages/profile/profile.js +247 -247
- package/core/lib/pages/profile/profile.scss +107 -107
- package/core/lib/pages/profile/theme-config.js +18 -18
- package/core/lib/pages/profile/themes-backup.json +310 -310
- package/core/lib/pages/profile/themes.json +254 -254
- package/core/lib/pages/register/register.js +176 -176
- package/core/lib/pages/register/register.scss +128 -128
- package/core/lib/react-styleguide.md +756 -756
- package/core/lib/utils/api/api.utils.js +188 -188
- package/core/lib/utils/api/readme.md +426 -426
- package/core/lib/utils/async.js +35 -35
- package/core/lib/utils/common/common.utils.js +123 -123
- package/core/lib/utils/common/readme.md +30 -30
- package/core/lib/utils/date/date.utils.js +295 -295
- package/core/lib/utils/date/readme.md +2 -2
- package/core/lib/utils/firebase.support.utils.js +98 -98
- package/core/lib/utils/firebase.utils.js +808 -808
- package/core/lib/utils/form/form.utils.js +255 -255
- package/core/lib/utils/generic/generic.utils.js +69 -69
- package/core/lib/utils/http/auth.helper.js +95 -95
- package/core/lib/utils/http/http.utils.js +157 -157
- package/core/lib/utils/http/readme.md +14 -14
- package/core/lib/utils/index.js +45 -45
- package/core/lib/utils/location/location.utils.js +137 -137
- package/core/lib/utils/location/readme.md +18 -18
- package/core/lib/utils/modal.utils.js +15 -15
- package/core/lib/utils/notification.utils.js +34 -34
- package/core/lib/utils/pwa/pwa.utils.js +88 -88
- package/core/lib/utils/script.utils.js +235 -235
- package/core/lib/utils/setting.utils.js +68 -68
- package/core/lib/utils/upload.utils.js +29 -29
- package/core/models/Preference/Preferences.js +46 -46
- package/core/models/base/base.js +399 -399
- package/core/models/base-clone-loader.js +107 -107
- package/core/models/base-clone.js +187 -187
- package/core/models/base-loader.js +97 -97
- package/core/models/core-scripts/core-scripts.js +150 -150
- package/core/models/dashboard/dashboard.js +201 -201
- package/core/models/detail-loader.js +88 -88
- package/core/models/doctor/components/doctor-add/doctor-add.js +422 -422
- package/core/models/doctor/components/doctor-add/doctor-add.scss +32 -32
- package/core/models/groups.js +82 -82
- package/core/models/index.js +100 -100
- package/core/models/lookup-types/components/lookup-detail/lookup-detail.js +129 -129
- package/core/models/lookup-types/lookup-types.js +96 -96
- package/core/models/lookup-values/components/lookup-values-modal/lookup-values-modal.js +95 -95
- package/core/models/lookup-values/lookup-values.js +92 -92
- package/core/models/menu-roles/components/menu-roles-add/menu-roles-add.js +153 -153
- package/core/models/menu-roles/menu-roles.js +158 -158
- package/core/models/menus/components/menu-add/menu-add.js +288 -288
- package/core/models/menus/components/menu-add/menu-add.scss +31 -31
- package/core/models/menus/components/menu-detail/menu-detail.js +263 -263
- package/core/models/menus/components/menu-list/menu-list.js +392 -392
- package/core/models/menus/components/menu-lists/menu-lists.js +585 -585
- package/core/models/menus/components/menu-lists/menu-lists.scss +46 -46
- package/core/models/menus/menus.js +291 -291
- package/core/models/model-columns.js +121 -121
- package/core/models/models/components/model-detail/model-add.js +120 -120
- package/core/models/models/components/model-detail/model-detail.js +133 -133
- package/core/models/models/models.js +154 -154
- package/core/models/pages/components/page-add/page-add.js +163 -163
- package/core/models/pages/components/page-add/page-add.scss +30 -30
- package/core/models/pages/components/page-details/page-details.js +209 -209
- package/core/models/pages/components/page-list/page-list.js +248 -248
- package/core/models/pages/pages.js +142 -142
- package/core/models/pages.js +142 -142
- package/core/models/roles/components/role-add/role-add.js +312 -312
- package/core/models/roles/components/role-add/role-add.scss +4 -4
- package/core/models/roles/components/role-list/role-list.js +386 -386
- package/core/models/roles/roles.js +205 -205
- package/core/models/staff/components/staff-add/staff-add.js +468 -464
- package/core/models/user-roles/components/user-roles-add/user-roles-add.js +149 -149
- package/core/models/user-roles/user-roles.js +99 -99
- package/core/models/users/components/assign-role/assign-role.js +300 -298
- package/core/models/users/components/assign-role/assign-role.scss +117 -117
- package/core/models/users/components/user-add/user-add.js +853 -853
- package/core/models/users/components/user-add/user-edit.js +89 -89
- package/core/models/users/components/user-detail/user-detail.js +236 -236
- package/core/models/users/components/user-list/user-list.js +397 -397
- package/core/models/users/users.js +353 -353
- package/core/modules/Informations/change-info/change-info.js +618 -618
- package/core/modules/Informations/change-info/change-info.scss +134 -134
- package/core/modules/dashboard/components/dashboard-card/animations.js +64 -64
- package/core/modules/dashboard/components/dashboard-card/dashboard-card.js +197 -197
- package/core/modules/dashboard/components/dashboard-card/menu-dashboard-card.js +430 -430
- package/core/modules/dashboard/components/dashboard-card/menu-dashboard-card.scss +59 -59
- package/core/modules/dashboard/components/pop-query-dashboard/pop-query-dashboard.js +66 -66
- package/core/modules/generic/components/generic-add/generic-add.js +121 -121
- package/core/modules/generic/components/generic-add/generic-add.scss +13 -13
- package/core/modules/generic/components/generic-add-modal/generic-add-modal.js +125 -125
- package/core/modules/generic/components/generic-add-modal/generic-add-modal.scss +13 -13
- package/core/modules/generic/components/generic-detail/generic-detail.js +184 -184
- package/core/modules/generic/components/generic-detail/generic-detail.scss +25 -25
- package/core/modules/generic/components/generic-edit/generic-edit.js +123 -123
- package/core/modules/generic/components/generic-list/generic-list.js +335 -335
- package/core/modules/generic/components/generic-list/generic-list.scss +35 -35
- package/core/modules/index.js +42 -42
- package/core/modules/module-routes/module-routes.js +37 -37
- package/core/modules/reporting/components/index.js +6 -6
- package/core/modules/reporting/components/reporting-dashboard/reporting-dashboard.js +1223 -1223
- package/core/modules/reporting/components/reporting-dashboard/reporting-dashboard.scss +171 -171
- package/core/modules/steps/action-buttons.js +76 -76
- package/core/modules/steps/action-buttons.scss +15 -15
- package/core/modules/steps/steps.js +379 -379
- package/core/modules/steps/steps.scss +159 -159
- package/core/modules/steps/timeline.js +54 -54
- package/core/pages/homepage-api/homepage-api.js +106 -106
- package/core/pages/homepage-api/homepage-api.scss +233 -233
- package/core/pages/homepage-api/menu-dashboard.js +169 -169
- package/core/pages/homepage-api/menu-dashboard.scss +11 -11
- package/core/translation.json +53 -53
- package/core/translations.json +19 -19
- package/core/utils/script.utils.js +129 -129
- package/core/utils/settings.utils.js +25 -25
- package/eslint.config.mjs +79 -79
- package/index.js +35 -35
- package/jest.config.js +7 -7
- package/jest.setup.js +1 -1
- package/package.json +123 -123
- package/tsconfig.json +26 -26
- package/webpack.config.js +173 -173
|
@@ -1,590 +1,590 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @author Ashique Mohammed
|
|
4
|
-
* @description Generic Form create accepts an array of fields to update any resource
|
|
5
|
-
* @version
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
// let forms = [{
|
|
10
|
-
// type: 'input'
|
|
11
|
-
// }, {
|
|
12
|
-
// type: 'tabs',
|
|
13
|
-
// tabs: [{}]
|
|
14
|
-
// }]
|
|
15
|
-
|
|
16
|
-
import React, { useState } from 'react';
|
|
17
|
-
|
|
18
|
-
import moment from 'moment';
|
|
19
|
-
|
|
20
|
-
import Button from '../../../../../lib/elements/basic/button/button';
|
|
21
|
-
|
|
22
|
-
import { Form, Input, Radio, InputNumber, DatePicker, TimePicker, Checkbox, Select, Row, Col, Tabs } from 'antd';
|
|
23
|
-
|
|
24
|
-
// import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
|
|
25
|
-
|
|
26
|
-
import FileUpload from './../../../../components/file-upload/file-upload';
|
|
27
|
-
|
|
28
|
-
import Camera from './../../../../components/camera/camera';
|
|
29
|
-
|
|
30
|
-
// import { ColumnHeightOutlined } from '@ant-design/icons';
|
|
31
|
-
|
|
32
|
-
import { DateUtils } from '../../../../utils';
|
|
33
|
-
|
|
34
|
-
import { FieldCustomizer, TabCustomizer, ReferenceSelect } from './../../../../';
|
|
35
|
-
|
|
36
|
-
import { prepareAndExecuteScript } from './../../../../utils/script.utils';
|
|
37
|
-
|
|
38
|
-
const { TextArea } = Input;
|
|
39
|
-
|
|
40
|
-
const { Option } = Select;
|
|
41
|
-
|
|
42
|
-
const { TabPane } = Tabs;
|
|
43
|
-
|
|
44
|
-
// const grid = 4;
|
|
45
|
-
|
|
46
|
-
import './form-creator.scss';
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Component accepts fields to render the necessary components and returns the values on submission
|
|
50
|
-
*
|
|
51
|
-
* @param {*} param0
|
|
52
|
-
* @returns
|
|
53
|
-
*/
|
|
54
|
-
function FormCreator({
|
|
55
|
-
/**If we want to change the existing information first we need the current information ie, selectedInformation*/
|
|
56
|
-
selectedInformation,
|
|
57
|
-
model,
|
|
58
|
-
formContent = {},
|
|
59
|
-
onSubmit,
|
|
60
|
-
fields = [],
|
|
61
|
-
callback,
|
|
62
|
-
layout,
|
|
63
|
-
// Below are arguments for use in form display
|
|
64
|
-
onFieldUpdate,
|
|
65
|
-
// onListUpdate,
|
|
66
|
-
onFieldRemove,
|
|
67
|
-
}) {
|
|
68
|
-
const [form] = Form.useForm();
|
|
69
|
-
|
|
70
|
-
let layoutValue;
|
|
71
|
-
|
|
72
|
-
if (layout) {
|
|
73
|
-
layoutValue = layout;
|
|
74
|
-
} else {
|
|
75
|
-
layoutValue = {
|
|
76
|
-
labelCol: { span: 12 },
|
|
77
|
-
wrapperCol: { span: 12 },
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Variable used for loading state
|
|
82
|
-
const [loading, setLoading] = useState(false);
|
|
83
|
-
|
|
84
|
-
// Variable stores the form body values
|
|
85
|
-
const [content, setContent] = useState(() => {
|
|
86
|
-
// Body for the files
|
|
87
|
-
let body = formContent || { [model.name]: {} };
|
|
88
|
-
|
|
89
|
-
fields.forEach((entry) => {
|
|
90
|
-
if (entry.transform) {
|
|
91
|
-
body[entry.field] = entry.transform(body[entry.field]);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// If its a date
|
|
95
|
-
if (['date'].indexOf(entry.type) !== -1 && formContent[entry.field]) {
|
|
96
|
-
body[entry.field] = DateUtils.getMomentObject(formContent[entry.field]);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
return body;
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Function handles trigger of onupload
|
|
105
|
-
*
|
|
106
|
-
* @param {*} element
|
|
107
|
-
* @param {*} attachments
|
|
108
|
-
*/
|
|
109
|
-
function onUpload(element, attachments) {
|
|
110
|
-
form.setFieldsValue({ [element.field]: attachments });
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Custom Listener for onchange of input
|
|
115
|
-
*
|
|
116
|
-
* @param {*} element
|
|
117
|
-
* @param {*} attachments
|
|
118
|
-
*/
|
|
119
|
-
function onChange(element, value) {
|
|
120
|
-
// Though we initially gave less respect to this method
|
|
121
|
-
// This is the game changer - 29/01/23
|
|
122
|
-
|
|
123
|
-
// Being able to listen to script , Bind onChange listeners to each input
|
|
124
|
-
// can avoid the need for building custom forms again
|
|
125
|
-
|
|
126
|
-
// console.log(element);
|
|
127
|
-
|
|
128
|
-
/** */
|
|
129
|
-
if (element.field) {
|
|
130
|
-
form.setFieldsValue({ [element.field]: value });
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// const onDragEnd = (result) => {
|
|
135
|
-
|
|
136
|
-
// onListUpdate(result.source, result.destination);
|
|
137
|
-
// }
|
|
138
|
-
|
|
139
|
-
// const getListStyle = (isDraggingOver) => ({
|
|
140
|
-
// // background: isDraggingOver ? 'lightblue' : '',
|
|
141
|
-
// boxShadow: isDraggingOver ? '0px 0px 5px 5px #eeeeee' : '',
|
|
142
|
-
|
|
143
|
-
// // padding: grid,
|
|
144
|
-
// // width: 250
|
|
145
|
-
// });
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Function triggered for any onChange of input
|
|
149
|
-
*
|
|
150
|
-
* @param {*} formFields
|
|
151
|
-
*/
|
|
152
|
-
const onFieldsChange = (formFields) => {
|
|
153
|
-
formFields.forEach((field) => {
|
|
154
|
-
if (field.name[0].includes('date')) {
|
|
155
|
-
// values[field.field] = new Timestamp(moment(field.value).valueOf());
|
|
156
|
-
// content[field.name[0]] = moment(field.value).format('DD/MM/YYYY');
|
|
157
|
-
} else {
|
|
158
|
-
// content[field.name[0]] = field.value;
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
// setContent({ ...content })
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Values Change
|
|
166
|
-
*
|
|
167
|
-
* @param {*} field
|
|
168
|
-
* @param {*} values
|
|
169
|
-
*/
|
|
170
|
-
const onValuesChange = async (field, values) => {
|
|
171
|
-
// Find the input that is changed
|
|
172
|
-
let key = Object.keys(field)[0];
|
|
173
|
-
|
|
174
|
-
// Configuration
|
|
175
|
-
let fieldConfiguration = fields.filter((config) => config.field === key)[0];
|
|
176
|
-
|
|
177
|
-
// We have to check if there is an onChange script for the field
|
|
178
|
-
if (fieldConfiguration.on_change) {
|
|
179
|
-
// Before Submit of form , execute the script
|
|
180
|
-
values = await prepareAndExecuteScript(values, null, fieldConfiguration.on_change);
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
return (
|
|
185
|
-
<section className="form-creator">
|
|
186
|
-
<div>
|
|
187
|
-
{/* <DragDropContext onDragEnd={onDragEnd}>
|
|
188
|
-
<Droppable droppableId="droppable">
|
|
189
|
-
|
|
190
|
-
{(provided, snapshot) => (
|
|
191
|
-
<div
|
|
192
|
-
ref={provided.innerRef}
|
|
193
|
-
style={getListStyle(snapshot.isDraggingOver)}
|
|
194
|
-
{...provided.droppableProps}
|
|
195
|
-
> */}
|
|
196
|
-
|
|
197
|
-
<Form
|
|
198
|
-
form={form}
|
|
199
|
-
// layout="inline"
|
|
200
|
-
{...layoutValue}
|
|
201
|
-
className="new-record"
|
|
202
|
-
name="new-record"
|
|
203
|
-
onFinish={(values) => {
|
|
204
|
-
setLoading(true);
|
|
205
|
-
|
|
206
|
-
// Do a screening to check if date fields are
|
|
207
|
-
fields.forEach((field) => {
|
|
208
|
-
if (field.field && field.field.includes('date')) {
|
|
209
|
-
// values[field.field] = new Timestamp(new Date());
|
|
210
|
-
|
|
211
|
-
values[field.field] = moment(values[field.field]).valueOf();
|
|
212
|
-
} else {
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (field.type === 'time') {
|
|
216
|
-
// values[field.field] = new Timestamp(new Date());
|
|
217
|
-
|
|
218
|
-
values[field.field] = moment(values[field.field]).format('HH:mm A');
|
|
219
|
-
} else {
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
onSubmit(values).then(() => {
|
|
224
|
-
setLoading(false);
|
|
225
|
-
});
|
|
226
|
-
}}
|
|
227
|
-
onFieldsChange={onFieldsChange}
|
|
228
|
-
onValuesChange={onValuesChange}
|
|
229
|
-
layout={layoutValue}
|
|
230
|
-
// validateMessages={validateMessages}
|
|
231
|
-
initialValues={{
|
|
232
|
-
...content,
|
|
233
|
-
remarks: '',
|
|
234
|
-
}}
|
|
235
|
-
>
|
|
236
|
-
{/* Mapper maps each fields to build the form */}
|
|
237
|
-
<FieldMapper
|
|
238
|
-
fields={fields}
|
|
239
|
-
onChange={onChange}
|
|
240
|
-
selectedInformation={selectedInformation}
|
|
241
|
-
onUpload={onUpload}
|
|
242
|
-
onFieldUpdate={onFieldUpdate}
|
|
243
|
-
onFieldRemove={onFieldRemove}
|
|
244
|
-
formContent={formContent}
|
|
245
|
-
/>
|
|
246
|
-
|
|
247
|
-
{/* Mapper Ends */}
|
|
248
|
-
|
|
249
|
-
<Button loading={loading} type="primary" htmlType="submit" className="submit-button">
|
|
250
|
-
SUBMIT
|
|
251
|
-
</Button>
|
|
252
|
-
</Form>
|
|
253
|
-
</div>
|
|
254
|
-
{/* </div>)}
|
|
255
|
-
|
|
256
|
-
</Droppable>
|
|
257
|
-
</DragDropContext> */}
|
|
258
|
-
</section>
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
export default FormCreator;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Field Mapper accepts fields to build the form
|
|
266
|
-
*
|
|
267
|
-
* @param {*} param0
|
|
268
|
-
* @returns
|
|
269
|
-
*/
|
|
270
|
-
function FieldMapper({ fields = [], onChange, selectedInformation, onUpload, onFieldUpdate, onFieldRemove, formContent }) {
|
|
271
|
-
return (
|
|
272
|
-
<>
|
|
273
|
-
{fields.map((field, index) => {
|
|
274
|
-
// For Tabs
|
|
275
|
-
if (field.type === 'Tabs') {
|
|
276
|
-
return (
|
|
277
|
-
<Tabs defaultActiveKey="0">
|
|
278
|
-
{field.tabs.map((tab, tabIndex) => {
|
|
279
|
-
return (
|
|
280
|
-
<TabPane tab={`${tab.caption}`} key={tabIndex}>
|
|
281
|
-
{/* Customizes the Tab */}
|
|
282
|
-
<TabCustomizer
|
|
283
|
-
tab={tab}
|
|
284
|
-
field={field}
|
|
285
|
-
onFieldUpdate={onFieldUpdate}
|
|
286
|
-
fieldIndex={tabIndex}
|
|
287
|
-
index={index}
|
|
288
|
-
onFieldRemove={onFieldRemove}
|
|
289
|
-
/>
|
|
290
|
-
{/* Customizes the Tab Ends */}
|
|
291
|
-
|
|
292
|
-
{/* Mapper maps each fields to build the form */}
|
|
293
|
-
<FieldMapper
|
|
294
|
-
fields={tab.fields}
|
|
295
|
-
onChange={onChange}
|
|
296
|
-
onUpload={onUpload}
|
|
297
|
-
onFieldUpdate={onFieldUpdate}
|
|
298
|
-
onFieldRemove={onFieldRemove}
|
|
299
|
-
/>
|
|
300
|
-
</TabPane>
|
|
301
|
-
);
|
|
302
|
-
})}
|
|
303
|
-
</Tabs>
|
|
304
|
-
);
|
|
305
|
-
} else {
|
|
306
|
-
if (field.condition) {
|
|
307
|
-
return field.condition(content) ? (
|
|
308
|
-
<UserInput
|
|
309
|
-
onChange={onChange}
|
|
310
|
-
index={index}
|
|
311
|
-
key={index}
|
|
312
|
-
onUpload={onUpload}
|
|
313
|
-
field={field}
|
|
314
|
-
onFieldUpdate={onFieldUpdate}
|
|
315
|
-
onFieldRemove={onFieldRemove}
|
|
316
|
-
formContent={formContent}
|
|
317
|
-
/>
|
|
318
|
-
) : null;
|
|
319
|
-
} else {
|
|
320
|
-
return (
|
|
321
|
-
<UserInput
|
|
322
|
-
onChange={onChange}
|
|
323
|
-
key={index}
|
|
324
|
-
selectedInformation={selectedInformation}
|
|
325
|
-
index={index}
|
|
326
|
-
field={field}
|
|
327
|
-
onUpload={onUpload}
|
|
328
|
-
onFieldUpdate={onFieldUpdate}
|
|
329
|
-
onFieldRemove={onFieldRemove}
|
|
330
|
-
formContent={formContent}
|
|
331
|
-
/>
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
})}
|
|
336
|
-
</>
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* Component accepts user input according to type
|
|
342
|
-
*
|
|
343
|
-
* @param {*} param0
|
|
344
|
-
*/
|
|
345
|
-
function UserInput({ field, onUpload, selectedInformation, onChange, onFieldUpdate, onFieldRemove, index, formContent }) {
|
|
346
|
-
let props = {};
|
|
347
|
-
|
|
348
|
-
// The extra text
|
|
349
|
-
if (field.extra) {
|
|
350
|
-
props.extra = field.extra;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
const isVisible = field.visible !== undefined ? field.visible : true;
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* According to the type render each element
|
|
357
|
-
*
|
|
358
|
-
* @param {*} field
|
|
359
|
-
*/
|
|
360
|
-
const inputElement = (field, onChange) => {
|
|
361
|
-
if (field.visible) {
|
|
362
|
-
if (field.visible === false) return null;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
switch (field.type) {
|
|
366
|
-
case 'number':
|
|
367
|
-
return <InputNumber required={field.required} />;
|
|
368
|
-
|
|
369
|
-
case 'input':
|
|
370
|
-
return <Input required={field.required} />;
|
|
371
|
-
|
|
372
|
-
case 'radio':
|
|
373
|
-
return (
|
|
374
|
-
<Radio.Group>
|
|
375
|
-
{field.options.map((option, key) => (
|
|
376
|
-
<Radio key={key} value={option}>
|
|
377
|
-
{option ? 'Yes' : 'No'}
|
|
378
|
-
</Radio>
|
|
379
|
-
))}
|
|
380
|
-
</Radio.Group>
|
|
381
|
-
);
|
|
382
|
-
|
|
383
|
-
case 'checkbox':
|
|
384
|
-
return (
|
|
385
|
-
<Checkbox.Group style={{ width: '100%' }}>
|
|
386
|
-
<Col>
|
|
387
|
-
{field.options.map((option, key) => {
|
|
388
|
-
let opt = typeof option === 'string' ? option : option.value;
|
|
389
|
-
|
|
390
|
-
return (
|
|
391
|
-
<Row>
|
|
392
|
-
<Checkbox key={key} value={opt}>
|
|
393
|
-
{opt}
|
|
394
|
-
</Checkbox>
|
|
395
|
-
</Row>
|
|
396
|
-
);
|
|
397
|
-
})}
|
|
398
|
-
</Col>
|
|
399
|
-
</Checkbox.Group>
|
|
400
|
-
);
|
|
401
|
-
|
|
402
|
-
// case 'checkbox':
|
|
403
|
-
// return <Checkbox.Group options={field.options}/>
|
|
404
|
-
case 'textarea':
|
|
405
|
-
return <TextArea rows={4} required={field.required} />;
|
|
406
|
-
|
|
407
|
-
case 'boolean':
|
|
408
|
-
return (
|
|
409
|
-
<Select style={{ width: 120 }} required={field.required}>
|
|
410
|
-
{[true, false].map((option, key) => (
|
|
411
|
-
<Option key={key} value={option}>
|
|
412
|
-
{option ? 'Yes' : 'No'}
|
|
413
|
-
</Option>
|
|
414
|
-
))}
|
|
415
|
-
</Select>
|
|
416
|
-
);
|
|
417
|
-
|
|
418
|
-
case 'select':
|
|
419
|
-
// Handle static select options
|
|
420
|
-
if (Array.isArray(field.options)) {
|
|
421
|
-
let defaultValue = field.default ? field.default : '';
|
|
422
|
-
|
|
423
|
-
/**If there is selected Information ie, for change info if there is selected guest information
|
|
424
|
-
* then we will match and set a default value from the guest details
|
|
425
|
-
*/
|
|
426
|
-
if (selectedInformation) {
|
|
427
|
-
// Get the field value dynamically from selectedInformation[0] using field.field
|
|
428
|
-
const fieldValue = selectedInformation[0] && selectedInformation[0][field.caption];
|
|
429
|
-
|
|
430
|
-
// Find the default value based on field value and matching DisplayMember or description
|
|
431
|
-
const defaultOption = field.options.find((option) => option.displayMember?.toLowerCase() === fieldValue?.toLowerCase());
|
|
432
|
-
|
|
433
|
-
// If a matching option is found, set the default value; otherwise, do not set a default value (i.e., null or undefined)
|
|
434
|
-
defaultValue = defaultOption ? defaultOption.valueMember : null;
|
|
435
|
-
}
|
|
436
|
-
/**In case of default selection we need to call the onchange manually */
|
|
437
|
-
if (defaultValue) {
|
|
438
|
-
onChange(field, defaultValue);
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
return (
|
|
442
|
-
<Select defaultValue={defaultValue} required={field.required} style={{ width: 120 }} onChange={(value) => onChange(field, value)}>
|
|
443
|
-
{field.options.map((option, key) => (
|
|
444
|
-
<Option key={key} value={option.valueMember}>
|
|
445
|
-
{option.displayMember}
|
|
446
|
-
</Option>
|
|
447
|
-
))}
|
|
448
|
-
</Select>
|
|
449
|
-
);
|
|
450
|
-
}
|
|
451
|
-
// case 'checkbox':
|
|
452
|
-
// return <Checkbox.Group options={field.options} />
|
|
453
|
-
case 'reference-select':
|
|
454
|
-
// If a default value is provided in the field configuration
|
|
455
|
-
if (field.default) {
|
|
456
|
-
onChange(field, field.default);
|
|
457
|
-
}
|
|
458
|
-
// Render the ReferenceSelect component
|
|
459
|
-
|
|
460
|
-
return (
|
|
461
|
-
<ReferenceSelect
|
|
462
|
-
style={{ width: 120 }}
|
|
463
|
-
field={field.code}
|
|
464
|
-
model={formContent[field.modelName]}
|
|
465
|
-
{...field}
|
|
466
|
-
onChange={(value) => onChange(field, value)}
|
|
467
|
-
defaultValue={field.default}
|
|
468
|
-
allowClear={true}
|
|
469
|
-
// defaultValue={'1'}
|
|
470
|
-
/>
|
|
471
|
-
);
|
|
472
|
-
|
|
473
|
-
case 'datetime':
|
|
474
|
-
return (
|
|
475
|
-
<DatePicker
|
|
476
|
-
format={'DD/MM/YYYY'}
|
|
477
|
-
onChange={(record) => {
|
|
478
|
-
onChange(field, record.format('DD/MM/YYYY'));
|
|
479
|
-
}}
|
|
480
|
-
/>
|
|
481
|
-
);
|
|
482
|
-
|
|
483
|
-
case 'date':
|
|
484
|
-
return <DatePicker format={'DD/MM/YYYY'} />;
|
|
485
|
-
|
|
486
|
-
case 'time':
|
|
487
|
-
return <TimePicker format={'HH:mm A'} />;
|
|
488
|
-
|
|
489
|
-
// onChange={(record) => {
|
|
490
|
-
|
|
491
|
-
// console.log(record);
|
|
492
|
-
|
|
493
|
-
// onChange(field, record.format('HH:mm A'))
|
|
494
|
-
|
|
495
|
-
// }}
|
|
496
|
-
|
|
497
|
-
case 'upload':
|
|
498
|
-
return (
|
|
499
|
-
<FileUpload
|
|
500
|
-
multiple={field.multiple}
|
|
501
|
-
maxSize={field.maxSize || 3}
|
|
502
|
-
callback={(attachment) => onUpload(field, attachment)}
|
|
503
|
-
onProgress={() => {}}
|
|
504
|
-
/>
|
|
505
|
-
);
|
|
506
|
-
|
|
507
|
-
case 'camera':
|
|
508
|
-
return <Camera />;
|
|
509
|
-
|
|
510
|
-
default:
|
|
511
|
-
return <Input />;
|
|
512
|
-
}
|
|
513
|
-
};
|
|
514
|
-
|
|
515
|
-
// const getItemStyle = (draggableStyle, isDragging) => ({
|
|
516
|
-
// // some basic styles to make the items look a bit nicer
|
|
517
|
-
// userSelect: 'none',
|
|
518
|
-
// // padding: grid,
|
|
519
|
-
// // margin: `0 0 ${grid}px 0`,
|
|
520
|
-
// // position: `absolute`,
|
|
521
|
-
// // right: '40px',
|
|
522
|
-
|
|
523
|
-
// // change background colour if dragging
|
|
524
|
-
// // background: isDragging ? 'lightgreen' : 'whitesmoke',
|
|
525
|
-
|
|
526
|
-
// boxShadow: isDragging ? '0px 0px 5px 5px #eeeeee' : '',
|
|
527
|
-
|
|
528
|
-
// // styles we need to apply on draggables
|
|
529
|
-
// ...draggableStyle
|
|
530
|
-
// });
|
|
531
|
-
|
|
532
|
-
return (
|
|
533
|
-
<>
|
|
534
|
-
{/* <Draggable
|
|
535
|
-
key={`${field.caption}-${index}`}
|
|
536
|
-
draggableId={`${field.caption}-${index}`}
|
|
537
|
-
index={index}
|
|
538
|
-
>
|
|
539
|
-
{(provided, snapshot) => (
|
|
540
|
-
<div>
|
|
541
|
-
<div
|
|
542
|
-
|
|
543
|
-
ref={provided.innerRef}
|
|
544
|
-
{...provided.dragHandleProps}
|
|
545
|
-
{...provided.draggableProps}
|
|
546
|
-
style={getItemStyle(
|
|
547
|
-
provided.draggableProps.style,
|
|
548
|
-
snapshot.isDragging
|
|
549
|
-
)}
|
|
550
|
-
|
|
551
|
-
> */}
|
|
552
|
-
{isVisible === true ? (
|
|
553
|
-
<div className="form-item-element">
|
|
554
|
-
{/* <Button
|
|
555
|
-
size="small"
|
|
556
|
-
ref={provided.innerRef}
|
|
557
|
-
{...provided.dragHandleProps}
|
|
558
|
-
{...provided.draggableProps}
|
|
559
|
-
style={getItemStyle(
|
|
560
|
-
provided.draggableProps.style,
|
|
561
|
-
snapshot.isDragging
|
|
562
|
-
)}
|
|
563
|
-
>
|
|
564
|
-
|
|
565
|
-
<ColumnHeightOutlined />
|
|
566
|
-
|
|
567
|
-
</Button> */}
|
|
568
|
-
|
|
569
|
-
{/* Customizes the form */}
|
|
570
|
-
<FieldCustomizer field={field} onFieldUpdate={onFieldUpdate} index={index} onFieldRemove={onFieldRemove} />
|
|
571
|
-
{/* Customizes the form Ends */}
|
|
572
|
-
|
|
573
|
-
<Form.Item
|
|
574
|
-
{...props}
|
|
575
|
-
name={field.field}
|
|
576
|
-
label={field.caption}
|
|
577
|
-
rules={[{ required: field.required, message: field.placeholder || 'Please enter ' + field.caption }]}
|
|
578
|
-
>
|
|
579
|
-
{inputElement(field, onChange)}
|
|
580
|
-
{/* <InputElement field={field} /> */}
|
|
581
|
-
</Form.Item>
|
|
582
|
-
</div>
|
|
583
|
-
) : null}
|
|
584
|
-
{/* </div>
|
|
585
|
-
</div>
|
|
586
|
-
)}
|
|
587
|
-
</Draggable> */}
|
|
588
|
-
</>
|
|
589
|
-
);
|
|
590
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @author Ashique Mohammed
|
|
4
|
+
* @description Generic Form create accepts an array of fields to update any resource
|
|
5
|
+
* @version
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// let forms = [{
|
|
10
|
+
// type: 'input'
|
|
11
|
+
// }, {
|
|
12
|
+
// type: 'tabs',
|
|
13
|
+
// tabs: [{}]
|
|
14
|
+
// }]
|
|
15
|
+
|
|
16
|
+
import React, { useState } from 'react';
|
|
17
|
+
|
|
18
|
+
import moment from 'moment';
|
|
19
|
+
|
|
20
|
+
import Button from '../../../../../lib/elements/basic/button/button';
|
|
21
|
+
|
|
22
|
+
import { Form, Input, Radio, InputNumber, DatePicker, TimePicker, Checkbox, Select, Row, Col, Tabs } from 'antd';
|
|
23
|
+
|
|
24
|
+
// import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
|
|
25
|
+
|
|
26
|
+
import FileUpload from './../../../../components/file-upload/file-upload';
|
|
27
|
+
|
|
28
|
+
import Camera from './../../../../components/camera/camera';
|
|
29
|
+
|
|
30
|
+
// import { ColumnHeightOutlined } from '@ant-design/icons';
|
|
31
|
+
|
|
32
|
+
import { DateUtils } from '../../../../utils';
|
|
33
|
+
|
|
34
|
+
import { FieldCustomizer, TabCustomizer, ReferenceSelect } from './../../../../';
|
|
35
|
+
|
|
36
|
+
import { prepareAndExecuteScript } from './../../../../utils/script.utils';
|
|
37
|
+
|
|
38
|
+
const { TextArea } = Input;
|
|
39
|
+
|
|
40
|
+
const { Option } = Select;
|
|
41
|
+
|
|
42
|
+
const { TabPane } = Tabs;
|
|
43
|
+
|
|
44
|
+
// const grid = 4;
|
|
45
|
+
|
|
46
|
+
import './form-creator.scss';
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Component accepts fields to render the necessary components and returns the values on submission
|
|
50
|
+
*
|
|
51
|
+
* @param {*} param0
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
function FormCreator({
|
|
55
|
+
/**If we want to change the existing information first we need the current information ie, selectedInformation*/
|
|
56
|
+
selectedInformation,
|
|
57
|
+
model,
|
|
58
|
+
formContent = {},
|
|
59
|
+
onSubmit,
|
|
60
|
+
fields = [],
|
|
61
|
+
callback,
|
|
62
|
+
layout,
|
|
63
|
+
// Below are arguments for use in form display
|
|
64
|
+
onFieldUpdate,
|
|
65
|
+
// onListUpdate,
|
|
66
|
+
onFieldRemove,
|
|
67
|
+
}) {
|
|
68
|
+
const [form] = Form.useForm();
|
|
69
|
+
|
|
70
|
+
let layoutValue;
|
|
71
|
+
|
|
72
|
+
if (layout) {
|
|
73
|
+
layoutValue = layout;
|
|
74
|
+
} else {
|
|
75
|
+
layoutValue = {
|
|
76
|
+
labelCol: { span: 12 },
|
|
77
|
+
wrapperCol: { span: 12 },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Variable used for loading state
|
|
82
|
+
const [loading, setLoading] = useState(false);
|
|
83
|
+
|
|
84
|
+
// Variable stores the form body values
|
|
85
|
+
const [content, setContent] = useState(() => {
|
|
86
|
+
// Body for the files
|
|
87
|
+
let body = formContent || { [model.name]: {} };
|
|
88
|
+
|
|
89
|
+
fields.forEach((entry) => {
|
|
90
|
+
if (entry.transform) {
|
|
91
|
+
body[entry.field] = entry.transform(body[entry.field]);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// If its a date
|
|
95
|
+
if (['date'].indexOf(entry.type) !== -1 && formContent[entry.field]) {
|
|
96
|
+
body[entry.field] = DateUtils.getMomentObject(formContent[entry.field]);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return body;
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Function handles trigger of onupload
|
|
105
|
+
*
|
|
106
|
+
* @param {*} element
|
|
107
|
+
* @param {*} attachments
|
|
108
|
+
*/
|
|
109
|
+
function onUpload(element, attachments) {
|
|
110
|
+
form.setFieldsValue({ [element.field]: attachments });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Custom Listener for onchange of input
|
|
115
|
+
*
|
|
116
|
+
* @param {*} element
|
|
117
|
+
* @param {*} attachments
|
|
118
|
+
*/
|
|
119
|
+
function onChange(element, value) {
|
|
120
|
+
// Though we initially gave less respect to this method
|
|
121
|
+
// This is the game changer - 29/01/23
|
|
122
|
+
|
|
123
|
+
// Being able to listen to script , Bind onChange listeners to each input
|
|
124
|
+
// can avoid the need for building custom forms again
|
|
125
|
+
|
|
126
|
+
// console.log(element);
|
|
127
|
+
|
|
128
|
+
/** */
|
|
129
|
+
if (element.field) {
|
|
130
|
+
form.setFieldsValue({ [element.field]: value });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// const onDragEnd = (result) => {
|
|
135
|
+
|
|
136
|
+
// onListUpdate(result.source, result.destination);
|
|
137
|
+
// }
|
|
138
|
+
|
|
139
|
+
// const getListStyle = (isDraggingOver) => ({
|
|
140
|
+
// // background: isDraggingOver ? 'lightblue' : '',
|
|
141
|
+
// boxShadow: isDraggingOver ? '0px 0px 5px 5px #eeeeee' : '',
|
|
142
|
+
|
|
143
|
+
// // padding: grid,
|
|
144
|
+
// // width: 250
|
|
145
|
+
// });
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Function triggered for any onChange of input
|
|
149
|
+
*
|
|
150
|
+
* @param {*} formFields
|
|
151
|
+
*/
|
|
152
|
+
const onFieldsChange = (formFields) => {
|
|
153
|
+
formFields.forEach((field) => {
|
|
154
|
+
if (field.name[0].includes('date')) {
|
|
155
|
+
// values[field.field] = new Timestamp(moment(field.value).valueOf());
|
|
156
|
+
// content[field.name[0]] = moment(field.value).format('DD/MM/YYYY');
|
|
157
|
+
} else {
|
|
158
|
+
// content[field.name[0]] = field.value;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
// setContent({ ...content })
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Values Change
|
|
166
|
+
*
|
|
167
|
+
* @param {*} field
|
|
168
|
+
* @param {*} values
|
|
169
|
+
*/
|
|
170
|
+
const onValuesChange = async (field, values) => {
|
|
171
|
+
// Find the input that is changed
|
|
172
|
+
let key = Object.keys(field)[0];
|
|
173
|
+
|
|
174
|
+
// Configuration
|
|
175
|
+
let fieldConfiguration = fields.filter((config) => config.field === key)[0];
|
|
176
|
+
|
|
177
|
+
// We have to check if there is an onChange script for the field
|
|
178
|
+
if (fieldConfiguration.on_change) {
|
|
179
|
+
// Before Submit of form , execute the script
|
|
180
|
+
values = await prepareAndExecuteScript(values, null, fieldConfiguration.on_change);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<section className="form-creator">
|
|
186
|
+
<div>
|
|
187
|
+
{/* <DragDropContext onDragEnd={onDragEnd}>
|
|
188
|
+
<Droppable droppableId="droppable">
|
|
189
|
+
|
|
190
|
+
{(provided, snapshot) => (
|
|
191
|
+
<div
|
|
192
|
+
ref={provided.innerRef}
|
|
193
|
+
style={getListStyle(snapshot.isDraggingOver)}
|
|
194
|
+
{...provided.droppableProps}
|
|
195
|
+
> */}
|
|
196
|
+
|
|
197
|
+
<Form
|
|
198
|
+
form={form}
|
|
199
|
+
// layout="inline"
|
|
200
|
+
{...layoutValue}
|
|
201
|
+
className="new-record"
|
|
202
|
+
name="new-record"
|
|
203
|
+
onFinish={(values) => {
|
|
204
|
+
setLoading(true);
|
|
205
|
+
|
|
206
|
+
// Do a screening to check if date fields are
|
|
207
|
+
fields.forEach((field) => {
|
|
208
|
+
if (field.field && field.field.includes('date')) {
|
|
209
|
+
// values[field.field] = new Timestamp(new Date());
|
|
210
|
+
|
|
211
|
+
values[field.field] = moment(values[field.field]).valueOf();
|
|
212
|
+
} else {
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (field.type === 'time') {
|
|
216
|
+
// values[field.field] = new Timestamp(new Date());
|
|
217
|
+
|
|
218
|
+
values[field.field] = moment(values[field.field]).format('HH:mm A');
|
|
219
|
+
} else {
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
onSubmit(values).then(() => {
|
|
224
|
+
setLoading(false);
|
|
225
|
+
});
|
|
226
|
+
}}
|
|
227
|
+
onFieldsChange={onFieldsChange}
|
|
228
|
+
onValuesChange={onValuesChange}
|
|
229
|
+
layout={layoutValue}
|
|
230
|
+
// validateMessages={validateMessages}
|
|
231
|
+
initialValues={{
|
|
232
|
+
...content,
|
|
233
|
+
remarks: '',
|
|
234
|
+
}}
|
|
235
|
+
>
|
|
236
|
+
{/* Mapper maps each fields to build the form */}
|
|
237
|
+
<FieldMapper
|
|
238
|
+
fields={fields}
|
|
239
|
+
onChange={onChange}
|
|
240
|
+
selectedInformation={selectedInformation}
|
|
241
|
+
onUpload={onUpload}
|
|
242
|
+
onFieldUpdate={onFieldUpdate}
|
|
243
|
+
onFieldRemove={onFieldRemove}
|
|
244
|
+
formContent={formContent}
|
|
245
|
+
/>
|
|
246
|
+
|
|
247
|
+
{/* Mapper Ends */}
|
|
248
|
+
|
|
249
|
+
<Button loading={loading} type="primary" htmlType="submit" className="submit-button">
|
|
250
|
+
SUBMIT
|
|
251
|
+
</Button>
|
|
252
|
+
</Form>
|
|
253
|
+
</div>
|
|
254
|
+
{/* </div>)}
|
|
255
|
+
|
|
256
|
+
</Droppable>
|
|
257
|
+
</DragDropContext> */}
|
|
258
|
+
</section>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export default FormCreator;
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Field Mapper accepts fields to build the form
|
|
266
|
+
*
|
|
267
|
+
* @param {*} param0
|
|
268
|
+
* @returns
|
|
269
|
+
*/
|
|
270
|
+
function FieldMapper({ fields = [], onChange, selectedInformation, onUpload, onFieldUpdate, onFieldRemove, formContent }) {
|
|
271
|
+
return (
|
|
272
|
+
<>
|
|
273
|
+
{fields.map((field, index) => {
|
|
274
|
+
// For Tabs
|
|
275
|
+
if (field.type === 'Tabs') {
|
|
276
|
+
return (
|
|
277
|
+
<Tabs defaultActiveKey="0">
|
|
278
|
+
{field.tabs.map((tab, tabIndex) => {
|
|
279
|
+
return (
|
|
280
|
+
<TabPane tab={`${tab.caption}`} key={tabIndex}>
|
|
281
|
+
{/* Customizes the Tab */}
|
|
282
|
+
<TabCustomizer
|
|
283
|
+
tab={tab}
|
|
284
|
+
field={field}
|
|
285
|
+
onFieldUpdate={onFieldUpdate}
|
|
286
|
+
fieldIndex={tabIndex}
|
|
287
|
+
index={index}
|
|
288
|
+
onFieldRemove={onFieldRemove}
|
|
289
|
+
/>
|
|
290
|
+
{/* Customizes the Tab Ends */}
|
|
291
|
+
|
|
292
|
+
{/* Mapper maps each fields to build the form */}
|
|
293
|
+
<FieldMapper
|
|
294
|
+
fields={tab.fields}
|
|
295
|
+
onChange={onChange}
|
|
296
|
+
onUpload={onUpload}
|
|
297
|
+
onFieldUpdate={onFieldUpdate}
|
|
298
|
+
onFieldRemove={onFieldRemove}
|
|
299
|
+
/>
|
|
300
|
+
</TabPane>
|
|
301
|
+
);
|
|
302
|
+
})}
|
|
303
|
+
</Tabs>
|
|
304
|
+
);
|
|
305
|
+
} else {
|
|
306
|
+
if (field.condition) {
|
|
307
|
+
return field.condition(content) ? (
|
|
308
|
+
<UserInput
|
|
309
|
+
onChange={onChange}
|
|
310
|
+
index={index}
|
|
311
|
+
key={index}
|
|
312
|
+
onUpload={onUpload}
|
|
313
|
+
field={field}
|
|
314
|
+
onFieldUpdate={onFieldUpdate}
|
|
315
|
+
onFieldRemove={onFieldRemove}
|
|
316
|
+
formContent={formContent}
|
|
317
|
+
/>
|
|
318
|
+
) : null;
|
|
319
|
+
} else {
|
|
320
|
+
return (
|
|
321
|
+
<UserInput
|
|
322
|
+
onChange={onChange}
|
|
323
|
+
key={index}
|
|
324
|
+
selectedInformation={selectedInformation}
|
|
325
|
+
index={index}
|
|
326
|
+
field={field}
|
|
327
|
+
onUpload={onUpload}
|
|
328
|
+
onFieldUpdate={onFieldUpdate}
|
|
329
|
+
onFieldRemove={onFieldRemove}
|
|
330
|
+
formContent={formContent}
|
|
331
|
+
/>
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
})}
|
|
336
|
+
</>
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Component accepts user input according to type
|
|
342
|
+
*
|
|
343
|
+
* @param {*} param0
|
|
344
|
+
*/
|
|
345
|
+
function UserInput({ field, onUpload, selectedInformation, onChange, onFieldUpdate, onFieldRemove, index, formContent }) {
|
|
346
|
+
let props = {};
|
|
347
|
+
|
|
348
|
+
// The extra text
|
|
349
|
+
if (field.extra) {
|
|
350
|
+
props.extra = field.extra;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
const isVisible = field.visible !== undefined ? field.visible : true;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* According to the type render each element
|
|
357
|
+
*
|
|
358
|
+
* @param {*} field
|
|
359
|
+
*/
|
|
360
|
+
const inputElement = (field, onChange) => {
|
|
361
|
+
if (field.visible) {
|
|
362
|
+
if (field.visible === false) return null;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
switch (field.type) {
|
|
366
|
+
case 'number':
|
|
367
|
+
return <InputNumber required={field.required} />;
|
|
368
|
+
|
|
369
|
+
case 'input':
|
|
370
|
+
return <Input required={field.required} />;
|
|
371
|
+
|
|
372
|
+
case 'radio':
|
|
373
|
+
return (
|
|
374
|
+
<Radio.Group>
|
|
375
|
+
{field.options.map((option, key) => (
|
|
376
|
+
<Radio key={key} value={option}>
|
|
377
|
+
{option ? 'Yes' : 'No'}
|
|
378
|
+
</Radio>
|
|
379
|
+
))}
|
|
380
|
+
</Radio.Group>
|
|
381
|
+
);
|
|
382
|
+
|
|
383
|
+
case 'checkbox':
|
|
384
|
+
return (
|
|
385
|
+
<Checkbox.Group style={{ width: '100%' }}>
|
|
386
|
+
<Col>
|
|
387
|
+
{field.options.map((option, key) => {
|
|
388
|
+
let opt = typeof option === 'string' ? option : option.value;
|
|
389
|
+
|
|
390
|
+
return (
|
|
391
|
+
<Row>
|
|
392
|
+
<Checkbox key={key} value={opt}>
|
|
393
|
+
{opt}
|
|
394
|
+
</Checkbox>
|
|
395
|
+
</Row>
|
|
396
|
+
);
|
|
397
|
+
})}
|
|
398
|
+
</Col>
|
|
399
|
+
</Checkbox.Group>
|
|
400
|
+
);
|
|
401
|
+
|
|
402
|
+
// case 'checkbox':
|
|
403
|
+
// return <Checkbox.Group options={field.options}/>
|
|
404
|
+
case 'textarea':
|
|
405
|
+
return <TextArea rows={4} required={field.required} />;
|
|
406
|
+
|
|
407
|
+
case 'boolean':
|
|
408
|
+
return (
|
|
409
|
+
<Select style={{ width: 120 }} required={field.required}>
|
|
410
|
+
{[true, false].map((option, key) => (
|
|
411
|
+
<Option key={key} value={option}>
|
|
412
|
+
{option ? 'Yes' : 'No'}
|
|
413
|
+
</Option>
|
|
414
|
+
))}
|
|
415
|
+
</Select>
|
|
416
|
+
);
|
|
417
|
+
|
|
418
|
+
case 'select':
|
|
419
|
+
// Handle static select options
|
|
420
|
+
if (Array.isArray(field.options)) {
|
|
421
|
+
let defaultValue = field.default ? field.default : '';
|
|
422
|
+
|
|
423
|
+
/**If there is selected Information ie, for change info if there is selected guest information
|
|
424
|
+
* then we will match and set a default value from the guest details
|
|
425
|
+
*/
|
|
426
|
+
if (selectedInformation) {
|
|
427
|
+
// Get the field value dynamically from selectedInformation[0] using field.field
|
|
428
|
+
const fieldValue = selectedInformation[0] && selectedInformation[0][field.caption];
|
|
429
|
+
|
|
430
|
+
// Find the default value based on field value and matching DisplayMember or description
|
|
431
|
+
const defaultOption = field.options.find((option) => option.displayMember?.toLowerCase() === fieldValue?.toLowerCase());
|
|
432
|
+
|
|
433
|
+
// If a matching option is found, set the default value; otherwise, do not set a default value (i.e., null or undefined)
|
|
434
|
+
defaultValue = defaultOption ? defaultOption.valueMember : null;
|
|
435
|
+
}
|
|
436
|
+
/**In case of default selection we need to call the onchange manually */
|
|
437
|
+
if (defaultValue) {
|
|
438
|
+
onChange(field, defaultValue);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
return (
|
|
442
|
+
<Select defaultValue={defaultValue} required={field.required} style={{ width: 120 }} onChange={(value) => onChange(field, value)}>
|
|
443
|
+
{field.options.map((option, key) => (
|
|
444
|
+
<Option key={key} value={option.valueMember}>
|
|
445
|
+
{option.displayMember}
|
|
446
|
+
</Option>
|
|
447
|
+
))}
|
|
448
|
+
</Select>
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
// case 'checkbox':
|
|
452
|
+
// return <Checkbox.Group options={field.options} />
|
|
453
|
+
case 'reference-select':
|
|
454
|
+
// If a default value is provided in the field configuration
|
|
455
|
+
if (field.default) {
|
|
456
|
+
onChange(field, field.default);
|
|
457
|
+
}
|
|
458
|
+
// Render the ReferenceSelect component
|
|
459
|
+
|
|
460
|
+
return (
|
|
461
|
+
<ReferenceSelect
|
|
462
|
+
style={{ width: 120 }}
|
|
463
|
+
field={field.code}
|
|
464
|
+
model={formContent[field.modelName]}
|
|
465
|
+
{...field}
|
|
466
|
+
onChange={(value) => onChange(field, value)}
|
|
467
|
+
defaultValue={field.default}
|
|
468
|
+
allowClear={true}
|
|
469
|
+
// defaultValue={'1'}
|
|
470
|
+
/>
|
|
471
|
+
);
|
|
472
|
+
|
|
473
|
+
case 'datetime':
|
|
474
|
+
return (
|
|
475
|
+
<DatePicker
|
|
476
|
+
format={'DD/MM/YYYY'}
|
|
477
|
+
onChange={(record) => {
|
|
478
|
+
onChange(field, record.format('DD/MM/YYYY'));
|
|
479
|
+
}}
|
|
480
|
+
/>
|
|
481
|
+
);
|
|
482
|
+
|
|
483
|
+
case 'date':
|
|
484
|
+
return <DatePicker format={'DD/MM/YYYY'} />;
|
|
485
|
+
|
|
486
|
+
case 'time':
|
|
487
|
+
return <TimePicker format={'HH:mm A'} />;
|
|
488
|
+
|
|
489
|
+
// onChange={(record) => {
|
|
490
|
+
|
|
491
|
+
// console.log(record);
|
|
492
|
+
|
|
493
|
+
// onChange(field, record.format('HH:mm A'))
|
|
494
|
+
|
|
495
|
+
// }}
|
|
496
|
+
|
|
497
|
+
case 'upload':
|
|
498
|
+
return (
|
|
499
|
+
<FileUpload
|
|
500
|
+
multiple={field.multiple}
|
|
501
|
+
maxSize={field.maxSize || 3}
|
|
502
|
+
callback={(attachment) => onUpload(field, attachment)}
|
|
503
|
+
onProgress={() => {}}
|
|
504
|
+
/>
|
|
505
|
+
);
|
|
506
|
+
|
|
507
|
+
case 'camera':
|
|
508
|
+
return <Camera />;
|
|
509
|
+
|
|
510
|
+
default:
|
|
511
|
+
return <Input />;
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
// const getItemStyle = (draggableStyle, isDragging) => ({
|
|
516
|
+
// // some basic styles to make the items look a bit nicer
|
|
517
|
+
// userSelect: 'none',
|
|
518
|
+
// // padding: grid,
|
|
519
|
+
// // margin: `0 0 ${grid}px 0`,
|
|
520
|
+
// // position: `absolute`,
|
|
521
|
+
// // right: '40px',
|
|
522
|
+
|
|
523
|
+
// // change background colour if dragging
|
|
524
|
+
// // background: isDragging ? 'lightgreen' : 'whitesmoke',
|
|
525
|
+
|
|
526
|
+
// boxShadow: isDragging ? '0px 0px 5px 5px #eeeeee' : '',
|
|
527
|
+
|
|
528
|
+
// // styles we need to apply on draggables
|
|
529
|
+
// ...draggableStyle
|
|
530
|
+
// });
|
|
531
|
+
|
|
532
|
+
return (
|
|
533
|
+
<>
|
|
534
|
+
{/* <Draggable
|
|
535
|
+
key={`${field.caption}-${index}`}
|
|
536
|
+
draggableId={`${field.caption}-${index}`}
|
|
537
|
+
index={index}
|
|
538
|
+
>
|
|
539
|
+
{(provided, snapshot) => (
|
|
540
|
+
<div>
|
|
541
|
+
<div
|
|
542
|
+
|
|
543
|
+
ref={provided.innerRef}
|
|
544
|
+
{...provided.dragHandleProps}
|
|
545
|
+
{...provided.draggableProps}
|
|
546
|
+
style={getItemStyle(
|
|
547
|
+
provided.draggableProps.style,
|
|
548
|
+
snapshot.isDragging
|
|
549
|
+
)}
|
|
550
|
+
|
|
551
|
+
> */}
|
|
552
|
+
{isVisible === true ? (
|
|
553
|
+
<div className="form-item-element">
|
|
554
|
+
{/* <Button
|
|
555
|
+
size="small"
|
|
556
|
+
ref={provided.innerRef}
|
|
557
|
+
{...provided.dragHandleProps}
|
|
558
|
+
{...provided.draggableProps}
|
|
559
|
+
style={getItemStyle(
|
|
560
|
+
provided.draggableProps.style,
|
|
561
|
+
snapshot.isDragging
|
|
562
|
+
)}
|
|
563
|
+
>
|
|
564
|
+
|
|
565
|
+
<ColumnHeightOutlined />
|
|
566
|
+
|
|
567
|
+
</Button> */}
|
|
568
|
+
|
|
569
|
+
{/* Customizes the form */}
|
|
570
|
+
<FieldCustomizer field={field} onFieldUpdate={onFieldUpdate} index={index} onFieldRemove={onFieldRemove} />
|
|
571
|
+
{/* Customizes the form Ends */}
|
|
572
|
+
|
|
573
|
+
<Form.Item
|
|
574
|
+
{...props}
|
|
575
|
+
name={field.field}
|
|
576
|
+
label={field.caption}
|
|
577
|
+
rules={[{ required: field.required, message: field.placeholder || 'Please enter ' + field.caption }]}
|
|
578
|
+
>
|
|
579
|
+
{inputElement(field, onChange)}
|
|
580
|
+
{/* <InputElement field={field} /> */}
|
|
581
|
+
</Form.Item>
|
|
582
|
+
</div>
|
|
583
|
+
) : null}
|
|
584
|
+
{/* </div>
|
|
585
|
+
</div>
|
|
586
|
+
)}
|
|
587
|
+
</Draggable> */}
|
|
588
|
+
</>
|
|
589
|
+
);
|
|
590
|
+
}
|