@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,12 +1,11 @@
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 { MatCheckboxModule } from '@angular/material/checkbox';
5
5
  import { MatFormFieldModule } from '@angular/material/form-field';
6
6
  import { MatOptionModule } from '@angular/material/core';
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
10
  import { PConnFieldProps } from '@pega/angular-sdk-components';
12
11
  import { deleteInstruction, insertInstruction, updateNewInstructions } from '@pega/angular-sdk-components';
@@ -36,29 +35,12 @@ interface CheckboxProps extends Omit<PConnFieldProps, 'value'> {
36
35
  styleUrls: ['./check-box.component.scss'],
37
36
  imports: [CommonModule, ReactiveFormsModule, MatCheckboxModule, MatFormFieldModule, MatOptionModule, forwardRef(() => ComponentMapperComponent)]
38
37
  })
39
- export class CheckBoxComponent implements OnInit, OnDestroy {
40
- @Input() pConn$: typeof PConnect;
41
- @Input() formGroup$: FormGroup;
42
-
43
- // Used with AngularPConnect
44
- angularPConnectData: AngularPConnectData = {};
38
+ export class CheckBoxComponent extends FieldBase implements OnInit, OnDestroy {
45
39
  configProps$: CheckboxProps;
46
40
 
47
- label$ = '';
48
- value$: any = '';
49
41
  caption$?: string = '';
50
- testId = '';
51
42
  showLabel$ = false;
52
43
  isChecked$ = false;
53
- bRequired$ = false;
54
- bReadonly$ = false;
55
- bDisabled$ = false;
56
- bVisible$ = true;
57
- displayMode$?: string = '';
58
- controlName$: string;
59
- bHasForm$ = true;
60
- componentReference = '';
61
- helperText: string;
62
44
  trueLabel$?: string;
63
45
  falseLabel$?: string;
64
46
 
@@ -70,86 +52,35 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
70
52
  selectedvalues: any;
71
53
  referenceList: string;
72
54
  listOfCheckboxes: any[] = [];
73
- actionsApi: Object;
74
- propName: string;
75
55
  variant?: string;
76
56
 
77
- fieldControl = new FormControl('', null);
78
-
79
- constructor(
80
- private angularPConnect: AngularPConnectService,
81
- private cdRef: ChangeDetectorRef,
82
- private utils: Utils
83
- ) {}
84
-
85
- ngOnInit(): void {
86
- // First thing in initialization is registering and subscribing to the AngularPConnect service
87
- this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
88
- this.controlName$ = this.angularPConnect.getComponentID(this);
89
-
90
- // Then, continue on with other initialization
91
-
92
- // call updateSelf when initializing
93
- // this.updateSelf();
94
- this.checkAndUpdate();
57
+ // Override ngOnInit method
58
+ override ngOnInit(): void {
59
+ super.ngOnInit();
95
60
 
96
61
  if (this.selectionMode === 'multi' && this.referenceList?.length > 0 && !this.bReadonly$) {
97
62
  this.pConn$.setReferenceList(this.selectionList);
98
63
  updateNewInstructions(this.pConn$, this.selectionList);
99
64
  }
100
-
101
- if (this.formGroup$) {
102
- // add control to formGroup
103
- this.formGroup$.addControl(this.controlName$, this.fieldControl);
104
- this.fieldControl.setValue(this.value$);
105
- this.bHasForm$ = true;
106
- } else {
107
- this.bReadonly$ = true;
108
- this.bHasForm$ = false;
109
- }
110
- }
111
-
112
- ngOnDestroy(): void {
113
- if (this.formGroup$) {
114
- this.formGroup$.removeControl(this.controlName$);
115
- }
116
-
117
- if (this.angularPConnectData.unsubscribeFn) {
118
- this.angularPConnectData.unsubscribeFn();
119
- }
120
65
  }
121
66
 
122
- // Callback passed when subscribing to store change
123
- onStateChange() {
124
- this.checkAndUpdate();
125
- }
126
-
127
- checkAndUpdate() {
128
- // Should always check the bridge to see if the component should
129
- // update itself (re-render)
130
- const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
131
-
132
- // ONLY call updateSelf when the component should update
133
- if (bUpdateSelf) {
134
- this.updateSelf();
135
- }
136
- }
137
-
138
- // updateSelf
139
- updateSelf(): void {
67
+ /**
68
+ * Updates the component when there are changes in the state.
69
+ */
70
+ override updateSelf(): void {
140
71
  // moved this from ngOnInit() and call this from there instead...
141
72
  this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as CheckboxProps;
142
73
 
143
- this.testId = this.configProps$.testId;
144
- this.displayMode$ = this.configProps$.displayMode;
145
- this.label$ = this.configProps$.label;
74
+ // Update component common properties
75
+ this.updateComponentCommonProperties(this.configProps$);
76
+
146
77
  if (this.label$ != '') {
147
78
  this.showLabel$ = true;
148
79
  }
149
-
150
- this.actionsApi = this.pConn$.getActionsApi();
151
- this.propName = this.pConn$.getStateProps().value;
152
80
  this.variant = this.configProps$.variant;
81
+ if (this.bReadonly$) {
82
+ this.fieldControl?.disable();
83
+ }
153
84
 
154
85
  // multi case
155
86
  this.selectionMode = this.configProps$.selectionMode;
@@ -176,54 +107,10 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
176
107
  }
177
108
 
178
109
  this.caption$ = this.configProps$.caption;
179
- this.helperText = this.configProps$.helperText;
180
110
  this.trueLabel$ = this.configProps$.trueLabel || 'Yes';
181
111
  this.falseLabel$ = this.configProps$.falseLabel || 'No';
182
112
 
183
- // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
184
- setTimeout(() => {
185
- if (this.configProps$.required != null) {
186
- this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
187
- }
188
- this.cdRef.detectChanges();
189
- });
190
-
191
- if (this.configProps$.visibility != null) {
192
- this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
193
- }
194
-
195
- // disabled
196
- if (this.configProps$.disabled != undefined) {
197
- this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
198
- }
199
-
200
- if (this.configProps$.readOnly != null) {
201
- this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
202
- }
203
-
204
- if (this.bDisabled$ || this.bReadonly$) {
205
- this.fieldControl.disable();
206
- } else {
207
- this.fieldControl.enable();
208
- }
209
-
210
- this.componentReference = this.pConn$.getStateProps().value;
211
-
212
- // eslint-disable-next-line sonarjs/no-redundant-boolean
213
- if (this.value$ === 'true' || this.value$ == true) {
214
- this.isChecked$ = true;
215
- } else {
216
- this.isChecked$ = false;
217
- }
218
- // trigger display of error message with field control
219
- if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
220
- const timer = interval(100).subscribe(() => {
221
- this.fieldControl.setErrors({ message: true });
222
- this.fieldControl.markAsTouched();
223
-
224
- timer.unsubscribe();
225
- });
226
- }
113
+ this.isChecked$ = this.value$ === 'true' || this.value$ == true;
227
114
  }
228
115
  }
229
116
 
@@ -261,21 +148,4 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
261
148
  context: ''
262
149
  });
