@unifylib/ui-lib 1.1.3 → 1.1.5

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 (286) hide show
  1. package/esm2022/iq-ui-lib.mjs +5 -0
  2. package/esm2022/lib/base-model/SearchStrConfig.mjs +11 -0
  3. package/esm2022/lib/base-model/api-response.mjs +2 -0
  4. package/esm2022/lib/base-model/audit-log-entry.mjs +3 -0
  5. package/esm2022/lib/base-model/button-action-settings.mjs +16 -0
  6. package/esm2022/lib/base-model/column-def.model.mjs +28 -0
  7. package/esm2022/lib/base-model/do-action-request.mjs +8 -0
  8. package/esm2022/lib/base-model/field-action.mjs +6 -0
  9. package/esm2022/lib/base-model/field-filter.model.mjs +3 -0
  10. package/esm2022/lib/base-model/field-info.mjs +57 -0
  11. package/esm2022/lib/base-model/field-predicate.model.mjs +10 -0
  12. package/esm2022/lib/base-model/filter-request.mjs +13 -0
  13. package/esm2022/lib/base-model/filter.model.mjs +25 -0
  14. package/esm2022/lib/base-model/get-items-list.mjs +10 -0
  15. package/esm2022/lib/base-model/index.mjs +12 -0
  16. package/esm2022/lib/base-model/items-total.model.mjs +8 -0
  17. package/esm2022/lib/base-model/line-item.model.mjs +11 -0
  18. package/esm2022/lib/base-model/lookupItem.mjs +16 -0
  19. package/esm2022/lib/base-model/page-info.mjs +17 -0
  20. package/esm2022/lib/base-model/report-request.model.mjs +17 -0
  21. package/esm2022/lib/base-model/response-envelop.model.mjs +10 -0
  22. package/esm2022/lib/base-model/snack-message.model.mjs +11 -0
  23. package/esm2022/lib/base-model/table-column.interface.mjs +2 -0
  24. package/esm2022/lib/base-model/table-page-user-action.interface.mjs +21 -0
  25. package/esm2022/lib/base-model/workflow/workflow-steps.model.mjs +9 -0
  26. package/esm2022/lib/base-model/workflow/workflow.model.mjs +42 -0
  27. package/esm2022/lib/components/action-comment/action-comment.component.mjs +101 -0
  28. package/esm2022/lib/components/action-confirmation/action-confirmation.component.mjs +55 -0
  29. package/esm2022/lib/components/activity-report-form/activity-report-form.component.mjs +499 -0
  30. package/esm2022/lib/components/advanced-filter/field-filter/field-filter.component.mjs +41 -0
  31. package/esm2022/lib/components/advanced-filter/filter-builder/filter-builder.component.mjs +162 -0
  32. package/esm2022/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.mjs +70 -0
  33. package/esm2022/lib/components/audit-log-list/audit-log.component.mjs +99 -0
  34. package/esm2022/lib/components/auto-complete/auto-complete.component.mjs +292 -0
  35. package/esm2022/lib/components/base-form/base-form.component.mjs +297 -0
  36. package/esm2022/lib/components/base-form-canvas/base-form-canvas.component.mjs +591 -0
  37. package/esm2022/lib/components/base-input-dialog/base-input-dialog.component.mjs +72 -0
  38. package/esm2022/lib/components/base-table/base-table.component.mjs +514 -0
  39. package/esm2022/lib/components/button-actions/button-actions.component.mjs +70 -0
  40. package/esm2022/lib/components/editable-base-table/editable-base-table.component.mjs +496 -0
  41. package/esm2022/lib/components/equation-builder/equation-builder.component.mjs +112 -0
  42. package/esm2022/lib/components/item-line-editor/item-line-editor.component.mjs +299 -0
  43. package/esm2022/lib/components/multi-auto-complete/multi-auto-complete.component.mjs +278 -0
  44. package/esm2022/lib/components/paginator/paginator.component.mjs +91 -0
  45. package/esm2022/lib/components/report-details-dialog/report-details-dialog.component.mjs +102 -0
  46. package/esm2022/lib/components/report-form/report-form.component.mjs +498 -0
  47. package/esm2022/lib/components/search-bar/search-bar.component.mjs +62 -0
  48. package/esm2022/lib/components/section-form-canvas/section-form-canvas.component.mjs +81 -0
  49. package/esm2022/lib/components/shared/action-button/action-button.component.mjs +59 -0
  50. package/esm2022/lib/components/shared/action-card/action-card.component.mjs +93 -0
  51. package/esm2022/lib/components/shared/attachment-uploader/attachment-uploader.component.mjs +70 -0
  52. package/esm2022/lib/components/shared-list/shared-list.component.mjs +47 -0
  53. package/esm2022/lib/components/snackbar-static/snackbar-static.component.mjs +43 -0
  54. package/esm2022/lib/components/title-bar/title-bar.component.mjs +119 -0
  55. package/esm2022/lib/services/backend-service.mjs +240 -0
  56. package/esm2022/lib/services/index.mjs +4 -0
  57. package/esm2022/lib/services/top-panel.mjs +22 -0
  58. package/esm2022/lib/services/trigger-form.service.mjs +17 -0
  59. package/esm2022/lib/utils/base-utils.mjs +97 -0
  60. package/esm2022/lib/validators/date-range-validator.mjs +27 -0
  61. package/esm2022/lib/validators/index.mjs +4 -0
  62. package/esm2022/lib/validators/match-list.validator.mjs +9 -0
  63. package/esm2022/lib/validators/multi-email-validator.mjs +13 -0
  64. package/esm2022/public-api.mjs +29 -0
  65. package/esm2022/q-btech-ui-lib.mjs +5 -0
  66. package/esm2022/unifylib-ui-lib.mjs +5 -0
  67. package/fesm2022/iq-ui-lib.mjs +5625 -0
  68. package/fesm2022/iq-ui-lib.mjs.map +1 -0
  69. package/fesm2022/q-btech-ui-lib.mjs +5619 -0
  70. package/fesm2022/q-btech-ui-lib.mjs.map +1 -0
  71. package/fesm2022/unifylib-ui-lib.mjs +5625 -0
  72. package/fesm2022/unifylib-ui-lib.mjs.map +1 -0
  73. package/index.d.ts +5 -0
  74. package/lib/base-model/SearchStrConfig.d.ts +8 -0
  75. package/{src/lib/base-model/api-response.ts → lib/base-model/api-response.d.ts} +21 -23
  76. package/lib/base-model/audit-log-entry.d.ts +7 -0
  77. package/lib/base-model/button-action-settings.d.ts +15 -0
  78. package/lib/base-model/column-def.model.d.ts +11 -0
  79. package/lib/base-model/do-action-request.d.ts +10 -0
  80. package/lib/base-model/field-action.d.ts +6 -0
  81. package/lib/base-model/field-filter.model.d.ts +7 -0
  82. package/lib/base-model/field-info.d.ts +53 -0
  83. package/lib/base-model/field-predicate.model.d.ts +7 -0
  84. package/lib/base-model/filter-request.d.ts +15 -0
  85. package/lib/base-model/filter.model.d.ts +22 -0
  86. package/lib/base-model/get-items-list.d.ts +21 -0
  87. package/lib/base-model/index.d.ts +11 -0
  88. package/lib/base-model/items-total.model.d.ts +6 -0
  89. package/lib/base-model/line-item.model.d.ts +9 -0
  90. package/lib/base-model/lookupItem.d.ts +13 -0
  91. package/lib/base-model/page-info.d.ts +52 -0
  92. package/lib/base-model/report-request.model.d.ts +18 -0
  93. package/lib/base-model/response-envelop.model.d.ts +8 -0
  94. package/lib/base-model/snack-message.model.d.ts +7 -0
  95. package/lib/base-model/table-column.interface.d.ts +28 -0
  96. package/lib/base-model/table-page-user-action.interface.d.ts +14 -0
  97. package/lib/base-model/workflow/workflow-steps.model.d.ts +7 -0
  98. package/lib/base-model/workflow/workflow.model.d.ts +13 -0
  99. package/lib/components/action-comment/action-comment.component.d.ts +32 -0
  100. package/lib/components/action-confirmation/action-confirmation.component.d.ts +19 -0
  101. package/lib/components/activity-report-form/activity-report-form.component.d.ts +93 -0
  102. package/lib/components/advanced-filter/field-filter/field-filter.component.d.ts +20 -0
  103. package/lib/components/advanced-filter/filter-builder/filter-builder.component.d.ts +28 -0
  104. package/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.d.ts +25 -0
  105. package/lib/components/audit-log-list/audit-log.component.d.ts +36 -0
  106. package/lib/components/auto-complete/auto-complete.component.d.ts +51 -0
  107. package/lib/components/base-form/base-form.component.d.ts +59 -0
  108. package/lib/components/base-form-canvas/base-form-canvas.component.d.ts +124 -0
  109. package/lib/components/base-input-dialog/base-input-dialog.component.d.ts +23 -0
  110. package/lib/components/base-table/base-table.component.d.ts +128 -0
  111. package/lib/components/button-actions/button-actions.component.d.ts +17 -0
  112. package/lib/components/editable-base-table/editable-base-table.component.d.ts +106 -0
  113. package/lib/components/equation-builder/equation-builder.component.d.ts +23 -0
  114. package/lib/components/item-line-editor/item-line-editor.component.d.ts +64 -0
  115. package/lib/components/multi-auto-complete/multi-auto-complete.component.d.ts +51 -0
  116. package/lib/components/paginator/paginator.component.d.ts +26 -0
  117. package/lib/components/report-details-dialog/report-details-dialog.component.d.ts +34 -0
  118. package/lib/components/report-form/report-form.component.d.ts +92 -0
  119. package/lib/components/search-bar/search-bar.component.d.ts +29 -0
  120. package/lib/components/section-form-canvas/section-form-canvas.component.d.ts +27 -0
  121. package/lib/components/shared/action-button/action-button.component.d.ts +17 -0
  122. package/lib/components/shared/action-card/action-card.component.d.ts +37 -0
  123. package/lib/components/shared/attachment-uploader/attachment-uploader.component.d.ts +16 -0
  124. package/lib/components/shared-list/shared-list.component.d.ts +21 -0
  125. package/lib/components/snackbar-static/snackbar-static.component.d.ts +15 -0
  126. package/lib/components/title-bar/title-bar.component.d.ts +42 -0
  127. package/lib/services/backend-service.d.ts +59 -0
  128. package/{src/lib/services/index.ts → lib/services/index.d.ts} +3 -3
  129. package/lib/services/top-panel.d.ts +8 -0
  130. package/lib/services/trigger-form.service.d.ts +7 -0
  131. package/lib/utils/base-utils.d.ts +13 -0
  132. package/lib/validators/date-range-validator.d.ts +2 -0
  133. package/{src/lib/validators/index.ts → lib/validators/index.d.ts} +3 -3
  134. package/lib/validators/match-list.validator.d.ts +4 -0
  135. package/lib/validators/multi-email-validator.d.ts +6 -0
  136. package/package.json +27 -14
  137. package/{src/public-api.ts → public-api.d.ts} +25 -29
  138. package/ng-package.json +0 -7
  139. package/src/lib/base-model/SearchStrConfig.ts +0 -12
  140. package/src/lib/base-model/audit-log-entry.ts +0 -7
  141. package/src/lib/base-model/button-action-settings.ts +0 -29
  142. package/src/lib/base-model/column-def.model.ts +0 -34
  143. package/src/lib/base-model/do-action-request.ts +0 -11
  144. package/src/lib/base-model/feature-item.ts +0 -9
  145. package/src/lib/base-model/field-action.ts +0 -7
  146. package/src/lib/base-model/field-filter.model.ts +0 -7
  147. package/src/lib/base-model/field-info.ts +0 -102
  148. package/src/lib/base-model/field-predicate.model.ts +0 -7
  149. package/src/lib/base-model/filter-request.ts +0 -27
  150. package/src/lib/base-model/filter.model.ts +0 -49
  151. package/src/lib/base-model/get-items-list.ts +0 -24
  152. package/src/lib/base-model/index.ts +0 -11
  153. package/src/lib/base-model/items-total.model.ts +0 -12
  154. package/src/lib/base-model/line-item.model.ts +0 -18
  155. package/src/lib/base-model/lookupItem.ts +0 -21
  156. package/src/lib/base-model/null-snackmessage.ts +0 -9
  157. package/src/lib/base-model/page-info.ts +0 -54
  158. package/src/lib/base-model/report-request.model.ts +0 -33
  159. package/src/lib/base-model/response-envelop.model.ts +0 -15
  160. package/src/lib/base-model/snack-message.model.ts +0 -14
  161. package/src/lib/base-model/snackmessage-interface.ts +0 -7
  162. package/src/lib/base-model/table-column.interface.ts +0 -29
  163. package/src/lib/base-model/table-page-user-action.interface.ts +0 -33
  164. package/src/lib/base-model/workflow/workflow-steps.model.ts +0 -9
  165. package/src/lib/base-model/workflow/workflow.model.ts +0 -52
  166. package/src/lib/components/action-comment/action-comment.component.css +0 -52
  167. package/src/lib/components/action-comment/action-comment.component.html +0 -47
  168. package/src/lib/components/action-comment/action-comment.component.spec.ts +0 -23
  169. package/src/lib/components/action-comment/action-comment.component.ts +0 -102
  170. package/src/lib/components/action-confirmation/action-confirmation.component.css +0 -46
  171. package/src/lib/components/action-confirmation/action-confirmation.component.html +0 -32
  172. package/src/lib/components/action-confirmation/action-confirmation.component.spec.ts +0 -23
  173. package/src/lib/components/action-confirmation/action-confirmation.component.ts +0 -58
  174. package/src/lib/components/activity-report-form/activity-report-form.component.html +0 -110
  175. package/src/lib/components/activity-report-form/activity-report-form.component.scss +0 -69
  176. package/src/lib/components/activity-report-form/activity-report-form.component.spec.ts +0 -25
  177. package/src/lib/components/activity-report-form/activity-report-form.component.ts +0 -616
  178. package/src/lib/components/advanced-filter/field-filter/field-filter.component.html +0 -8
  179. package/src/lib/components/advanced-filter/field-filter/field-filter.component.scss +0 -0
  180. package/src/lib/components/advanced-filter/field-filter/field-filter.component.spec.ts +0 -25
  181. package/src/lib/components/advanced-filter/field-filter/field-filter.component.ts +0 -55
  182. package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.html +0 -36
  183. package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.scss +0 -130
  184. package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.spec.ts +0 -25
  185. package/src/lib/components/advanced-filter/filter-builder/filter-builder.component.ts +0 -186
  186. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.css +0 -51
  187. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.html +0 -23
  188. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.spec.ts +0 -23
  189. package/src/lib/components/audit-log-details-dialog/audit-log-details-dialog.component.ts +0 -69
  190. package/src/lib/components/audit-log-list/audit-log.component.html +0 -26
  191. package/src/lib/components/audit-log-list/audit-log.component.scss +0 -50
  192. package/src/lib/components/audit-log-list/audit-log.component.spec.ts +0 -25
  193. package/src/lib/components/audit-log-list/audit-log.component.ts +0 -114
  194. package/src/lib/components/auto-complete/auto-complete.component.css +0 -55
  195. package/src/lib/components/auto-complete/auto-complete.component.html +0 -45
  196. package/src/lib/components/auto-complete/auto-complete.component.spec.ts +0 -23
  197. package/src/lib/components/auto-complete/auto-complete.component.ts +0 -331
  198. package/src/lib/components/base-form/base-form.component.html +0 -59
  199. package/src/lib/components/base-form/base-form.component.scss +0 -68
  200. package/src/lib/components/base-form/base-form.component.spec.ts +0 -25
  201. package/src/lib/components/base-form/base-form.component.ts +0 -323
  202. package/src/lib/components/base-form-canvas/base-form-canvas.component.css +0 -196
  203. package/src/lib/components/base-form-canvas/base-form-canvas.component.html +0 -1095
  204. package/src/lib/components/base-form-canvas/base-form-canvas.component.spec.ts +0 -23
  205. package/src/lib/components/base-form-canvas/base-form-canvas.component.ts +0 -680
  206. package/src/lib/components/base-input-dialog/base-input-dialog.component.css +0 -67
  207. package/src/lib/components/base-input-dialog/base-input-dialog.component.html +0 -47
  208. package/src/lib/components/base-input-dialog/base-input-dialog.component.spec.ts +0 -23
  209. package/src/lib/components/base-input-dialog/base-input-dialog.component.ts +0 -77
  210. package/src/lib/components/base-table/base-table.component.html +0 -268
  211. package/src/lib/components/base-table/base-table.component.scss +0 -140
  212. package/src/lib/components/base-table/base-table.component.spec.ts +0 -25
  213. package/src/lib/components/base-table/base-table.component.ts +0 -621
  214. package/src/lib/components/button-actions/button-actions.component.html +0 -27
  215. package/src/lib/components/button-actions/button-actions.component.scss +0 -101
  216. package/src/lib/components/button-actions/button-actions.component.spec.ts +0 -23
  217. package/src/lib/components/button-actions/button-actions.component.ts +0 -70
  218. package/src/lib/components/editable-base-table/editable-base-table.component.html +0 -337
  219. package/src/lib/components/editable-base-table/editable-base-table.component.scss +0 -126
  220. package/src/lib/components/editable-base-table/editable-base-table.component.spec.ts +0 -25
  221. package/src/lib/components/editable-base-table/editable-base-table.component.ts +0 -579
  222. package/src/lib/components/equation-builder/equation-builder.component.css +0 -39
  223. package/src/lib/components/equation-builder/equation-builder.component.html +0 -31
  224. package/src/lib/components/equation-builder/equation-builder.component.spec.ts +0 -23
  225. package/src/lib/components/equation-builder/equation-builder.component.ts +0 -119
  226. package/src/lib/components/item-line-editor/item-line-editor.component.html +0 -102
  227. package/src/lib/components/item-line-editor/item-line-editor.component.scss +0 -152
  228. package/src/lib/components/item-line-editor/item-line-editor.component.spec.ts +0 -23
  229. package/src/lib/components/item-line-editor/item-line-editor.component.ts +0 -306
  230. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.css +0 -19
  231. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.html +0 -38
  232. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.spec.ts +0 -23
  233. package/src/lib/components/multi-auto-complete/multi-auto-complete.component.ts +0 -315
  234. package/src/lib/components/paginator/paginator.component.css +0 -65
  235. package/src/lib/components/paginator/paginator.component.html +0 -30
  236. package/src/lib/components/paginator/paginator.component.ts +0 -87
  237. package/src/lib/components/report-details-dialog/report-details-dialog.component.css +0 -17
  238. package/src/lib/components/report-details-dialog/report-details-dialog.component.html +0 -16
  239. package/src/lib/components/report-details-dialog/report-details-dialog.component.spec.ts +0 -23
  240. package/src/lib/components/report-details-dialog/report-details-dialog.component.ts +0 -111
  241. package/src/lib/components/report-form/report-form.component.html +0 -92
  242. package/src/lib/components/report-form/report-form.component.scss +0 -51
  243. package/src/lib/components/report-form/report-form.component.spec.ts +0 -25
  244. package/src/lib/components/report-form/report-form.component.ts +0 -599
  245. package/src/lib/components/search-bar/search-bar.component.html +0 -51
  246. package/src/lib/components/search-bar/search-bar.component.scss +0 -63
  247. package/src/lib/components/search-bar/search-bar.component.spec.ts +0 -25
  248. package/src/lib/components/search-bar/search-bar.component.ts +0 -68
  249. package/src/lib/components/section-form-canvas/section-form-canvas.component.html +0 -43
  250. package/src/lib/components/section-form-canvas/section-form-canvas.component.scss +0 -81
  251. package/src/lib/components/section-form-canvas/section-form-canvas.component.spec.ts +0 -23
  252. package/src/lib/components/section-form-canvas/section-form-canvas.component.ts +0 -67
  253. package/src/lib/components/shared/action-button/action-button.component.html +0 -12
  254. package/src/lib/components/shared/action-button/action-button.component.scss +0 -45
  255. package/src/lib/components/shared/action-button/action-button.component.ts +0 -51
  256. package/src/lib/components/shared/action-card/action-card.component.html +0 -78
  257. package/src/lib/components/shared/action-card/action-card.component.scss +0 -238
  258. package/src/lib/components/shared/action-card/action-card.component.ts +0 -56
  259. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.css +0 -135
  260. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.html +0 -36
  261. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.spec.ts +0 -23
  262. package/src/lib/components/shared/attachment-uploader/attachment-uploader.component.ts +0 -71
  263. package/src/lib/components/shared-list/shared-list.component.css +0 -0
  264. package/src/lib/components/shared-list/shared-list.component.html +0 -17
  265. package/src/lib/components/shared-list/shared-list.component.spec.ts +0 -23
  266. package/src/lib/components/shared-list/shared-list.component.ts +0 -53
  267. package/src/lib/components/snackbar-static/snackbar-static.component.html +0 -20
  268. package/src/lib/components/snackbar-static/snackbar-static.component.scss +0 -135
  269. package/src/lib/components/snackbar-static/snackbar-static.component.ts +0 -26
  270. package/src/lib/components/title-bar/title-bar.component.css +0 -0
  271. package/src/lib/components/title-bar/title-bar.component.css.map +0 -1
  272. package/src/lib/components/title-bar/title-bar.component.html +0 -35
  273. package/src/lib/components/title-bar/title-bar.component.scss +0 -126
  274. package/src/lib/components/title-bar/title-bar.component.spec.ts +0 -23
  275. package/src/lib/components/title-bar/title-bar.component.ts +0 -126
  276. package/src/lib/services/backend-service.ts +0 -287
  277. package/src/lib/services/top-panel.ts +0 -17
  278. package/src/lib/services/trigger-form.service.ts +0 -11
  279. package/src/lib/share-module/shared-module.ts +0 -10
  280. package/src/lib/utils/base-utils.ts +0 -102
  281. package/src/lib/validators/date-range-validator.ts +0 -31
  282. package/src/lib/validators/match-list.validator.ts +0 -10
  283. package/src/lib/validators/multi-email-validator.ts +0 -15
  284. package/tsconfig.lib.json +0 -15
  285. package/tsconfig.lib.prod.json +0 -11
  286. package/tsconfig.spec.json +0 -15
