@cccteam/ccc-lib 0.0.13 → 0.0.15

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 (226) hide show
  1. package/eslint.config.js +32 -0
  2. package/ng-package.json +11 -0
  3. package/package.json +7 -68
  4. package/src/auth-authentication-guard/authentication.guard.ts +40 -0
  5. package/src/auth-authentication-guard/ng-package.json +6 -0
  6. package/src/auth-authorization-guard/authorization.guard.ts +17 -0
  7. package/src/auth-authorization-guard/ng-package.json +6 -0
  8. package/src/auth-forms/ccc-field/ccc-field.component.html +1 -0
  9. package/src/auth-forms/ccc-field/ccc-field.component.scss +0 -0
  10. package/src/auth-forms/ccc-field/ccc-field.component.spec.ts +22 -0
  11. package/src/auth-forms/ccc-field/ccc-field.component.ts +74 -0
  12. package/src/auth-forms/form-helpers.ts +39 -0
  13. package/src/auth-forms/{public-api.d.ts → index.ts} +1 -0
  14. package/src/auth-forms/ng-package.json +6 -0
  15. package/src/auth-has-permission/has-permission.directive.ts +34 -0
  16. package/src/auth-has-permission/ng-package.json +6 -0
  17. package/src/auth-service/auth.service.ts +92 -0
  18. package/src/auth-service/ng-package.json +6 -0
  19. package/src/ccc-camel-case-to-title/camel-case-to-title.pipe.ts +23 -0
  20. package/src/ccc-camel-case-to-title/index.ts +1 -0
  21. package/src/ccc-camel-case-to-title/ng-package.json +6 -0
  22. package/src/ccc-grid/ccc-grid.component.ts +155 -0
  23. package/src/ccc-grid/index.ts +3 -0
  24. package/src/ccc-grid/ng-package.json +6 -0
  25. package/src/ccc-grid/table-button/table-button.component.html +16 -0
  26. package/src/ccc-grid/table-button/table-button.component.scss +5 -0
  27. package/src/ccc-grid/table-button/table-button.component.spec.ts +22 -0
  28. package/src/ccc-grid/table-button/table-button.component.ts +49 -0
  29. package/src/ccc-resource/can-deactivate.guard.ts +41 -0
  30. package/src/ccc-resource/compound-resource/compound-resource.component.html +57 -0
  31. package/src/ccc-resource/compound-resource/compound-resource.component.scss +86 -0
  32. package/src/ccc-resource/compound-resource/compound-resource.component.spec.ts +22 -0
  33. package/src/ccc-resource/compound-resource/compound-resource.component.ts +158 -0
  34. package/src/ccc-resource/concat-fns.ts +162 -0
  35. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.html +12 -0
  36. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.scss +0 -0
  37. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.spec.ts +23 -0
  38. package/src/ccc-resource/empty-readonly-field/empty-readonly-field.component.ts +17 -0
  39. package/src/ccc-resource/form-state.service.ts +24 -0
  40. package/src/ccc-resource/format-fns.ts +49 -0
  41. package/src/ccc-resource/gui-constants.ts +88 -0
  42. package/src/ccc-resource/index.ts +23 -0
  43. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.html +8 -0
  44. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.scss +0 -0
  45. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.spec.ts +22 -0
  46. package/src/ccc-resource/leave-page-confirmation-modal/leave-page-confirmation-modal.component.ts +12 -0
  47. package/src/ccc-resource/ng-package.json +6 -0
  48. package/src/ccc-resource/operation-types.ts +19 -0
  49. package/src/ccc-resource/padding-element/padding-element.component.html +1 -0
  50. package/src/ccc-resource/padding-element/padding-element.component.scss +3 -0
  51. package/src/ccc-resource/padding-element/padding-element.component.spec.ts +22 -0
  52. package/src/ccc-resource/padding-element/padding-element.component.ts +20 -0
  53. package/src/ccc-resource/resource-array-view/resource-array-view.component.html +81 -0
  54. package/src/ccc-resource/resource-array-view/resource-array-view.component.scss +21 -0
  55. package/src/ccc-resource/resource-array-view/resource-array-view.component.spec.ts +22 -0
  56. package/src/ccc-resource/resource-array-view/resource-array-view.component.ts +143 -0
  57. package/src/ccc-resource/resource-base/resource-base.component.spec.ts +22 -0
  58. package/src/ccc-resource/resource-base/resource-base.component.ts +11 -0
  59. package/src/ccc-resource/resource-cache.service.ts +232 -0
  60. package/src/ccc-resource/resource-create/resource-create.component.html +31 -0
  61. package/src/ccc-resource/resource-create/resource-create.component.scss +130 -0
  62. package/src/ccc-resource/resource-create/resource-create.component.spec.ts +22 -0
  63. package/src/ccc-resource/resource-create/resource-create.component.ts +303 -0
  64. package/src/ccc-resource/resource-field/base-field.directive.ts +102 -0
  65. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.html +16 -0
  66. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.scss +0 -0
  67. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.spec.ts +22 -0
  68. package/src/ccc-resource/resource-field/fields/boolean-field/boolean-field.component.ts +15 -0
  69. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.html +13 -0
  70. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.scss +0 -0
  71. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.spec.ts +23 -0
  72. package/src/ccc-resource/resource-field/fields/computed-field/computed-field.component.ts +50 -0
  73. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.html +22 -0
  74. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.scss +0 -0
  75. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.spec.ts +22 -0
  76. package/src/ccc-resource/resource-field/fields/date-field/date-field.component.ts +14 -0
  77. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.html +71 -0
  78. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.scss +9 -0
  79. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.spec.ts +22 -0
  80. package/src/ccc-resource/resource-field/fields/enumerated-field/enumerated-field.component.ts +207 -0
  81. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.html +38 -0
  82. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.scss +3 -0
  83. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.spec.ts +22 -0
  84. package/src/ccc-resource/resource-field/fields/nullboolean-field/nullboolean-field.component.ts +87 -0
  85. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.html +23 -0
  86. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.scss +6 -0
  87. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.spec.ts +22 -0
  88. package/src/ccc-resource/resource-field/fields/number-field/number-field.component.ts +14 -0
  89. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.html +29 -0
  90. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.scss +6 -0
  91. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.spec.ts +22 -0
  92. package/src/ccc-resource/resource-field/fields/text-field/text-field.component.ts +23 -0
  93. package/src/ccc-resource/resource-field/resource-field.component.html +112 -0
  94. package/src/ccc-resource/resource-field/resource-field.component.scss +7 -0
  95. package/src/ccc-resource/resource-field/resource-field.component.spec.ts +22 -0
  96. package/src/ccc-resource/resource-field/resource-field.component.ts +214 -0
  97. package/src/ccc-resource/resource-layout/resource-layout.component.html +73 -0
  98. package/src/ccc-resource/resource-layout/resource-layout.component.scss +26 -0
  99. package/src/ccc-resource/resource-layout/resource-layout.component.spec.ts +22 -0
  100. package/src/ccc-resource/resource-layout/resource-layout.component.ts +176 -0
  101. package/src/ccc-resource/resource-list/ resource-list.component.spec.ts +22 -0
  102. package/src/ccc-resource/resource-list/resource-list.component.html +27 -0
  103. package/src/ccc-resource/resource-list/resource-list.component.scss +67 -0
  104. package/src/ccc-resource/resource-list/resource-list.component.ts +376 -0
  105. package/src/ccc-resource/resource-list-create/resource-list-create.component.html +71 -0
  106. package/src/ccc-resource/resource-list-create/resource-list-create.component.scss +9 -0
  107. package/src/ccc-resource/resource-list-create/resource-list-create.component.spec.ts +22 -0
  108. package/src/ccc-resource/resource-list-create/resource-list-create.component.ts +103 -0
  109. package/src/ccc-resource/resource-resolver/resource-resolver.component.html +1 -0
  110. package/src/ccc-resource/resource-resolver/resource-resolver.component.scss +0 -0
  111. package/src/ccc-resource/resource-resolver/resource-resolver.component.spec.ts +22 -0
  112. package/src/ccc-resource/resource-resolver/resource-resolver.component.ts +69 -0
  113. package/src/ccc-resource/resource-store.service.ts +93 -0
  114. package/src/ccc-resource/resource-view/resource-view.component.html +133 -0
  115. package/src/ccc-resource/resource-view/resource-view.component.scss +150 -0
  116. package/src/ccc-resource/resource-view/resource-view.component.spec.ts +22 -0
  117. package/src/ccc-resource/resource-view/resource-view.component.ts +354 -0
  118. package/src/ccc-resource/resources-helpers.ts +262 -0
  119. package/src/ccc-resource/utils/validator-utils.ts +6 -0
  120. package/{fesm2022/cccteam-ccc-lib.mjs → src/index.ts} +32 -11
  121. package/src/internal-types/index.ts +1 -0
  122. package/src/internal-types/ng-package.json +6 -0
  123. package/src/types/auth.actions.ts +46 -0
  124. package/src/types/configs.ts +952 -0
  125. package/src/types/constants.ts +1 -0
  126. package/src/types/core.actions.ts +33 -0
  127. package/src/types/{public-api.d.ts → index.ts} +3 -0
  128. package/src/types/ng-package.json +6 -0
  129. package/src/types/notification-message.ts +20 -0
  130. package/src/types/{permissions.d.ts → permissions.ts} +9 -9
  131. package/src/types/{session-info.d.ts → session-info.ts} +4 -3
  132. package/src/types/tokens.ts +20 -0
  133. package/src/ui-alert/alert.component.html +13 -0
  134. package/src/ui-alert/alert.component.scss +48 -0
  135. package/src/ui-alert/alert.component.spec.ts +22 -0
  136. package/src/ui-alert/alert.component.ts +35 -0
  137. package/src/ui-alert/ng-package.json +6 -0
  138. package/src/ui-core-service/index.ts +1 -0
  139. package/src/ui-core-service/ng-package.json +6 -0
  140. package/src/ui-core-service/ui-core.service.ts +34 -0
  141. package/src/ui-interceptor/api.interceptor.spec.ts +16 -0
  142. package/src/ui-interceptor/api.interceptor.ts +45 -0
  143. package/src/ui-interceptor/ng-package.json +6 -0
  144. package/src/ui-notification-service/ng-package.json +6 -0
  145. package/src/ui-notification-service/notification.service.ts +59 -0
  146. package/src/ui-sidenav/ng-package.json +6 -0
  147. package/src/ui-sidenav/sidenav.component.html +60 -0
  148. package/src/ui-sidenav/sidenav.component.scss +99 -0
  149. package/src/ui-sidenav/sidenav.component.spec.ts +22 -0
  150. package/src/ui-sidenav/sidenav.component.ts +64 -0
  151. package/src/util-request-options/ng-package.json +6 -0
  152. package/src/util-request-options/request-options.ts +17 -0
  153. package/tsconfig.lib.json +13 -0
  154. package/tsconfig.lib.prod.json +11 -0
  155. package/tsconfig.spec.json +15 -0
  156. package/cccteam-ccc-lib-0.0.13.tgz +0 -0
  157. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs +0 -44
  158. package/fesm2022/cccteam-ccc-lib-src-auth-authentication-guard.mjs.map +0 -1
  159. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs +0 -24
  160. package/fesm2022/cccteam-ccc-lib-src-auth-authorization-guard.mjs.map +0 -1
  161. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs +0 -118
  162. package/fesm2022/cccteam-ccc-lib-src-auth-forms.mjs.map +0 -1
  163. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs +0 -51
  164. package/fesm2022/cccteam-ccc-lib-src-auth-has-permission.mjs.map +0 -1
  165. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs +0 -56
  166. package/fesm2022/cccteam-ccc-lib-src-auth-service.mjs.map +0 -1
  167. package/fesm2022/cccteam-ccc-lib-src-auth-state.mjs +0 -109
  168. package/fesm2022/cccteam-ccc-lib-src-auth-state.mjs.map +0 -1
  169. package/fesm2022/cccteam-ccc-lib-src-types.mjs +0 -137
  170. package/fesm2022/cccteam-ccc-lib-src-types.mjs.map +0 -1
  171. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs +0 -48
  172. package/fesm2022/cccteam-ccc-lib-src-ui-alert.mjs.map +0 -1
  173. package/fesm2022/cccteam-ccc-lib-src-ui-core-state.mjs +0 -100
  174. package/fesm2022/cccteam-ccc-lib-src-ui-core-state.mjs.map +0 -1
  175. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs +0 -48
  176. package/fesm2022/cccteam-ccc-lib-src-ui-interceptor.mjs.map +0 -1
  177. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs +0 -57
  178. package/fesm2022/cccteam-ccc-lib-src-ui-notification-service.mjs.map +0 -1
  179. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs +0 -70
  180. package/fesm2022/cccteam-ccc-lib-src-ui-sidenav.mjs.map +0 -1
  181. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs +0 -19
  182. package/fesm2022/cccteam-ccc-lib-src-util-request-options.mjs.map +0 -1
  183. package/fesm2022/cccteam-ccc-lib.mjs.map +0 -1
  184. package/index.d.ts +0 -5
  185. package/public-api.d.ts +0 -13
  186. package/src/auth-authentication-guard/authentication.guard.d.ts +0 -3
  187. package/src/auth-authentication-guard/index.d.ts +0 -5
  188. package/src/auth-authorization-guard/authorization.guard.d.ts +0 -3
  189. package/src/auth-authorization-guard/index.d.ts +0 -5
  190. package/src/auth-forms/ccc-field/ccc-field.component.d.ts +0 -25
  191. package/src/auth-forms/form-helpers.d.ts +0 -16
  192. package/src/auth-forms/index.d.ts +0 -5
  193. package/src/auth-has-permission/has-permission.directive.d.ts +0 -12
  194. package/src/auth-has-permission/index.d.ts +0 -5
  195. package/src/auth-service/auth.service.d.ts +0 -24
  196. package/src/auth-service/index.d.ts +0 -5
  197. package/src/auth-state/auth.state.d.ts +0 -27
  198. package/src/auth-state/index.d.ts +0 -5
  199. package/src/auth-state/public-api.d.ts +0 -1
  200. package/src/types/auth.actions.d.ts +0 -41
  201. package/src/types/core.actions.d.ts +0 -31
  202. package/src/types/index.d.ts +0 -5
  203. package/src/types/notification-message.d.ts +0 -18
  204. package/src/types/tokens.d.ts +0 -13
  205. package/src/ui-alert/alert.component.d.ts +0 -13
  206. package/src/ui-alert/index.d.ts +0 -5
  207. package/src/ui-core-state/core.state.d.ts +0 -28
  208. package/src/ui-core-state/index.d.ts +0 -5
  209. package/src/ui-core-state/public-api.d.ts +0 -1
  210. package/src/ui-interceptor/api.interceptor.d.ts +0 -12
  211. package/src/ui-interceptor/index.d.ts +0 -5
  212. package/src/ui-notification-service/index.d.ts +0 -5
  213. package/src/ui-notification-service/notification.service.d.ts +0 -30
  214. package/src/ui-sidenav/index.d.ts +0 -5
  215. package/src/ui-sidenav/sidenav.component.d.ts +0 -31
  216. package/src/util-request-options/index.d.ts +0 -5
  217. package/src/util-request-options/request-options.d.ts +0 -8
  218. /package/src/auth-authentication-guard/{public-api.d.ts → index.ts} +0 -0
  219. /package/src/auth-authorization-guard/{public-api.d.ts → index.ts} +0 -0
  220. /package/src/auth-has-permission/{public-api.d.ts → index.ts} +0 -0
  221. /package/src/auth-service/{public-api.d.ts → index.ts} +0 -0
  222. /package/src/ui-alert/{public-api.d.ts → index.ts} +0 -0
  223. /package/src/ui-interceptor/{public-api.d.ts → index.ts} +0 -0
  224. /package/src/ui-notification-service/{public-api.d.ts → index.ts} +0 -0
  225. /package/src/ui-sidenav/{public-api.d.ts → index.ts} +0 -0
  226. /package/src/util-request-options/{public-api.d.ts → index.ts} +0 -0
