@pega/dx-component-builder-sdk 25.1.10 → 25.1.12

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 (52) hide show
  1. package/package.json +1 -1
  2. package/src/tasks/create/templates/SDK-Angular/field/Boolean/boolean.component.ts.mustache +18 -149
  3. package/src/tasks/create/templates/SDK-Angular/field/Date/date.component.html.mustache +1 -1
  4. package/src/tasks/create/templates/SDK-Angular/field/Date/date.component.ts.mustache +29 -150
  5. package/src/tasks/create/templates/SDK-Angular/field/DateTime/date-time.component.ts.mustache +31 -149
  6. package/src/tasks/create/templates/SDK-Angular/field/Decimal/decimal.component.ts.mustache +37 -163
  7. package/src/tasks/create/templates/SDK-Angular/field/Decimal-Currency/decimal-currency.component.ts.mustache +34 -169
  8. package/src/tasks/create/templates/SDK-Angular/field/Decimal-Percentage/decimal-percentage.component.ts.mustache +36 -154
  9. package/src/tasks/create/templates/SDK-Angular/field/Integer/integer.component.ts.mustache +18 -157
  10. package/src/tasks/create/templates/SDK-Angular/field/Picklist/picklist.component.ts.mustache +24 -148
  11. package/src/tasks/create/templates/SDK-Angular/field/Picklist-Autocomplete/demo.stories.tsx.mustache +7 -2
  12. package/src/tasks/create/templates/SDK-Angular/field/Picklist-Autocomplete/picklist-autocomplete.component.ts.mustache +28 -162
  13. package/src/tasks/create/templates/SDK-Angular/field/Picklist-RadioButtons/picklist-radio-buttons.component.ts.mustache +35 -161
  14. package/src/tasks/create/templates/SDK-Angular/field/Text/text.component.ts.mustache +29 -144
  15. package/src/tasks/create/templates/SDK-Angular/field/Text-Email/text-email.component.ts.mustache +15 -155
  16. package/src/tasks/create/templates/SDK-Angular/field/Text-Input/text.component.ts.mustache +15 -155
  17. package/src/tasks/create/templates/SDK-Angular/field/Text-Paragraph/text-paragraph.component.ts.mustache +18 -152
  18. package/src/tasks/create/templates/SDK-Angular/field/Text-Phone/text-phone.component.ts.mustache +29 -142
  19. package/src/tasks/create/templates/SDK-Angular/field/Text-URL/text-url.component.ts.mustache +16 -154
  20. package/src/tasks/create/templates/SDK-Angular/field/TimeOfDay/time-of-day.component.ts.mustache +17 -151
  21. package/src/tasks/create/templates/SDK-Angular/template/DETAILS/details.component.ts.mustache +0 -1
  22. package/src/tasks/create/templates/SDK-Angular/template/DETAILS-region/details.component.ts.mustache +0 -1
  23. package/src/tasks/create/templates/SDK-Angular/template/FORM/form.component.ts.mustache +10 -3
  24. package/src/tasks/create/templates/SDK-Angular/template/FORM-region/form.component.ts.mustache +0 -1
  25. package/src/tasks/create/templates/SDK-Angular/template/PAGE/page.component.ts.mustache +0 -1
  26. package/src/tasks/create/templates/SDK-Angular/widget/CASE/case.component.ts.mustache +0 -1
  27. package/src/tasks/create/templates/SDK-Angular/widget/PAGE/page.component.ts.mustache +0 -1
  28. package/src/tasks/create/templates/SDK-Angular/widget/PAGE-CASE/page-case.component.html.mustache +2 -2
  29. package/src/tasks/create/templates/SDK-Angular/widget/PAGE-CASE/page-case.component.ts.mustache +4 -4
  30. package/src/tasks/create/templates/SDK-React/field/Boolean/index.tsx.mustache +96 -4
  31. package/src/tasks/create/templates/SDK-React/field/Picklist-RadioButtons/index.tsx.mustache +48 -1
  32. package/src/tasks/validator/index.js +3 -2
  33. package/src/util.js +3 -3
  34. package/tests/assets/sdk-r/components/create/override-sdk/infra/Assignment/Assignment.tsx +2 -2
  35. package/tests/assets/sdk-r/components/create/override-sdk/infra/NavBar/NavBar.tsx +13 -3
  36. package/tests/assets/sdk-r/components/create/override-sdk/infra/Stages/Stages.tsx +2 -3
  37. package/tests/assets/sdk-r/components/create/override-sdk/template/CaseView/CaseView.tsx +3 -2
  38. package/tests/assets/sdk-r/components/createAll/custom-sdk/field/Pega_DXIL_MyBoolean/index.tsx +93 -4
  39. package/tests/assets/sdk-r/components/createAll/custom-sdk/field/Pega_DXIL_MyRadiobuttons/index.tsx +45 -1
  40. package/tests/assets/sdk-r/components/createAll/override-sdk/infra/Assignment/Assignment.tsx +2 -2
  41. package/tests/assets/sdk-r/components/createAll/override-sdk/infra/NavBar/NavBar.tsx +13 -3
  42. package/tests/assets/sdk-r/components/createAll/override-sdk/infra/Stages/Stages.tsx +2 -3
  43. package/tests/assets/sdk-r/components/createAll/override-sdk/template/CaseView/CaseView.tsx +3 -2
  44. /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/PConnProps.d.ts +0 -0
  45. /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/create-nonce.ts +0 -0
  46. /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/demo.stories.tsx +0 -0
  47. /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/event-utils.ts +0 -0
  48. /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/index.tsx +0 -0
  49. /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/mock.ts +0 -0
  50. /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/styles.ts +0 -0
  51. /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/suggestions-handler.ts +0 -0
  52. /package/tests/assets/sdk-a/components/createAll/custom-constellation/field/{Pega_DXIL_MyRadioButtons → Pega_DXIL_MyRadiobuttons}/textformat-utils.tsx +0 -0
