@mediusinc/mng-commons 0.2.0 → 0.2.1-rc

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 (328) hide show
  1. package/.browserslistrc +16 -0
  2. package/karma.conf.js +51 -0
  3. package/ng-package.json +14 -0
  4. package/package.json +3 -24
  5. package/src/lib/api/models/builders/query-param.builder.ts +54 -0
  6. package/src/lib/api/models/filter-match-type.model.ts +25 -0
  7. package/src/lib/api/models/filter-param.model.ts +59 -0
  8. package/{lib/api/models/index.d.ts → src/lib/api/models/index.ts} +10 -8
  9. package/src/lib/api/models/mappers.ts +18 -0
  10. package/{lib/api/models/filter-match-type.model.d.ts → src/lib/api/models/query-mode.model.ts} +18 -23
  11. package/src/lib/api/models/query-param.model.ts +99 -0
  12. package/src/lib/api/models/query-result.model.ts +77 -0
  13. package/{lib/api/models/serialization.model.d.ts → src/lib/api/models/serialization.model.ts} +9 -8
  14. package/src/lib/api/services/crud-api.abstract.service.ts +113 -0
  15. package/{lib/api/services/index.d.ts → src/lib/api/services/index.ts} +1 -1
  16. package/{lib/api/utils/index.d.ts → src/lib/api/utils/index.ts} +2 -2
  17. package/src/lib/api/utils/medius-rest.util.ts +146 -0
  18. package/src/lib/api/utils/object-serializer.util.ts +227 -0
  19. package/src/lib/components/action/action.component.html +30 -0
  20. package/src/lib/components/action/action.component.ts +77 -0
  21. package/src/lib/components/action/dialog/action-dialog.component.html +26 -0
  22. package/src/lib/components/action/dialog/action-dialog.component.ts +171 -0
  23. package/{lib/components/action/index.d.ts → src/lib/components/action/index.ts} +3 -3
  24. package/{lib/components/action/models/action-confirmation-service.model.d.ts → src/lib/components/action/models/action-confirmation-service.model.ts} +7 -6
  25. package/src/lib/components/action/models/action-execution.model.ts +81 -0
  26. package/{lib/components/action/models/index.d.ts → src/lib/components/action/models/index.ts} +2 -2
  27. package/src/lib/components/action/route/action-route.component.html +1 -0
  28. package/src/lib/components/action/route/action-route.component.ts +159 -0
  29. package/src/lib/components/form/autocomplete/autocomplete.component.html +16 -0
  30. package/src/lib/components/form/autocomplete/autocomplete.component.ts +113 -0
  31. package/src/lib/components/form/dropdown/dropdown.component.html +29 -0
  32. package/src/lib/components/form/dropdown/dropdown.component.ts +109 -0
  33. package/src/lib/components/form/editor/form-editor.component.html +5 -0
  34. package/src/lib/components/form/editor/form-editor.component.ts +149 -0
  35. package/src/lib/components/form/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.html +7 -0
  36. package/src/lib/components/form/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.ts +21 -0
  37. package/src/lib/components/form/formly/fields/formly-field-dropdown/formly-field-dropdown.component.html +9 -0
  38. package/src/lib/components/form/formly/fields/formly-field-dropdown/formly-field-dropdown.component.ts +22 -0
  39. package/src/lib/components/form/formly/fields/formly-field-fieldset/formly-field-fieldset.component.html +8 -0
  40. package/src/lib/components/form/formly/fields/formly-field-fieldset/formly-field-fieldset.component.ts +10 -0
  41. package/src/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.html +56 -0
  42. package/src/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.ts +22 -0
  43. package/src/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.html +13 -0
  44. package/src/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.scss +4 -0
  45. package/src/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.ts +114 -0
  46. package/src/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.html +37 -0
  47. package/src/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.ts +133 -0
  48. package/src/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.html +10 -0
  49. package/src/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.ts +10 -0
  50. package/{lib/components/form/formly/fields/index.d.ts → src/lib/components/form/formly/fields/index.ts} +7 -7
  51. package/src/lib/components/form/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.html +7 -0
  52. package/src/lib/components/form/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.ts +13 -0
  53. package/src/lib/components/form/formly/wrappers/formly-table-wrapper/formly-table-wrapper.component.html +6 -0
  54. package/src/lib/components/form/formly/wrappers/formly-table-wrapper/formly-table-wrapper.component.ts +13 -0
  55. package/{lib/components/form/formly/wrappers/index.d.ts → src/lib/components/form/formly/wrappers/index.ts} +2 -2
  56. package/{lib/components/form/index.d.ts → src/lib/components/form/index.ts} +3 -3
  57. package/src/lib/components/form/models/form-editor.event.ts +7 -0
  58. package/{lib/components/form/models/index.d.ts → src/lib/components/form/models/index.ts} +1 -1
  59. package/src/lib/components/layout/breadcrumb.component.html +5 -0
  60. package/src/lib/components/layout/breadcrumb.component.ts +12 -0
  61. package/src/lib/components/layout/footer.component.html +7 -0
  62. package/src/lib/components/layout/footer.component.ts +15 -0
  63. package/{lib/components/layout/index.d.ts → src/lib/components/layout/index.ts} +6 -6
  64. package/src/lib/components/layout/main-layout.component.html +26 -0
  65. package/src/lib/components/layout/main-layout.component.ts +54 -0
  66. package/src/lib/components/layout/menu-item.component.html +41 -0
  67. package/src/lib/components/layout/menu-item.component.ts +170 -0
  68. package/src/lib/components/layout/menu.component.html +27 -0
  69. package/src/lib/components/layout/menu.component.ts +17 -0
  70. package/{lib/components/layout/services/index.d.ts → src/lib/components/layout/services/index.ts} +1 -1
  71. package/src/lib/components/layout/services/main-layout.component.service.ts +231 -0
  72. package/src/lib/components/layout/topbar.component.html +38 -0
  73. package/src/lib/components/layout/topbar.component.ts +62 -0
  74. package/{lib/components/tableview/index.d.ts → src/lib/components/tableview/index.ts} +5 -5
  75. package/{lib/components/tableview/models/index.d.ts → src/lib/components/tableview/models/index.ts} +1 -1
  76. package/src/lib/components/tableview/models/table.event.ts +22 -0
  77. package/src/lib/components/tableview/route/tableview-route.abstract.component.ts +31 -0
  78. package/{lib/components/tableview/services/index.d.ts → src/lib/components/tableview/services/index.ts} +1 -1
  79. package/src/lib/components/tableview/services/tableview.component.service.ts +22 -0
  80. package/src/lib/components/tableview/table/column-filter/column-filter.component.html +36 -0
  81. package/src/lib/components/tableview/table/column-filter/column-filter.component.ts +70 -0
  82. package/src/lib/components/tableview/table/column-value/column-value.component.html +14 -0
  83. package/src/lib/components/tableview/table/column-value/column-value.component.ts +19 -0
  84. package/src/lib/components/tableview/table/table.component.html +110 -0
  85. package/src/lib/components/tableview/table/table.component.ts +327 -0
  86. package/src/lib/components/tableview/tableview.component.html +37 -0
  87. package/src/lib/components/tableview/tableview.component.ts +78 -0
  88. package/src/lib/config/formly.config.ts +154 -0
  89. package/{lib/config/index.d.ts → src/lib/config/index.ts} +1 -1
  90. package/{lib/config/models/index.d.ts → src/lib/config/models/index.ts} +1 -1
  91. package/{lib/config/models/mng-config.model.d.ts → src/lib/config/models/mng-config.model.ts} +35 -34
  92. package/src/lib/data-providers/base.data-provider.ts +42 -0
  93. package/src/lib/data-providers/editor.data-provider.ts +60 -0
  94. package/{lib/data-providers/index.d.ts → src/lib/data-providers/index.ts} +5 -5
  95. package/src/lib/data-providers/lookup.data-provider.ts +29 -0
  96. package/{lib/data-providers/table.data-provider.d.ts → src/lib/data-providers/table.data-provider.ts} +8 -6
  97. package/src/lib/data-providers/tableview.data-provider.ts +29 -0
  98. package/src/lib/descriptors/action.descriptor.ts +439 -0
  99. package/src/lib/descriptors/editor.descriptor.ts +880 -0
  100. package/src/lib/descriptors/field.validator.ts +35 -0
  101. package/{lib/descriptors/index.d.ts → src/lib/descriptors/index.ts} +7 -7
  102. package/{lib/descriptors/lookup.descriptor.d.ts → src/lib/descriptors/lookup.descriptor.ts} +20 -17
  103. package/src/lib/descriptors/model.descriptor.ts +47 -0
  104. package/src/lib/descriptors/table.descriptor.ts +514 -0
  105. package/src/lib/descriptors/tableview.descriptor.ts +180 -0
  106. package/src/lib/directives/component.directive.ts +18 -0
  107. package/{lib/directives/index.d.ts → src/lib/directives/index.ts} +2 -2
  108. package/src/lib/directives/template.directive.ts +24 -0
  109. package/src/lib/mng-commons.module.ts +240 -0
  110. package/{lib/models/index.d.ts → src/lib/models/index.ts} +2 -2
  111. package/src/lib/models/router.model.ts +16 -0
  112. package/{lib/models/user.model.d.ts → src/lib/models/user.model.ts} +9 -8
  113. package/src/lib/pipes/boolean.pipe.ts +17 -0
  114. package/{lib/pipes/index.d.ts → src/lib/pipes/index.ts} +2 -2
  115. package/src/lib/pipes/property-path.pipe.ts +30 -0
  116. package/src/lib/services/action.service.ts +310 -0
  117. package/src/lib/services/commons.service.ts +407 -0
  118. package/src/lib/services/configuration.service.ts +98 -0
  119. package/{lib/services/index.d.ts → src/lib/services/index.ts} +4 -4
  120. package/src/lib/services/navigation.service.ts +42 -0
  121. package/src/lib/services/providers/commons-init.provider.ts +5 -0
  122. package/src/lib/services/providers/config-service.provider.ts +22 -0
  123. package/src/lib/services/providers/formly-config.provider.ts +39 -0
  124. package/{lib/services/providers/index.d.ts → src/lib/services/providers/index.ts} +3 -3
  125. package/src/lib/services/tokens/browser-storage.token.ts +9 -0
  126. package/{lib/services/tokens/index.d.ts → src/lib/services/tokens/index.ts} +2 -2
  127. package/src/lib/services/tokens/module-config.token.ts +5 -0
  128. package/{lib/types/index.d.ts → src/lib/types/index.ts} +2 -2
  129. package/src/lib/types/type.decorator.ts +7 -0
  130. package/src/lib/types/type.model.ts +12 -0
  131. package/src/lib/utils/editor-formly.util.ts +193 -0
  132. package/src/lib/utils/i18n.util.ts +148 -0
  133. package/{lib/utils/index.d.ts → src/lib/utils/index.ts} +5 -5
  134. package/src/lib/utils/model.util.ts +66 -0
  135. package/src/lib/utils/toast.util.ts +49 -0
  136. package/src/lib/utils/type.util.ts +44 -0
  137. package/{public-api.d.ts → src/public-api.ts} +42 -25
  138. package/src/test.ts +26 -0
  139. package/tsconfig.lib.json +15 -0
  140. package/tsconfig.lib.prod.json +10 -0
  141. package/tsconfig.spec.json +17 -0
  142. package/esm2020/lib/api/models/builders/query-param.builder.mjs +0 -48
  143. package/esm2020/lib/api/models/filter-match-type.model.mjs +0 -26
  144. package/esm2020/lib/api/models/filter-param.model.mjs +0 -46
  145. package/esm2020/lib/api/models/index.mjs +0 -9
  146. package/esm2020/lib/api/models/mappers.mjs +0 -17
  147. package/esm2020/lib/api/models/query-mode.model.mjs +0 -19
  148. package/esm2020/lib/api/models/query-param.model.mjs +0 -69
  149. package/esm2020/lib/api/models/query-result.model.mjs +0 -45
  150. package/esm2020/lib/api/models/serialization.model.mjs +0 -2
  151. package/esm2020/lib/api/services/crud-api.abstract.service.mjs +0 -72
  152. package/esm2020/lib/api/services/index.mjs +0 -2
  153. package/esm2020/lib/api/utils/index.mjs +0 -3
  154. package/esm2020/lib/api/utils/medius-rest.util.mjs +0 -122
  155. package/esm2020/lib/api/utils/object-serializer.util.mjs +0 -226
  156. package/esm2020/lib/components/action/action.component.mjs +0 -65
  157. package/esm2020/lib/components/action/dialog/action-dialog.component.mjs +0 -148
  158. package/esm2020/lib/components/action/index.mjs +0 -4
  159. package/esm2020/lib/components/action/models/action-confirmation-service.model.mjs +0 -2
  160. package/esm2020/lib/components/action/models/action-execution.model.mjs +0 -58
  161. package/esm2020/lib/components/action/models/index.mjs +0 -3
  162. package/esm2020/lib/components/action/route/action-route.component.mjs +0 -144
  163. package/esm2020/lib/components/form/autocomplete/autocomplete.component.mjs +0 -114
  164. package/esm2020/lib/components/form/dropdown/dropdown.component.mjs +0 -113
  165. package/esm2020/lib/components/form/editor/form-editor.component.mjs +0 -141
  166. package/esm2020/lib/components/form/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.mjs +0 -19
  167. package/esm2020/lib/components/form/formly/fields/formly-field-dropdown/formly-field-dropdown.component.mjs +0 -19
  168. package/esm2020/lib/components/form/formly/fields/formly-field-fieldset/formly-field-fieldset.component.mjs +0 -16
  169. package/esm2020/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.mjs +0 -26
  170. package/esm2020/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.mjs +0 -109
  171. package/esm2020/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.mjs +0 -122
  172. package/esm2020/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.mjs +0 -17
  173. package/esm2020/lib/components/form/formly/fields/index.mjs +0 -8
  174. package/esm2020/lib/components/form/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.mjs +0 -17
  175. package/esm2020/lib/components/form/formly/wrappers/formly-table-wrapper/formly-table-wrapper.component.mjs +0 -16
  176. package/esm2020/lib/components/form/formly/wrappers/index.mjs +0 -3
  177. package/esm2020/lib/components/form/index.mjs +0 -4
  178. package/esm2020/lib/components/form/models/form-editor.event.mjs +0 -7
  179. package/esm2020/lib/components/form/models/index.mjs +0 -2
  180. package/esm2020/lib/components/layout/breadcrumb.component.mjs +0 -17
  181. package/esm2020/lib/components/layout/footer.component.mjs +0 -17
  182. package/esm2020/lib/components/layout/index.mjs +0 -7
  183. package/esm2020/lib/components/layout/main-layout.component.mjs +0 -54
  184. package/esm2020/lib/components/layout/menu-item.component.mjs +0 -173
  185. package/esm2020/lib/components/layout/menu.component.mjs +0 -20
  186. package/esm2020/lib/components/layout/services/index.mjs +0 -2
  187. package/esm2020/lib/components/layout/services/main-layout.component.service.mjs +0 -190
  188. package/esm2020/lib/components/layout/topbar.component.mjs +0 -59
  189. package/esm2020/lib/components/tableview/index.mjs +0 -6
  190. package/esm2020/lib/components/tableview/models/index.mjs +0 -2
  191. package/esm2020/lib/components/tableview/models/table.event.mjs +0 -16
  192. package/esm2020/lib/components/tableview/route/tableview-route.abstract.component.mjs +0 -24
  193. package/esm2020/lib/components/tableview/services/index.mjs +0 -2
  194. package/esm2020/lib/components/tableview/services/tableview.component.service.mjs +0 -17
  195. package/esm2020/lib/components/tableview/table/column-filter/column-filter.component.mjs +0 -74
  196. package/esm2020/lib/components/tableview/table/column-value/column-value.component.mjs +0 -25
  197. package/esm2020/lib/components/tableview/table/table.component.mjs +0 -307
  198. package/esm2020/lib/components/tableview/tableview.component.mjs +0 -82
  199. package/esm2020/lib/config/formly.config.mjs +0 -136
  200. package/esm2020/lib/config/index.mjs +0 -2
  201. package/esm2020/lib/config/models/index.mjs +0 -2
  202. package/esm2020/lib/config/models/mng-config.model.mjs +0 -2
  203. package/esm2020/lib/data-providers/base.data-provider.mjs +0 -24
  204. package/esm2020/lib/data-providers/editor.data-provider.mjs +0 -37
  205. package/esm2020/lib/data-providers/index.mjs +0 -6
  206. package/esm2020/lib/data-providers/lookup.data-provider.mjs +0 -16
  207. package/esm2020/lib/data-providers/table.data-provider.mjs +0 -2
  208. package/esm2020/lib/data-providers/tableview.data-provider.mjs +0 -17
  209. package/esm2020/lib/descriptors/action.descriptor.mjs +0 -332
  210. package/esm2020/lib/descriptors/editor.descriptor.mjs +0 -670
  211. package/esm2020/lib/descriptors/field.validator.mjs +0 -21
  212. package/esm2020/lib/descriptors/index.mjs +0 -8
  213. package/esm2020/lib/descriptors/lookup.descriptor.mjs +0 -2
  214. package/esm2020/lib/descriptors/model.descriptor.mjs +0 -34
  215. package/esm2020/lib/descriptors/table.descriptor.mjs +0 -401
  216. package/esm2020/lib/descriptors/tableview.descriptor.mjs +0 -131
  217. package/esm2020/lib/directives/component.directive.mjs +0 -23
  218. package/esm2020/lib/directives/index.mjs +0 -3
  219. package/esm2020/lib/directives/template.directive.mjs +0 -29
  220. package/esm2020/lib/mng-commons.module.mjs +0 -410
  221. package/esm2020/lib/models/index.mjs +0 -3
  222. package/esm2020/lib/models/router.model.mjs +0 -2
  223. package/esm2020/lib/models/user.model.mjs +0 -2
  224. package/esm2020/lib/pipes/boolean.pipe.mjs +0 -22
  225. package/esm2020/lib/pipes/index.mjs +0 -3
  226. package/esm2020/lib/pipes/property-path.pipe.mjs +0 -36
  227. package/esm2020/lib/services/action.service.mjs +0 -269
  228. package/esm2020/lib/services/commons.service.mjs +0 -353
  229. package/esm2020/lib/services/configuration.service.mjs +0 -78
  230. package/esm2020/lib/services/index.mjs +0 -5
  231. package/esm2020/lib/services/navigation.service.mjs +0 -48
  232. package/esm2020/lib/services/providers/commons-init.provider.mjs +0 -4
  233. package/esm2020/lib/services/providers/config-service.provider.mjs +0 -20
  234. package/esm2020/lib/services/providers/formly-config.provider.mjs +0 -31
  235. package/esm2020/lib/services/providers/index.mjs +0 -4
  236. package/esm2020/lib/services/tokens/browser-storage.token.mjs +0 -6
  237. package/esm2020/lib/services/tokens/index.mjs +0 -3
  238. package/esm2020/lib/services/tokens/module-config.token.mjs +0 -3
  239. package/esm2020/lib/types/index.mjs +0 -3
  240. package/esm2020/lib/types/type.decorator.mjs +0 -7
  241. package/esm2020/lib/types/type.model.mjs +0 -2
  242. package/esm2020/lib/utils/editor-formly.util.mjs +0 -176
  243. package/esm2020/lib/utils/i18n.util.mjs +0 -125
  244. package/esm2020/lib/utils/index.mjs +0 -6
  245. package/esm2020/lib/utils/model.util.mjs +0 -57
  246. package/esm2020/lib/utils/toast.util.mjs +0 -39
  247. package/esm2020/lib/utils/type.util.mjs +0 -39
  248. package/esm2020/mediusinc-mng-commons.mjs +0 -5
  249. package/esm2020/public-api.mjs +0 -36
  250. package/fesm2015/mediusinc-mng-commons.mjs +0 -6250
  251. package/fesm2015/mediusinc-mng-commons.mjs.map +0 -1
  252. package/fesm2020/mediusinc-mng-commons.mjs +0 -6176
  253. package/fesm2020/mediusinc-mng-commons.mjs.map +0 -1
  254. package/lib/api/models/builders/query-param.builder.d.ts +0 -11
  255. package/lib/api/models/filter-param.model.d.ts +0 -23
  256. package/lib/api/models/mappers.d.ts +0 -6
  257. package/lib/api/models/query-mode.model.d.ts +0 -16
  258. package/lib/api/models/query-param.model.d.ts +0 -31
  259. package/lib/api/models/query-result.model.d.ts +0 -36
  260. package/lib/api/services/crud-api.abstract.service.d.ts +0 -23
  261. package/lib/api/utils/medius-rest.util.d.ts +0 -12
  262. package/lib/api/utils/object-serializer.util.d.ts +0 -30
  263. package/lib/components/action/action.component.d.ts +0 -36
  264. package/lib/components/action/dialog/action-dialog.component.d.ts +0 -46
  265. package/lib/components/action/models/action-execution.model.d.ts +0 -53
  266. package/lib/components/action/route/action-route.component.d.ts +0 -32
  267. package/lib/components/form/autocomplete/autocomplete.component.d.ts +0 -36
  268. package/lib/components/form/dropdown/dropdown.component.d.ts +0 -34
  269. package/lib/components/form/editor/form-editor.component.d.ts +0 -39
  270. package/lib/components/form/formly/fields/formly-field-autocomplete/formly-field-autocomplete.component.d.ts +0 -11
  271. package/lib/components/form/formly/fields/formly-field-dropdown/formly-field-dropdown.component.d.ts +0 -11
  272. package/lib/components/form/formly/fields/formly-field-fieldset/formly-field-fieldset.component.d.ts +0 -6
  273. package/lib/components/form/formly/fields/formly-field-input/formly-field-input.component.d.ts +0 -12
  274. package/lib/components/form/formly/fields/formly-field-table-dialog-form/formly-field-table-dialog-form.component.d.ts +0 -17
  275. package/lib/components/form/formly/fields/formly-field-table-dialog-multiselect/formly-field-table-dialog-multiselect.component.d.ts +0 -36
  276. package/lib/components/form/formly/fields/formly-field-tabs/formly-field-tabs.component.d.ts +0 -6
  277. package/lib/components/form/formly/wrappers/formly-field-wrapper/formly-field-wrapper.component.d.ts +0 -8
  278. package/lib/components/form/formly/wrappers/formly-table-wrapper/formly-table-wrapper.component.d.ts +0 -8
  279. package/lib/components/form/models/form-editor.event.d.ts +0 -5
  280. package/lib/components/layout/breadcrumb.component.d.ts +0 -8
  281. package/lib/components/layout/footer.component.d.ts +0 -9
  282. package/lib/components/layout/main-layout.component.d.ts +0 -21
  283. package/lib/components/layout/menu-item.component.d.ts +0 -29
  284. package/lib/components/layout/menu.component.d.ts +0 -10
  285. package/lib/components/layout/services/main-layout.component.service.d.ts +0 -65
  286. package/lib/components/layout/topbar.component.d.ts +0 -25
  287. package/lib/components/tableview/models/table.event.d.ts +0 -17
  288. package/lib/components/tableview/route/tableview-route.abstract.component.d.ts +0 -14
  289. package/lib/components/tableview/services/tableview.component.service.d.ts +0 -13
  290. package/lib/components/tableview/table/column-filter/column-filter.component.d.ts +0 -22
  291. package/lib/components/tableview/table/column-value/column-value.component.d.ts +0 -12
  292. package/lib/components/tableview/table/table.component.d.ts +0 -79
  293. package/lib/components/tableview/tableview.component.d.ts +0 -35
  294. package/lib/config/formly.config.d.ts +0 -14
  295. package/lib/data-providers/base.data-provider.d.ts +0 -17
  296. package/lib/data-providers/editor.data-provider.d.ts +0 -25
  297. package/lib/data-providers/lookup.data-provider.d.ts +0 -14
  298. package/lib/data-providers/tableview.data-provider.d.ts +0 -15
  299. package/lib/descriptors/action.descriptor.d.ts +0 -148
  300. package/lib/descriptors/editor.descriptor.d.ts +0 -255
  301. package/lib/descriptors/field.validator.d.ts +0 -18
  302. package/lib/descriptors/model.descriptor.d.ts +0 -15
  303. package/lib/descriptors/table.descriptor.d.ts +0 -164
  304. package/lib/descriptors/tableview.descriptor.d.ts +0 -39
  305. package/lib/directives/component.directive.d.ts +0 -11
  306. package/lib/directives/template.directive.d.ts +0 -13
  307. package/lib/mng-commons.module.d.ts +0 -79
  308. package/lib/models/router.model.d.ts +0 -14
  309. package/lib/pipes/boolean.pipe.d.ts +0 -7
  310. package/lib/pipes/property-path.pipe.d.ts +0 -7
  311. package/lib/services/action.service.d.ts +0 -92
  312. package/lib/services/commons.service.d.ts +0 -72
  313. package/lib/services/configuration.service.d.ts +0 -35
  314. package/lib/services/navigation.service.d.ts +0 -14
  315. package/lib/services/providers/commons-init.provider.d.ts +0 -2
  316. package/lib/services/providers/config-service.provider.d.ts +0 -5
  317. package/lib/services/providers/formly-config.provider.d.ts +0 -4
  318. package/lib/services/tokens/browser-storage.token.d.ts +0 -2
  319. package/lib/services/tokens/module-config.token.d.ts +0 -3
  320. package/lib/types/type.decorator.d.ts +0 -2
  321. package/lib/types/type.model.d.ts +0 -10
  322. package/lib/utils/editor-formly.util.d.ts +0 -9
  323. package/lib/utils/i18n.util.d.ts +0 -18
  324. package/lib/utils/model.util.d.ts +0 -7
  325. package/lib/utils/toast.util.d.ts +0 -13
  326. package/lib/utils/type.util.d.ts +0 -15
  327. package/mediusinc-mng-commons-0.2.0.tgz +0 -0
  328. package/mediusinc-mng-commons.d.ts +0 -5