@@ -0,0 +1,155 @@
1
+ import { CommonModule } from '@angular/common';
2
+ import { Component, computed, input, output, TemplateRef } from '@angular/core';
3
+ import { MatIconButton } from '@angular/material/button';
4
+ import { MatIconModule } from '@angular/material/icon';
5
+ import { MatTooltipModule } from '@angular/material/tooltip';
6
+ import { RouterModule } from '@angular/router';
7
+ import { CamelCaseToTitlePipe } from '@cccteam/ccc-lib/src/ccc-camel-case-to-title';
8
+ import { ColumnConfig, RecordData } from '@cccteam/ccc-lib/src/types';
9
+ import { GridModule, SelectableMode, SelectableSettings } from '@progress/kendo-angular-grid';
10
+ import { TableButtonComponent } from './table-button/table-button.component';
11
+
12
+ @Component({
13
+ selector: 'ccc-grid',
14
+ standalone: true,
15
+ imports: [
16
+ GridModule,
17
+ CommonModule,
18
+ TableButtonComponent,
19
+ CamelCaseToTitlePipe,
20
+ RouterModule,
21
+ MatIconButton,
22
+ MatIconModule,
23
+ MatTooltipModule,
24
+ ],
25
+ template: `
26
+ <kendo-grid
27
+ [kendoGridBinding]="rowData()"
28
+ filterable="menu"
29
+ [sortable]="true"
30
+ scrollable="none"
31
+ [selectable]="selectionMode()"
32
+ [selectedKeys]="selectedKeys"
33
+ kendoGridSelectBy="id"
34
+ (selectedKeysChange)="onSelectedKeysChange($event)">
35
+ @if (selectionMode() !== false) {
36
+ <kendo-grid-checkbox-column
37
+ [width]="40"
38
+ [showSelectAll]="selectionType() === 'multiple'"></kendo-grid-checkbox-column>
39
+ }
40
+ @for (col of columnDefs(); track col.id + col.header) {
41
+ @if (col.buttonConfig) {
42
+ <kendo-grid-column
43
+ [field]="col.id"
44
+ [filterable]="false"
45
+ [sortable]="false"
46
+ [width]="66"
47
+ [resizable]="col.resizable ?? true">
48
+ <ng-template kendoGridHeaderTemplate> </ng-template>
49
+ <ng-template kendoGridCellTemplate let-dataItem>
50
+ @if (col.buttonConfig.actionType === 'link' && col.buttonConfig.viewRoute) {
51
+ <a
52
+ mat-icon-button
53
+ [routerLink]="['/', col.buttonConfig.viewRoute, dataItem['id']]"
54
+ [matTooltip]="col.buttonConfig.label || ''"
55
+ [matTooltipPosition]="col.tooltipPosition || 'above'">
56
+ <mat-icon>{{ col.buttonConfig.icon || 'arrow_forward' }}</mat-icon>
57
+ </a>
58
+ } @else {
59
+ <ccc-table-button
60
+ [config]="col.buttonConfig"
61
+ [rowData]="dataItem"
62
+ [tooltipPosition]="col.tooltipPosition || 'above'"
63
+ [viewRoute]="col.buttonConfig.viewRoute || ''"
64
+ [id]="dataItem['id']">
65
+ </ccc-table-button>
66
+ }
67
+ </ng-template>
68
+ </kendo-grid-column>
69
+ } @else {
70
+ @if (col.width) {
71
+ <kendo-grid-column [field]="col.id" [width]="col.width" [resizable]="col.resizable ?? true">
72
+ <ng-template kendoGridHeaderTemplate>
73
+ @if (!col.hideHeader) {
74
+ <span class="col-header">{{ col.header || col.id | camelCaseToTitle }}</span>
75
+ }
76
+ </ng-template>
77
+ <ng-template kendoGridCellTemplate let-dataItem>{{ dataItem[col.id] }} </ng-template>
78
+ </kendo-grid-column>
79
+ } @else {
80
+ <kendo-grid-column [field]="col.id" [resizable]="col.resizable ?? true">
81
+ <ng-template kendoGridHeaderTemplate>
82
+ @if (!col.hideHeader) {
83
+ <span class="col-header">{{ col.header || col.id | camelCaseToTitle }}</span>
84
+ }
85
+ </ng-template>
86
+ <ng-template kendoGridCellTemplate let-dataItem>{{ dataItem[col.id] }} </ng-template>
87
+ </kendo-grid-column>
88
+ }
89
+ }
90
+ }
91
+ <ng-template kendoGridNoRecordsTemplate>
92
+ <div style="text-align: center; padding: 20px;">No records found</div>
93
+ </ng-template>
94
+ </kendo-grid>
95
+ `,
96
+ styles: [
97
+ `
98
+ :host {
99
+ display: block;
100
+ height: 100%;
101
+ }
102
+ kendo-grid {
103
+ height: 100%;
104
+ }
105
+ .col-header {
106
+ font-weight: bold;
107
+ }
108
+ ccc-table-button {
109
+ position: relative;
110
+ z-index: 10;
111
+ }
112
+ a[mat-button] {
113
+ position: relative;
114
+ z-index: 11;
115
+ }
116
+ ::ng-deep .k-grid .k-grid-aria-root {
117
+ overflow-x: auto; /* Allow horizontal scrolling */
118
+ overflow-y: hidden; /* Keep vertical behavior as needed */
119
+ }
120
+ `,
121
+ ],
122
+ })
123
+ export class AppGridComponent {
124
+ /* eslint-disable @typescript-eslint/no-explicit-any */
125
+ rowData = input<any[]>([]);
126
+ columnDefs = input<ColumnConfig[]>([]);
127
+ masterDetail = input<boolean>(false);
128
+ detailTemplate = input<TemplateRef<unknown>>();
129
+ selectionType = input<'multiple' | 'single' | 'none'>('none');
130
+ selectedRows = output<RecordData[]>();
131
+
132
+ public selectedKeys: number[] = [];
133
+
134
+ onSelectedKeysChange(keys: number[]): void {
135
+ this.selectedKeys = keys;
136
+ const selectedRows = this.rowData().filter((row: any) => keys.includes(row.id));
137
+ this.selectedRows.emit(selectedRows);
138
+ }
139
+
140
+ selectionMode = computed(() => {
141
+ if (this.selectionType() === 'none') {
142
+ return false;
143
+ } else if (this.selectionType() === 'single') {
144
+ return {
145
+ mode: 'single' as SelectableMode,
146
+ checkboxOnly: true,
147
+ } as SelectableSettings;
148
+ } else {
149
+ return {
150
+ mode: 'multiple' as SelectableMode,
151
+ checkboxOnly: true,
152
+ } as SelectableSettings;
153
+ }
154
+ });
155
+ }
@@ -0,0 +1,3 @@
1
+ export * from './ccc-grid.component';
2
+ export * from './table-button/table-button.component';
3
+
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "lib": {
4
+ "entryFile": "./index.ts"
5
+ }
6
+ }
@@ -0,0 +1,16 @@
1
+ <span
2
+ [matTooltip]="disabled() ? config().disabledLabel : config().label"
3
+ [matTooltipPosition]="tooltipPosition()"
4
+ class="parent">
5
+ @if (config().actionType === 'link') {
6
+ <a [routerLink]="viewRoute()">
7
+ <button mat-icon-button [disabled]="disabled()" [color]="config().color">
8
+ <mat-icon>{{ config().icon }}</mat-icon>
9
+ </button>
10
+ </a>
11
+ } @else if (config().actionType === 'function') {
12
+ <button mat-icon-button (click)="callAction()" [disabled]="disabled()" [color]="color()">
13
+ <mat-icon>{{ config().icon }}</mat-icon>
14
+ </button>
15
+ }
16
+ </span>
@@ -0,0 +1,5 @@
1
+ .parent {
2
+ width: 100%;
3
+ height: 100%;
4
+ display: flex;
5
+ }
@@ -0,0 +1,22 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { TableButtonComponent } from './table-button.component';
4
+
5
+ xdescribe('TableButtonComponent', () => {
6
+ let component: TableButtonComponent<null>;
7
+ let fixture: ComponentFixture<TableButtonComponent<null>>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [TableButtonComponent],
12
+ }).compileComponents();
13
+
14
+ fixture = TestBed.createComponent(TableButtonComponent<null>);
15
+ component = fixture.componentInstance;
16
+ fixture.detectChanges();
17
+ });
18
+
19
+ it('should create', () => {
20
+ expect(component).toBeTruthy();
21
+ });
22
+ });
@@ -0,0 +1,49 @@
1
+ import { Component, computed, input, signal } from '@angular/core';
2
+ import { MatButtonModule } from '@angular/material/button';
3
+ import { MatIconModule } from '@angular/material/icon';
4
+ import { MatTooltipModule, TooltipPosition } from '@angular/material/tooltip';
5
+ import { RouterModule } from '@angular/router';
6
+ import { ActionButtonConfig } from '@cccteam/ccc-lib/src/types';
7
+
8
+ @Component({
9
+ selector: 'ccc-table-button',
10
+ standalone: true,
11
+ imports: [MatButtonModule, MatIconModule, MatTooltipModule, RouterModule],
12
+ templateUrl: './table-button.component.html',
13
+ styleUrl: './table-button.component.scss',
14
+ })
15
+ export class TableButtonComponent<T> {
16
+ config = input.required<ActionButtonConfig>();
17
+
18
+ rowData = input.required<T>();
19
+ tooltipPosition = input<TooltipPosition>('above' as TooltipPosition);
20
+ color = input<string>('');
21
+ disabled = signal<boolean>(false);
22
+ viewRoute = input<string>('');
23
+ id = input<string>('');
24
+
25
+ link = computed(() => {
26
+ const viewRoute = this.viewRoute();
27
+ const id = this.id();
28
+
29
+ if (!viewRoute || !id) {
30
+ return '';
31
+ }
32
+
33
+ if (!viewRoute.startsWith('/')) {
34
+ return `${viewRoute}/${id}`;
35
+ }
36
+
37
+ return `${viewRoute}/${id}`;
38
+ });
39
+
40
+ callAction(): void {
41
+ const rowData = this.rowData();
42
+ const action = this.config().action;
43
+ if (rowData && action !== undefined) {
44
+ const id = 'id' as keyof T;
45
+ const idVal = rowData[id] as string;
46
+ action({ id: idVal });
47
+ }
48
+ }
49
+ }
@@ -0,0 +1,41 @@
1
+ import { inject } from '@angular/core';
2
+ import { MatDialog } from '@angular/material/dialog';
3
+ import { CanDeactivateFn, UrlTree } from '@angular/router';
4
+ import { firstValueFrom, Observable, tap } from 'rxjs';
5
+ import { FormStateService } from './form-state.service';
6
+ import { LeavePageConfirmationModalComponent } from './leave-page-confirmation-modal/leave-page-confirmation-modal.component';
7
+
8
+ export type CanDeactivateType = Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree;
9
+
10
+ export interface CanComponentDeactivate {
11
+ canDeactivate: () => CanDeactivateType;
12
+ }
13
+
14
+ export const dirtyFormDeactivateGuard: CanDeactivateFn<CanComponentDeactivate> = async (_, __, ___, nextState) => {
15
+ const dialog = inject(MatDialog);
16
+ const formStateService = inject(FormStateService);
17
+
18
+ if (nextState?.url === '/login') {
19
+ return true;
20
+ }
21
+
22
+ if (!formStateService.isDirty()) {
23
+ return true;
24
+ }
25
+
26
+ const existingDialog = dialog.openDialogs.find(
27
+ (d) => d.componentInstance instanceof LeavePageConfirmationModalComponent,
28
+ );
29
+
30
+ const dialogRef = existingDialog ?? dialog.open(LeavePageConfirmationModalComponent, { delayFocusTrap: false });
31
+
32
+ const result = dialogRef.afterClosed().pipe(
33
+ tap((value) => {
34
+ if (value === true) {
35
+ formStateService.resetDirtyForms();
36
+ }
37
+ }),
38
+ );
39
+
40
+ return firstValueFrom(result);
41
+ };
@@ -0,0 +1,57 @@
1
+ <div class="page-container">
2
+ <div class="header-container">
3
+ <div class="title" [class.title-without-back]="title()">
4
+ @if (title() !== '') {
5
+ <h1>{{ title() }}</h1>
6
+ }
7
+ </div>
8
+ </div>
9
+
10
+ @if (hasElements() || configs().length > 0) {
11
+ <div class="resource-container" [class.empty-elements]="!hasElements()">
12
+ @let primaryConfigRef = primaryConfig();
13
+ @if (primaryConfigRef.type === 'View' || primaryConfigRef.type === 'ListView') {
14
+ <ccc-resource-view
15
+ [uuid]="uuid()"
16
+ [config]="primaryConfigRef"
17
+ [relatedData]="resolvedData()"
18
+ [compoundResourceView]="true">
19
+ </ccc-resource-view>
20
+ }
21
+
22
+ @for (config of configs(); track config) {
23
+ @let hasrelatedConfigs = 'relatedConfigs' in config && config.relatedConfigs.length > 0;
24
+ @if (hasrelatedConfigs) {
25
+ <ccc-compound-resource
26
+ [uuid]="primaryConfigParentId()"
27
+ [parentData]="resolvedData()"
28
+ [resourceConfig]="config">
29
+ </ccc-compound-resource>
30
+ } @else if (config.type === 'ListView') {
31
+ <ccc-resource-list-create
32
+ [resourceConfig]="config"
33
+ [parentData]="resolvedData()"
34
+ [isRootList]="false"
35
+ [parentId]="primaryConfigParentId()">
36
+ </ccc-resource-list-create>
37
+ } @else if (config.type === 'Array') {
38
+ <ccc-resource-array-view
39
+ [resourceConfig]="config"
40
+ [parentData]="store.viewData()"
41
+ [compoundResourceComponent]="componentRef">
42
+ </ccc-resource-array-view>
43
+ } @else if (config.type === 'View') {
44
+ <ccc-resource-view
45
+ [uuid]="primaryConfigParentId()"
46
+ [config]="config"
47
+ [relatedData]="resolvedData()"></ccc-resource-view>
48
+ } @else if (config.type === 'Component') {
49
+ <ccc-resource-resolver
50
+ [parentData]="resolvedData()"
51
+ [resourceConfig]="config"
52
+ [compoundResourceComponent]="componentRef"> </ccc-resource-resolver>
53
+ }
54
+ }
55
+ </div>
56
+ }
57
+ </div>
@@ -0,0 +1,86 @@
1
+ .page-container {
2
+ position: relative;
3
+ }
4
+
5
+ .header-container {
6
+ display: flex;
7
+ flex-direction: row;
8
+ position: absolute;
9
+ top: 0;
10
+ z-index: 11;
11
+ background: transparent;
12
+ }
13
+
14
+ .title {
15
+ display: flex;
16
+ align-items: center;
17
+ flex-shrink: 0;
18
+ }
19
+
20
+ .title-without-back {
21
+ margin-left: 48px;
22
+ height: 48px;
23
+ }
24
+
25
+ .message {
26
+ margin-top: auto;
27
+ margin-bottom: auto;
28
+ }
29
+
30
+ .state-buttons {
31
+ display: flex;
32
+ flex-direction: row;
33
+ margin-bottom: auto;
34
+ justify-content: right;
35
+ flex-grow: 1;
36
+ gap: 20px;
37
+ margin-right: 32px;
38
+ }
39
+
40
+ .mode-text {
41
+ margin-top: auto;
42
+ margin-bottom: auto;
43
+ }
44
+
45
+ .resource {
46
+ margin: 10px;
47
+ }
48
+
49
+ .mat-input-element:disabled[readonly] {
50
+ color: currentColor;
51
+ }
52
+
53
+ .unsaved {
54
+ color: #f44336;
55
+ }
56
+
57
+ .edit-button {
58
+ margin-top: auto;
59
+ margin-bottom: auto;
60
+ padding-left: 10px;
61
+ }
62
+
63
+ .button-text {
64
+ display: flex;
65
+ flex-direction: row;
66
+ align-items: center;
67
+
68
+ .edit {
69
+ color: #003b49;
70
+ }
71
+
72
+ .mat-icon {
73
+ margin-right: 8px;
74
+ }
75
+ }
76
+
77
+ .empty-elements {
78
+ padding-top: 30px;
79
+ }
80
+
81
+ .rpc-buttons-container {
82
+ display: flex;
83
+ flex-direction: row;
84
+ justify-content: flex-end;
85
+ padding-bottom: 10px;
86
+ }
@@ -0,0 +1,22 @@
1
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
2
+
3
+ import { CompoundResourceComponent } from './compound-resource.component';
4
+
5
+ xdescribe('CompoundResourceComponent', () => {
6
+ let component: CompoundResourceComponent;
7
+ let fixture: ComponentFixture<CompoundResourceComponent>;
8
+
9
+ beforeEach(async () => {
10
+ await TestBed.configureTestingModule({
11
+ imports: [CompoundResourceComponent],
12
+ }).compileComponents();
13
+
14
+ fixture = TestBed.createComponent(CompoundResourceComponent);
15
+ component = fixture.componentInstance;
16
+ fixture.detectChanges();
17
+ });
18
+
19
+ it('should create', () => {
20
+ expect(component).toBeTruthy();
21
+ });
22
+ });
@@ -0,0 +1,158 @@
1
+ import { CommonModule, Location } from '@angular/common';
2
+ import {
3
+ ChangeDetectionStrategy,
4
+ Component,
5
+ ComponentRef,
6
+ computed,
7
+ effect,
8
+ inject,
9
+ Injector,
10
+ input,
11
+ OnInit,
12
+ signal
13
+ } from '@angular/core';
14
+ import { MatButtonModule } from '@angular/material/button';
15
+ import { MatIconModule } from '@angular/material/icon';
16
+ import { ActivatedRoute, RouterModule } from '@angular/router';
17
+ import { ChildResourceConfig, ParentResourceConfig, RecordData, Resource, RESOURCE_META, RootConfig } from '@cccteam/ccc-lib/src/types';
18
+ import { ResourceArrayViewComponent } from '../resource-array-view/resource-array-view.component';
19
+ import { ResourceListCreateComponent } from '../resource-list-create/resource-list-create.component';
20
+ import { ResourceResolverComponent } from '../resource-resolver/resource-resolver.component';
21
+ import { ResourceStore } from '../resource-store.service';
22
+ import { ResourceViewComponent } from '../resource-view/resource-view.component';
23
+
24
+ @Component({
25
+ selector: 'ccc-compound-resource',
26
+ templateUrl: './compound-resource.component.html',
27
+ styleUrl: './compound-resource.component.scss',
28
+ changeDetection: ChangeDetectionStrategy.OnPush,
29
+ standalone: true,
30
+ imports: [
31
+ MatIconModule,
32
+ RouterModule,
33
+ MatButtonModule,
34
+ ResourceViewComponent,
35
+ ResourceListCreateComponent,
36
+ ResourceArrayViewComponent,
37
+ ResourceResolverComponent,
38
+ CommonModule,
39
+ RouterModule,
40
+ ],
41
+ providers: [ResourceStore],
42
+ })
43
+ export class CompoundResourceComponent implements OnInit {
44
+ location = inject(Location);
45
+ route = inject(ActivatedRoute);
46
+ store = inject(ResourceStore);
47
+ injector = inject(Injector);
48
+ componentRef = this.injector.get(ComponentRef<CompoundResourceComponent>);
49
+ resourceMeta = inject(RESOURCE_META);
50
+
51
+ resourceConfig = input<ParentResourceConfig | ChildResourceConfig>();
52
+ isArrayChild = input<boolean>(false);
53
+ uuid = input.required<string>();
54
+ parentData = input<RecordData>();
55
+
56
+ rootConfig = computed(() => this.route.snapshot.data['config'] as RootConfig);
57
+
58
+ emptyOneToOne = signal(false);
59
+
60
+ hasElements = computed(() => {
61
+ const config = this.primaryConfig();
62
+ return config && (config.type === 'ListView' || config.type === 'View') && config.elements.length > 0;
63
+ });
64
+
65
+ primaryConfigParentId = computed(() => {
66
+ const config = this.primaryConfig();
67
+ const data = this.resolvedData();
68
+ if (config.type === 'View' || config.type === 'ListView') {
69
+ const parentKey = config.parentRelation?.parentKey;
70
+ if (parentKey !== '') {
71
+ return String(data[parentKey]);
72
+ }
73
+ }
74
+ return this.uuid();
75
+ });
76
+
77
+ primaryConfig = computed(() => {
78
+ const config = this.resourceConfig();
79
+ if (config) {
80
+ return config;
81
+ }
82
+ return this.rootConfig().parentConfig;
83
+ });
84
+
85
+ title = computed(() => {
86
+ if (this.isArrayChild()) {
87
+ return '';
88
+ }
89
+ const config = this.primaryConfig();
90
+ if (config.type !== 'Component') {
91
+ return config.title;
92
+ }
93
+ return '';
94
+ });
95
+
96
+ isRootConfig = computed(() => {
97
+ return this.resourceConfig() === undefined;
98
+ });
99
+
100
+ configs = computed(() => {
101
+ if (this.hasElements() && this.emptyOneToOne()) {
102
+ return [];
103
+ }
104
+
105
+ if (this.isRootConfig()) {
106
+ return this.rootConfig().relatedConfigs;
107
+ }
108
+
109
+ const config = this.primaryConfig();
110
+ if (config.type === 'ListView' || config.type === 'View') {
111
+ return config.relatedConfigs;
112
+ }
113
+ return [];
114
+ });
115
+
116
+ rpcConfigs = computed(() => (this.isRootConfig() ? this.rootConfig().rpcConfigs : undefined));
117
+ hasRpcConfigs = computed(() => !!this.rpcConfigs() && this.rpcConfigs()!.length > 0);
118
+
119
+ resolvedData = computed(() => {
120
+ if (this.store.viewData()) {
121
+ return this.store.viewData() as RecordData;
122
+ }
123
+
124
+ return this.parentData() || ({} as RecordData);
125
+ });
126
+
127
+ ngOnInit(): void {
128
+ const resource = this.primaryConfig().primaryResource as Resource;
129
+ const meta = this.resourceMeta(resource);
130
+
131
+ if (meta) {
132
+ this.store.resourceName.set(resource);
133
+ this.store.resourceMeta.set(meta);
134
+ }
135
+ }
136
+
137
+ constructor() {
138
+ effect(() => {
139
+ this.store.uuid.set(this.primaryConfigParentId());
140
+
141
+ const c = this.primaryConfig();
142
+ if (c.type === 'View') {
143
+ this.store.resetResourceView();
144
+ } else if (c.type === 'ListView') {
145
+ this.store.resetResourceList();
146
+ this.store.resetResourceView();
147
+ }
148
+ });
149
+ }
150
+
151
+ handleEmptyOneToOne(value: boolean): void {
152
+ this.emptyOneToOne.set(value);
153
+ }
154
+
155
+ goBack(): void {
156
+ this.location.back();
157
+ }
158
+ }