@@ -1,20 +1,18 @@
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 { MatDatepickerModule } from '@angular/material/datepicker';
5
5
  import { MatInputModule } from '@angular/material/input';
6
6
  import { MatFormFieldModule } from '@angular/material/form-field';
7
7
  import { OwlDateTimeModule, OwlNativeDateTimeModule } from '@danielmoncada/angular-datetime-picker';
8
- import { interval } from 'rxjs';
9
8
  import dayjs from 'dayjs';
10
- import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
11
- import { Utils } from '@pega/angular-sdk-components';
9
+
10
+ import { FieldBase } from '@pega/angular-sdk-components';
12
11
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
13
- import { dateFormatInfoDefault, getDateFormatInfo } from '@pega/angular-sdk-components';
14
- import { PConnFieldProps } from '@pega/angular-sdk-components';
12
+ import { getDateFormatInfo } from '@pega/angular-sdk-components';
15
13
  import { handleEvent } from '@pega/angular-sdk-components';
16
- import { format } from '@pega/angular-sdk-components';
17
14
  import { DateFormatters } from '@pega/angular-sdk-components';
15
+ import { PConnFieldProps } from '@pega/angular-sdk-components';
18
16
 
19
17
  interface {{COMPONENT_CLASS_NAME}}Props extends PConnFieldProps {
20
18
  // If any, enter additional props that only exist on DateTime here
@@ -35,162 +33,61 @@ interface {{COMPONENT_CLASS_NAME}}Props extends PConnFieldProps {
35
33
  forwardRef(() => ComponentMapperComponent)
36
34
  ]
37
35
  })
