@cccteam/ccc-lib 0.0.15 → 0.0.16

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 (221) hide show
  1. package/README.md +38 -13
  2. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs +36 -0
  3. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs.map +1 -0
  4. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs +25 -0
  5. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs.map +1 -0
  6. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs +83 -0
  7. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs.map +1 -0
  8. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs +44 -0
  9. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs.map +1 -0
  10. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs +82 -0
  11. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs.map +1 -0
  12. package/fesm2022/cccteam-ccc-lib-src-ccc-camel-case-to-title.mjs +33 -0
  13. package/fesm2022/cccteam-ccc-lib-src-ccc-camel-case-to-title.mjs.map +1 -0
  14. package/fesm2022/cccteam-ccc-lib-src-ccc-grid.mjs +256 -0
  15. package/fesm2022/cccteam-ccc-lib-src-ccc-grid.mjs.map +1 -0
  16. package/fesm2022/cccteam-ccc-lib-src-ccc-resource.mjs +3129 -0
  17. package/fesm2022/cccteam-ccc-lib-src-ccc-resource.mjs.map +1 -0
  18. package/fesm2022/cccteam-ccc-lib-src-forms.mjs +79 -0
  19. package/fesm2022/cccteam-ccc-lib-src-forms.mjs.map +1 -0
  20. package/fesm2022/cccteam-ccc-lib-src-internal-types.mjs +6 -0
  21. package/fesm2022/cccteam-ccc-lib-src-internal-types.mjs.map +1 -0
  22. package/fesm2022/cccteam-ccc-lib-src-types.mjs +431 -0
  23. package/fesm2022/cccteam-ccc-lib-src-types.mjs.map +1 -0
  24. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs +48 -0
  25. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs.map +1 -0
  26. package/fesm2022/cccteam-ccc-lib-src-ui-core-service.mjs +41 -0
  27. package/fesm2022/cccteam-ccc-lib-src-ui-core-service.mjs.map +1 -0
  28. package/fesm2022/cccteam-ccc-lib-src-ui-idle-service.mjs +157 -0
  29. package/fesm2022/cccteam-ccc-lib-src-ui-idle-service.mjs.map +1 -0
  30. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs +50 -0
  31. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs.map +1 -0
  32. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs +63 -0
  33. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs.map +1 -0
  34. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs +60 -0
  35. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs.map +1 -0
  36. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs +19 -0
  37. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs.map +1 -0
  38. package/fesm2022/cccteam-ccc-lib.mjs +4444 -0
  39. package/fesm2022/cccteam-ccc-lib.mjs.map +1 -0
  40. package/package.json +88 -5
  41. package/types/cccteam-ccc-lib-src-auth-authentication-guard.d.ts +6 -0
  42. package/types/cccteam-ccc-lib-src-auth-authorization-guard.d.ts +6 -0
  43. package/types/cccteam-ccc-lib-src-auth-forms.d.ts +28 -0
  44. package/types/cccteam-ccc-lib-src-auth-has-permission.d.ts +15 -0
  45. package/types/cccteam-ccc-lib-src-auth-service.d.ts +38 -0
  46. package/types/cccteam-ccc-lib-src-ccc-camel-case-to-title.d.ts +10 -0
  47. package/types/cccteam-ccc-lib-src-ccc-grid.d.ts +35 -0
  48. package/types/cccteam-ccc-lib-src-ccc-resource.d.ts +674 -0
  49. package/types/cccteam-ccc-lib-src-forms.d.ts +27 -0
  50. package/types/cccteam-ccc-lib-src-types.d.ts +934 -0
  51. package/types/cccteam-ccc-lib-src-ui-alert.d.ts +16 -0
  52. package/types/cccteam-ccc-lib-src-ui-core-service.d.ts +20 -0
  53. package/types/cccteam-ccc-lib-src-ui-idle-service.d.ts +49 -0
  54. package/types/cccteam-ccc-lib-src-ui-interceptor.d.ts +16 -0
  55. package/types/cccteam-ccc-lib-src-ui-notification-service.d.ts +33 -0
  56. package/types/cccteam-ccc-lib-src-ui-sidenav.d.ts +33 -0
  57. package/types/cccteam-ccc-lib-src-util-request-options.d.ts +12 -0
  58. package/types/cccteam-ccc-lib.d.ts +1877 -0
  59. package/eslint.config.js +0 -32
  60. package/ng-package.json +0 -11
  61. package/src/auth-authentication-guard/authentication.guard.ts +0 -40
  62. package/src/auth-authentication-guard/index.ts +0 -1
  63. package/src/auth-authentication-guard/ng-package.json +0 -6
  64. package/src/auth-authorization-guard/authorization.guard.ts +0 -17
  65. package/src/auth-authorization-guard/index.ts +0 -1
  66. package/src/auth-authorization-guard/ng-package.json +0 -6
  67. package/src/auth-forms/ccc-field/ccc-field.component.html +0 -1
  68. package/src/auth-forms/ccc-field/ccc-field.component.scss +0 -0
  69. package/src/auth-forms/ccc-field/ccc-field.component.spec.ts +0 -22
  70. package/src/auth-forms/ccc-field/ccc-field.component.ts +0 -74
  71. package/src/auth-forms/form-helpers.ts +0 -39
  72. package/src/auth-forms/index.ts +0 -3
  73. package/src/auth-forms/ng-package.json +0 -6
  74. package/src/auth-has-permission/has-permission.directive.ts +0 -34
  75. package/src/auth-has-permission/index.ts +0 -1
  76. package/src/auth-has-permission/ng-package.json +0 -6
  77. package/src/auth-service/auth.service.ts +0 -92
  78. package/src/auth-service/index.ts +0 -1
  79. package/src/auth-service/ng-package.json +0 -6
  80. package/src/ccc-camel-case-to-title/camel-case-to-title.pipe.ts +0 -23
  81. package/src/ccc-camel-case-to-title/index.ts +0 -1
  82. package/src/ccc-camel-case-to-title/ng-package.json +0 -6
  83. package/src/ccc-grid/ccc-grid.component.ts +0 -155
  84. package/src/ccc-grid/index.ts +0 -3
  85. package/src/ccc-grid/ng-package.json +0 -6
  86. package/src/ccc-grid/table-button/table-button.component.html +0 -16
  87. package/src/ccc-grid/table-button/table-button.component.scss +0 -5
  88. package/src/ccc-grid/table-button/table-button.component.spec.ts +0 -22
  89. package/src/ccc-grid/table-button/table-button.component.ts +0 -49
  90. package/src/ccc-resource/can-deactivate.guard.ts +0 -41
  91. package/src/ccc-resource/compound-resource/compound-resource.component.html +0 -57
  92. package/src/ccc-resource/compound-resource/compound-resource.component.scss +0 -86
  93. package/src/ccc-resource/compound-resource/compound-resource.component.spec.ts +0 -22
  94. package/src/ccc-resource/compound-resource/compound-resource.component.ts +0 -158
  95. package/src/ccc-resource/concat-fns.ts +0 -162
  96. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.html +0 -12
  97. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.scss +0 -0
  98. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.spec.ts +0 -23
  99. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.ts +0 -17
  100. package/src/ccc-resource/form-state.service.ts +0 -24
  101. package/src/ccc-resource/format-fns.ts +0 -49
  102. package/src/ccc-resource/gui-constants.ts +0 -88
  103. package/src/ccc-resource/index.ts +0 -23
  104. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.html +0 -8
  105. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.scss +0 -0
  106. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.spec.ts +0 -22
  107. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.ts +0 -12
  108. package/src/ccc-resource/ng-package.json +0 -6
  109. package/src/ccc-resource/operation-types.ts +0 -19
  110. package/src/ccc-resource/padding-element/padding-element.component.html +0 -1
  111. package/src/ccc-resource/padding-element/padding-element.component.scss +0 -3
  112. package/src/ccc-resource/padding-element/padding-element.component.spec.ts +0 -22
  113. package/src/ccc-resource/padding-element/padding-element.component.ts +0 -20
  114. package/src/ccc-resource/resource-array-view/resource-array-view.component.html +0 -81
  115. package/src/ccc-resource/resource-array-view/resource-array-view.component.scss +0 -21
  116. package/src/ccc-resource/resource-array-view/resource-array-view.component.spec.ts +0 -22
  117. package/src/ccc-resource/resource-array-view/resource-array-view.component.ts +0 -143
  118. package/src/ccc-resource/resource-base/resource-base.component.spec.ts +0 -22
  119. package/src/ccc-resource/resource-base/resource-base.component.ts +0 -11
  120. package/src/ccc-resource/resource-cache.service.ts +0 -232
  121. package/src/ccc-resource/resource-create/resource-create.component.html +0 -31
  122. package/src/ccc-resource/resource-create/resource-create.component.scss +0 -130
  123. package/src/ccc-resource/resource-create/resource-create.component.spec.ts +0 -22
  124. package/src/ccc-resource/resource-create/resource-create.component.ts +0 -303
  125. package/src/ccc-resource/resource-field/base-field.directive.ts +0 -102
  126. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.html +0 -16
  127. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.scss +0 -0
  128. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.spec.ts +0 -22
  129. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.ts +0 -15
  130. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.html +0 -13
  131. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.scss +0 -0
  132. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.spec.ts +0 -23
  133. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.ts +0 -50
  134. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.html +0 -22
  135. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.scss +0 -0
  136. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.spec.ts +0 -22
  137. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.ts +0 -14
  138. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.html +0 -71
  139. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.scss +0 -9
  140. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.spec.ts +0 -22
  141. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.ts +0 -207
  142. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.html +0 -38
  143. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.scss +0 -3
  144. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.spec.ts +0 -22
  145. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.ts +0 -87
  146. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.html +0 -23
  147. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.scss +0 -6
  148. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.spec.ts +0 -22
  149. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.ts +0 -14
  150. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.html +0 -29
  151. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.scss +0 -6
  152. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.spec.ts +0 -22
  153. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.ts +0 -23
  154. package/src/ccc-resource/resource-field/resource-field.component.html +0 -112
  155. package/src/ccc-resource/resource-field/resource-field.component.scss +0 -7
  156. package/src/ccc-resource/resource-field/resource-field.component.spec.ts +0 -22
  157. package/src/ccc-resource/resource-field/resource-field.component.ts +0 -214
  158. package/src/ccc-resource/resource-layout/resource-layout.component.html +0 -73
  159. package/src/ccc-resource/resource-layout/resource-layout.component.scss +0 -26
  160. package/src/ccc-resource/resource-layout/resource-layout.component.spec.ts +0 -22
  161. package/src/ccc-resource/resource-layout/resource-layout.component.ts +0 -176
  162. package/src/ccc-resource/resource-list/ resource-list.component.spec.ts +0 -22
  163. package/src/ccc-resource/resource-list/resource-list.component.html +0 -27
  164. package/src/ccc-resource/resource-list/resource-list.component.scss +0 -67
  165. package/src/ccc-resource/resource-list/resource-list.component.ts +0 -376
  166. package/src/ccc-resource/resource-list-create/resource-list-create.component.html +0 -71
  167. package/src/ccc-resource/resource-list-create/resource-list-create.component.scss +0 -9
  168. package/src/ccc-resource/resource-list-create/resource-list-create.component.spec.ts +0 -22
  169. package/src/ccc-resource/resource-list-create/resource-list-create.component.ts +0 -103
  170. package/src/ccc-resource/resource-resolver/resource-resolver.component.html +0 -1
  171. package/src/ccc-resource/resource-resolver/resource-resolver.component.scss +0 -0
  172. package/src/ccc-resource/resource-resolver/resource-resolver.component.spec.ts +0 -22
  173. package/src/ccc-resource/resource-resolver/resource-resolver.component.ts +0 -69
  174. package/src/ccc-resource/resource-store.service.ts +0 -93
  175. package/src/ccc-resource/resource-view/resource-view.component.html +0 -133
  176. package/src/ccc-resource/resource-view/resource-view.component.scss +0 -150
  177. package/src/ccc-resource/resource-view/resource-view.component.spec.ts +0 -22
  178. package/src/ccc-resource/resource-view/resource-view.component.ts +0 -354
  179. package/src/ccc-resource/resources-helpers.ts +0 -262
  180. package/src/ccc-resource/utils/validator-utils.ts +0 -6
  181. package/src/index.ts +0 -44
  182. package/src/internal-types/ng-package.json +0 -6
  183. package/src/types/auth.actions.ts +0 -46
  184. package/src/types/configs.ts +0 -952
  185. package/src/types/constants.ts +0 -1
  186. package/src/types/core.actions.ts +0 -33
  187. package/src/types/index.ts +0 -9
  188. package/src/types/ng-package.json +0 -6
  189. package/src/types/notification-message.ts +0 -20
  190. package/src/types/permissions.ts +0 -17
  191. package/src/types/session-info.ts +0 -10
  192. package/src/types/tokens.ts +0 -20
  193. package/src/ui-alert/alert.component.html +0 -13
  194. package/src/ui-alert/alert.component.scss +0 -48
  195. package/src/ui-alert/alert.component.spec.ts +0 -22
  196. package/src/ui-alert/alert.component.ts +0 -35
  197. package/src/ui-alert/index.ts +0 -1
  198. package/src/ui-alert/ng-package.json +0 -6
  199. package/src/ui-core-service/index.ts +0 -1
  200. package/src/ui-core-service/ng-package.json +0 -6
  201. package/src/ui-core-service/ui-core.service.ts +0 -34
  202. package/src/ui-interceptor/api.interceptor.spec.ts +0 -16
  203. package/src/ui-interceptor/api.interceptor.ts +0 -45
  204. package/src/ui-interceptor/index.ts +0 -1
  205. package/src/ui-interceptor/ng-package.json +0 -6
  206. package/src/ui-notification-service/index.ts +0 -1
  207. package/src/ui-notification-service/ng-package.json +0 -6
  208. package/src/ui-notification-service/notification.service.ts +0 -59
  209. package/src/ui-sidenav/index.ts +0 -1
  210. package/src/ui-sidenav/ng-package.json +0 -6
  211. package/src/ui-sidenav/sidenav.component.html +0 -60
  212. package/src/ui-sidenav/sidenav.component.scss +0 -99
  213. package/src/ui-sidenav/sidenav.component.spec.ts +0 -22
  214. package/src/ui-sidenav/sidenav.component.ts +0 -64
  215. package/src/util-request-options/index.ts +0 -1
  216. package/src/util-request-options/ng-package.json +0 -6
  217. package/src/util-request-options/request-options.ts +0 -17
  218. package/tsconfig.lib.json +0 -13
  219. package/tsconfig.lib.prod.json +0 -11
  220. package/tsconfig.spec.json +0 -15
  221. /package/{src/internal-types/index.ts → types/cccteam-ccc-lib-src-internal-types.d.ts} +0 -0
