@pega/angular-sdk-overrides 0.25.1 → 0.25.3

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
@@ -15,11 +15,13 @@
15
15
  .psdk-radio-horizontal {
16
16
  display: flex;
17
17
  flex-direction: row;
18
+ margin-top: 1rem;
18
19
  }
19
20
 
20
21
  .psdk-radio-vertical {
21
22
  display: flex;
22
23
  flex-direction: column;
24
+ margin-top: 1rem;
23
25
  }
24
26
 
25
27
  .psdk-radio-button {
@@ -30,8 +32,8 @@
30
32
  width: 100%;
31
33
  }
32
34
 
33
- .psdk-radio-form ::ng-deep .mat-form-field-underline {
34
- background-color: transparent;
35
+ .psdk-radio-form ::ng-deep .mdc-line-ripple {
36
+ display: none;
35
37
  }
36
38
 
37
39
  .psdk-radio-form ::ng-deep .mat-form-field-label {
@@ -1,15 +1,15 @@
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 { ReactiveFormsModule } from '@angular/forms';
4
4
  import { MatRadioModule } from '@angular/material/radio';
5
5
  import { MatInputModule } from '@angular/material/input';
6
6
  import { MatFormFieldModule } from '@angular/material/form-field';
7
- import { interval } from 'rxjs';
8
- import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
9
- import { Utils } from '@pega/angular-sdk-components';
7
+
8
+ import { FieldBase } from '@pega/angular-sdk-components';
10
9
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
11
- import { PConnFieldProps } from '@pega/angular-sdk-components';
10
+ import { Utils } from '@pega/angular-sdk-components';
12
11
  import { handleEvent } from '@pega/angular-sdk-components';
12
+ import { PConnFieldProps } from '@pega/angular-sdk-components';
13
13
 
14
14
  interface IOption {
15
15
  key: string;
@@ -30,159 +30,58 @@ interface RadioButtonsProps extends PConnFieldProps {
30
30
  providers: [Utils],
31
31
  imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule, MatRadioModule, forwardRef(() => ComponentMapperComponent)]
32
32
  })
33
- export class RadioButtonsComponent implements OnInit, OnDestroy {
34
- @Input() pConn$: typeof PConnect;
35
- @Input() formGroup$: FormGroup;
36
-
37
- // Used with AngularPConnect
38
- angularPConnectData: AngularPConnectData = {};
33
+ export class RadioButtonsComponent extends FieldBase {
39
34
  configProps$: RadioButtonsProps;
40
35
 
41
- label$ = '';
42
- value$ = '';
43
- bRequired$ = false;
44
- bReadonly$ = false;
45
- bDisabled$ = false;
46
- bVisible$ = true;
47
36
  bInline$ = false;
48
- displayMode$?: string = '';
49
- controlName$: string;
50
- bHasForm$ = true;
37
+
51
38
  options$: IOption[];
52
39
  componentReference = '';
53
- testId: string;
54
- helperText: string;
55
- placeholder: string;
56
-
57
- fieldControl = new FormControl('', null);
58
40
  fieldMetadata: any[];
59
41
  localeContext = '';
60
42
  localeClass = '';
61
43
  localeName = '';
62
44
  localePath = '';
63
45
  localizedValue = '';
64
- actionsApi: Object;
65
- propName: string;
66
46
  variant?: string;
67
47
 
68
- constructor(
69
- private angularPConnect: AngularPConnectService,
70
- private cdRef: ChangeDetectorRef,
71
- private utils: Utils
72
- ) {}
73
-
74
- ngOnInit(): void {
75
- // First thing in initialization is registering and subscribing to the AngularPConnect service
76
- this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
77
- this.controlName$ = this.angularPConnect.getComponentID(this);
78
-
79
- // Then, continue on with other initialization
80
-
81
- // call updateSelf when initializing
82
- // this.updateSelf();
83
- this.checkAndUpdate();
84
-
85
- if (this.formGroup$) {
86
- // add control to formGroup
87
- this.formGroup$.addControl(this.controlName$, this.fieldControl);
88
- this.fieldControl.setValue(this.value$);
89
- this.bHasForm$ = true;
90
- } else {
91
- this.bReadonly$ = true;
92
- this.bHasForm$ = false;
93
- }
94
- }
95
-
96
- ngOnDestroy(): void {
97
- if (this.formGroup$) {
98
- this.formGroup$.removeControl(this.controlName$);
99
- }
100
-
101
- if (this.angularPConnectData.unsubscribeFn) {
102
- this.angularPConnectData.unsubscribeFn();
103
- }
104
- }
105
-
106
- // Callback passed when subscribing to store change
107
- onStateChange() {
108
- this.checkAndUpdate();
109
- }
110
-
111
- checkAndUpdate() {
112
- // Should always check the bridge to see if the component should
113
- // update itself (re-render)
114
- const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
115
-
116
- // ONLY call updateSelf when the component should update
117
- if (bUpdateSelf) {
118
- this.updateSelf();
119
- }
120
- }
121
-
122
- // updateSelf
123
- updateSelf(): void {
124
- // moved this from ngOnInit() and call this from there instead...
48
+ /**
49
+ * Updates the component when there are changes in the state.
50
+ */
51
+ override updateSelf(): void {
52
+ // Resolve config properties
125
53
  this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as RadioButtonsProps;
126
54
 
127
- if (this.configProps$.value != undefined) {
128
- this.value$ = this.configProps$.value;
129
- }
130
-
131
- this.testId = this.configProps$.testId;
132
- this.label$ = this.configProps$.label;
133
- this.displayMode$ = this.configProps$.displayMode;
134
- this.helperText = this.configProps$.helperText;
135
- this.placeholder = this.configProps$.placeholder || '';
136
-
137
- this.variant = this.configProps$.variant;
138
-
139
- // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
140
- setTimeout(() => {
141
- if (this.configProps$.required != null) {
142
- this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
143
- }
144
- this.cdRef.detectChanges();
145
- });
146
-
147
- if (this.configProps$.visibility != null) {
148
- this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
149
- }
55
+ // Update component common properties
56
+ this.updateComponentCommonProperties(this.configProps$);
150
57
 
151
- if (this.configProps$.inline != null) {
152
- this.bInline$ = this.utils.getBooleanValue(this.configProps$.inline);
153
- }
58
+ // Extract and normalize the value property
59
+ const { value } = this.configProps$;
60
+ this.value$ = value;
154
61
 
155
- if (this.configProps$.disabled != undefined) {
156
- this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
157
- }
158
-
159
- if (this.configProps$.inline != null) {
160
- this.bInline$ = this.utils.getBooleanValue(this.configProps$.inline);
161
- }
162
-
163
- if (this.bDisabled$) {
164
- this.fieldControl.disable();
165
- } else {
166
- this.fieldControl.enable();
167
- }
168
-
169
- if (this.configProps$.readOnly != null) {
170
- this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
171
- }
62
+ // Set component specific properties
63
+ this.updateRadioButtonsProperties(this.configProps$);
64
+ }
172
65
 
173
- this.componentReference = this.pConn$.getStateProps().value;
66
+ /**
67
+ * Updates radio buttons properties based on the provided config props.
68
+ * @param configProps Configuration properties.
69
+ */
70
+ protected updateRadioButtonsProperties(configProps) {
71
+ const { inline, fieldMetadata, variant } = configProps;
174
72
 
175
- this.options$ = this.utils.getOptionList(this.configProps$, this.pConn$.getDataObject());
73
+ this.variant = variant;
74
+ this.bInline$ = this.utils.getBooleanValue(inline);
176
75
 
177
- this.actionsApi = this.pConn$.getActionsApi();
178
- this.propName = this.pConn$.getStateProps().value;
76
+ // Get options from config props and data object
77
+ this.options$ = this.utils.getOptionList(configProps, this.pConn$.getDataObject());
179
78
 
79
+ // Extract metadata and locale information
180
80
  const className = this.pConn$.getCaseInfo().getClassName();
181
81
  const refName = this.propName?.slice(this.propName.lastIndexOf('.') + 1);
82
+ const metaData = Array.isArray(fieldMetadata) ? fieldMetadata.filter(field => field?.classID === className)[0] : fieldMetadata;
182
83
 
183
- this.fieldMetadata = this.configProps$.fieldMetadata;
184
- const metaData = Array.isArray(this.fieldMetadata) ? this.fieldMetadata.filter(field => field?.classID === className)[0] : this.fieldMetadata;
185
-
84
+ // Determine display name and locale context
186
85
  let displayName = metaData?.datasource?.propertyForDisplayText;
187
86
  displayName = displayName?.slice(displayName.lastIndexOf('.') + 1);
188
87
  this.localeContext = metaData?.datasource?.tableType === 'DataPage' ? 'datapage' : 'associated';
@@ -190,20 +89,12 @@ export class RadioButtonsComponent implements OnInit, OnDestroy {
190
89
  this.localeName = this.localeContext === 'datapage' ? metaData?.datasource?.name : refName;
191
90
  this.localePath = this.localeContext === 'datapage' ? displayName : this.localeName;
192
91
 
92
+ // Get localized value
193
93
  this.localizedValue = this.pConn$.getLocalizedValue(
194
94
  this.value$,
195
95
  this.localePath,
196
96
  this.pConn$.getLocaleRuleNameFromKeys(this.localeClass, this.localeContext, this.localeName)
197
97
  );
198
- // trigger display of error message with field control
199
- if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
200
- const timer = interval(100).subscribe(() => {
201
- this.fieldControl.setErrors({ message: true });
202
- this.fieldControl.markAsTouched();
203
-
204
- timer.unsubscribe();
205
- });
206
- }
207
98
  }
208
99
 
209
100
  isSelected(buttonValue: string): boolean {
@@ -221,21 +112,4 @@ export class RadioButtonsComponent implements OnInit, OnDestroy {
221
112
  this.pConn$.getLocaleRuleNameFromKeys(this.localeClass, this.localeContext, this.localeName)
222
113
  );
223
114
  }
224
-
225
- getErrorMessage() {
226
- let errMessage = '';
227
-
228
- // look for validation messages for json, pre-defined or just an error pushed from workitem (400)
229
- if (this.fieldControl.hasError('message')) {
230
- errMessage = this.angularPConnectData.validateMessage ?? '';
231
- return errMessage;
232
- }
233
- if (this.fieldControl.hasError('required')) {
234
- errMessage = 'You must enter a value';
235
- } else if (this.fieldControl.errors) {
236
- errMessage = this.fieldControl.errors.toString();
237
- }
238
-
239
- return errMessage;
240
- }
241
115
  }
@@ -1,8 +1,8 @@
1
- import { Component, OnInit, Input, forwardRef, OnDestroy } from '@angular/core';
1
+ import { Component, forwardRef } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
- import { FormGroup, ReactiveFormsModule } from '@angular/forms';
4
- import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
5
- import { Utils } from '@pega/angular-sdk-components';
3
+ import { ReactiveFormsModule } from '@angular/forms';
4
+
5
+ import { FieldBase } from '@pega/angular-sdk-components';
6
6
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
7
7
  import { handleEvent } from '@pega/angular-sdk-components';
8
8
  import { PConnFieldProps } from '@pega/angular-sdk-components';
@@ -17,102 +17,31 @@ interface RichTextProps extends PConnFieldProps {
17
17
  styleUrls: ['./rich-text.component.scss'],
18
18
  imports: [CommonModule, ReactiveFormsModule, forwardRef(() => ComponentMapperComponent)]
19
19
  })
20
- export class RichTextComponent implements OnInit, OnDestroy {
21
- @Input() pConn$: typeof PConnect;
22
- @Input() formGroup$: FormGroup;
23
-
24
- // Used with AngularPConnect
25
- angularPConnectData: AngularPConnectData = {};
20
+ export class RichTextComponent extends FieldBase {
26
21
  configProps$: RichTextProps;
27
22
 
28
- label$ = '';
29
- value$ = '';
30
- bRequired$ = false;
31
- bReadonly$ = false;
32
- bDisabled$ = false;
33
- bVisible$ = true;
34
- displayMode$?: string = '';
35
- controlName$: string;
36
- testId: string;
37
- helperText: string;
38
- placeholder: any;
39
23
  info: any;
40
24
  error: boolean;
41
25
  status: any;
42
- actionsApi: Object;
43
- propName: string;
44
-
45
- constructor(
46
- private angularPConnect: AngularPConnectService,
47
- private utils: Utils
48
- ) {}
49
-
50
- ngOnInit(): void {
51
- // First thing in initialization is registering and subscribing to the AngularPConnect service
52
- this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
53
-
54
- // call updateSelf when initializing
55
- this.checkAndUpdate();
56
- }
57
-
58
- ngOnDestroy(): void {
59
- if (this.angularPConnectData.unsubscribeFn) {
60
- this.angularPConnectData.unsubscribeFn();
61
- }
62
- }
63
-
64
- // Callback passed when subscribing to store change
65
- onStateChange() {
66
- this.checkAndUpdate();
67
- }
68
-
69
- checkAndUpdate() {
70
- // Should always check the bridge to see if the component should
71
- // update itself (re-render)
72
- const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
73
26
 
74
- // ONLY call updateSelf when the component should update
75
- if (bUpdateSelf) {
76
- this.updateSelf();
77
- }
78
- }
79
-
80
- // updateSelf
81
- updateSelf(): void {
82
- // moved this from ngOnInit() and call this from there instead...
27
+ /**
28
+ * Updates the component when there are changes in the state.
29
+ */
30
+ override updateSelf(): void {
31
+ // Resolve config properties
83
32
  this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as RichTextProps;
84
- const stateProps = this.pConn$.getStateProps();
85
- this.status = stateProps?.status;
86
-
87
- if (this.configProps$.value != undefined) {
88
- this.value$ = this.configProps$.value;
89
- }
90
-
91
- this.testId = this.configProps$.testId;
92
- this.displayMode$ = this.configProps$.displayMode;
93
- this.label$ = this.configProps$.label;
94
- this.placeholder = this.configProps$.placeholder;
95
- this.info = stateProps?.validatemessage || this.configProps$.helperText;
96
- this.error = stateProps?.status === 'error';
97
33
 
98
- this.actionsApi = this.pConn$.getActionsApi();
99
- this.propName = this.pConn$.getStateProps().value;
34
+ // Update component common properties
35
+ this.updateComponentCommonProperties(this.configProps$);
100
36
 
101
- if (this.configProps$.required != null) {
102
- this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
103
- }
104
-
105
- if (this.configProps$.visibility != null) {
106
- this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
107
- }
37
+ // Extract and normalize the value property
38
+ const { value, helperText } = this.configProps$;
39
+ this.value$ = value;
108
40
 
109
- if (this.configProps$.disabled != undefined) {
110
- this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
111
- }
112
-
113
- if (this.configProps$.readOnly != null) {
114
- this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
115
- }
41
+ const { status, validatemessage } = this.pConn$.getStateProps();
42
+ this.status = status;
43
+ this.info = validatemessage || helperText;
44
+ this.error = status === 'error';
116
45
  }
117
46
 
118
47
  fieldOnChange(editorValue: any) {
@@ -1,7 +1,7 @@
1
1
  import { CommonModule } from '@angular/common';
2
- import { Component, forwardRef, Input, OnDestroy, OnInit } from '@angular/core';
3
- import { FormControl, FormGroup } from '@angular/forms';
4
- import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
2
+ import { Component, forwardRef } from '@angular/core';
3
+
4
+ import { FieldBase } from '@pega/angular-sdk-components';
5
5
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
6
6
  import { PConnFieldProps } from '@pega/angular-sdk-components';
7
7
 
@@ -19,83 +19,27 @@ interface ScalarListProps extends Omit<PConnFieldProps, 'value'> {
19
19
  styleUrls: ['./scalar-list.component.scss'],
20
20
  imports: [CommonModule, forwardRef(() => ComponentMapperComponent)]
21
21
  })
22
- export class ScalarListComponent implements OnInit, OnDestroy {
23
- @Input() pConn$: typeof PConnect;
24
- @Input() formGroup$: FormGroup;
25
-
26
- angularPConnectData: AngularPConnectData = {};
22
+ export class ScalarListComponent extends FieldBase {
27
23
  configProps$: ScalarListProps;
28
24
 
29
- label$ = '';
30
- value$: any;
31
- displayMode$?: string = '';
32
25
  items: any[];
33
26
  isDisplayModeEnabled = false;
34
- controlName$: string;
35
- fieldControl = new FormControl('', null);
36
- bHasForm$ = true;
37
- bReadonly$ = false;
38
-
39
- constructor(private angularPConnect: AngularPConnectService) {}
40
-
41
- ngOnInit(): void {
42
- // First thing in initialization is registering and subscribing to the AngularPConnect service
43
- this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
44
- this.controlName$ = this.angularPConnect.getComponentID(this);
45
- // Then, continue on with other initialization
46
-
47
- // call updateSelf when initializing
48
- // this.updateSelf();
49
- this.checkAndUpdate();
50
-
51
- if (this.formGroup$) {
52
- // add control to formGroup
53
- this.formGroup$.addControl(this.controlName$, this.fieldControl);
54
- this.fieldControl.setValue(this.value$);
55
- this.bHasForm$ = true;
56
- } else {
57
- this.bReadonly$ = true;
58
- this.bHasForm$ = false;
59
- }
60
- }
61
-
62
- ngOnDestroy(): void {
63
- if (this.formGroup$) {
64
- this.formGroup$.removeControl(this.controlName$);
65
- }
66
27
 
67
- if (this.angularPConnectData.unsubscribeFn) {
68
- this.angularPConnectData.unsubscribeFn();
69
- }
70
- }
28
+ /**
29
+ * Updates the component when there are changes in the state.
30
+ */
31
+ override updateSelf(): void {
32
+ // Resolve config properties
33
+ this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as ScalarListProps;
71
34
 
72
- // Callback passed when subscribing to store change
73
- onStateChange() {
74
- this.checkAndUpdate();
75
- }
35
+ // Extract properties from config props
36
+ const { componentType, displayMode = '', label, value, restProps } = this.configProps$;
76
37
 
77
- checkAndUpdate() {
78
- // Should always check the bridge to see if the component should
79
- // update itself (re-render)
80
- const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
38
+ // Update component properties
39
+ this.label$ = label;
40
+ this.displayMode$ = displayMode;
81
41
 
82
- // ONLY call updateSelf when the component should update
83
- if (bUpdateSelf) {
84
- this.updateSelf();
85
- }
86
- }
87
-
88
- // updateSelf
89
- updateSelf(): void {
90
- this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as ScalarListProps;
91
- this.label$ = this.configProps$.label;
92
- const componentType = this.configProps$.componentType;
93
- const scalarValues = this.configProps$.value;
94
- this.displayMode$ = this.configProps$.displayMode;
95
- const restProps = this.configProps$.restProps;
96
- console.log('scalar values: ', scalarValues);
97
- this.items = scalarValues?.map(scalarValue => {
98
- console.log('scalar value: ', scalarValue);
42
+ this.items = value?.map(scalarValue => {
99
43
  return this.pConn$.createComponent(
100
44
  {
101
45
  type: componentType,
@@ -112,6 +56,7 @@ export class ScalarListComponent implements OnInit, OnDestroy {
112
56
  {}
113
57
  ); // 2nd, 3rd, and 4th args empty string/object/null until typedef marked correctly as optional;
114
58
  });
59
+
115
60
  this.isDisplayModeEnabled = ['STACKED_LARGE_VAL', 'DISPLAY_ONLY'].includes(this.displayMode$ as string);
116
61
  this.value$ = this.items;
117
62
  }
@@ -1,4 +1,7 @@
1
- <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 40ch), 1fr)); grid-auto-rows: 1fr; gap: 0.5rem">
1
+ <div
2
+ *ngIf="type === 'checkbox'"
3
+ style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); grid-auto-rows: 1fr; gap: 0.5rem"
4
+ >
2
5
  <div *ngFor="let cardContent of contentList">
3
6
  <mat-card [ngStyle]="cardStyle" appearance="outlined" (click)="cardSelect($event, cardContent.commonCardProps)">
4
7
  <img
@@ -9,32 +12,59 @@
9
12
  [ngStyle]="cardContent.cardImage.style"
10
13
  />
11
14
  <mat-card-content>
12
- <div *ngIf="type === 'radio'">
13
- <mat-radio-button
14
- [checked]="radioBtnValue === cardContent?.commonCardProps?.key"
15
- [disabled]="disabled"
16
- [value]="cardContent.commonCardProps.key"
17
- (change)="fieldOnChange(cardContent.commonCardProps.key)"
18
- >
19
- {{ cardContent.commonCardProps.label }}
20
- </mat-radio-button>
21
- </div>
22
- <div *ngIf="type === 'checkbox'">
23
- <mat-checkbox
24
- [labelPosition]="'after'"
25
- [checked]="cardContent.commonCardProps.selected"
26
- [disabled]="disabled || readOnly"
27
- [attr.data-test-id]="testId + ':' + cardContent.commonCardProps.label"
28
- (change)="handleChangeMultiMode($event, cardContent.commonCardProps)"
29
- (blur)="fieldOnBlur()"
30
- >{{ cardContent.commonCardProps.label }}</mat-checkbox
31
- >
32
- </div>
33
- <div *ngFor="let field of cardContent.commonCardProps.fields" [ngStyle]="field.type !== 'TextArea' ? defaultStyle : specialStyle">
34
- <div style="color: rgba(0, 0, 0, 0.6)">{{ field.name }}</div>
15
+ <mat-checkbox
16
+ [labelPosition]="'after'"
17
+ [checked]="cardContent.commonCardProps.selected"
18
+ [disabled]="disabled || readOnly"
19
+ [attr.data-test-id]="testId + ':' + cardContent.commonCardProps.label"
20
+ (change)="handleChangeMultiMode($event, cardContent.commonCardProps)"
21
+ (blur)="fieldOnBlur()"
22
+ >{{ cardContent.commonCardProps.label }}</mat-checkbox
23
+ >
24
+ <div
25
+ *ngFor="let field of cardContent.commonCardProps.fields"
26
+ [ngStyle]="field.type !== 'TextArea' ? (field.name ? defaultStyle : noLabelStyle) : specialStyle"
27
+ >
28
+ <div>{{ field.name }}</div>
35
29
  <div>{{ field?.value?.getPConnect().getConfigProps().value ?? '--' }}</div>
36
30
  </div>
37
31
  </mat-card-content>
38
32
  </mat-card>
39
33
  </div>
40
34
  </div>
35
+
36
+ <mat-radio-group
37
+ *ngIf="type === 'radio'"
38
+ style="display: grid; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); grid-auto-rows: 1fr; gap: 0.5rem"
39
+ [name]="propName"
40
+ [value]="radioBtnValue"
41
+ (change)="fieldOnChange($event.value)"
42
+ >
43
+ <div *ngFor="let cardContent of contentList">
44
+ <mat-card [ngStyle]="cardStyle" appearance="outlined" (click)="cardSelect($event, cardContent.commonCardProps)">
45
+ <img
46
+ *ngIf="cardContent.cardImage"
47
+ mat-card-image
48
+ src="{{ cardContent.cardImage.src }}"
49
+ alt="{{ cardContent.cardImage.alt }}"
50
+ [ngStyle]="cardContent.cardImage.style"
51
+ />
52
+ <mat-card-content>
53
+ <mat-radio-button
54
+ [checked]="radioBtnValue === cardContent?.commonCardProps?.key"
55
+ [disabled]="disabled"
56
+ [value]="cardContent.commonCardProps.key"
57
+ >
58
+ {{ cardContent.commonCardProps.label }}
59
+ </mat-radio-button>
60
+ <div
61
+ *ngFor="let field of cardContent.commonCardProps.fields"
62
+ [ngStyle]="field.type !== 'TextArea' ? (field.name ? defaultStyle : noLabelStyle) : specialStyle"
63
+ >
64
+ <div>{{ field.name }}</div>
65
+ <div>{{ field?.value?.getPConnect().getConfigProps().value ?? '--' }}</div>
66
+ </div>
67
+ </mat-card-content>
68
+ </mat-card>
69
+ </div>
70
+ </mat-radio-group>
@@ -0,0 +1,11 @@
1
+ ::ng-deep .mdc-label {
2
+ font-size: large;
3
+ }
4
+
5
+ .mat-mdc-card-content:last-child {
6
+ padding-bottom: 0;
7
+ }
8
+
9
+ .mat-mdc-card-content:first-child {
10
+ padding-top: 0;
11
+ }