38
- export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
39
- @Input() pConn$: typeof PConnect;
40
- @Input() formGroup$: FormGroup;
41
-
42
- // Used with AngularPConnect
43
- angularPConnectData: AngularPConnectData = {};
36
+ export class {{COMPONENT_CLASS_NAME}}Component extends FieldBase implements OnInit, OnDestroy {
44
37
  configProps$: {{COMPONENT_CLASS_NAME}}Props;
45
38
 
46
- label$ = '';
47
- value$: any;
48
- bRequired$ = false;
49
- bReadonly$ = false;
50
- bDisabled$ = false;
51
- bVisible$ = true;
52
- displayMode$?: string = '';
53
- controlName$: string;
54
- bHasForm$ = true;
55
- componentReference = '';
56
- testId = '';
57
- helperText: string;
58
-
59
- fieldControl = new FormControl('', null);
60
39
  stepHour = 1;
61
40
  stepMinute = 1;
62
41
  stepSecond = 1;
63
42
  public color = 'primary';
64
- // Start with default dateFormatInfo
65
- dateFormatInfo = dateFormatInfoDefault;
66
- // and then update, as needed, based on locale, etc.
67
- theDateFormat = getDateFormatInfo();
68
- placeholder: string;
69
- actionsApi: object;
70
- propName: string;
71
43
  formattedValue$: any;
44
+ theDateFormat = getDateFormatInfo();
72
45
  timezone = PCore.getEnvironmentInfo()?.getTimeZone();
46
+ override placeholder = `${this.theDateFormat.dateFormatStringLC}, hh:mm A`;
73
47
 
74
- constructor(
75
- private angularPConnect: AngularPConnectService,
76
- private cdRef: ChangeDetectorRef,
77
- private utils: Utils
78
- ) {}
79
-
80
- ngOnInit(): void {
81
- this.placeholder = `${this.theDateFormat.dateFormatStringLC}, hh:mm A`;
82
- // First thing in initialization is registering and subscribing to the AngularPConnect service
83
- this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
84
- this.controlName$ = this.angularPConnect.getComponentID(this);
85
- // Then, continue on with other initialization
86
- // call updateSelf when initializing
87
- // this.updateSelf();
88
- this.checkAndUpdate();
48
+ override ngOnInit(): void {
49
+ super.ngOnInit();
89
50
 
90
51
  if (this.formGroup$) {
91
- // add control to formGroup
92
- this.formGroup$.addControl(this.controlName$, this.fieldControl);
93
52
  let dateTimeValue = this.value$ ?? '';
94
53
 
95
54
  if (this.value$) {
96
55
  dateTimeValue = dayjs(DateFormatters?.convertToTimezone(this.value$, { timezone: this.timezone }))?.toISOString();
97
56
  }
98
57
  this.fieldControl.setValue(dateTimeValue);
99
- this.bHasForm$ = true;
100
- } else {
101
- this.bReadonly$ = true;
102
- this.bHasForm$ = false;
103
58
  }
104
59
  }
105
60
 
106
- ngOnDestroy(): void {
107
- if (this.formGroup$) {
108
- this.formGroup$.removeControl(this.controlName$);
109
- }
110
- if (this.angularPConnectData.unsubscribeFn) {
111
- this.angularPConnectData.unsubscribeFn();
112
- }
113
- }
114
-
115
- // Callback passed when subscribing to store change
116
- onStateChange() {
117
- this.checkAndUpdate();
118
- }
119
-
120
- checkAndUpdate() {
121
- // Should always check the bridge to see if the component should
122
- // update itself (re-render)
123
- const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
61
+ /**
62
+ * Updates the component when there are changes in the state.
63
+ */
64
+ override updateSelf(): void {
65
+ // Resolve config properties
66
+ this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as {{COMPONENT_CLASS_NAME}}Props;
124
67
 
125
- // ONLY call updateSelf when the component should update
126
- if (bUpdateSelf) {
127
- this.updateSelf();
128
- }
129
- }
68
+ // Update component common properties
69
+ this.updateComponentCommonProperties(this.configProps$);
130
70
 
131
- // updateSelf
132
- updateSelf(): void {
133
- // starting very simple...
134
- // moved this from ngOnInit() and call this from there instead...
135
- this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as {{COMPONENT_CLASS_NAME}}Props;
71
+ // Extract the value property
72
+ const { value } = this.configProps$;
136
73
 
137
- this.label$ = this.configProps$.label;
138
- this.displayMode$ = this.configProps$.displayMode;
139
- this.testId = this.configProps$.testId;
140
- this.helperText = this.configProps$.helperText;
141
- this.value$ = this.configProps$?.value;
142
- let dateTimeValue = this.configProps$?.value ?? '';
74
+ // Update component properties
75
+ this.value$ = value;
76
+ let dateTimeValue = value ?? '';
143
77
  if (this.value$) {
144
78
  dateTimeValue = dayjs(DateFormatters?.convertToTimezone(this.value$, { timezone: this.timezone }))?.toISOString();
145
79
  }
146
80
  this.fieldControl.setValue(dateTimeValue);
147
- // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
148
- setTimeout(() => {
149
- if (this.configProps$.required != null) {
150
- this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
151
- }
152
- this.cdRef.detectChanges();
153
- });
154
-
155
- if (this.displayMode$ === 'DISPLAY_ONLY' || this.displayMode$ === 'STACKED_LARGE_VAL') {
156
- this.formattedValue$ = format(this.value$, 'datetime', {
157
- format: `${this.theDateFormat.dateFormatString} hh:mm A`
158
- });
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
81
 
176
- if (this.configProps$.readOnly != null) {
177
- this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
82
+ if (['DISPLAY_ONLY', 'STACKED_LARGE_VAL'].includes(this.displayMode$)) {
83
+ this.formattedValue$ = this.generateDateTime(this.value$);
178
84
  }
85
+ }
179
86
 
180
- this.componentReference = this.pConn$.getStateProps().value;
181
-
182
- this.actionsApi = this.pConn$.getActionsApi();
183
- this.propName = this.pConn$.getStateProps().value;
184
-
185
- // trigger display of error message with field control
186
- if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
187
- const timer = interval(100).subscribe(() => {
188
- this.fieldControl.setErrors({ message: true });
189
- this.fieldControl.markAsTouched();
190
-
191
- timer.unsubscribe();
192
- });
193
- }
87
+ generateDateTime(sVal): string {
88
+ if (!sVal) return '';
89
+ if (sVal.length === 10) return this.utils.generateDate(sVal, 'Date-Long-Custom-YYYY');
90
+ return this.utils.generateDateTime(sVal, 'DateTime-Long-YYYY-Custom');
194
91
  }
195
92
 
196
93
  fieldOnDateChange(event: any) {
@@ -203,19 +100,4 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
203
100
  }
204
101
  handleEvent(this.actionsApi, 'changeNblur', this.propName, event.value);
205
102
  }
206
-
207
- getErrorMessage() {
208
- let errMessage = '';
209
- // look for validation messages for json, pre-defined or just an error pushed from workitem (400)
210
- if (this.fieldControl.hasError('message')) {
211
- errMessage = this.angularPConnectData.validateMessage ?? '';
212
- return errMessage;
213
- }
214
- if (this.fieldControl.hasError('required')) {
215
- errMessage = 'You must enter a value';
216
- } else if (this.fieldControl.errors) {
217
- errMessage = this.fieldControl.errors.toString();
218
- }
219
- return errMessage;
220
- }
221
103
  }
@@ -1,17 +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, FormsModule, ReactiveFormsModule } from '@angular/forms';
3
+ import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
4
4
  import { MatInputModule } from '@angular/material/input';
5
5
  import { MatFormFieldModule } from '@angular/material/form-field';
6
6
  import { NgxCurrencyDirective, NgxCurrencyInputMode } from 'ngx-currency';
7
- import { interval } from 'rxjs';
8
- import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
9
- import { Utils } from '@pega/angular-sdk-components';
7
+ import { FieldBase } from '@pega/angular-sdk-components';
10
8
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
11
9
  import { handleEvent } from '@pega/angular-sdk-components';
12
10
  import { getCurrencyCharacters, getCurrencyOptions } from '@pega/angular-sdk-components';
13
- import { PConnFieldProps } from '@pega/angular-sdk-components';
14
11
  import { format } from '@pega/angular-sdk-components';
12
+ import { PConnFieldProps } from '@pega/angular-sdk-components';
15
13
 
16
14
  interface {{COMPONENT_CLASS_NAME}}Props extends PConnFieldProps {
17
15
  // If any, enter additional props that only exist on Decimal here
@@ -35,176 +33,69 @@ interface {{COMPONENT_CLASS_NAME}}Props extends PConnFieldProps {
35
33
  forwardRef(() => ComponentMapperComponent)
36
34
  ]
37
35
  })