@@ -0,0 +1,110 @@
1
+ <div [style.height]="scrollHeight === 'flex' ? 'calc(100vh - ' + descriptor.tableFullHeightOffset + 'px)' : null">
2
+ <!-- MUST NOT use observable for value when using virtual scroll - does not work for some reason -->
3
+ <p-table *ngIf="!useQueryParams || useQueryParamsInitialized"
4
+ [value]="infiniteScroll ? dataProviderInfiniteScrollItems : ((queryResult$ | async)?.pageData ?? [])"
5
+ [dataKey]="$any(descriptor.dataKeyProperty)"
6
+ [lazy]="useDataProvider"
7
+ [loading]="(loading$ | async) ?? false"
8
+ [paginator]="useDataProvider && !infiniteScroll"
9
+ [rows]="$any(infiniteScroll ? 20 : rows)"
10
+ [first]="$any(infiniteScroll ? 0 : offset)"
11
+ [totalRecords]="$any(infiniteScroll ? null : (queryResult$ | async)?.allDataCount ?? 0)"
12
+ [rowsPerPageOptions]="$any(infiniteScroll ? null : rowsPerPageOptions)"
13
+ [showCurrentPageReport]="!infiniteScroll"
14
+ [currentPageReportTemplate]="'mngTable.paginationMsg' | translate"
15
+ [multiSortMeta]="$any(multiSortMeta)"
16
+ [filters]="filterMetadata"
17
+ [(selection)]="selection"
18
+ (selectionChange)="onSelectionChange($event)"
19
+ [scrollable]="infiniteScroll"
20
+ [virtualScroll]="infiniteScroll"
21
+ [virtualRowHeight]="$any(rowHeight)"
22
+ [scrollHeight]="$any(scrollHeight)"
23
+ [rowHover]="true"
24
+ (onLazyLoad)="onTableLazyLoad($event)"
25
+ (onSort)="onTableSort($event)"
26
+ (onFilter)="onTableFilter($event)"
27
+ sortMode="multiple"
28
+ responsiveLayout="scroll">
29
+
30
+ <ng-template *ngIf="captionTemplate || descriptor.title" pTemplate="caption">
31
+ <ng-container *ngIf="captionTemplate; else defaultCaption">
32
+ <ng-container *ngTemplateOutlet="captionTemplate"></ng-container>
33
+ </ng-container>
34
+ <ng-template #defaultCaption>
35
+ <h5 class="p-m-0">{{ descriptor.title }}</h5>
36
+ </ng-template>
37
+ </ng-template>
38
+
39
+ <ng-template pTemplate="header">
40
+ <tr>
41
+ <th *ngIf="selectionEnabled">
42
+ <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
43
+ </th>
44
+ <ng-container *ngFor="let col of descriptor.columns">
45
+ <th *ngIf="col.isSortEnabled" [pSortableColumn]="col.property">
46
+ <div class="flex justify-content-between align-items-center">
47
+ {{ descriptor.model.typeName + ".properties." + col.property | translate }}
48
+ <p-sortIcon [field]="col.property"></p-sortIcon>
49
+ <mng-table-column-filter *ngIf="col.filterDescriptor && descriptor.filterDisplay === filterDisplayMenu"
50
+ class="ml-auto"
51
+ [display]="descriptor.filterDisplay"
52
+ [descriptor]="col.filterDescriptor">
53
+ </mng-table-column-filter>
54
+ </div>
55
+ </th>
56
+ <th *ngIf="!col.isSortEnabled">
57
+ {{ descriptor.model.typeName + ".properties." + col.property | translate }}
58
+ <ng-container>
59
+ <mng-table-column-filter *ngIf="col.filterDescriptor && descriptor.filterDisplay === filterDisplayMenu"
60
+ class="ml-auto"
61
+ [display]="descriptor.filterDisplay"
62
+ [descriptor]="col.filterDescriptor">
63
+ </mng-table-column-filter>
64
+ </ng-container>
65
+ </th>
66
+ </ng-container>
67
+ <th *ngIf="columnActionTemplate"></th>
68
+ </tr>
69
+ <tr *ngIf="descriptor.filterDisplay === filterDisplayRow">
70
+ <th *ngFor="let col of descriptor.columns">
71
+ <div class="flex" *ngIf="col.filterDescriptor">
72
+ <mng-table-column-filter [display]="descriptor.filterDisplay" [descriptor]="col.filterDescriptor"></mng-table-column-filter>
73
+ </div>
74
+ </th>
75
+ <th *ngIf="columnActionTemplate"></th>
76
+ </tr>
77
+ </ng-template>
78
+
79
+ <ng-template pTemplate="body" let-item let-idx="rowIndex">
80
+ <tr [style.height.px]="descriptor.rowHeight">
81
+ <td *ngIf="selectionEnabled">
82
+ <p-tableCheckbox [value]="item"></p-tableCheckbox>
83
+ </td>
84
+ <td *ngFor="let col of descriptor.columns" (click)="onCellClick(col, item, idx)" class="clickable">
85
+ <mng-table-column-value [descriptor]="col" [item]="item"></mng-table-column-value>
86
+ </td>
87
+ <td *ngIf="columnActionTemplate" class="text-right">
88
+ <ng-container *ngTemplateOutlet="columnActionTemplate; context: { rowItem: item, rowIndex: idx }"></ng-container>
89
+ </td>
90
+ </tr>
91
+ </ng-template>
92
+
93
+ <ng-template pTemplate="loadingbody">
94
+ <tr [style.height.px]="descriptor.rowHeight">
95
+ <td [attr.colspan]="descriptor.columns.length + (columnActionTemplate ? 1 : 0) + (selectionEnabled ? 1 : 0)">
96
+ <div class="loading-text"></div>
97
+ <p-skeleton [ngStyle]="{'width': '100%'}"></p-skeleton>
98
+ </td>
99
+ </tr>
100
+ </ng-template>
101
+
102
+ <ng-template pTemplate="emptymessage">
103
+ <tr [style.height.px]="rowHeight">
104
+ <td [attr.colspan]="descriptor.columns.length + (columnActionTemplate ? 1 : 0) + (selectionEnabled ? 1 : 0)">
105
+ {{ 'mngTable.noItems' | translate }}
106
+ </td>
107
+ </tr>
108
+ </ng-template>
109
+ </p-table>
110
+ </div>
@@ -0,0 +1,327 @@
1
+ import {AfterContentInit, ChangeDetectionStrategy, Component, ContentChildren, EventEmitter, Injector, Input, OnDestroy, OnInit, Optional, Output, QueryList, TemplateRef, ViewChild} from '@angular/core';
2
+ import {ActivatedRoute, Params, Router} from '@angular/router';
3
+
4
+ import {Table} from 'primeng/table';
5
+ import {LazyLoadEvent, SortMeta} from 'primeng/api';
6
+ import {FilterMetadata} from 'primeng/api/filtermetadata';
7
+ import {Observable, of, ReplaySubject, Subscription} from 'rxjs';
8
+ import {finalize, first, map} from 'rxjs/operators';
9
+ import {TranslateService} from '@ngx-translate/core';
10
+
11
+ import {MediusQueryParam, MediusQueryParamBuilder, MediusQueryResult} from '../../../api/models';
12
+ import {MediusRestUtil} from '../../../api/utils';
13
+ import {ColumnDescriptor, FilterDescriptor, TableDescriptor} from '../../../descriptors';
14
+ import {ITableDataProvider} from '../../../data-providers';
15
+ import {MngTableCellClickEvent, MngTableLoadEvent} from '../models';
16
+ import {MngTemplateDirective} from '../../../directives';
17
+ import {ToastUtil} from '../../../utils';
18
+ import {TableviewComponentService} from '../services';
19
+
20
+ import TypeEnum = FilterDescriptor.TypeEnum;
21
+ import PaginationModeEnum = TableDescriptor.PaginationModeEnum;
22
+
23
+ @Component({
24
+ selector: 'mng-table',
25
+ templateUrl: './table.component.html',
26
+ changeDetection: ChangeDetectionStrategy.OnPush
27
+ })
28
+ export class MngTableComponent<T, S> implements OnInit, AfterContentInit, OnDestroy {
29
+
30
+ public readonly filterDisplayRow: TableDescriptor.FilterDisplayEnum = TableDescriptor.FilterDisplayEnum.Row;
31
+ public readonly filterDisplayMenu: TableDescriptor.FilterDisplayEnum = TableDescriptor.FilterDisplayEnum.Menu;
32
+
33
+ // metadata input
34
+ @Input() public descriptor!: TableDescriptor<T>;
35
+
36
+ // data source inputs
37
+ @Input() public items?: Observable<Array<T>>|Array<T>;
38
+ @Input() public queryResult?: Observable<MediusQueryResult<T>>|MediusQueryResult<T>;
39
+ @Input() public loading?: Observable<boolean>|boolean;
40
+ @Input() public dataProvider?: ITableDataProvider<T, any>;
41
+ @Input() public useQueryParams = false;
42
+
43
+ // extra features input
44
+ @Input() public selectionEnabled: boolean = false;
45
+
46
+ // event outputs
47
+ @Output('onLoad') private loadEventEmitter = new EventEmitter<MngTableLoadEvent>();
48
+ @Output('onCellClick') private cellClickEventEmitter = new EventEmitter<MngTableCellClickEvent<T>>();
49
+ @Output('onSelectionChange') private selectionChangeEventEmitter = new EventEmitter<Array<T>>();
50
+
51
+ // content and view queries
52
+ @ContentChildren(MngTemplateDirective) templates!: QueryList<MngTemplateDirective>;
53
+ @ViewChild(Table) private primeTable!: Table;
54
+
55
+ // templates
56
+ public captionTemplate?: TemplateRef<any>;
57
+ public columnActionTemplate?: TemplateRef<any>;
58
+
59
+ // data provider and items
60
+ public useDataProvider: boolean = false;
61
+ public useQueryParamsInitialized: boolean = false;
62
+ public queryResult$?: Observable<MediusQueryResult<T>>;
63
+ public loading$?: Observable<boolean>;
64
+ public dataProviderInfiniteScrollItems: Array<T> = [];
65
+ private dataProviderService: any = null;
66
+ private dataProviderQueryResultSubject = new ReplaySubject<MediusQueryResult<T>>(1);
67
+ private dataProviderLoadingSubject = new ReplaySubject<boolean>(1);
68
+ private dataProviderLatestLazyLoadEvent?: LazyLoadEvent;
69
+ private dataProviderLatestLazyLoadEventVersion: number = 0;
70
+ private dataProviderLatestQueryParam?: MediusQueryParam;
71
+ private dataProviderLatestQueryParamVersion: number = 0;
72
+ private dataProviderSubscription?: Subscription;
73
+
74
+ // pagination, sort and filters
75
+ public readonly rowsPerPageOptions = [25, 50, 100];
76
+ public rows = this.rowsPerPageOptions[0];
77
+ public offset = 0;
78
+ public multiSortMeta: SortMeta[]|null = null;
79
+ public filterMetadata: { [s: string]: FilterMetadata | FilterMetadata[] } = {};
80
+ private isFilterChanged = false;
81
+ private isSortChanged = false;
82
+
83
+ // infinite scroll
84
+ public infiniteScroll = false;
85
+ public scrollHeight: 'flex'|null = null;
86
+ public rowHeight: number|null = null;
87
+
88
+ public selection: Array<T> = [];
89
+ private subscriptions: Subscription[] = [];
90
+ private filterDescriptors: Array<FilterDescriptor<any>> = [];
91
+
92
+ constructor(private injector: Injector,
93
+ private router: Router,
94
+ private activatedRoute: ActivatedRoute,
95
+ private translate: TranslateService,
96
+ @Optional() private tableviewService: TableviewComponentService<T, S>
97
+ ) { }
98
+
99
+ public ngOnInit() {
100
+
101
+ // @ts-ignore
102
+ this.filterDescriptors = this.descriptor.columns.filter(c => typeof c.filterDescriptor !== 'undefined').map(c => c.filterDescriptor);
103
+
104
+ if (this.descriptor.paginationMode === PaginationModeEnum.InfiniteScroll) {
105
+ this.infiniteScroll = true;
106
+ this.scrollHeight = 'flex';
107
+ this.rowHeight = this.descriptor.rowHeight;
108
+ this.useQueryParams = false;
109
+ }
110
+
111
+ // check if data provider is supplied, if is, use it primarily
112
+ if (this.dataProvider) {
113
+ // map subjects to observables and initiate data
114
+ this.useDataProvider = true;
115
+ this.queryResult$ = this.dataProviderQueryResultSubject.asObservable();
116
+ this.loading$ = this.dataProviderLoadingSubject.asObservable();
117
+ const emptyQueryResult = new MediusQueryResult<T>();
118
+ emptyQueryResult.pageData = [];
119
+ emptyQueryResult.allDataCount = 0;
120
+ this.dataProviderLoadingSubject.next(false);
121
+ this.dataProviderQueryResultSubject.next(emptyQueryResult)
122
+
123
+ // inject service
124
+ if (this.dataProvider.serviceType) {
125
+ this.dataProviderService = this.injector.get<any>(this.dataProvider.serviceType);
126
+ }
127
+ } else {
128
+ // if query result is provided, use it as secondary source or else try to use items
129
+ if (this.queryResult) {
130
+ this.queryResult$ = this.queryResult instanceof Observable ? this.queryResult : of(this.queryResult);
131
+ } else if (!this.queryResult && this.items) {
132
+ this.queryResult$ = (this.items instanceof Observable ? this.items : of(this.items)).pipe(
133
+ // distinctUntilChanged((v1, v2) => v1.length === v2.length &&
134
+ // v1.every((v1i, idx) => v1i[this.descriptor.dataKeyProperty] === v2[idx][this.descriptor.dataKeyProperty])),
135
+ map(items => {
136
+ const queryResult = new MediusQueryResult<T>();
137
+ queryResult.pageData = items;
138
+ queryResult.allDataCount = items.length;
139
+ return queryResult;
140
+ }));
141
+ }
142
+ if (typeof this.loading !== 'undefined') {
143
+ this.loading$ = this.loading instanceof Observable ? this.loading : of(this.loading);
144
+ }
145
+ }
146
+
147
+ if (this.useQueryParams) {
148
+ const subscription = this.activatedRoute.queryParams.subscribe(qp => {
149
+ this.loadTableFromRouteUpdate(qp);
150
+ });
151
+ this.subscriptions.push(subscription);
152
+ } else {
153
+ // initialize default sort if present
154
+ const defaultSort = this.getDefaultSortMeta();
155
+ if (defaultSort.length > 0) {
156
+ this.multiSortMeta = defaultSort;
157
+ }
158
+ }
159
+ }
160
+
161
+ public ngAfterContentInit() {
162
+ this.templates.forEach(template => {
163
+ switch(template.getType()) {
164
+ case 'caption':
165
+ this.captionTemplate = template.template;
166
+ break;
167
+ case 'columnAction':
168
+ this.columnActionTemplate = template.template;
169
+ break;
170
+ }
171
+ });
172
+ }
173
+
174
+ public ngOnDestroy() {
175
+ this.subscriptions.forEach(s => s.unsubscribe());
176
+ }
177
+
178
+ public reload(emitEvent: boolean = false, resetParams: boolean = false) {
179
+ this.loadTableWithDataProvider(resetParams
180
+ ? MediusQueryParamBuilder.create(this.rowsPerPageOptions[0], 0).build()
181
+ : (this.dataProviderLatestQueryParam ?? new MediusQueryParam()), emitEvent);
182
+ }
183
+
184
+ public onTableLazyLoad(event: LazyLoadEvent) {
185
+ this.dataProviderLatestLazyLoadEvent = event;
186
+ this.dataProviderLatestLazyLoadEventVersion++;
187
+
188
+ if (this.useQueryParams) {
189
+ if (!event.multiSortMeta || event.multiSortMeta.length === 0) {
190
+ // add default sort meta to event if not multisort meta is present
191
+ event.multiSortMeta = this.getDefaultSortMeta();
192
+ }
193
+ this.router.navigate([], {
194
+ relativeTo: this.activatedRoute,
195
+ replaceUrl: true,
196
+ queryParams: MediusRestUtil.fromPrimeLazyLoadEventToAngularQueryParams(event, this.rowsPerPageOptions[0])
197
+ });
198
+ } else {
199
+ const mediusQueryParams = event ? MediusRestUtil.fromPrimeLazyLoadEventToMediusQueryParams(event) : new MediusQueryParam();
200
+ this.loadTableWithDataProvider(mediusQueryParams);
201
+ }
202
+ }
203
+
204
+ public onTableSort(event: any) {
205
+ this.isSortChanged = true;
206
+ }
207
+
208
+ public onTableFilter(event: any) {
209
+ this.isFilterChanged = true;
210
+ }
211
+
212
+ public onCellClick(col: ColumnDescriptor<any, T>, item: T, idx: number) {
213
+ const mngEvent = new MngTableCellClickEvent<T>(col, item, idx);
214
+ this.cellClickEventEmitter.next(mngEvent);
215
+ }
216
+
217
+ public onSelectionChange(event: Array<T>) {
218
+ this.selectionChangeEventEmitter.emit(event);
219
+ }
220
+
221
+ private loadTableWithDataProvider(queryParam: MediusQueryParam|null = null, emitEvent: boolean = true) {
222
+ if (!this.useDataProvider) {
223
+ return;
224
+ }
225
+ if (this.dataProviderSubscription) {
226
+ this.dataProviderSubscription.unsubscribe();
227
+ }
228
+
229
+ this.dataProviderLoadingSubject.next(true);
230
+
231
+ if (!queryParam) {
232
+ queryParam = MediusQueryParamBuilder.create(this.rowsPerPageOptions[0]).build();
233
+ }
234
+ this.dataProviderLatestQueryParam = queryParam;
235
+ this.dataProviderLatestQueryParamVersion++;
236
+
237
+ this.dataProviderSubscription = this.dataProvider?.getAll(queryParam, this.dataProviderService)
238
+ .pipe(
239
+ first(),
240
+ finalize(() => this.dataProviderLoadingSubject.next(false))
241
+ )
242
+ .subscribe((res) => {
243
+ if (this.infiniteScroll) {
244
+ if (this.isFilterChanged || this.isSortChanged) {
245
+ this.dataProviderInfiniteScrollItems = [];
246
+ }
247
+ // @ts-ignore
248
+ this.dataProviderInfiniteScrollItems.splice(queryParam.itemsOffset ?? 0, queryParam.itemsPerPage ?? this.rows, ...res.pageData)
249
+ this.dataProviderInfiniteScrollItems = [...this.dataProviderInfiniteScrollItems];
250
+ } else {
251
+ this.dataProviderQueryResultSubject.next(res);
252
+ }
253
+ this.isFilterChanged = false;
254
+ this.isSortChanged = false;
255
+ }, err => {
256
+ ToastUtil.tableNotificationError(this.translate, this.descriptor, err, this.tableviewService);
257
+ const emptyQueryResult = new MediusQueryResult<T>();
258
+ emptyQueryResult.pageData = [];
259
+ emptyQueryResult.allDataCount = 0;
260
+ this.dataProviderQueryResultSubject.next(emptyQueryResult);
261
+ });
262
+
263
+ if (emitEvent) {
264
+ const mngEvent = new MngTableLoadEvent();
265
+ mngEvent.originalEvent = this.dataProviderLatestLazyLoadEvent ?? undefined;
266
+ mngEvent.queryParam = queryParam;
267
+ this.loadEventEmitter.next(mngEvent);
268
+ }
269
+ }
270
+
271
+ private loadTableFromRouteUpdate(params: Params) {
272
+ const mediusQueryParam = MediusRestUtil.fromAngularQueryParamsToMediusQueryParams(params, this.filterDescriptors, this.rowsPerPageOptions[0]);
273
+ if (this.dataProviderLatestLazyLoadEventVersion < this.dataProviderLatestQueryParamVersion + 1) {
274
+ // update only if new version from query params will be higher
275
+ this.updatePrimeSortAndFilter(mediusQueryParam);
276
+ }
277
+ this.useQueryParamsInitialized = true;
278
+ this.loadTableWithDataProvider(mediusQueryParam);
279
+ }
280
+
281
+ private updatePrimeSortAndFilter(mediusQueryParam: MediusQueryParam) {
282
+ const primeSortMeta: SortMeta[] = [];
283
+ const primeFilterMeta: { [s: string]: FilterMetadata | FilterMetadata[] } = {};
284
+
285
+ this.filterDescriptors.forEach(f => {
286
+ // @ts-ignore
287
+ primeFilterMeta[f.property] = {
288
+ value: null,
289
+ matchMode: f.filterType === TypeEnum.String ? 'contains' : 'equals'
290
+ };
291
+ });
292
+
293
+ mediusQueryParam?.sortProperty?.forEach((s, idx) => {
294
+ primeSortMeta.push({
295
+ field: s,
296
+ order: (mediusQueryParam?.sortAsc?.[idx] ?? true) ? 1 : -1
297
+ });
298
+ });
299
+
300
+ mediusQueryParam?.filterParams?.forEach((f, idx) => {
301
+ const descriptor = this.filterDescriptors.find(fd => fd.filterProperty === f.property || fd.property === f.property);
302
+ const operator = MediusRestUtil.matchModeMapping.find(mapping => mapping[2] === f.filterMatchType);
303
+ if (descriptor && operator) {
304
+ primeFilterMeta[descriptor.property] = {
305
+ value: f.filterValue,
306
+ matchMode: operator[0]
307
+ };
308
+ }
309
+ });
310
+
311
+ this.multiSortMeta = primeSortMeta;
312
+ this.filterMetadata = primeFilterMeta;
313
+ this.rows = mediusQueryParam?.itemsPerPage ?? this.rowsPerPageOptions[0];
314
+ this.offset = mediusQueryParam?.itemsOffset ?? 0;
315
+ }
316
+
317
+ private getDefaultSortMeta(): SortMeta[] {
318
+ if (this.descriptor.hasDefaultSort) {
319
+ return this.descriptor.defaultSortProperty.map((p, idx) => <SortMeta>{
320
+ field: p,
321
+ order: this.descriptor.defaultSortAsc[idx] ? 1 : -1
322
+ });
323
+ } else {
324
+ return [];
325
+ }
326
+ }
327
+ }
@@ -0,0 +1,37 @@
1
+ <div class="mng-tableview">
2
+ <p-toast></p-toast>
3
+
4
+ <div class="card">
5
+ <p-toolbar styleClass="mb-4" *ngIf="toolbarLeftActions.length > 0 || toolbarRightActions.length > 0">
6
+ <ng-template pTemplate="left">
7
+ <mng-action *ngFor="let action of toolbarLeftActions"
8
+ [action]="action">
9
+ </mng-action>
10
+ </ng-template>
11
+
12
+ <ng-template pTemplate="right">
13
+ <mng-action *ngFor="let action of toolbarRightActions"
14
+ [action]="action">
15
+ </mng-action>
16
+ </ng-template>
17
+ </p-toolbar>
18
+
19
+ <mng-table [descriptor]="descriptor.table"
20
+ [dataProvider]="dataProvider"
21
+ [useQueryParams]="true"
22
+ (onCellClick)="onTableCellClick($event)">
23
+ <ng-template mngTemplate="caption">
24
+ <div class="flex flex-column md:flex-row md:justify-content-between table-header">
25
+ <h5 class="p-m-0">{{ descriptor.tableTitle | translate }}</h5>
26
+ </div>
27
+ </ng-template>
28
+ <ng-template mngTemplate="columnAction" let-item="rowItem">
29
+ <mng-action *ngFor="let action of rowInlineActions"
30
+ [action]="action" [item]="item" [itemId]="descriptor.model.idPropertyName ? item[descriptor.model.idPropertyName] : null">
31
+ </mng-action>
32
+ </ng-template>
33
+ </mng-table>
34
+ </div>
35
+
36
+ <router-outlet></router-outlet>
37
+ </div>
@@ -0,0 +1,78 @@
1
+ import {Component, Input, OnInit, ViewChild} from '@angular/core';
2
+ import {ActivatedRoute} from '@angular/router';
3
+
4
+ import {TranslateService} from '@ngx-translate/core';
5
+ import {ConfirmationService, MessageService} from 'primeng/api';
6
+ import {DialogService} from 'primeng/dynamicdialog';
7
+
8
+ import {MngActionService} from '../../services';
9
+ import {TableviewDescriptor, ActionDescriptor, ActionPositionEnum} from '../../descriptors';
10
+ import {ITableviewDataProvider} from '../../data-providers';
11
+ import {MngTableCellClickEvent} from './models';
12
+ import {TableviewComponentService} from './services';
13
+ import {MngTableComponent} from './table/table.component';
14
+
15
+ @Component({
16
+ selector: 'mng-tableview',
17
+ templateUrl: './tableview.component.html',
18
+ providers: [MessageService, ConfirmationService, TableviewComponentService]
19
+ })
20
+ export class MngTableviewComponent<T, S> implements OnInit {
21
+
22
+ @Input() descriptor!: TableviewDescriptor<T>;
23
+ @Input() dataProvider?: ITableviewDataProvider<T, S>;
24
+ @Input() actions: Array<ActionDescriptor<T>> = [];
25
+
26
+ @ViewChild(MngTableComponent) tableComponent: MngTableComponent<T, S>|null = null;
27
+
28
+ public rowClickActions: ActionDescriptor<T>[] = [];
29
+ public rowInlineActions: ActionDescriptor<T>[] = [];
30
+ public toolbarLeftActions: ActionDescriptor<T>[] = [];
31
+ public toolbarRightActions: ActionDescriptor<T>[] = [];
32
+
33
+ constructor(
34
+ private route: ActivatedRoute,
35
+ private messageService: MessageService,
36
+ private translateService: TranslateService,
37
+ private dialogService: DialogService,
38
+ private confirmationService: ConfirmationService,
39
+ private actionService: MngActionService,
40
+ private tableviewService: TableviewComponentService<T, S>
41
+ ) {
42
+ }
43
+
44
+ ngOnInit() {
45
+
46
+ this.tableviewService.actions = this.actions;
47
+ this.tableviewService.dataProvider = this.dataProvider;
48
+ this.tableviewService.messageService = this.messageService;
49
+ for (const action of this.actions) {
50
+ switch (action.position) {
51
+ case ActionPositionEnum.RowClick:
52
+ this.rowClickActions.push(action);
53
+ break;
54
+ case ActionPositionEnum.RowInline:
55
+ this.rowInlineActions.push(action);
56
+ break;
57
+ case ActionPositionEnum.ToolbarLeft:
58
+ this.toolbarLeftActions.push(action);
59
+ break;
60
+ case ActionPositionEnum.ToolbarRight:
61
+ this.toolbarRightActions.push(action);
62
+ break;
63
+ }
64
+ }
65
+ }
66
+
67
+ public reloadTable() {
68
+ this.tableComponent?.reload();
69
+ }
70
+
71
+ public onTableCellClick(event: MngTableCellClickEvent<T>) {
72
+ if (this.rowClickActions.length) {
73
+ for (const action of this.rowClickActions) {
74
+ this.actionService.triggerRowClickAction(action, event, this.route);
75
+ }
76
+ }
77
+ }
78
+ }