@@ -1,23 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { BaseFormCanvasComponent } from './base-form-canvas.component';
4
-
5
- describe('BaseFormCanvasComponent', () => {
6
- let component: BaseFormCanvasComponent;
7
- let fixture: ComponentFixture<BaseFormCanvasComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [BaseFormCanvasComponent]
12
- })
13
- .compileComponents();
14
-
15
- fixture = TestBed.createComponent(BaseFormCanvasComponent);
16
- component = fixture.componentInstance;
17
- fixture.detectChanges();
18
- });
19
-
20
- it('should create', () => {
21
- expect(component).toBeTruthy();
22
- });
23
- });
@@ -1,680 +0,0 @@
1
- import {
2
- Component, ElementRef,
3
- EventEmitter,
4
- Input,
5
- OnChanges,
6
- OnDestroy,
7
- OnInit,
8
- Output,
9
- SimpleChanges,
10
- ViewChild,
11
- computed,
12
- model,
13
- signal
14
- } from '@angular/core';
15
- import {FormBuilder, FormGroup, ReactiveFormsModule, FormsModule, FormControl} from "@angular/forms";
16
- import {
17
- MatChip,
18
- MatChipGrid,
19
- MatChipInput,
20
- MatChipInputEvent,
21
- MatChipListbox, MatChipOption, MatChipRemove,
22
- MatChipRow
23
- } from "@angular/material/chips";
24
- import {FieldInfo} from "../../base-model/field-info";
25
- import {ActivatedRoute} from "@angular/router";
26
- import {BackendService} from "../../services/backend-service";
27
- import {TranslateModule, TranslateService} from "@ngx-translate/core";
28
- import {PageInfo} from "../../base-model/page-info";
29
- import {COMMA, ENTER, SEMICOLON} from "@angular/cdk/keycodes";
30
- import {LookupItem} from "../../base-model/lookupItem";
31
- import {FieldMessage} from "../../base-model/api-response";
32
- import {
33
- AsyncPipe,
34
- CurrencyPipe,
35
- DatePipe,
36
- KeyValuePipe,
37
- NgForOf,
38
- NgIf, NgStyle,
39
- NgSwitch,
40
- NgSwitchCase,
41
- NgTemplateOutlet
42
- } from "@angular/common";
43
- import {MatError, MatFormFieldModule, MatLabel} from "@angular/material/form-field";
44
- import {MatInputModule} from "@angular/material/input";
45
- import {MatDatepicker, MatDatepickerInput, MatDatepickerToggle, MatDateRangeInput} from "@angular/material/datepicker";
46
- import {MatIcon} from "@angular/material/icon";
47
- import {CdkTextareaAutosize} from "@angular/cdk/text-field";
48
- import {MatRadioButton, MatRadioGroup} from "@angular/material/radio";
49
- import {MatCheckbox} from "@angular/material/checkbox";
50
- import {MatOption, MatSelect} from "@angular/material/select";
51
- import {MatDivider} from "@angular/material/divider";
52
- import {NgxJsonViewerModule} from "ngx-json-viewer";
53
- import {CKEditorModule} from "@ckeditor/ckeditor5-angular";
54
- import {NgxMatIntlTelInputComponent} from "ngx-mat-intl-tel-input";
55
- import {MultiAutoCompleteComponent} from "../multi-auto-complete/multi-auto-complete.component";
56
- import {AutoCompleteComponent} from "../auto-complete/auto-complete.component";
57
- import {MatAutocomplete, MatAutocompleteSelectedEvent, MatAutocompleteTrigger} from "@angular/material/autocomplete";
58
- import {BehaviorSubject, map} from "rxjs";
59
- import {LiveAnnouncer} from "@angular/cdk/a11y";
60
- import {buildFormFields, extractFieldName} from "../../utils/base-utils";
61
- import ClassicEditor from "@ckeditor/ckeditor5-build-classic"
62
- import moment, {Moment} from "moment/moment";
63
- import {MatCell, MatCellDef, MatHeaderCell, MatHeaderCellDef} from "@angular/material/table";
64
- import {DateAdapter, MAT_DATE_FORMATS, MAT_DATE_LOCALE} from "@angular/material/core";
65
- import {MAT_MOMENT_DATE_ADAPTER_OPTIONS, MomentDateAdapter} from "@angular/material-moment-adapter";
66
- export const DD_MM_YYYY_Format = {
67
- parse: { dateInput: 'DD/MM/YYYY' },
68
- display: {
69
- dateInput: 'DD/MM/YYYY',
70
- monthYearLabel: 'MMM YYYY',
71
- dateA11yLabel: 'DD/MM/YYYY',
72
- monthYearA11yLabel: 'MMMM YYYY',
73
- },
74
- };
75
- @Component({
76
- selector: 'app-base-form-canvas',
77
- standalone: true,
78
- imports: [
79
- ReactiveFormsModule,
80
- NgSwitch,
81
- FormsModule,
82
- NgForOf,
83
- NgTemplateOutlet,
84
- KeyValuePipe,
85
- NgIf,
86
- MatLabel,
87
- MatFormFieldModule,
88
- TranslateModule,
89
- MatInputModule,
90
- MatDatepickerInput,
91
- MatDatepicker,
92
- MatDatepickerToggle,
93
- MatError,
94
- NgSwitchCase,
95
- MatIcon,
96
- MatAutocomplete,
97
- MatAutocompleteTrigger,
98
- MatChip,
99
- CdkTextareaAutosize,
100
- MatRadioGroup,
101
- MatCheckbox,
102
- MatRadioButton,
103
- MatSelect,
104
- MatOption,
105
- MatDivider,
106
- DatePipe,
107
- NgxJsonViewerModule,
108
- CurrencyPipe,
109
- CKEditorModule,
110
- NgxMatIntlTelInputComponent,
111
- MatChipGrid,
112
- MatChipInput,
113
- MatChipRow,
114
- MatChipListbox,
115
- MatChipOption,
116
- MultiAutoCompleteComponent,
117
- AutoCompleteComponent,
118
- MatDateRangeInput,
119
- AsyncPipe,
120
- MatChipRemove,
121
- MatCell,
122
- MatCellDef,
123
- MatHeaderCell,
124
- MatHeaderCellDef,
125
- NgStyle
126
- ],
127
- templateUrl: './base-form-canvas.component.html',
128
- styleUrl: './base-form-canvas.component.css',
129
- providers: [
130
- {
131
- provide: DateAdapter,
132
- useClass: MomentDateAdapter,
133
- deps: [MAT_DATE_LOCALE, MAT_MOMENT_DATE_ADAPTER_OPTIONS]
134
- },
135
- { provide: MAT_DATE_FORMATS, useValue: DD_MM_YYYY_Format },
136
- { provide: MAT_DATE_LOCALE, useValue: 'en-GB' }
137
- ]
138
-
139
- })
140
- export class BaseFormCanvasComponent implements OnInit, OnChanges, OnDestroy {
141
- public Editor = ClassicEditor;
142
- public hide: boolean = true;
143
- dateViewMode: 'month' | 'year' | 'multi-year' = 'month';
144
- @Input()
145
- pageInfo!: PageInfo;
146
-
147
-
148
- @Input()
149
- currency: string;
150
-
151
- @Input()// @ts-ignore
152
- fields: FieldInfo[] = [];
153
-
154
- @Input()// @ts-ignore
155
- errors: FieldMessage[] = [];
156
-
157
- @Input()
158
- workflowEditableFields: string[]=[];
159
- @Input()
160
- isWorkflowEditableManaged: boolean = false;
161
-
162
- @Input()
163
- supportingAttributes: any;
164
-
165
- @Input()
166
- editable: boolean = false;
167
-
168
- // When true, emit formUpdated on every value change. Default is false to avoid
169
- // noisy emissions for all consumers. Item-line-editor will enable this explicitly.
170
- @Input()
171
- emitOnValueChanges: boolean = false;
172
-
173
- @Input()
174
- item: any = {};
175
-
176
- _defaults: any = {};
177
-
178
- @Output() attachmentEmitter: EventEmitter<any> = new EventEmitter<any>();
179
-
180
- @Output() actionEmitter: EventEmitter<any> = new EventEmitter<any>();
181
-
182
-
183
- @Output()
184
- formUpdated: EventEmitter<FormGroup> = new EventEmitter<FormGroup>();
185
-
186
- @Output()
187
- hyperTextEvent: EventEmitter<boolean> = new EventEmitter();
188
-
189
-
190
- formParam!: FormGroup;
191
- screenFields = new Map<number, FieldInfo[]>();
192
- removable = true;
193
- selectable = true;
194
- addOnBlur = true;
195
-
196
- readonly separatorKeysCodes: number[] = [ENTER, COMMA, SEMICOLON];
197
-
198
-
199
- public isPending: boolean = false;
200
- public isNew: boolean = false;
201
- itemId: number | undefined;
202
-
203
- equationOperators : string[] = ['+','-','(' ];
204
- @Input() equationSuggestedFields: { name: string, id: string }[] = [];
205
- allEquationFields: BehaviorSubject<string[]>;
206
- readonly equationValues = signal<string[]>([]);
207
- currentEquationValue = model<string>('');
208
-
209
- readonly equationFilteredFields = computed(() => {
210
- const currentEquationValue = this.currentEquationValue().toLowerCase();
211
- return this.allEquationFields.pipe(
212
- map(fields =>
213
- currentEquationValue ? fields?.filter(field => field.toLowerCase().includes(currentEquationValue)) : fields?.slice()
214
- )
215
- );
216
- });
217
- @ViewChild('EquationValueInput') fieldsInput: ElementRef<HTMLInputElement>;
218
-
219
- set defaults(value: any | undefined) {
220
- // this.backendService._defaults = value;
221
- this._defaults = value;
222
- this.buildForm();
223
- // this.myCallback = value;
224
- }
225
-
226
- get defaults(): any | undefined {
227
- // this.myCallback;
228
- return this._defaults;
229
- // return this.backendService._defaults;
230
- }
231
-
232
- constructor(protected translateService: TranslateService,
233
- protected activatedRoute: ActivatedRoute,
234
- protected backendService: BackendService,
235
- private fb: FormBuilder,
236
- private announcer: LiveAnnouncer) {
237
- ClassicEditor.defaultConfig = {
238
- toolbar: {
239
- items: ['heading', '|', 'bold', 'italic', '|', 'bulletedList', 'numberedList']
240
- },
241
- image: {
242
- toolbar: ['imageStyle:side', '|', 'imageTextAlternative']
243
- },
244
- table: {
245
- contentToolbar: [ 'tableColumn', 'tableRow', 'mergeTableCells' ]
246
- },
247
- language: 'en'
248
- };
249
- }
250
-
251
- ngOnInit(): void {
252
- if(this.item && this.item.fieldValue){
253
- this.equationValues.update(value => this.item.fieldValue)
254
- }
255
- this.defaults = this.item;
256
- this.extractLables();
257
- this.buildForm();
258
- this.activatedRoute.data.subscribe(data => {
259
- this.isPending = data['mode'] === 'pending';
260
- this.isNew = data['mode'] === 'new';
261
- });
262
- // this.authService.summaryPanelState$.next(Constants.SUMMARY_PANEL_CLOSED);
263
- // this.defaults = {};
264
- // this.invoiceQInit();
265
- this.allEquationFields = new BehaviorSubject<string[]>([]);
266
-
267
- this.updateEquationOptions();
268
- }
269
-
270
- formatTimeToDate(v: any){
271
- const fromTime: Date = new Date();
272
- if (v) {
273
- let split = v.split(":");
274
- fromTime.setHours(split[0], split[1]);
275
- }
276
- return new Date(fromTime.getTime());
277
- }
278
-
279
- patchLookupValue($event: LookupItem, fieldName: string) {
280
- if ($event?.id !== -1 && this.defaults) {
281
- // @ts-ignore
282
- this.defaults[fieldName] = this.formParam.get(fieldName).value;
283
- }
284
- }
285
- getBankName(fieldName: string) {
286
- //TODO Batool do we need this here ?
287
- if (this.formParam.get(fieldName).value?.length > 10 && !isNaN(this.formParam.get(fieldName).value) ) {
288
- return ' / ' + this.translateService.instant('BANK.' + this.formParam.get(fieldName).value?.substr(4, 4));
289
- } else {
290
- return '';
291
- }
292
- }
293
-
294
- patchMultiSelectValue($event: LookupItem[], fieldName: string) {
295
- if ($event?.length >= 0 && this.defaults) {
296
- this.defaults[fieldName] = this.formParam.get(fieldName).value;
297
- }
298
- }
299
-
300
- ngOnChanges({item, errors, fields}: SimpleChanges): void {
301
- errors?.currentValue?.forEach((msg: FieldMessage) => {
302
- this.formParam.get(msg.fieldName)?.setErrors({serverError: msg.message});
303
- });
304
-
305
- if (item?.currentValue && !item.isFirstChange()){
306
- this.defaults = item.currentValue;
307
- }
308
-
309
- if (fields?.currentValue && !fields.isFirstChange()){
310
- this.buildForm();
311
- }
312
- }
313
-
314
- showField(item: any, field: any) {
315
- return (item.id || (!item.id && !field.updateOnly)) && field.visible
316
- }
317
-
318
- workflowEditableField(field: { property: string; }) {
319
- const x = this.isWorkflowEditableManaged ? this.workflowEditableFields?.findIndex(d => d === field.property) > -1 : true;
320
- return x;
321
- }
322
-
323
- showMultiSelectValuesAsReadonly(field: FieldInfo) {
324
- const viewProp = this.translateService.getDefaultLang() === 'en' ? 'englishName' : 'arabicName';
325
- return this.extractFieldName(this.defaults,field.property)?.map((a: { [x: string]: any; }) => a[viewProp]);
326
- }
327
-
328
- splitReadonly(values: any) {
329
- return !values || values === '' ? []: values.split(';');
330
- }
331
-
332
-
333
- referenceAttributeTrue(fieldName: string, attribute: any) {
334
- // return this.authService.referenceAttributeTrue(fieldName, this.pageInfo.processId, attribute);
335
- }
336
-
337
- translateLable(itemElement: any) {
338
- return this.translateService.instant(itemElement)
339
- }
340
-
341
- buildForm() {
342
- if (!this.fields || this.fields.length === 0 || !this.defaults) return;
343
-
344
- if (!this.formParam) {
345
- this.formParam = this.fb.group(buildFormFields(this.fields, this.defaults));
346
- // Emit initial form reference
347
- this.formUpdated.next(this.formParam);
348
- // Emit on every value change so parent components can react live
349
- if (this.emitOnValueChanges) {
350
- this.formParam.valueChanges.subscribe(() => {
351
- this.formUpdated.emit(this.formParam);
352
- });
353
- }
354
- return;
355
- }
356
-
357
- const patchValues: any = {};
358
- for (const field of this.fields) {
359
- if (field.readonly) {
360
- this.formParam.get(field.property)?.disable({ emitEvent: false });
361
- } else {
362
- this.formParam.get(field.property)?.enable({ emitEvent: false });
363
- }
364
- if (field.type !== 'spacer') {
365
- patchValues[field.property] = extractFieldName(this.defaults, field.property);
366
- }
367
- }
368
-
369
- this.formParam.patchValue(patchValues, { emitEvent: false });
370
- }
371
-
372
- labelKey(column: any) {
373
- const configuredKey = column.label ? column.label : column.property
374
- return configuredKey.startsWith(this.pageInfo.labelsSection) ? `${configuredKey}` : `${this.pageInfo.labelsSection}.${configuredKey}`;
375
- }
376
-
377
- labelKeyPlaceHolder(column: any) {
378
- const configuredKey = column.placeholder ? column.placeholder : column.property
379
- return configuredKey.startsWith(this.pageInfo.labelsSection) ? `${configuredKey}` : `${this.pageInfo.labelsSection}.${configuredKey}`;
380
- }
381
-
382
- getErrors(prop: string): string {
383
- const control = this.formParam.get(prop);
384
- if (!control || control.disabled) return '';
385
-
386
- const field = this.fields.find(f => f.property === prop);
387
-
388
- if (!field?.validationMessages) {
389
- if (control.value && control.status !== 'VALID' && this.getFirstErrorKey) {
390
- return this.getFirstErrorKey(prop);
391
- }
392
- return '';
393
- }
394
-
395
- if (control.invalid) {
396
- const errors = control.errors || {};
397
- const prefix = this.pageInfo.labelsSection + ".";
398
-
399
- if (errors['required']) return prefix + 'REQUIRED';
400
- if (errors['min']) return prefix + (field.validationMessages?.min || 'NUMBER_MIN');
401
- if (errors['max']) return prefix + (field.validationMessages?.max || 'NUMBER_MAX');
402
- if (errors['maxlength']) return prefix + (field.validationMessages?.maxlength || 'MAX_LENGTH');
403
- if (errors['decimalMin']) return prefix + (field.validationMessages?.decimalMin || 'DECIMAL_MIN');
404
- if (errors['decimalMax']) return prefix + (field.validationMessages?.decimalMax || 'DECIMAL_MAX');
405
- if (errors['pattern']) return prefix + (field.validationMessages?.pattern || 'INVALID_FORMAT');
406
- if (errors['invalidMathExpression']) return prefix + 'INVALID_MATH';
407
- if (errors['serverError']) return prefix + errors['serverError'];
408
-
409
- return prefix + 'INVALID_VALUE';
410
- }
411
-
412
- return '';
413
- }
414
-
415
-
416
- getFirstErrorKey(prop: string): string {
417
- const errors = this.formParam.get(prop)?.errors;
418
-
419
- if (!errors || Object.keys(errors).length === 0) {
420
- return errors?.['serverError'] || 'INVALID_FORMAT';
421
- }
422
-
423
- return Object.keys(errors)[0];
424
- }
425
-
426
- public getCountryCodeList() {
427
- return ['af', 'ax', 'al', 'dz', 'as', 'ad', 'ao', 'ai', 'aq', 'ag', 'ar', 'am', 'aw', 'au', 'at', 'az',
428
- 'bs', 'bh', 'bd', 'bb', 'by', 'be', 'bz', 'bj', 'bm', 'bt', 'bo', 'ba', 'bw', 'bv', 'br', 'io', 'bn',
429
- 'bg', 'bf', 'bi', 'kh', 'cm', 'ca', 'cv', 'ky', 'cf', 'td', 'cl', 'cn', 'cx', 'cc', 'co', 'km', 'cg',
430
- 'cd', 'ck', 'cr', 'ci', 'hr', 'cu', 'cy', 'cz', 'dk', 'dj', 'dm', 'do', 'ec', 'eg', 'sv', 'gq', 'er',
431
- 'ee', 'et', 'fk', 'fo', 'fj', 'fi', 'fr', 'gf', 'pf', 'tf', 'ga', 'gm', 'ge', 'de', 'gh', 'gi', 'gr',
432
- 'gl', 'gd', 'gp', 'gu', 'gt', 'gg', 'gn', 'gw', 'gy', 'ht', 'hm', 'va', 'hn', 'hk', 'hu', 'is', 'in',
433
- 'id', 'ir', 'iq', 'ie', 'im', 'it', 'jm', 'jp', 'je', 'jo', 'kz', 'ke', 'ki', 'kr', 'kw', 'kg', 'la',
434
- 'lv', 'lb', 'ls', 'lr', 'ly', 'li', 'lt', 'lu', 'mo', 'mk', 'mg', 'mw', 'my', 'mv', 'ml', 'mt', 'mh',
435
- 'mq', 'mr', 'mu', 'yt', 'mx', 'fm', 'md', 'mc', 'mn', 'me', 'ms', 'ma', 'mz', 'mm', 'na', 'nr', 'np',
436
- 'nl', 'an', 'nc', 'nz', 'ni', 'ne', 'ng', 'nu', 'nf', 'mp', 'no', 'om', 'pk', 'pw', 'ps', 'pa', 'pg',
437
- 'py', 'pe', 'ph', 'pn', 'pl', 'pt', 'pr', 'qa', 're', 'ro', 'ru', 'rw', 'bl', 'sh', 'kn', 'lc', 'mf',
438
- 'pm', 'vc', 'ws', 'sm', 'st', 'sa', 'sn', 'rs', 'sc', 'sl', 'sg', 'sk', 'si', 'sb', 'so', 'za', 'gs',
439
- 'es', 'lk', 'sd', 'sr', 'sj', 'sz', 'se', 'ch', 'sy', 'tw', 'tj', 'tz', 'th', 'tl', 'tg', 'tk', 'to',
440
- 'tt', 'tn', 'tr', 'tm', 'tc', 'tv', 'ug', 'ua', 'ae', 'gb', 'us', 'um', 'uy', 'uz', 'vu', 've', 'vn',
441
- 'vg', 'vi', 'wf', 'eh', 'ye', 'zm', 'zw'];
442
- }
443
-
444
-
445
- friendlyName(fullPath: string , subPath: string , item: string){
446
- return fullPath.substring(0, fullPath.indexOf(subPath)) + item ;
447
- }
448
-
449
- showValue(defaults, field){
450
- return this.friendlyName(field.label , field.property , defaults[field.property]);
451
- }
452
-
453
- showError(prop: string) {
454
- return (this.formParam?.get(prop)?.value || this.formParam?.get(prop)?.value == 0)
455
- && this.formParam.get(prop).status === 'INVALID';
456
- }
457
-
458
- ngOnDestroy(): void {
459
- this.defaults = null;
460
- }
461
-
462
- private extractLables() {
463
- this.fields.forEach(f => {
464
- if (f.visible) {
465
- f.label = this.labelKey(f);
466
-
467
- if (!this.screenFields.has(f.row)) {
468
- this.screenFields.set(f.row, []);
469
- }
470
- this.screenFields.get(f.row)!.push(f);
471
-
472
- if (f.cascadedBy) {
473
- this.formParam?.get(f.cascadedBy)?.valueChanges.subscribe(() => {
474
- this.formParam?.get(f.property)?.patchValue(null);
475
- })
476
- }
477
- }
478
- });
479
-
480
- for (let i = 1; i < this.screenFields.size; i++) {
481
- this.calcFlexSize(i);
482
- }
483
- // console.log(this.screenFields)
484
- }
485
-
486
- private calcFlexSize(i: number){
487
- // Preserve explicit fieldSize values only. For fields without fieldSize, allow
488
- // the layout to auto-size via flex (handled in the template/CSS).
489
- // Intentionally do nothing here so that unspecified fields remain flexible.
490
- return;
491
- }
492
-
493
- getCurrencyPattern(field: FieldInfo) {
494
- // const decimalPlaces = this.authService?.myCurrencies?.find(c => c.key === this.formParam.get(field.currency)?.value)?.currencyNumOfDecimalPattern || 3;
495
- const decimalPlaces = 3;
496
- return '^\\d*(?:[.,]\\d{1,' + decimalPlaces + '})?$';
497
- }
498
-
499
- splittedChips(form: FormGroup, fieldName: string):string[] {
500
- return form.get(fieldName).value === '' ? []: form.get(fieldName).value.trim().split(';');
501
- }
502
-
503
-
504
- fixArabicNumbers(str: any) {
505
- // if(typeof str === 'string') {
506
- // str = str.replace(/([٠١٢٣٤٥٦٧٨٩])|([۰۱۲۳۴۵۶۷۸۹])/g, (m, $1, $2) => m.charCodeAt(0) - ($1 ? 1632 : 1776));
507
- // }
508
- // console.log(str);
509
- }
510
-
511
- listShowValue(defaults: any, field: FieldInfo) {
512
- return defaults[field.property] ? this.showValue(defaults, field) : '';
513
- }
514
-
515
- removeChipsItem(form: FormGroup, fieldName: string, idx: number) {
516
- const emails = this.splittedChips(form, fieldName);
517
- if (emails.length >= 1){
518
- emails.splice(idx,1);
519
- }
520
- let cleanedEmails = emails.join(";");
521
- form.get(fieldName).setValue(cleanedEmails);
522
- }
523
-
524
- extractFieldName(element: any, property: string) {
525
- if (property?.includes('.')) {
526
- return property.split('.').reduce((acc, part) => acc && acc[part], element);
527
- } else {
528
- return element[property];
529
- }
530
- }
531
-
532
- getMultiValue(field: FieldInfo) {
533
- return this.formParam.get(field.property)?.value;
534
- }
535
-
536
- private validateEmail(email) {
537
- var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
538
- return re.test(String(email).toLowerCase());
539
- }
540
-
541
- addEmailToChips(event: MatChipInputEvent, form: FormGroup, fieldName: string) {
542
-
543
- const input = event.input;
544
- const value = event.value;
545
- const items = value.split(';');
546
- // value.split(' ');
547
- items.forEach(itm => {
548
- if (this.validateEmail((itm || '').trim())) {
549
- const x = this.splittedChips(form, fieldName);
550
- x.push(itm);
551
- form.get(fieldName).patchValue(x.join(';'));
552
- if (input) {
553
- input.value = '';
554
- }
555
- }
556
- });
557
-
558
- }
559
-
560
- extractJsonFieldName(defaults: any, property: string) {
561
- const x= this.extractFieldName(defaults, property);
562
- if (x?.length > 0)
563
- return JSON.parse(x);
564
- else return '{}';
565
- }
566
-
567
- getOptionValue(item: any) {
568
- const value = typeof item === 'object' ?
569
- this.translateService.getDefaultLang() === 'en' ? item.englishName : item.arabicName
570
- : item;
571
- return value;
572
- }
573
-
574
- getHyperTextEvent() {
575
- this.hyperTextEvent.emit(true);
576
- }
577
-
578
- add(event: MatChipInputEvent): void {
579
- const value = (event.value || '').trim();
580
- if (value) {
581
- if (this.equationOperators.includes(value) || !this.equationValues().includes(value)) {
582
- this.equationValues.update(equationValues => [...equationValues, value]);
583
- }
584
- }
585
-
586
- this.fieldsInput.nativeElement.value = '';
587
- this.currentEquationValue.set('');
588
- this.updateEquationOptions();
589
-
590
- }
591
-
592
- remove(item: string, index: number): void {
593
- this.equationValues.update(equationValues => {
594
- if (index < 0) {
595
- return equationValues;
596
- }
597
-
598
- equationValues.splice(index, 1);
599
- this.announcer.announce(`Removed ${item}`);
600
- return [...equationValues];
601
- });
602
- this.updateEquationOptions();
603
- }
604
-
605
- selected(event: MatAutocompleteSelectedEvent): void{
606
- const selectedValue = event.option.viewValue.trim();
607
-
608
- if (!this.equationOperators.includes(selectedValue) && !this.equationValues().includes(selectedValue)) {
609
- this.equationValues.update(equationValues => [...equationValues, selectedValue]);
610
- } else if (this.equationOperators.includes(selectedValue)) {
611
- this.equationValues.update(equationValues => [...equationValues, selectedValue]);
612
- }
613
-
614
- this.currentEquationValue.set('');
615
- event.option.deselect();
616
- this.fieldsInput.nativeElement.value = '';
617
- this.updateEquationOptions();
618
- }
619
-
620
- updateEquationOptions(){
621
- this.reflectEquationValueOnForm();
622
-
623
- let updatedFields: string[];
624
- if (this.equationValues().length === 0) {
625
- updatedFields = this.getNamesFromSuggestedEquationFields();
626
- } else {
627
- let lastElement = this.equationValues()[this.equationValues().length - 1];
628
- if (this.equationOperators.includes(lastElement)) {
629
- updatedFields = this.getNamesFromSuggestedEquationFields();
630
- } else {
631
- updatedFields = this.equationOperators;
632
- }
633
- }
634
- // console.log('*****', updatedFields);
635
- this.allEquationFields.next(updatedFields);
636
- }
637
-
638
- getNamesFromSuggestedEquationFields(): string[] {
639
- return this.equationSuggestedFields?.map(field => field.name);
640
- }
641
-
642
- reflectEquationValueOnForm() {
643
- if (this.formParam && this.formParam.get('fieldValue')) {
644
- this.formParam.get('fieldValue').setValue(this.equationValues());
645
- } else {
646
- // console.log('Form or fieldValue is not available.');
647
- }
648
- }
649
-
650
- checkEquation(field: FieldInfo, $event: Event) {
651
- // console.log('$event', $event);
652
- // try {
653
- // evaluate(equation.replace(/[a-zA-Z0-9]+/g, '1')); // Replace variables with dummy values
654
- // this.formGroups[index].get('xyz').setErrors(null);
655
- // console.log('valid ', equation)
656
- // } catch (e) {
657
- // this.formGroups[index].get('xyz').setErrors({serverError: 'incomplete '});
658
- // console.log('bad ', equation)
659
- // }
660
- }
661
-
662
- getView(field): 'month' | 'year' | 'multi-year' {
663
- return field.pattern || 'month';
664
- }
665
-
666
- setMonthAndYear(normalizedMonthAndYear: Moment, picker: MatDatepicker<Moment>, field) {
667
- console.log('field.pattern', field.pattern)
668
- if (field.pattern === 'multi-year') {
669
- console.log('hi')
670
- const date = new FormControl(moment());
671
- const ctrlValue = date.value;
672
- ctrlValue.year(normalizedMonthAndYear.year());
673
- ctrlValue.month(1);
674
- ctrlValue.dayOfYear(1);
675
- this.formParam.get(field.property).setValue(ctrlValue)
676
- picker.close();
677
- }
678
- }
679
- }
680
-