38
- export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
39
- @Input() pConn$: typeof PConnect;
40
- @Input() formGroup$: FormGroup;
41
-
42
- // Used with AngularPConnect
43
- angularPConnectData: AngularPConnectData = {};
36
+ export class {{COMPONENT_CLASS_NAME}}Component extends FieldBase {
44
37
  configProps$: {{COMPONENT_CLASS_NAME}}Props;
38
+ override fieldControl = new FormControl<number | null>(null, null);
45
39
 
46
- label$ = '';
47
- value$: any;
48
- bRequired$ = false;
49
- bReadonly$ = false;
50
- bDisabled$ = false;
51
- bVisible$ = true;
52
- displayMode$?: string = '';
53
- controlName$: string;
54
- bHasForm$ = true;
55
- componentReference = '';
56
- testId: string;
57
- helperText: string;
58
- placeholder: string;
59
-
60
- fieldControl = new FormControl<number | null>(null, null);
61
40
  decimalSeparator: string;
62
41
  thousandSeparator: string;
63
42
  currencySymbol = '';
64
43
  decimalPrecision: number | undefined;
65
44
  formatter;
66
45
  formattedValue: any;
67
- inputMode: any;
46
+ inputMode: any = NgxCurrencyInputMode.Natural;
68
47
  suffix = '';
69
48
 
70
- constructor(
71
- private angularPConnect: AngularPConnectService,
72
- private cdRef: ChangeDetectorRef,
73
- private utils: Utils
74
- ) {}
75
-
76
- ngOnInit(): void {
77
- // First thing in initialization is registering and subscribing to the AngularPConnect service
78
- this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
79
- this.controlName$ = this.angularPConnect.getComponentID(this);
80
-
81
- // Then, continue on with other initialization
49
+ /**
50
+ * Updates the component when there are changes in the state.
51
+ */
52
+ override updateSelf(): void {
53
+ // Resolve config properties
54
+ this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as {{COMPONENT_CLASS_NAME}}Props;
82
55
 
83
- // call updateSelf when initializing
84
- // this.updateSelf();
85
- this.checkAndUpdate();
56
+ // Update common properties
57
+ this.updateComponentCommonProperties(this.configProps$);
86
58
 
87
- if (this.formGroup$) {
88
- // add control to formGroup
89
- this.formGroup$.addControl(this.controlName$, this.fieldControl);
59
+ // Extract and normalize the value property
60
+ const { value } = this.configProps$;
61
+ if (value) {
62
+ this.value$ = typeof value === 'string' ? parseFloat(value) : value;
90
63
  this.fieldControl.setValue(this.value$);
91
- this.bHasForm$ = true;
92
- } else {
93
- this.bReadonly$ = true;
94
- this.bHasForm$ = false;
95
- }
96
- }
97
-
98
- ngOnDestroy(): void {
99
- if (this.formGroup$) {
100
- this.formGroup$.removeControl(this.controlName$);
101
64
  }
102
65
 
103
- if (this.angularPConnectData.unsubscribeFn) {
104
- this.angularPConnectData.unsubscribeFn();
105
- }
66
+ // updates decimal properties
67
+ this.updateDecimalProperties(this.configProps$);
106
68
  }
107
69
 
108
- // Callback passed when subscribing to store change
109
- onStateChange() {
110
- this.checkAndUpdate();
111
- }
112
-
113
- checkAndUpdate() {
114
- // Should always check the bridge to see if the component should
115
- // update itself (re-render)
116
- const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
117
-
118
- // ONLY call updateSelf when the component should update
119
- if (bUpdateSelf) {
120
- this.updateSelf();
121
- }
122
- }
123
-
124
- // updateSelf
125
- updateSelf(): void {
126
- // starting very simple...
127
-
128
- // moved this from ngOnInit() and call this from there instead...
129
- this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as {{COMPONENT_CLASS_NAME}}Props;
130
- this.testId = this.configProps$.testId;
131
- this.label$ = this.configProps$.label;
132
- this.displayMode$ = this.configProps$.displayMode;
133
- this.inputMode = NgxCurrencyInputMode.Natural;
134
- let nValue: any = this.configProps$.value;
135
- if (nValue) {
136
- if (typeof nValue === 'string') {
137
- nValue = parseFloat(nValue);
138
- }
139
- this.value$ = nValue;
140
- this.fieldControl.setValue(this.value$);
141
- }
142
- this.helperText = this.configProps$.helperText;
143
- this.placeholder = this.configProps$.placeholder || '';
144
- const showGroupSeparators = this.configProps$.showGroupSeparators;
145
- const currencyISOCode = this.configProps$?.currencyISOCode ?? '';
146
-
70
+ /**
71
+ * Updates decimal properties based on the provided configuration.
72
+ *
73
+ * @param {Object} configProps - Configuration properties.
74
+ * @param {string} configProps.currencyISOCode - ISO code of the currency.
75
+ * @param {string} configProps.formatter - Formatter type (e.g., 'decimal', 'currency').
76
+ * @param {boolean} configProps.showGroupSeparators - Whether to show group separators.
77
+ */
78
+ protected updateDecimalProperties(configProps): void {
79
+ const { currencyISOCode = '', formatter, showGroupSeparators } = configProps;
80
+
81
+ // Extract currency symbols and options
147
82
  const theSymbols = getCurrencyCharacters(currencyISOCode);
148
83
  this.decimalSeparator = theSymbols.theDecimalIndicator;
149
84
  this.thousandSeparator = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
150
85
 
151
86
  const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
152
- this.formatter = this.configProps$.formatter;
87
+ const formatterLower = formatter?.toLowerCase() || 'decimal';
88
+ this.formattedValue = format(this.value$, formatterLower, theCurrencyOptions);
153
89
 
154
- if (this.formatter) {
155
- this.formattedValue = format(this.value$, this.formatter.toLowerCase(), theCurrencyOptions);
156
- } else {
157
- this.formattedValue = format(this.value$, 'decimal', theCurrencyOptions);
158
- }
159
-
160
- // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
161
- setTimeout(() => {
162
- if (this.configProps$.required != null) {
163
- this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
164
- }
165
- this.cdRef.detectChanges();
166
- });
167
-
168
- if (this.configProps$.visibility != null) {
169
- this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
170
- }
171
-
172
- if (this.configProps$.readOnly != null) {
173
- this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
174
- }
175
-
176
- // disabled
177
- if (this.configProps$.disabled != undefined) {
178
- this.bDisabled$ = this.utils.getBooleanValue(this.configProps$.disabled);
179
- }
180
-
181
- if (this.bDisabled$) {
182
- this.fieldControl.disable();
183
- } else {
184
- this.fieldControl.enable();
185
- }
186
-
187
- if (this.bReadonly$ && this.formatter === 'Currency') {
90
+ if (this.bReadonly$ && formatter === 'Currency') {
188
91
  this.currencySymbol = theSymbols.theCurrencySymbol;
189
92
  }
190
93
 
191
- if (this.bReadonly$ && this.formatter === 'Percentage') {
94
+ if (this.bReadonly$ && formatter === 'Percentage') {
192
95
  this.suffix = '%';
193
96
  }
194
97
 
195
98
  this.decimalPrecision = this.configProps$?.decimalPrecision ?? 2;
196
-
197
- this.componentReference = this.pConn$.getStateProps().value;
198
-
199
- // trigger display of error message with field control
200
- if (this.angularPConnectData.validateMessage != null && this.angularPConnectData.validateMessage != '') {
201
- const timer = interval(100).subscribe(() => {
202
- this.fieldControl.setErrors({ message: true });
203
- this.fieldControl.markAsTouched();
204
-
205
- timer.unsubscribe();
206
- });
207
- }
208
99
  }
209
100
 
210
101
  fieldOnBlur(event: any) {
@@ -229,21 +120,4 @@ export class {{COMPONENT_CLASS_NAME}}Component implements OnInit, OnDestroy {
229
120
  handleEvent(actionsApi, 'changeNblur', propName, value);
230
121
  }
231
122
  }
232
-
233
- getErrorMessage() {
234
- let errMessage = '';
235
-
236
- // look for validation messages for json, pre-defined or just an error pushed from workitem (400)
237
- if (this.fieldControl.hasError('message')) {
238
- errMessage = this.angularPConnectData.validateMessage ?? '';
239
- return errMessage;
240
- }
241
- if (this.fieldControl.hasError('required')) {
242
- errMessage = 'You must enter a value';
243
- } else if (this.fieldControl.errors) {
244
- errMessage = this.fieldControl.errors.toString();
245
- }
246
-
247
- return errMessage;
248
- }
249
123
  }