@pega/angular-sdk-overrides 0.25.1 → 0.25.2

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 (160) hide show
  1. package/lib/designSystemExtension/alert/alert.component.scss +3 -3
  2. package/lib/designSystemExtension/banner/banner.component.scss +12 -2
  3. package/lib/designSystemExtension/material-case-summary/material-case-summary.component.html +6 -3
  4. package/lib/designSystemExtension/material-case-summary/material-case-summary.component.scss +5 -34
  5. package/lib/designSystemExtension/material-details/material-details.component.scss +0 -5
  6. package/lib/designSystemExtension/material-details-fields/material-details-fields.component.html +2 -2
  7. package/lib/designSystemExtension/material-details-fields/material-details-fields.component.scss +4 -3
  8. package/lib/designSystemExtension/material-summary-item/material-summary-item.component.scss +2 -17
  9. package/lib/designSystemExtension/material-utility/material-utility.component.scss +1 -2
  10. package/lib/designSystemExtension/material-vertical-tabs/material-vertical-tabs.component.scss +1 -1
  11. package/lib/designSystemExtension/operator/operator.component.html +1 -1
  12. package/lib/designSystemExtension/operator/operator.component.scss +3 -10
  13. package/lib/designSystemExtension/operator/operator.component.ts +0 -1
  14. package/lib/designSystemExtension/pulse/pulse.component.scss +2 -2
  15. package/lib/designSystemExtension/rich-text-editor/rich-text-editor.component.scss +0 -1
  16. package/lib/designSystemExtension/wss-quick-create/wss-quick-create.component.scss +16 -8
  17. package/lib/field/auto-complete/auto-complete.component.html +0 -1
  18. package/lib/field/auto-complete/auto-complete.component.ts +35 -172
  19. package/lib/field/cancel-alert/cancel-alert.component.html +8 -12
  20. package/lib/field/cancel-alert/cancel-alert.component.scss +2 -3
  21. package/lib/field/cancel-alert/cancel-alert.component.ts +24 -36
  22. package/lib/field/check-box/check-box.component.html +0 -1
  23. package/lib/field/check-box/check-box.component.scss +0 -1
  24. package/lib/field/check-box/check-box.component.ts +19 -149
  25. package/lib/field/currency/currency.component.ts +36 -168
  26. package/lib/field/date/date.component.html +1 -1
  27. package/lib/field/date/date.component.ts +30 -150
  28. package/lib/field/date-time/date-time.component.ts +31 -149
  29. package/lib/field/decimal/decimal.component.ts +38 -163
  30. package/lib/field/dropdown/dropdown.component.ts +29 -151
  31. package/lib/field/email/email.component.ts +16 -155
  32. package/lib/field/field.base.ts +149 -0
  33. package/lib/field/group/group.component.ts +7 -4
  34. package/lib/field/integer/integer.component.ts +18 -157
  35. package/lib/field/location/location.component.ts +1 -1
  36. package/lib/field/multiselect/multiselect.component.ts +46 -148
  37. package/lib/field/multiselect/utils.ts +55 -47
  38. package/lib/field/object-reference/object-reference.component.html +17 -0
  39. package/lib/field/object-reference/object-reference.component.scss +0 -0
  40. package/lib/field/object-reference/object-reference.component.spec.ts +22 -0
  41. package/lib/field/object-reference/object-reference.component.ts +237 -0
  42. package/lib/field/percentage/percentage.component.ts +37 -154
  43. package/lib/field/phone/phone.component.ts +28 -142
  44. package/lib/field/radio-buttons/radio-buttons.component.scss +4 -2
  45. package/lib/field/radio-buttons/radio-buttons.component.ts +35 -161
  46. package/lib/field/rich-text/rich-text.component.ts +19 -90
  47. package/lib/field/scalar-list/scalar-list.component.ts +17 -72
  48. package/lib/field/selectable-card/selectable-card.component.html +54 -24
  49. package/lib/field/selectable-card/selectable-card.component.scss +11 -0
  50. package/lib/field/selectable-card/selectable-card.component.ts +16 -52
  51. package/lib/field/semantic-link/semantic-link.component.html +4 -8
  52. package/lib/field/semantic-link/semantic-link.component.scss +0 -13
  53. package/lib/field/semantic-link/semantic-link.component.ts +165 -5
  54. package/lib/field/text/text.component.scss +0 -1
  55. package/lib/field/text-area/text-area.component.ts +18 -152
  56. package/lib/field/text-input/text-input.component.ts +16 -155
  57. package/lib/field/time/time.component.ts +17 -151
  58. package/lib/field/url/url.component.ts +16 -154
  59. package/lib/field/user-reference/user-reference.component.scss +0 -1
  60. package/lib/field/user-reference/user-reference.component.ts +2 -3
  61. package/lib/infra/Containers/flow-container/flow-container.component.ts +5 -7
  62. package/lib/infra/Containers/modal-view-container/modal-view-container.component.ts +5 -10
  63. package/lib/infra/Containers/view-container/helper.ts +35 -2
  64. package/lib/infra/Containers/view-container/view-container.component.ts +1 -1
  65. package/lib/infra/action-buttons/action-buttons.component.html +13 -8
  66. package/lib/infra/action-buttons/action-buttons.component.scss +23 -0
  67. package/lib/infra/action-buttons/action-buttons.component.ts +1 -2
  68. package/lib/infra/assignment/assignment.component.ts +8 -6
  69. package/lib/infra/assignment-card/assignment-card.component.html +1 -2
  70. package/lib/infra/assignment-card/assignment-card.component.scss +0 -4
  71. package/lib/infra/assignment-card/assignment-card.component.ts +21 -4
  72. package/lib/infra/defer-load/defer-load.component.html +6 -2
  73. package/lib/infra/defer-load/defer-load.component.ts +16 -10
  74. package/lib/infra/multi-step/multi-step.component.scss +1 -21
  75. package/lib/infra/navbar/navbar.component.html +25 -28
  76. package/lib/infra/navbar/navbar.component.scss +16 -4
  77. package/lib/infra/navbar/navbar.component.ts +8 -3
  78. package/lib/infra/root-container/root-container.component.scss +0 -1
  79. package/lib/infra/root-container/root-container.component.ts +1 -2
  80. package/lib/infra/stages/stages.component.html +2 -2
  81. package/lib/infra/stages/stages.component.scss +7 -35
  82. package/lib/infra/stages/stages.component.ts +4 -2
  83. package/lib/infra/view/view.component.html +1 -1
  84. package/lib/infra/view/view.component.ts +0 -2
  85. package/lib/template/advanced-search/advanced-search.component.html +12 -0
  86. package/lib/template/advanced-search/advanced-search.component.scss +0 -0
  87. package/lib/template/advanced-search/advanced-search.component.spec.ts +0 -0
  88. package/lib/template/advanced-search/advanced-search.component.ts +112 -0
  89. package/lib/template/advanced-search/advanced-search.service.ts +27 -0
  90. package/lib/template/advanced-search/search-group/persist-utils.ts +56 -0
  91. package/lib/template/advanced-search/search-groups/search-groups.component.html +32 -0
  92. package/lib/template/advanced-search/search-groups/search-groups.component.scss +0 -0
  93. package/lib/template/advanced-search/search-groups/search-groups.component.spec.ts +0 -0
  94. package/lib/template/advanced-search/search-groups/search-groups.component.ts +294 -0
  95. package/lib/template/advanced-search/search-groups/utils.ts +29 -0
  96. package/lib/template/app-shell/app-shell.component.html +4 -1
  97. package/lib/template/app-shell/app-shell.component.scss +0 -3
  98. package/lib/template/app-shell/app-shell.component.ts +46 -7
  99. package/lib/template/case-summary/case-summary.component.scss +0 -2
  100. package/lib/template/case-view/case-view.component.html +3 -3
  101. package/lib/template/case-view/case-view.component.scss +18 -10
  102. package/lib/template/case-view/case-view.component.ts +1 -1
  103. package/lib/template/data-reference/data-reference-advanced-search.service.ts +16 -0
  104. package/lib/template/data-reference/data-reference.component.html +11 -8
  105. package/lib/template/data-reference/data-reference.component.ts +346 -112
  106. package/lib/template/data-reference/search-form/search-form.component.html +39 -0
  107. package/lib/template/data-reference/search-form/search-form.component.scss +11 -0
  108. package/lib/template/data-reference/search-form/search-form.component.spec.ts +0 -0
  109. package/lib/template/data-reference/search-form/search-form.component.ts +167 -0
  110. package/lib/template/data-reference/search-form/tabsData.ts +160 -0
  111. package/lib/template/data-reference/utils.ts +92 -0
  112. package/lib/template/default-form/default-form.component.ts +10 -2
  113. package/lib/template/default-page/default-page.component.html +34 -0
  114. package/lib/template/default-page/default-page.component.scss +31 -0
  115. package/lib/template/default-page/default-page.component.spec.ts +24 -0
  116. package/lib/template/default-page/default-page.component.ts +64 -0
  117. package/lib/template/field-group-list/field-group-list.component.scss +0 -1
  118. package/lib/template/inline-dashboard-page/inline-dashboard-page.component.ts +1 -1
  119. package/lib/template/list-view/list-view.component.html +9 -4
  120. package/lib/template/list-view/list-view.component.scss +21 -21
  121. package/lib/template/list-view/list-view.component.ts +154 -84
  122. package/lib/template/list-view/utils.ts +25 -2
  123. package/lib/template/object-page/object-page.component.html +1 -0
  124. package/lib/template/object-page/object-page.component.scss +0 -0
  125. package/lib/template/object-page/object-page.component.spec.ts +22 -0
  126. package/lib/template/object-page/object-page.component.ts +14 -0
  127. package/lib/template/one-column-tab/one-column-tab.component.scss +1 -1
  128. package/lib/template/repeating-structures/repeating-structures.component.ts +0 -1
  129. package/lib/template/self-service-case-view/self-service-case-view.component.html +80 -0
  130. package/lib/template/self-service-case-view/self-service-case-view.component.scss +124 -0
  131. package/lib/template/self-service-case-view/self-service-case-view.component.spec.ts +24 -0
  132. package/lib/template/self-service-case-view/self-service-case-view.component.ts +216 -0
  133. package/lib/template/simple-table/simple-table.component.ts +0 -1
  134. package/lib/template/simple-table-manual/helpers.ts +2 -2
  135. package/lib/template/simple-table-manual/simple-table-manual.component.html +4 -4
  136. package/lib/template/simple-table-manual/simple-table-manual.component.scss +4 -14
  137. package/lib/template/simple-table-manual/simple-table-manual.component.ts +8 -4
  138. package/lib/template/single-reference-readonly/single-reference-readonly.component.html +4 -1
  139. package/lib/template/single-reference-readonly/single-reference-readonly.component.scss +21 -0
  140. package/lib/template/single-reference-readonly/single-reference-readonly.component.ts +104 -3
  141. package/lib/template/utils.ts +42 -0
  142. package/lib/template/wss-nav-bar/wss-nav-bar.component.html +5 -4
  143. package/lib/template/wss-nav-bar/wss-nav-bar.component.scss +2 -8
  144. package/lib/template/wss-nav-bar/wss-nav-bar.component.ts +1 -8
  145. package/lib/widget/app-announcement/app-announcement.component.html +1 -2
  146. package/lib/widget/app-announcement/app-announcement.component.scss +2 -2
  147. package/lib/widget/attachment/Attachment.types.ts +92 -0
  148. package/lib/widget/attachment/AttachmentUtils.ts +287 -0
  149. package/lib/widget/attachment/attachment.component.html +3 -3
  150. package/lib/widget/attachment/attachment.component.scss +2 -5
  151. package/lib/widget/attachment/attachment.component.ts +255 -254
  152. package/lib/widget/feed-container/feed-container.component.scss +3 -9
  153. package/lib/widget/feed-container/feed-container.component.ts +2 -2
  154. package/lib/widget/file-utility/file-utility.component.html +3 -3
  155. package/lib/widget/file-utility/file-utility.component.scss +5 -16
  156. package/lib/widget/list-utility/list-utility.component.scss +3 -5
  157. package/lib/widget/todo/todo.component.html +8 -5
  158. package/lib/widget/todo/todo.component.scss +10 -11
  159. package/lib/widget/todo/todo.component.ts +6 -2
  160. package/package.json +1 -1