263
150
  }
264
-
265
- getErrorMessage() {
266
- let errMessage = '';
267
-
268
- // look for validation messages for json, pre-defined or just an error pushed from workitem (400)
269
- if (this.fieldControl.hasError('message')) {
270
- errMessage = this.angularPConnectData.validateMessage ?? '';
271
- return errMessage;
272
- }
273
- if (this.fieldControl.hasError('required')) {
274
- errMessage = 'You must enter a value';
275
- } else if (this.fieldControl.errors) {
276
- errMessage = this.fieldControl.errors.toString();
277
- }
278
-
279
- return errMessage;
280
- }
281
151
  }
@@ -1,17 +1,16 @@
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
6
  import { NgxCurrencyDirective, NgxCurrencyInputMode } from 'ngx-currency';
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
10
  import { handleEvent } from '@pega/angular-sdk-components';
12
11
  import { getCurrencyCharacters, getCurrencyOptions } from '@pega/angular-sdk-components';
13
- import { PConnFieldProps } from '@pega/angular-sdk-components';
14
12
  import { format } from '@pega/angular-sdk-components';
13
+ import { PConnFieldProps } from '@pega/angular-sdk-components';
15
14
 
16
15
  interface CurrrencyProps extends PConnFieldProps {
17
16
  // If any, enter additional props that only exist on Currency here
@@ -26,173 +25,59 @@ interface CurrrencyProps extends PConnFieldProps {
26
25
  styleUrls: ['./currency.component.scss'],
27
26
  imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, MatInputModule, NgxCurrencyDirective, forwardRef(() => ComponentMapperComponent)]
28
27
  })