@@ -1,112 +0,0 @@
1
- <div [class.hidden-field]="!showField()">
2
- @if (showEmptyField()) {
3
- <ccc-empty-readonly-field [label]="fieldConfig().label"></ccc-empty-readonly-field>
4
- } @else {
5
- @switch (fieldMeta().displayType) {
6
- @case ('date') {
7
- <ccc-date-field
8
- [form]="form()"
9
- [fieldConfig]="fieldConfig()"
10
- [editMode]="mode()"
11
- [fieldClass]="fieldClass()"
12
- [meta]="meta()"
13
- [pristineValue]="pristineValue()"
14
- [relatedData]="data()"
15
- [fieldMeta]="fieldMeta()"
16
- [showField]="showField()">
17
- </ccc-date-field>
18
- }
19
-
20
- @case ('civildate') {
21
- <ccc-date-field
22
- [form]="form()"
23
- [fieldConfig]="fieldConfig()"
24
- [editMode]="mode()"
25
- [fieldClass]="fieldClass()"
26
- [meta]="meta()"
27
- [pristineValue]="pristineValue()"
28
- [relatedData]="data()"
29
- [fieldMeta]="fieldMeta()"
30
- [showField]="showField()">
31
- </ccc-date-field>
32
- }
33
-
34
- @case ('number') {
35
- <ccc-number-field
36
- [form]="form()"
37
- [fieldConfig]="fieldConfig()"
38
- [editMode]="mode()"
39
- [fieldClass]="fieldClass()"
40
- [meta]="meta()"
41
- [pristineValue]="pristineValue()"
42
- [relatedData]="data()"
43
- [fieldMeta]="fieldMeta()"
44
- [showField]="showField()">
45
- </ccc-number-field>
46
- }
47
-
48
- @case ('boolean') {
49
- <ng-container *ngTemplateOutlet="booleanFragment"></ng-container>
50
- }
51
- @case ('nullboolean') {
52
- <ng-container *ngTemplateOutlet="booleanFragment"></ng-container>
53
- }
54
-
55
- @case ('enumerated') {
56
- <ccc-enumerated-field
57
- [form]="form()"
58
- [fieldConfig]="fieldConfig()"
59
- [editMode]="mode()"
60
- [fieldClass]="fieldClass()"
61
- [meta]="meta()"
62
- [pristineValue]="pristineValue()"
63
- [relatedData]="data()"
64
- [fieldMeta]="fieldMeta()"
65
- [showField]="showField()">
66
- </ccc-enumerated-field>
67
- }
68
-
69
- @default {
70
- <ccc-text-field
71
- [form]="form()"
72
- [fieldConfig]="fieldConfig()"
73
- [editMode]="mode()"
74
- [fieldClass]="fieldClass()"
75
- [meta]="meta()"
76
- [pristineValue]="pristineValue()"
77
- [relatedData]="data()"
78
- [fieldMeta]="fieldMeta()"
79
- [showField]="showField()">
80
- </ccc-text-field>
81
- }
82
- }
83
- }
84
- </div>
85
-
86
- <ng-template #booleanFragment>
87
- @if (booleanEditDisplayType() === 'boolean') {
88
- <ccc-boolean-field
89
- [form]="form()"
90
- [fieldConfig]="fieldConfig()"
91
- [editMode]="mode()"
92
- [fieldClass]="fieldClass()"
93
- [meta]="meta()"
94
- [pristineValue]="pristineValue()"
95
- [relatedData]="data()"
96
- [fieldMeta]="fieldMeta()"
97
- [showField]="showField()">
98
- </ccc-boolean-field>
99
- } @else if (booleanEditDisplayType() === 'nullboolean') {
100
- <ccc-nullboolean-field
101
- [form]="form()"
102
- [fieldConfig]="fieldConfig()"
103
- [editMode]="mode()"
104
- [fieldClass]="fieldClass()"
105
- [meta]="meta()"
106
- [pristineValue]="pristineValue()"
107
- [relatedData]="data()"
108
- [fieldMeta]="fieldMeta()"
109
- [showField]="showField()">
110
- </ccc-nullboolean-field>
111
- }
112
- </ng-template>
@@ -1,7 +0,0 @@
1
- .checkbox {
2
- margin-top: 10px;
3
- }
4
-
5
- .dirty-input {
6
- background-color: #00617f26;
7
- }
@@ -1,22 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ResourceFieldComponent } from './resource-field.component';
4
-
5
- xdescribe('ResourceFieldComponent', () => {
6
- let component: ResourceFieldComponent;
7
- let fixture: ComponentFixture<ResourceFieldComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ResourceFieldComponent],
12
- }).compileComponents();
13
-
14
- fixture = TestBed.createComponent(ResourceFieldComponent);
15
- component = fixture.componentInstance;
16
- fixture.detectChanges();
17
- });
18
-
19
- it('should create', () => {
20
- expect(component).toBeTruthy();
21
- });
22
- });
@@ -1,214 +0,0 @@
1
- import { NgTemplateOutlet } from '@angular/common';
2
- import {
3
- ChangeDetectionStrategy,
4
- Component,
5
- computed,
6
- effect,
7
- HostBinding,
8
- input,
9
- Signal,
10
- untracked,
11
- } from '@angular/core';
12
- import { FormGroup, Validators } from '@angular/forms';
13
- import { MatFormFieldModule } from '@angular/material/form-field';
14
- import { DataType, FieldElement, FieldMeta, Meta, RecordData, ValidDisplayTypes } from '@cccteam/ccc-lib/src/types';
15
- import { EmptyReadonlyFieldComponent } from '../empty-readonly-field/empty-readonly-field.component';
16
- import { validatorsPresent } from '../gui-constants';
17
- import { BooleanFieldComponent } from './fields/boolean-field/boolean-field.component';
18
- import { DateFieldComponent } from './fields/date-field/date-field.component';
19
- import { EnumeratedFieldComponent } from './fields/enumerated-field/enumerated-field.component';
20
- import { NullBooleanFieldComponent } from './fields/nullboolean-field/nullboolean-field.component';
21
- import { NumberFieldComponent } from './fields/number-field/number-field.component';
22
- import { TextFieldComponent } from './fields/text-field/text-field.component';
23
-
24
- @Component({
25
- selector: 'ccc-resource-field',
26
- imports: [
27
- DateFieldComponent,
28
- BooleanFieldComponent,
29
- TextFieldComponent,
30
- NumberFieldComponent,
31
- EnumeratedFieldComponent,
32
- MatFormFieldModule,
33
- EmptyReadonlyFieldComponent,
34
- NullBooleanFieldComponent,
35
- NgTemplateOutlet,
36
- ],
37
- templateUrl: './resource-field.component.html',
38
- styleUrl: './resource-field.component.scss',
39
- changeDetection: ChangeDetectionStrategy.OnPush,
40
- })
41
- export class ResourceFieldComponent {
42
- fieldConfig = input.required<FieldElement>();
43
- meta = input.required<Meta>();
44
- fieldClass = input<string>();
45
- editMode = input<'edit' | 'view'>('edit');
46
- form = input.required<FormGroup>();
47
- formDataState = input<RecordData>();
48
- pristineValue = input<DataType | null>();
49
- data = input<RecordData>();
50
- previouslyNulled: boolean | null = null;
51
-
52
- fieldMeta: Signal<FieldMeta> = computed(() => {
53
- return (
54
- (this.meta().fields?.find((field) => field.fieldName === this.fieldConfig().name) as FieldMeta) ||
55
- ({} as FieldMeta)
56
- );
57
- });
58
-
59
- mode = computed(() => {
60
- if (this.fieldConfig().readOnly) {
61
- return 'view';
62
- }
63
- return this.editMode();
64
- });
65
-
66
- showField = computed(() => {
67
- const shouldRender = this.fieldConfig().shouldRender;
68
- const conditionallyNull = this.fieldConfig().nullIfConditionallyHidden;
69
- const isForeignKeyDefault = this.fieldConfig().default?.type === 'foreignKey';
70
-
71
- if (typeof shouldRender === 'boolean') {
72
- return shouldRender && !isForeignKeyDefault;
73
- }
74
- const formValues = this.formDataState();
75
- if (!formValues) {
76
- return true;
77
- }
78
-
79
- console.debug('Field: ', this.fieldConfig().name, ' | Values to be used in showField calculation ', formValues);
80
-
81
- try {
82
- const showField = shouldRender(formValues) && !isForeignKeyDefault;
83
-
84
- if (!conditionallyNull) {
85
- return showField;
86
- }
87
-
88
- const formControlName = this.fieldConfig()?.name;
89
- const control = this.form()?.controls[formControlName];
90
- const pristineFieldValue = this.data()?.[formControlName];
91
- const previouslyNulled = this.previouslyNulled;
92
-
93
- untracked(() => {
94
- if (!showField && !previouslyNulled) {
95
- this.previouslyNulled = true;
96
- control?.setValue(null);
97
- }
98
-
99
- if (showField && previouslyNulled) {
100
- this.previouslyNulled = false;
101
- control?.setValue(pristineFieldValue);
102
- }
103
- });
104
-
105
- return showField;
106
- } catch (e) {
107
- console.error('Failed to calculate value for should Render function for field: ', this.fieldConfig().name);
108
- console.error(e);
109
- return true;
110
- }
111
- });
112
-
113
- showEmptyField = computed(() => {
114
- const editMode = this.mode();
115
- const showField = this.showField();
116
-
117
- if (!showField || editMode === 'edit') {
118
- return false;
119
- }
120
-
121
- const form = this.form();
122
- const config = this.fieldConfig();
123
- const meta = this.fieldMeta();
124
- if (form === undefined || config === undefined || meta === undefined) {
125
- return false;
126
- }
127
-
128
- if (meta.displayType === 'nullboolean') {
129
- return false;
130
- }
131
-
132
- const value = form.get(config.name)?.value;
133
- // TODO: In phase 3 of visual updates, allow control of which
134
- // values can trigger the empty field display on a per field basis
135
- if (value === null || value === '') {
136
- return true;
137
- }
138
-
139
- return false;
140
- });
141
-
142
- @HostBinding('class') class = '';
143
-
144
- booleanEditDisplayType: Signal<BooleanDisplayTypes> = computed(() => {
145
- const fieldConfig = this.fieldConfig();
146
- const fieldMeta = this.fieldMeta();
147
- const form = this.form();
148
-
149
- if (fieldConfig === undefined || fieldMeta === undefined || form === undefined) {
150
- return 'boolean';
151
- }
152
-
153
- const control = form.get(fieldConfig.name);
154
- if (control === null) {
155
- console.warn("Unable to find control for field '" + fieldConfig.name + "' to determine boolean display type");
156
- return 'boolean';
157
- }
158
-
159
- // Frontend forcing users to make a choice displays nullboolean to
160
- // trigger form validation - users must interact and explicitly
161
- // choose a true or false value
162
- if (control.hasValidator(Validators.required) || fieldMeta.displayType === 'nullboolean') {
163
- return 'nullboolean';
164
- }
165
-
166
- return 'boolean';
167
- });
168
-
169
- constructor() {
170
- effect(() => {
171
- this.class = this.showField() ? 'col-' + this.fieldConfig()?.cols : 'hidden-field';
172
- });
173
-
174
- effect(() => {
175
- const getValidators = this.fieldConfig().validators;
176
-
177
- if (typeof getValidators !== 'function') {
178
- return;
179
- }
180
-
181
- const formValues = this.formDataState();
182
-
183
- if (!formValues) {
184
- return;
185
- }
186
-
187
- console.debug('Field: ', this.fieldConfig().name, ' | Values to be used in validators calculation ', formValues);
188
-
189
- try {
190
- const newValidators = getValidators(formValues);
191
-
192
- const formControlName = this.fieldConfig().name;
193
- const control = this.form().get(formControlName);
194
-
195
- if (control === null) {
196
- throw new Error(`Control with name ${this.fieldConfig().name} not found during forceRequired calculation`);
197
- }
198
-
199
- const addValidators = !validatorsPresent(control, newValidators);
200
-
201
- if (addValidators) {
202
- control.setValidators(newValidators);
203
- control.updateValueAndValidity();
204
- }
205
- } catch (e) {
206
- console.error('Failed to calculate value for forceRequired function for field: ', this.fieldConfig().name);
207
- console.error(e);
208
- return;
209
- }
210
- });
211
- }
212
- }
213
-
214
- type BooleanDisplayTypes = Extract<ValidDisplayTypes, 'boolean' | 'nullboolean'>;
@@ -1,73 +0,0 @@
1
- <div class="section {{ parentClass() }}" [class.hidden-field]="!showLayout()">
2
- @let parentElement = element();
3
- @if (children().length > 0) {
4
- <div
5
- class="section-elements dense-1 resource-layout-container"
6
- [class]="layoutNestingDepth() % 2 === 0 ? 'resource-layout-container-even' : 'resource-layout-container-odd'">
7
- @if (parentElement.type !== 'padding' && parentElement.label !== '') {
8
- <div class="label">{{ parentElement.label }}</div>
9
- }
10
- @for (elementField of children(); track elementField) {
11
- @let childElement = elementField;
12
- @if (childElement.type === 'section') {
13
- @if (layoutNestingDepth() < maxLayoutNestingDepth) {
14
- <ccc-resource-layout-template
15
- [layoutNestingDepth]="layoutNestingDepth() + 1"
16
- [element]="childElement"
17
- [meta]="meta()"
18
- [fieldClass]="fieldClass()"
19
- [editMode]="editMode()"
20
- [form]="form()"
21
- [formDataState]="formDataState()"
22
- [pristineValue]="pristineValue()"
23
- [relatedData]="relatedData()"
24
- [parentClass]="parentClass()">
25
- </ccc-resource-layout-template>
26
- }
27
- } @else if (childElement.type === 'field') {
28
- <ccc-resource-field
29
- [meta]="meta()"
30
- [fieldClass]="fieldClass()"
31
- [fieldConfig]="childElement"
32
- [editMode]="editMode()"
33
- [form]="form()"
34
- [formDataState]="formDataState()"
35
- [pristineValue]="pristineValue()"
36
- [data]="relatedData()">
37
- </ccc-resource-field>
38
- } @else if (childElement.type === 'computedDisplayField') {
39
- <ccc-computed-field
40
- [fieldClass]="fieldClass()"
41
- [fieldConfig]="childElement"
42
- [formDataState]="formDataState()"></ccc-computed-field>
43
- } @else if (childElement.type === 'padding') {
44
- <ccc-padding-element [paddingElement]="childElement"></ccc-padding-element>
45
- }
46
- }
47
- </div>
48
- } @else {
49
- @if (parentElement.type === 'field') {
50
- <div
51
- class="section-elements dense-1 resource-layout-container"
52
- [class]="layoutNestingDepth() % 2 === 0 ? 'resource-layout-container-even' : 'resource-layout-container-odd'">
53
- <ccc-resource-field
54
- [meta]="meta()"
55
- [fieldClass]="fieldClass()"
56
- [fieldConfig]="parentElement"
57
- [editMode]="editMode()"
58
- [form]="form()"
59
- [formDataState]="formDataState()"
60
- [pristineValue]="pristineValue()"
61
- [data]="relatedData()">
62
- </ccc-resource-field>
63
- </div>
64
- } @else if (parentElement.type === 'computedDisplayField') {
65
- <ccc-computed-field
66
- [fieldClass]="fieldClass()"
67
- [fieldConfig]="parentElement"
68
- [formDataState]="formDataState()"></ccc-computed-field>
69
- } @else if (parentElement.type === 'padding') {
70
- <ccc-padding-element [paddingElement]="parentElement"></ccc-padding-element>
71
- }
72
- }
73
- </div>
@@ -1,26 +0,0 @@
1
- .section {
2
- margin-top: 15px;
3
- }
4
-
5
- .section-elements {
6
- display: flex;
7
- flex-wrap: wrap;
8
- padding-bottom: 4px;
9
- }
10
-
11
- .label {
12
- position: absolute;
13
- top: -15px;
14
- left: 20px;
15
- height: 20px;
16
- background-color: var(--layout-label-background-color);
17
- border-radius: 8px;
18
- margin: 0px 10px 0px 10px;
19
- padding: 0px 10px 0px 10px;
20
- text-align: center;
21
- z-index: 10;
22
- font-weight: 500;
23
- font:
24
- 18px 'Roboto',
25
- sans-serif;
26
- }
@@ -1,22 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ResourceLayoutComponent } from './resource-layout.component';
4
-
5
- describe('ResourceLayoutComponent', () => {
6
- let component: ResourceLayoutComponent;
7
- let fixture: ComponentFixture<ResourceLayoutComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ResourceLayoutComponent],
12
- }).compileComponents();
13
-
14
- fixture = TestBed.createComponent(ResourceLayoutComponent);
15
- component = fixture.componentInstance;
16
- fixture.detectChanges();
17
- });
18
-
19
- it('should create', () => {
20
- expect(component).toBeTruthy();
21
- });
22
- });
@@ -1,176 +0,0 @@
1
- import { Component, computed, effect, HostBinding, input, model, OnInit, untracked } from '@angular/core';
2
- import { FormGroup } from '@angular/forms';
3
- import { ConfigElement, DataType, FieldElement, Meta, RecordData } from '@cccteam/ccc-lib/src/types';
4
- import { flattenElements, maxLayoutNestingDepth } from '../gui-constants';
5
- import { PaddingElementComponent } from '../padding-element/padding-element.component';
6
- import { ComputedFieldComponent } from '../resource-field/fields/computed-field/computed-field.component';
7
- import { ResourceFieldComponent } from '../resource-field/resource-field.component';
8
-
9
- @Component({
10
- selector: 'ccc-resource-layout-template',
11
- imports: [PaddingElementComponent, ResourceFieldComponent, ComputedFieldComponent],
12
- templateUrl: './resource-layout.component.html',
13
- styleUrls: ['./resource-layout.component.scss'],
14
- })
15
- export class ResourceLayoutComponent implements OnInit {
16
- element = input.required<ConfigElement>();
17
- meta = input.required<Meta>();
18
- fieldClass = input<string>();
19
- editMode = input.required<'edit' | 'view'>();
20
- form = input.required<FormGroup>();
21
- formDataState = model<RecordData>();
22
- pristineValue = input<DataType | null>('');
23
- relatedData = input<RecordData>();
24
- parentClass = input<string>();
25
- layoutNestingDepth = input<number>(1);
26
-
27
- maxLayoutNestingDepth = maxLayoutNestingDepth;
28
-
29
- children = computed(() => {
30
- const element = this.element();
31
- if (element.type === 'section') {
32
- return element.children;
33
- }
34
- return [];
35
- });
36
-
37
- layoutChildrenConfig = computed(() => {
38
- return flattenElements(this.children());
39
- });
40
- previouslyNulled = false;
41
-
42
- nullIfConditionallyHidden = computed(() => {
43
- const element = this.element();
44
- if (element.type === 'field') {
45
- return element.nullIfConditionallyHidden;
46
- }
47
- if (element.type === 'section') {
48
- return element.nullAllChildrenIfConditionallyHidden;
49
- }
50
- return false;
51
- });
52
-
53
- showLayout = computed(() => {
54
- const element = this.element();
55
- const shouldRender = element.shouldRender;
56
- const conditionallyNull = this.nullIfConditionallyHidden();
57
- const form = this.form();
58
- const label = 'label' in element ? element.label : 'padding';
59
- const isForeignKeyDefault = element.type === 'field' && element.default?.type === 'foreignKey';
60
-
61
- if (typeof shouldRender === 'boolean') {
62
- return shouldRender && !isForeignKeyDefault;
63
- }
64
-
65
- const formValues = this.formDataState();
66
- if (!formValues) {
67
- return true;
68
- }
69
-
70
- console.debug('Layout: ', label, ' | Values to be used in showLayout calculation ', formValues);
71
- try {
72
- const showLayout = shouldRender(formValues) && !isForeignKeyDefault;
73
-
74
- if (!conditionallyNull) {
75
- return showLayout;
76
- }
77
- const previouslyNulled = this.previouslyNulled;
78
-
79
- untracked(() => {
80
- this.layoutChildrenConfig().forEach((configElement) => {
81
- const isFormControl = configElement.type === 'field';
82
- if (!isFormControl) {
83
- return;
84
- }
85
-
86
- const control = form?.controls[configElement.name];
87
- const pristineFieldValue = this.relatedData()?.[configElement.name];
88
-
89
- if (!showLayout && !previouslyNulled) {
90
- this.previouslyNulled = true;
91
- control?.setValue(null);
92
- }
93
-
94
- if (showLayout && previouslyNulled) {
95
- this.previouslyNulled = false;
96
- control?.setValue(pristineFieldValue);
97
- }
98
- });
99
- });
100
-
101
- return showLayout;
102
- } catch (e) {
103
- console.error('Failed to calculate value for should Render function for layout: ', label);
104
- console.error(e);
105
- return true;
106
- }
107
- });
108
-
109
- @HostBinding('class') class = '';
110
-
111
- constructor() {
112
- // TODO: Remove this effect once Angular supports signals in Reactive forms to obtain changes to form values.
113
- // This effect has been necessary because translating from Observables to Signals, specifically via an input signal
114
- // doesn't have a clean solution
115
-
116
- effect((onCleanup) => {
117
- const element = this.element();
118
- if (element === undefined) {
119
- return;
120
- }
121
- const currentForm = this.form();
122
- const shouldRender = element.shouldRender;
123
- const nestingDepth = this.layoutNestingDepth();
124
- const layoutChildren = this.layoutChildrenConfig();
125
- const label = 'label' in element ? element.label : 'padding';
126
- if (!this.shouldInitializeFormData(currentForm, nestingDepth, shouldRender, layoutChildren)) {
127
- return;
128
- }
129
- console.debug('USAGE | New subscription for formValuesSignal created for layout: ', label);
130
-
131
- this.formDataState.set(currentForm.getRawValue());
132
- const subscription = currentForm.valueChanges.subscribe((value) => {
133
- this.formDataState.set(value);
134
- });
135
-
136
- onCleanup(() => {
137
- console.debug('USAGE | Unsubscribing from valueChanges for layout: ', label);
138
- subscription.unsubscribe();
139
- });
140
- });
141
- }
142
-
143
- ngOnInit(): void {
144
- this.class = 'col-' + this.element().cols;
145
- }
146
-
147
- shouldInitializeFormData(
148
- form: FormGroup,
149
- layoutNestingDepth: number,
150
- shouldRender: ConfigElement['shouldRender'],
151
- layoutChildren: ConfigElement[],
152
- ): boolean {
153
- const childrenNeedFormDataState = layoutChildren.some((config) => {
154
- const shouldRenderIsFunction = typeof config.shouldRender === 'function';
155
- const isComputedField = config.type === 'computedDisplayField';
156
- let validatorsIsFunction = false;
157
-
158
- const castConfig = config as FieldElement;
159
- if (castConfig.validators && typeof castConfig.validators === 'function') {
160
- validatorsIsFunction = true;
161
- }
162
-
163
- return shouldRenderIsFunction || isComputedField || validatorsIsFunction;
164
- });
165
-
166
- if (!form || layoutNestingDepth > 1) {
167
- return false;
168
- }
169
-
170
- if (!childrenNeedFormDataState && typeof shouldRender !== 'function') {
171
- return false;
172
- }
173
-
174
- return true;
175
- }
176
- }
@@ -1,22 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { ResourceListComponent } from './resource-list.component';
4
-
5
- xdescribe('ResourceListComponent', () => {
6
- let component: ResourceListComponent;
7
- let fixture: ComponentFixture<ResourceListComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [ResourceListComponent],
12
- }).compileComponents();
13
-
14
- fixture = TestBed.createComponent(ResourceListComponent);
15
- component = fixture.componentInstance;
16
- fixture.detectChanges();
17
- });
18
-
19
- it('should create', () => {
20
- expect(component).toBeTruthy();
21
- });
22
- });