ui-soxo-bootstrap-core 2.6.59 → 2.6.62-dev.1

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