29
- export class CurrencyComponent implements OnInit, OnDestroy {
30
- @Input() pConn$: typeof PConnect;
31
- @Input() formGroup$: FormGroup;
32
-
33
- // Used with AngularPConnect
34
- angularPConnectData: AngularPConnectData = {};
28
+ export class CurrencyComponent extends FieldBase {
35
29
  configProps$: CurrrencyProps;
30
+ override fieldControl = new FormControl<number | null>(null, { updateOn: 'blur' });
36
31
 
37
- label$ = '';
38
- value$: any;
39
- bRequired$ = false;
40
- bReadonly$ = false;
41
- bDisabled$ = false;
42
- bVisible$ = true;
43
- displayMode$?: string = '';
44
- controlName$: string;
45
- bHasForm$ = true;
46
- componentReference = '';
47
- testId: string;
48
- helperText: string;
49
- placeholder: string;
50
- currencyISOCode = 'USD';
51
- currencyOptions: Object = {};
52
-
53
- fieldControl = new FormControl<number | null>(null, { updateOn: 'blur' });
32
+ currencyOptions: object = {};
54
33
  currencySymbol: string;
55
34
  thousandSeparator: string;
56
35
  decimalSeparator: string;
57
- inputMode: any;
58
36
  decimalPrecision: number | undefined;
59
37
  formattedValue: string;
60
38
  formatter;
39
+ inputMode = NgxCurrencyInputMode.Natural;
61
40
 
62
- constructor(
63
- private angularPConnect: AngularPConnectService,
64
- private cdRef: ChangeDetectorRef,
65
- private utils: Utils
66
- ) {}
67
-
68
- ngOnInit(): void {
69
- // First thing in initialization is registering and subscribing to the AngularPConnect service
70
- this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
71
- this.controlName$ = this.angularPConnect.getComponentID(this);
72
-
73
- // Then, continue on with other initialization
41
+ /**
42
+ * Updates the component when there are changes in the state.
43
+ */
44
+ override updateSelf(): void {
45
+ // Resolve configuration properties
46
+ this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as CurrrencyProps;
74
47
 
75
- // call updateSelf when initializing
76
- // this.updateSelf();
77
- this.checkAndUpdate();
48
+ // Update component common properties
49
+ this.updateComponentCommonProperties(this.configProps$);
78
50
 
79
- if (this.formGroup$) {
80
- // add control to formGroup
81
- this.formGroup$.addControl(this.controlName$, this.fieldControl);
51
+ // Extract and normalize the value property
52
+ const { value } = this.configProps$;
53
+ if (value) {
54
+ this.value$ = typeof value === 'string' ? parseFloat(value) : value;
82
55
  this.fieldControl.setValue(this.value$);
83
- this.bHasForm$ = true;
84
- } else {
85
- this.bReadonly$ = true;
86
- this.bHasForm$ = false;
87
- }
88
- }
89
-
90
- ngOnDestroy(): void {
91
- if (this.formGroup$) {
92
- this.formGroup$.removeControl(this.controlName$);
93
- }
94
-
95
- if (this.angularPConnectData.unsubscribeFn) {
96
- this.angularPConnectData.unsubscribeFn();
97
56
  }
98
- }
99
-
100
- // Callback passed when subscribing to store change
101
- onStateChange() {
102
- this.checkAndUpdate();
103
- }
104
-
105
- checkAndUpdate() {
106
- // Should always check the bridge to see if the component should
107
- // update itself (re-render)
108
- const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
109
57
 
110
- // ONLY call updateSelf when the component should update
111
- if (bUpdateSelf) {
112
- this.updateSelf();
113
- }
58
+ // update currency properties
59
+ this.updateCurrencyProperties(this.configProps$);
114
60
  }
115
61
 
116
- // updateSelf
117
- updateSelf(): void {
118
- // starting very simple...
119
-
120
- // moved this from ngOnInit() and call this from there instead...
121
- this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as CurrrencyProps;
122
- this.testId = this.configProps$.testId;
123
- this.label$ = this.configProps$.label;
124
- this.displayMode$ = this.configProps$.displayMode;
125
- this.inputMode = NgxCurrencyInputMode.Natural;
126
- let nValue: any = this.configProps$.value;
127
- if (nValue) {
128
- if (typeof nValue === 'string') {
129
- nValue = parseFloat(nValue);
130
- }
131
- this.value$ = nValue;
132
- this.fieldControl.setValue(this.value$);
133
- }
134
- this.helperText = this.configProps$.helperText;
135
- this.placeholder = this.configProps$.placeholder || '';
136
- const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
62
+ /**
63
+ * Updates the currency properties
64
+ *
65
+ * @param {Object} configProps - Configuration properties.
66
+ * @param {boolean} configProps.allowDecimals - Whether to allow decimal values.
67
+ * @param {string} configProps.currencyISOCode - The ISO code of the currency.
68
+ * @param {string} configProps.formatter - The formatter type (e.g., 'currency').
69
+ */
70
+ protected updateCurrencyProperties(configProps): void {
71
+ const { allowDecimals, currencyISOCode = 'USD', formatter } = configProps;
137
72
 
138
73
  const theSymbols = getCurrencyCharacters(currencyISOCode);
139
74
  this.currencySymbol = theSymbols.theCurrencySymbol;
140
75
  this.thousandSeparator = theSymbols.theDigitGroupSeparator;
141
76
  this.decimalSeparator = theSymbols.theDecimalIndicator;
142
- this.formatter = this.configProps$.formatter;
77
+ this.decimalPrecision = allowDecimals ? 2 : 0;
143
78
 
144
- if (this.displayMode$ === 'DISPLAY_ONLY' || this.displayMode$ === 'STACKED_LARGE_VAL') {
145
- const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
146
- if (this.formatter) {
147
- this.formattedValue = format(this.value$, this.formatter.toLowerCase(), theCurrencyOptions);
148
- } else {
149
- this.formattedValue = format(this.value$, 'currency', theCurrencyOptions);
150
- }
151
- }
152
-
153
- // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
154
- setTimeout(() => {
155
- if (this.configProps$.required != null) {
156
- this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
157
- }
158
- this.cdRef.detectChanges();
159
- });
160
-
161
- if (this.configProps$.visibility != null) {
162
- this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
163
- }
164
-
165
- // disabled
166
- if (this.configProps$.disabled != undefined) {
167
- this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
168
- }
169
-
170
- if (this.bDisabled$) {
171
- this.fieldControl.disable();
172
- } else {
173
- this.fieldControl.enable();
174
- }
175
-
176
- if (this.configProps$.readOnly != null) {
177
- this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
178
- }
179
-
180
- if (this.configProps$.currencyISOCode != null) {
181
- this.currencyISOCode = this.configProps$.currencyISOCode;
182
- }
183
-
184
- this.decimalPrecision = this.configProps$?.allowDecimals ? 2 : 0;
185
-
186
- this.componentReference = this.pConn$.getStateProps().value;
187
-
188
- // trigger display of error message with field control
189
- if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
190
- const timer = interval(100).subscribe(() => {
191
- this.fieldControl.setErrors({ message: true });
192
- this.fieldControl.markAsTouched();
193
-
194
- timer.unsubscribe();
195
- });
79
+ if (['DISPLAY_ONLY', 'STACKED_LARGE_VAL'].includes(this.displayMode$)) {
80
+ this.formattedValue = format(this.value$, formatter ? formatter.toLowerCase() : 'currency', getCurrencyOptions(currencyISOCode));
196
81
  }
197
82
  }
198
83
 
@@ -217,21 +102,4 @@ export class CurrencyComponent implements OnInit, OnDestroy {
217
102
  handleEvent(actionsApi, 'changeNblur', propName, value);
218
103
  }
219
104
  }
220
-
221
- getErrorMessage() {
222
- let errMessage = '';
223
-
224
- // look for validation messages for json, pre-defined or just an error pushed from workitem (400)
225
- if (this.fieldControl.hasError('message')) {
226
- errMessage = this.angularPConnectData.validateMessage ?? '';
227
- return errMessage;
228
- }
229
- if (this.fieldControl.hasError('required')) {
230
- errMessage = 'You must enter a value';
231
- } else if (this.fieldControl.errors) {
232
- errMessage = this.fieldControl.errors.toString();
233
- }
234
-
235
- return errMessage;
236
- }
237
105
  }
@@ -11,7 +11,7 @@
11
11
  #dateInput
12
12
  [attr.data-test-id]="testId"
13
13
  [matDatepicker]="pegadate"
14
- [placeholder]="dateFormatInfo.dateFormatStringLC"
14
+ [placeholder]="theDateFormat.dateFormatStringLC"
15
15
  type="text"
16
16
  [value]="value$"
17
17
  [required]="bRequired$"