@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
package/eslint.config.js DELETED
@@ -1,32 +0,0 @@
1
- // @ts-check
2
- const tseslint = require("typescript-eslint");
3
- const rootConfig = require("../../eslint.config.js");
4
-
5
- module.exports = tseslint.config(
6
- ...rootConfig,
7
- {
8
- files: ["**/*.ts"],
9
- rules: {
10
- "@angular-eslint/directive-selector": [
11
- "error",
12
- {
13
- type: "attribute",
14
- prefix: "ccc",
15
- style: "camelCase",
16
- },
17
- ],
18
- "@angular-eslint/component-selector": [
19
- "error",
20
- {
21
- type: "element",
22
- prefix: "ccc",
23
- style: "kebab-case",
24
- },
25
- ],
26
- },
27
- },
28
- {
29
- files: ["**/*.html"],
30
- rules: {},
31
- }
32
- );
package/ng-package.json DELETED
@@ -1,11 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/ccc-lib",
4
- "lib": {
5
- "entryFile": "src/index.ts"
6
- },
7
- "allowedNonPeerDependencies": [
8
- "date-fns",
9
- "date-fns-tz"
10
- ]
11
- }
@@ -1,40 +0,0 @@
1
- import { inject } from '@angular/core';
2
- import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
3
- import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
4
- import { BASE_URL } from '@cccteam/ccc-lib/src/types';
5
- import { Observable, of } from 'rxjs';
6
- import { catchError, map } from 'rxjs/operators';
7
-
8
- export const AuthenticationGuard = (
9
- route: ActivatedRouteSnapshot,
10
- routerState: RouterStateSnapshot,
11
- ): Observable<boolean> => {
12
- const authService = inject(AuthService);
13
- const baseUrl = inject(BASE_URL);
14
-
15
- const authenticate = (): void => {
16
- const url = routerState.url;
17
- const absoluteUrl = baseUrl + (!url.toString().startsWith('/') ? '/' + url : url);
18
- const encodedUrl = encodeURIComponent(absoluteUrl);
19
- window.location.href = `${authService.loginRoute()}?returnUrl=${encodedUrl}`;
20
- };
21
-
22
- if (authService.authenticated()) {
23
- return of(true);
24
- }
25
-
26
- return authService.checkUserSession().pipe(
27
- map((sessionInfo) => {
28
- if (sessionInfo?.authenticated) {
29
- return true;
30
- }
31
-
32
- authenticate();
33
- return false;
34
- }),
35
- catchError(() => {
36
- authenticate();
37
- return of(false);
38
- }),
39
- );
40
- };
@@ -1 +0,0 @@
1
- export * from './authentication.guard';
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "./index.ts"
5
- }
6
- }
@@ -1,17 +0,0 @@
1
- import { computed, inject, Signal } from '@angular/core';
2
- import { ActivatedRouteSnapshot, Router } from '@angular/router';
3
- import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
4
-
5
- export const AuthorizationGuard = (route: ActivatedRouteSnapshot): Signal<boolean> => {
6
- const router = inject(Router);
7
- const auth = inject(AuthService);
8
- return computed(() => {
9
- const hasPermission = auth.hasPermission(route.data['scope']);
10
- if (hasPermission) {
11
- return true;
12
- } else {
13
- router.navigate(['/']);
14
- return false;
15
- }
16
- });
17
- };
@@ -1 +0,0 @@
1
- export * from './authorization.guard';
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "./index.ts"
5
- }
6
- }
@@ -1 +0,0 @@
1
- <p>ccc-field works!</p>
File without changes
@@ -1,22 +0,0 @@
1
- import { ComponentFixture, TestBed } from '@angular/core/testing';
2
-
3
- import { CccInputFieldComponent } from './ccc-field.component';
4
-
5
- describe('CccFieldComponent', () => {
6
- let component: CccInputFieldComponent;
7
- let fixture: ComponentFixture<CccInputFieldComponent>;
8
-
9
- beforeEach(async () => {
10
- await TestBed.configureTestingModule({
11
- imports: [CccInputFieldComponent],
12
- }).compileComponents();
13
-
14
- fixture = TestBed.createComponent(CccInputFieldComponent);
15
- component = fixture.componentInstance;
16
- fixture.detectChanges();
17
- });
18
-
19
- it('should create', () => {
20
- expect(component).toBeTruthy();
21
- });
22
- });
@@ -1,74 +0,0 @@
1
- import { Component, computed, inject, input, OnInit, signal, Signal } from '@angular/core';
2
- import { MatFormFieldModule } from '@angular/material/form-field';
3
- import { MatInputModule } from '@angular/material/input';
4
- import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
5
- import { Domain, ReadPermission, Resource, UpdatePermission } from '@cccteam/ccc-lib/src/types';
6
-
7
- export enum InputMode {
8
- Read = 'read',
9
- Edit = 'edit',
10
- }
11
-
12
- @Component({
13
- selector: 'ccc-input-field',
14
- imports: [MatFormFieldModule, MatInputModule],
15
- template: `
16
- <mat-form-field [class]="className()">
17
- <mat-label>{{ name() }}</mat-label>
18
- <input matInput [disabled]="mode() === inputMode.Edit && canEdit()" [value]="value()" />
19
- </mat-form-field>
20
- `,
21
- styleUrl: './ccc-field.component.scss',
22
- })
23
- export class CccInputFieldComponent implements OnInit {
24
- auth = inject(AuthService);
25
- className = input();
26
- mode = input.required<InputMode>();
27
- resource = input.required<Resource>();
28
- domain = input.required<Domain>();
29
- value = input.required();
30
- name = input.required<string>();
31
-
32
- inputMode = InputMode;
33
-
34
- canEdit: Signal<boolean> = signal(false);
35
- canEditSelector = false;
36
-
37
- canRead: Signal<boolean> = signal(false);
38
- canReadSelector = false;
39
-
40
- ngOnInit(): void {
41
- this.canEditSelector = this.auth.hasPermission({
42
- resource: this.resource(),
43
- permission: ReadPermission,
44
- domain: this.domain(),
45
- });
46
- this.canReadSelector = this.auth.hasPermission({
47
- resource: this.resource(),
48
- permission: UpdatePermission,
49
- domain: this.domain(),
50
- });
51
-
52
- this.canRead = computed(() => {
53
- const res = this.resource();
54
- if (!res) {
55
- return false;
56
- }
57
- if (AuthService.requiresPermission(this.resource(), ReadPermission)) {
58
- return this.canReadSelector;
59
- }
60
- return false;
61
- });
62
-
63
- this.canEdit = computed(() => {
64
- const res = this.resource();
65
- if (!res) {
66
- return false;
67
- }
68
- if (AuthService.requiresPermission(this.resource(), UpdatePermission)) {
69
- return this.canEditSelector;
70
- }
71
- return false;
72
- });
73
- }
74
- }
@@ -1,39 +0,0 @@
1
- import { FormArray, FormGroup } from '@angular/forms';
2
- import { isEqual } from 'lodash-es';
3
-
4
- /**
5
- * Accepts a FormGroup and compares it to an object to return the dirty form values
6
- * as a sparse object
7
- * @param form - FormGroup
8
- * @param compareData - object to compare form values against
9
- * @returns Partial<T>
10
- * @example sparseFormData<UserCreate>(this.userForm, initUser)
11
- */
12
- export function sparseFormData<T>(form: FormGroup, compareData: T): T {
13
- const sparseFormData: T = {} as T;
14
-
15
- for (const [key, control] of Object.entries(form.controls)) {
16
- const controlValue = control.value;
17
- const compareValue = compareData[key as keyof T];
18
-
19
- if (!isEqual(controlValue, compareValue)) {
20
- sparseFormData[key as keyof T] = controlValue as T[keyof T];
21
- }
22
- }
23
-
24
- return sparseFormData;
25
- }
26
-
27
- /**
28
- * Accepts a FormArray and removes empty strings
29
- * @param formArray - FormArray
30
- * @returns FormArray
31
- */
32
- export function cleanStringFormArray(formArray: FormArray): FormArray {
33
- for (let i = formArray.controls.length - 1; i >= 0; i--) {
34
- if (formArray.at(i).value === '') {
35
- formArray.removeAt(i);
36
- }
37
- }
38
- return formArray;
39
- }
@@ -1,3 +0,0 @@
1
- export * from './ccc-field/ccc-field.component';
2
- export * from './form-helpers';
3
-
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "./index.ts"
5
- }
6
- }
@@ -1,34 +0,0 @@
1
- import { Directive, Input, TemplateRef, ViewContainerRef, effect, inject, signal } from '@angular/core';
2
- import { AuthService } from '@cccteam/ccc-lib/src/auth-service';
3
- import { PermissionScope } from '@cccteam/ccc-lib/src/types';
4
-
5
- @Directive({
6
- selector: '[cccHasPermission]',
7
- standalone: true,
8
- })
9
- export class HasPermissionDirective {
10
- private auth = inject(AuthService);
11
- private templateRef = inject(TemplateRef<unknown>);
12
- private viewContainer = inject(ViewContainerRef);
13
-
14
- private scope = signal<PermissionScope | undefined>(undefined);
15
-
16
- @Input()
17
- set cccHasPermission(scope: PermissionScope) {
18
- this.scope.set(scope);
19
- }
20
-
21
- constructor() {
22
- effect(() => {
23
- const scope = this.scope();
24
-
25
- if (this.auth.hasPermission(scope) && this.auth.authenticated()) {
26
- if (!this.viewContainer.get(0)) {
27
- this.viewContainer.createEmbeddedView(this.templateRef);
28
- }
29
- } else {
30
- this.viewContainer.clear();
31
- }
32
- });
33
- }
34
- }
@@ -1 +0,0 @@
1
- export * from './has-permission.directive';
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "./index.ts"
5
- }
6
- }
@@ -1,92 +0,0 @@
1
- import { HttpClient } from '@angular/common/http';
2
- import { inject, Inject, Injectable, signal } from '@angular/core';
3
- import {
4
- API_URL,
5
- Permission,
6
- PERMISSION_REQUIRED,
7
- PermissionScope,
8
- Resource,
9
- SessionInfo,
10
- } from '@cccteam/ccc-lib/src/types';
11
- import { errorOptions } from '@cccteam/ccc-lib/src/util-request-options';
12
- import { map, Observable, tap } from 'rxjs';
13
-
14
- const routes = {
15
- login: (rootUrl: string): string => `${rootUrl}/user/login`,
16
- session: (rootUrl: string): string => `${rootUrl}/user/session`,
17
- };
18
-
19
- @Injectable({
20
- providedIn: 'root',
21
- })
22
- export class AuthService {
23
- http = inject(HttpClient);
24
- private authenticatedSignal = signal(false);
25
- private sessionInfoSignal = signal({} as SessionInfo);
26
-
27
- redirectUrl = signal('');
28
- authenticated = this.authenticatedSignal.asReadonly();
29
- sessionInfo = this.sessionInfoSignal.asReadonly();
30
-
31
- constructor(@Inject(API_URL) private apiUrl: string) {
32
- this.initializePermissionFn();
33
- }
34
-
35
- private static permissionFn: (resource: Resource, permission: Permission) => boolean;
36
-
37
- hasPermission(scope?: PermissionScope): boolean {
38
- if (!scope) return true;
39
- const resourcePermissions = this.sessionInfo().permissions?.[scope.domain]?.[scope.resource];
40
- return Array.isArray(resourcePermissions) && resourcePermissions.includes(scope.permission);
41
- }
42
-
43
- static requiresPermission(resource: Resource, permission: Permission): boolean {
44
- if (!AuthService.permissionFn) {
45
- throw new Error(
46
- `AuthState has not been initialized. Ensure AuthState is provided in your module or instantiated at least once.`,
47
- );
48
- }
49
- return AuthService.permissionFn(resource, permission);
50
- }
51
-
52
- private initializePermissionFn(): void {
53
- if (!AuthService.permissionFn) {
54
- AuthService.permissionFn = inject(PERMISSION_REQUIRED);
55
- }
56
- }
57
-
58
- /**
59
- * Logs a user out.
60
- *
61
- * @returns Observable with a boolean indicating whether they were logged out.
62
- */
63
- logout(): Observable<boolean> {
64
- return this.http
65
- .delete(routes.session(this.apiUrl), errorOptions(false))
66
- .pipe(map(() => true))
67
- .pipe(
68
- tap(() => {
69
- this.authenticatedSignal.set(false);
70
- this.sessionInfoSignal.set({} as SessionInfo);
71
- }),
72
- );
73
- }
74
-
75
- /**
76
- * Checks a user's session with the server.
77
- *
78
- * @returns Observable with the user session info
79
- */
80
- checkUserSession(): Observable<SessionInfo> {
81
- return this.http.get<SessionInfo>(routes.session(this.apiUrl), errorOptions(false)).pipe(
82
- tap((sessionInfo) => {
83
- this.authenticatedSignal.set(!!sessionInfo?.authenticated);
84
- this.sessionInfoSignal.set(sessionInfo);
85
- }),
86
- );
87
- }
88
-
89
- loginRoute(): string {
90
- return routes.login(this.apiUrl);
91
- }
92
- }
@@ -1 +0,0 @@
1
- export * from './auth.service';
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "./index.ts"
5
- }
6
- }
@@ -1,23 +0,0 @@
1
- import { Pipe, PipeTransform } from '@angular/core';
2
-
3
- @Pipe({
4
- name: 'camelCaseToTitle',
5
- })
6
- export class CamelCaseToTitlePipe implements PipeTransform {
7
- transform(value: string): string {
8
- if (!value) {
9
- return value;
10
- }
11
-
12
- if (value === value.toUpperCase() && !/[0-9]/.test(value)) {
13
- return value;
14
- }
15
-
16
- let transformed = value.replace(/([A-Z])/g, ' $1');
17
- transformed = transformed.replace(/([a-zA-Z])([0-9])/g, '$1 $2');
18
- transformed = transformed.trim();
19
- transformed = transformed.charAt(0).toUpperCase() + transformed.slice(1);
20
-
21
- return transformed;
22
- }
23
- }
@@ -1 +0,0 @@
1
- export * from './camel-case-to-title.pipe';
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "index.ts"
5
- }
6
- }
@@ -1,155 +0,0 @@
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
- }
@@ -1,3 +0,0 @@
1
- export * from './ccc-grid.component';
2
- export * from './table-button/table-button.component';
3
-
@@ -1,6 +0,0 @@
1
- {
2
- "$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3
- "lib": {
4
- "entryFile": "./index.ts"
5
- }
6
- }
@@ -1,16 +0,0 @@
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>
@@ -1,5 +0,0 @@
1
- .parent {
2
- width: 100%;
3
- height: 100%;
4
- display: flex;
5
- }