@@ -1,14 +1,13 @@
1
- import { Component, OnInit, Input, ChangeDetectorRef, forwardRef, OnDestroy } from '@angular/core';
1
+ import { Component, OnInit, forwardRef, OnDestroy } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
- import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
3
+ import { ReactiveFormsModule } from '@angular/forms';
4
4
  import { MatInputModule } from '@angular/material/input';
5
5
  import { MatFormFieldModule } from '@angular/material/form-field';
6
- import { interval } from 'rxjs';
7
- import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
8
- import { Utils } from '@pega/angular-sdk-components';
6
+
7
+ import { FieldBase } from '@pega/angular-sdk-components';
9
8
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
- import { PConnFieldProps } from '@pega/angular-sdk-components';
11
9
  import { handleEvent } from '@pega/angular-sdk-components';
10
+ import { PConnFieldProps } from '@pega/angular-sdk-components';
12
11
 
13
12
  interface EmailProps extends PConnFieldProps {
14
13
  // If any, enter additional props that only exist on Email here
@@ -20,141 +19,22 @@ interface EmailProps extends PConnFieldProps {
20
19
  styleUrls: ['./email.component.scss'],
21
20
  imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule, forwardRef(() => ComponentMapperComponent)]
22
21
  })
23
- export class EmailComponent implements OnInit, OnDestroy {
24
- @Input() pConn$: typeof PConnect;
25
- @Input() formGroup$: FormGroup;
26
-
27
- // Used with AngularPConnect
28
- angularPConnectData: AngularPConnectData = {};
22
+ export class EmailComponent extends FieldBase implements OnInit, OnDestroy {
29
23
  configProps$: EmailProps;
30
24
 
31
- label$ = '';
32
- value$: string;
33
- bRequired$ = false;
34
- bReadonly$ = false;
35
- bDisabled$ = false;
36
- bVisible$ = true;
37
- displayMode$?: string = '';
38
- controlName$: string;
39
- bHasForm$ = true;
40
- componentReference = '';
41
- testId: string;
42
- helperText: string;
43
- placeholder: string;
44
-
45
- fieldControl = new FormControl('', null);
46
- actionsApi: Object;
47
- propName: string;
48
-
49
- constructor(
50
- private angularPConnect: AngularPConnectService,
51
- private cdRef: ChangeDetectorRef,
52
- private utils: Utils
53
- ) {}
54
-
55
- ngOnInit(): void {
56
- // First thing in initialization is registering and subscribing to the AngularPConnect service
57
- this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
58
- this.controlName$ = this.angularPConnect.getComponentID(this);
59
-
60
- // Then, continue on with other initialization
61
-
62
- // call updateSelf when initializing
63
- // this.updateSelf();
64
- this.checkAndUpdate();
65
-
66
- if (this.formGroup$) {
67
- // add control to formGroup
68
- this.formGroup$.addControl(this.controlName$, this.fieldControl);
69
- this.fieldControl.setValue(this.value$);
70
- this.bHasForm$ = true;
71
- } else {
72
- this.bReadonly$ = true;
73
- this.bHasForm$ = false;
74
- }
75
- }
76
-
77
- ngOnDestroy(): void {
78
- if (this.formGroup$) {
79
- this.formGroup$.removeControl(this.controlName$);
80
- }
81
-
82
- if (this.angularPConnectData.unsubscribeFn) {
83
- this.angularPConnectData.unsubscribeFn();
84
- }
85
- }
86
-
87
- // Callback passed when subscribing to store change
88
- onStateChange() {
89
- this.checkAndUpdate();
90
- }
91
-
92
- checkAndUpdate() {
93
- // Should always check the bridge to see if the component should
94
- // update itself (re-render)
95
- const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
96
-
97
- // ONLY call updateSelf when the component should update
98
- if (bUpdateSelf) {
99
- this.updateSelf();
100
- }
101
- }
102
-
103
- // updateSelf
104
- updateSelf(): void {
105
- // moved this from ngOnInit() and call this from there instead...
25
+ /**
26
+ * Updates the component when there are changes in the state.
27
+ */
28
+ override updateSelf(): void {
29
+ // Resolve configuration properties
106
30
  this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as EmailProps;
107
- this.testId = this.configProps$.testId;
108
- this.label$ = this.configProps$.label;
109
- this.displayMode$ = this.configProps$.displayMode;
110
31
 
111
- if (this.configProps$.value != undefined) {
112
- this.value$ = this.configProps$.value;
113
- }
114
- this.helperText = this.configProps$.helperText;
115
- this.placeholder = this.configProps$.placeholder || '';
116
-
117
- // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
118
- setTimeout(() => {
119
- if (this.configProps$.required != null) {
120
- this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
121
- }
122
- this.cdRef.detectChanges();
123
- });
124
-
125
- if (this.configProps$.visibility != null) {
126
- this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
127
- }
128
-
129
- // disabled
130
- if (this.configProps$.disabled != undefined) {
131
- this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
132
- }
133
-
134
- if (this.bDisabled$) {
135
- this.fieldControl.disable();
136
- } else {
137
- this.fieldControl.enable();
138
- }
139
-
140
- if (this.configProps$.readOnly != null) {
141
- this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
142
- }
143
-
144
- this.actionsApi = this.pConn$.getActionsApi();
145
- this.propName = this.pConn$.getStateProps().value;
146
-
147
- this.componentReference = this.pConn$.getStateProps().value;
32
+ // Update component common properties
33
+ this.updateComponentCommonProperties(this.configProps$);
148
34
 
149
- // trigger display of error message with field control
150
- if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
151
- const timer = interval(100).subscribe(() => {
152
- this.fieldControl.setErrors({ message: true });
153
- this.fieldControl.markAsTouched();
154
-
155
- timer.unsubscribe();
156
- });
157
- }
35
+ // Set component specific properties
36
+ const { value } = this.configProps$;
37
+ this.value$ = value;
158
38
  }
159
39
 
160
40
  fieldOnChange(event: any) {
@@ -162,8 +42,6 @@ export class EmailComponent implements OnInit, OnDestroy {
162
42
  const isValueChanged = event.target.value.toString() !== oldVal.toString();
163
43
 
164
44
  if (isValueChanged) {
165
- const value = event?.target?.value;
166
- handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
167
45
  this.pConn$.clearErrorMessages({
168
46
  property: this.propName
169
47
  });
@@ -179,21 +57,4 @@ export class EmailComponent implements OnInit, OnDestroy {
179
57
  handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
180
58
  }
181
59
  }
182
-
183
- getErrorMessage() {
184
- let errMessage = '';
185
-
186
- // look for validation messages for json, pre-defined or just an error pushed from workitem (400)
187
- if (this.fieldControl.hasError('message')) {
188
- errMessage = this.angularPConnectData.validateMessage ?? '';
189
- return errMessage;
190
- }
191
- if (this.fieldControl.hasError('required')) {
192
- errMessage = 'You must enter a value';
193
- } else if (this.fieldControl.errors) {
194
- errMessage = this.fieldControl.errors.toString();
195
- }
196
-
197
- return errMessage;
198
- }
199
60
  }
@@ -0,0 +1,149 @@
1
+ import { Directive, inject, Input, OnDestroy, OnInit } from '@angular/core';
2
+ import { FormControl, FormGroup } from '@angular/forms';
3
+
4
+ import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
5
+ import { Utils } from '@pega/angular-sdk-components';
6
+
7
+ @Directive()
8
+ export class FieldBase implements OnInit, OnDestroy {
9
+ @Input() pConn$: typeof PConnect;
10
+ @Input() formGroup$: FormGroup;
11
+
12
+ protected angularPConnect = inject(AngularPConnectService);
13
+ protected utils = inject(Utils);
14
+
15
+ protected angularPConnectData: AngularPConnectData = {};
16
+
17
+ fieldControl: FormControl<any> = new FormControl('', null);
18
+ controlName$: string;
19
+ actionsApi: object;
20
+ propName: string;
21
+
22
+ bHasForm$ = true;
23
+ testId: string;
24
+ helperText: string;
25
+ placeholder: string;
26
+ value$: any = '';
27
+ label$ = '';
28
+ hideLabel = false;
29
+ bRequired$ = false;
30
+ bReadonly$ = false;
31
+ bDisabled$ = false;
32
+ bVisible$ = true;
33
+ displayMode$ = '';
34
+
35
+ /**
36
+ * Initializes the component, registers with AngularPConnect, and sets up form control.
37
+ */
38
+ ngOnInit(): void {
39
+ // First thing in initialization is registering and subscribing to the AngularPConnect service
40
+ this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange.bind(this));
41
+ this.controlName$ = this.angularPConnect.getComponentID(this);
42
+
43
+ // call checkAndUpdate
44
+ this.checkAndUpdate();
45
+
46
+ if (this.formGroup$) {
47
+ this.formGroup$.addControl(this.controlName$, this.fieldControl);
48
+ this.fieldControl.setValue(this.value$);
49
+ this.bHasForm$ = true;
50
+ } else {
51
+ this.bReadonly$ = true;
52
+ this.bHasForm$ = false;
53
+ }
54
+
55
+ this.actionsApi = this.pConn$.getActionsApi();
56
+ this.propName = this.pConn$.getStateProps().value;
57
+ }
58
+
59
+ /**
60
+ * Cleans up the component by removing it from the form group and unsubscribing from any observables.
61
+ */
62
+ ngOnDestroy(): void {
63
+ if (this.formGroup$) {
64
+ this.formGroup$.removeControl(this.controlName$);
65
+ }
66
+
67
+ if (this.angularPConnectData.unsubscribeFn) {
68
+ this.angularPConnectData.unsubscribeFn();
69
+ }
70
+ }
71
+
72
+ // Callback passed when subscribing to store change
73
+ onStateChange() {
74
+ this.checkAndUpdate();
75
+ }
76
+
77
+ // Should always check the bridge to see if the component should update itself (re-render)
78
+ checkAndUpdate() {
79
+ const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
80
+
81
+ // ONLY call updateSelf when the component should update
82
+ if (bUpdateSelf) {
83
+ this.updateSelf();
84
+ }
85
+ }
86
+
87
+ // will be overriden by child components
88
+ updateSelf(): void {}
89
+
90
+ /**
91
+ * Updates the component's common properties based on the provided configuration.
92
+ *
93
+ * @param configProps The configuration properties to update.
94
+ */
95
+ protected updateComponentCommonProperties(configProps) {
96
+ // Extract properties from config
97
+ const { testId, label, hideLabel, displayMode = '', helperText, placeholder, required, visibility = true, disabled, readOnly } = configProps;
98
+
99
+ // Update component properties
100
+ this.testId = testId;
101
+ this.label$ = label;
102
+ this.hideLabel = hideLabel;
103
+ this.displayMode$ = displayMode;
104
+ this.helperText = helperText;
105
+ this.placeholder = placeholder || '';
106
+
107
+ // Convert boolean properties
108
+ this.bVisible$ = this.utils.getBooleanValue(visibility);
109
+ this.bRequired$ = this.utils.getBooleanValue(required);
110
+ this.bDisabled$ = this.utils.getBooleanValue(disabled);
111
+ this.bReadonly$ = this.utils.getBooleanValue(readOnly);
112
+
113
+ // Enable or disable field control
114
+ this.fieldControl[this.bDisabled$ ? 'disable' : 'enable']();
115
+
116
+ // Display error message if validation message exists
117
+ this.displayValidationMessage();
118
+ }
119
+
120
+ /**
121
+ * Displays the validation message if it exists.
122
+ */
123
+ private displayValidationMessage(): void {
124
+ if (this.angularPConnectData.validateMessage) {
125
+ setTimeout(() => {
126
+ this.fieldControl.setErrors({ message: true });
127
+ this.fieldControl.markAsTouched();
128
+ }, 100);
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Retrieves the error message for the current field control.
134
+ *
135
+ * @returns The error message, or an empty string if no error is found.
136
+ */
137
+ getErrorMessage() {
138
+ // look for validation messages for json, pre-defined or just an error pushed from workitem (400)
139
+ if (this.fieldControl.hasError('message')) {
140
+ return this.angularPConnectData.validateMessage ?? '';
141
+ }
142
+
143
+ if (this.fieldControl.hasError('required')) {
144
+ return 'You must enter a value';
145
+ }
146
+
147
+ return this.fieldControl.errors?.toString() ?? '';
148
+ }
149
+ }
@@ -24,6 +24,10 @@ export class GroupComponent implements OnInit {
24
24
  @Input() pConn$: typeof PConnect;
25
25
  @Input() formGroup$: FormGroup;
26
26
 
27
+ // Used with AngularPConnect
28
+ angularPConnectData: AngularPConnectData = {};
29
+ configProps$: GroupProps;
30
+
27
31
  arChildren$: any[];
28
32
  visibility$?: boolean;
29
33
  showHeading$?: boolean;
@@ -31,10 +35,6 @@ export class GroupComponent implements OnInit {
31
35
  instructions$: string;
32
36
  collapsible$: boolean;
33
37
 
34
- // Used with AngularPConnect
35
- angularPConnectData: AngularPConnectData = {};
36
- configProps$: GroupProps;
37
-
38
38
  constructor(private angularPConnect: AngularPConnectService) {}
39
39
 
40
40
  ngOnInit(): void {
@@ -59,6 +59,9 @@ export class GroupComponent implements OnInit {
59
59
  }
60
60
  }
61
61
 
62
+ /**
63
+ * Updates the component when there are changes in the state.
64
+ */
62
65
  updateSelf(): void {
63
66
  this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as GroupProps;
64
67
  this.arChildren$ = ReferenceComponent.normalizePConnArray(this.pConn$.getChildren());
@@ -1,14 +1,13 @@
1
- import { Component, OnInit, Input, ChangeDetectorRef, forwardRef, OnDestroy } from '@angular/core';
1
+ import { Component, forwardRef } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
- import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
3
+ import { FormControl, ReactiveFormsModule } from '@angular/forms';
4
4
  import { MatInputModule } from '@angular/material/input';
5
5
  import { MatFormFieldModule } from '@angular/material/form-field';
6
- import { interval } from 'rxjs';
7
- import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
8
- import { Utils } from '@pega/angular-sdk-components';
6
+
7
+ import { FieldBase } from '@pega/angular-sdk-components';
9
8
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
- import { PConnFieldProps } from '@pega/angular-sdk-components';
11
9
  import { handleEvent } from '@pega/angular-sdk-components';
10
+ import { PConnFieldProps } from '@pega/angular-sdk-components';
12
11
 
13
12
  interface IntegerProps extends PConnFieldProps {
14
13
  // If any, enter additional props that only exist on Integer here
@@ -20,143 +19,24 @@ interface IntegerProps extends PConnFieldProps {
20
19
  styleUrls: ['./integer.component.scss'],
21
20
  imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule, forwardRef(() => ComponentMapperComponent)]
22
21
  })
23
- export class IntegerComponent implements OnInit, OnDestroy {
24
- @Input() pConn$: typeof PConnect;
25
- @Input() formGroup$: FormGroup;
26
-
27
- // Used with AngularPConnect
28
- angularPConnectData: AngularPConnectData = {};
22
+ export class IntegerComponent extends FieldBase {
29
23
  configProps$: IntegerProps;
24
+ override fieldControl = new FormControl<number | null>(null, null);
30
25
 
31
- label$ = '';
32
- value$: number;
33
- bRequired$ = false;
34
- bReadonly$ = false;
35
- bDisabled$ = false;
36
- bVisible$ = true;
37
- displayMode$?: string = '';
38
- controlName$: string;
39
- bHasForm$ = true;
40
- componentReference = '';
41
- testId: string;
42
- helperText: string;
43
- placeholder: string;
44
-
45
- fieldControl = new FormControl<number | null>(null, null);
46
- actionsApi: Object;
47
- propName: string;
48
-
49
- constructor(
50
- private angularPConnect: AngularPConnectService,
51
- private cdRef: ChangeDetectorRef,
52
- private utils: Utils
53
- ) {}
54
-
55
- ngOnInit(): void {
56
- // First thing in initialization is registering and subscribing to the AngularPConnect service
57
- this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
58
- this.controlName$ = this.angularPConnect.getComponentID(this);
59
-
60
- // Then, continue on with other initialization
61
-
62
- // call updateSelf when initializing
63
- // this.updateSelf();
64
- this.checkAndUpdate();
65
-
66
- if (this.formGroup$) {
67
- // add control to formGroup
68
- this.formGroup$.addControl(this.controlName$, this.fieldControl);
69
- this.fieldControl.setValue(this.value$);
70
- this.bHasForm$ = true;
71
- } else {
72
- this.bReadonly$ = true;
73
- this.bHasForm$ = false;
74
- }
75
- }
76
-
77
- ngOnDestroy(): void {
78
- if (this.formGroup$) {
79
- this.formGroup$.removeControl(this.controlName$);
80
- }
81
-
82
- if (this.angularPConnectData.unsubscribeFn) {
83
- this.angularPConnectData.unsubscribeFn();
84
- }
85
- }
86
-
87
- // Callback passed when subscribing to store change
88
- onStateChange() {
89
- this.checkAndUpdate();
90
- }
91
-
92
- checkAndUpdate() {
93
- // Should always check the bridge to see if the component should
94
- // update itself (re-render)
95
- const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
96
-
97
- // ONLY call updateSelf when the component should update
98
- if (bUpdateSelf) {
99
- this.updateSelf();
100
- }
101
- }
102
-
103
- // updateSelf
104
- updateSelf(): void {
105
- // moved this from ngOnInit() and call this from there instead...
26
+ /**
27
+ * Updates the component when there are changes in the state.
28
+ */
29
+ override updateSelf(): void {
30
+ // Resolve configuration properties
106
31
  this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as IntegerProps;
107
- this.testId = this.configProps$.testId;
108
- this.label$ = this.configProps$.label;
109
- this.displayMode$ = this.configProps$.displayMode;
110
- let nValue: any = this.configProps$.value;
111
- if (nValue) {
112
- if (typeof nValue === 'string') {
113
- nValue = parseInt(nValue, 10);
114
- }
115
- this.value$ = nValue;
116
- }
117
- this.helperText = this.configProps$.helperText;
118
- this.placeholder = this.configProps$.placeholder || '';
119
-
120
- this.actionsApi = this.pConn$.getActionsApi();
121
- this.propName = this.pConn$.getStateProps().value;
122
-
123
- // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
124
- setTimeout(() => {
125
- if (this.configProps$.required != null) {
126
- this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
127
- }
128
- this.cdRef.detectChanges();
129
- });
130
-
131
- if (this.configProps$.visibility != null) {
132
- this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
133
- }
134
-
135
- // disabled
136
- if (this.configProps$.disabled != undefined) {
137
- this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
138
- }
139
-
140
- if (this.bDisabled$) {
141
- this.fieldControl.disable();
142
- } else {
143
- this.fieldControl.enable();
144
- }
145
32
 
146
- if (this.configProps$.readOnly != null) {
147
- this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
148
- }
149
-
150
- this.componentReference = this.pConn$.getStateProps().value;
151
-
152
- // trigger display of error message with field control
153
- if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
154
- const timer = interval(100).subscribe(() => {
155
- this.fieldControl.setErrors({ message: true });
156
- this.fieldControl.markAsTouched();
33
+ // Update component common properties
34
+ this.updateComponentCommonProperties(this.configProps$);
157
35
 
158
- timer.unsubscribe();
159
- });
36
+ // Extract and normalize the value property
37
+ const { value } = this.configProps$;
38
+ if (value) {
39
+ this.value$ = typeof value === 'string' ? parseInt(value, 10) : value;
160
40
  }
161
41
  }
162
42
 
@@ -180,23 +60,4 @@ export class IntegerComponent implements OnInit, OnDestroy {
180
60
  handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
181
61
  }
182
62
  }
183
-
184
- getErrorMessage() {
185
- // field control gets error message from here
186
-
187
- let errMessage = '';
188
-
189
- // look for validation messages for json, pre-defined or just an error pushed from workitem (400)
190
- if (this.fieldControl.hasError('message')) {
191
- errMessage = this.angularPConnectData.validateMessage ?? '';
192
- return errMessage;
193
- }
194
- if (this.fieldControl.hasError('required')) {
195
- errMessage = 'You must enter a value';
196
- } else if (this.fieldControl.errors) {
197
- errMessage = this.fieldControl.errors.toString();
198
- }
199
-
200
- return errMessage;
201
- }
202
63
  }
@@ -73,7 +73,7 @@ export class LocationComponent implements OnInit, OnDestroy {
73
73
  testId = '';
74
74
  helperText: string;
75
75
  placeholder: string;
76
- actionsApi: Object;
76
+ actionsApi: object;
77
77
  valueProp: string;
78
78
  coordinatesProp: string;
79
79