@pega/angular-sdk-overrides 0.242.2 → 0.242.4

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 (50) hide show
  1. package/lib/designSystemExtension/material-case-summary/material-case-summary.component.scss +2 -1
  2. package/lib/designSystemExtension/material-details-fields/material-details-fields.component.html +1 -1
  3. package/lib/designSystemExtension/material-details-fields/material-details-fields.component.ts +4 -1
  4. package/lib/field/auto-complete/auto-complete.component.ts +14 -11
  5. package/lib/field/check-box/check-box.component.ts +8 -7
  6. package/lib/field/currency/currency.component.html +4 -4
  7. package/lib/field/currency/currency.component.ts +29 -12
  8. package/lib/field/date/date.component.html +1 -6
  9. package/lib/field/date/date.component.ts +19 -36
  10. package/lib/field/date-time/date-time.component.html +1 -2
  11. package/lib/field/date-time/date-time.component.ts +16 -11
  12. package/lib/field/decimal/decimal.component.html +3 -3
  13. package/lib/field/decimal/decimal.component.ts +18 -15
  14. package/lib/field/dropdown/dropdown.component.ts +117 -17
  15. package/lib/field/email/email.component.ts +13 -3
  16. package/lib/field/integer/integer.component.html +1 -1
  17. package/lib/field/integer/integer.component.ts +12 -4
  18. package/lib/field/multiselect/multiselect.component.ts +11 -3
  19. package/lib/field/percentage/percentage.component.html +4 -4
  20. package/lib/field/percentage/percentage.component.ts +33 -18
  21. package/lib/field/phone/phone.component.html +1 -1
  22. package/lib/field/phone/phone.component.ts +11 -14
  23. package/lib/field/radio-buttons/radio-buttons.component.ts +8 -8
  24. package/lib/field/rich-text/rich-text.component.ts +7 -5
  25. package/lib/field/text/text.component.ts +2 -0
  26. package/lib/field/text-area/text-area.component.html +2 -1
  27. package/lib/field/text-area/text-area.component.ts +12 -5
  28. package/lib/field/text-input/text-input.component.html +1 -1
  29. package/lib/field/text-input/text-input.component.ts +12 -4
  30. package/lib/field/time/time.component.html +2 -2
  31. package/lib/field/time/time.component.ts +20 -6
  32. package/lib/field/url/url.component.html +1 -1
  33. package/lib/field/url/url.component.ts +12 -4
  34. package/lib/field/user-reference/user-reference.component.ts +10 -4
  35. package/lib/infra/Containers/flow-container/flow-container.component.html +1 -1
  36. package/lib/infra/Containers/flow-container/flow-container.component.ts +1 -0
  37. package/lib/infra/stages/stages.component.scss +2 -2
  38. package/lib/infra/view/view.component.html +1 -1
  39. package/lib/infra/view/view.component.ts +5 -1
  40. package/lib/template/default-form/default-form.component.html +0 -4
  41. package/lib/template/default-form/default-form.component.ts +0 -19
  42. package/lib/template/details-two-column/details-two-column.component.ts +1 -1
  43. package/lib/template/dynamic-tabs/dynamic-tabs.component.html +3 -0
  44. package/lib/template/dynamic-tabs/dynamic-tabs.component.ts +6 -1
  45. package/lib/template/field-value-list/field-value-list.component.scss +2 -1
  46. package/lib/template/list-view/list-view.component.html +3 -0
  47. package/lib/template/list-view/list-view.component.scss +11 -0
  48. package/lib/template/list-view/list-view.component.ts +21 -1
  49. package/lib/template/simple-table-manual/simple-table-manual.component.scss +1 -0
  50. package/package.json +1 -1
@@ -5,12 +5,47 @@ import { MatOptionModule } from '@angular/material/core';
5
5
  import { MatSelectModule } from '@angular/material/select';
6
6
  import { MatFormFieldModule } from '@angular/material/form-field';
7
7
  import { interval } from 'rxjs';
8
+ import isEqual from 'fast-deep-equal';
8
9
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
10
+ import { DatapageService } from '@pega/angular-sdk-components';
9
11
  import { Utils } from '@pega/angular-sdk-components';
10
12
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
11
13
  import { handleEvent } from '@pega/angular-sdk-components';
12
14
  import { PConnFieldProps } from '@pega/angular-sdk-components';
13
15
 
16
+ function flattenParameters(params = {}) {
17
+ const flatParams = {};
18
+ Object.keys(params).forEach(key => {
19
+ const { name, value: theVal } = params[key];
20
+ flatParams[name] = theVal;
21
+ });
22
+
23
+ return flatParams;
24
+ }
25
+
26
+ function preProcessColumns(columnList) {
27
+ return columnList.map(col => {
28
+ const tempColObj = { ...col };
29
+ tempColObj.value = col.value && col.value.startsWith('.') ? col.value.substring(1) : col.value;
30
+ return tempColObj;
31
+ });
32
+ }
33
+
34
+ function getDisplayFieldsMetaData(columnList) {
35
+ const displayColumns = columnList.filter(col => col.display === 'true');
36
+ const metaDataObj: any = { key: '', primary: '', secondary: [] };
37
+ const keyCol = columnList.filter(col => col.key === 'true');
38
+ metaDataObj.key = keyCol.length > 0 ? keyCol[0].value : 'auto';
39
+ for (let index = 0; index < displayColumns.length; index += 1) {
40
+ if (displayColumns[index].primary === 'true') {
41
+ metaDataObj.primary = displayColumns[index].value;
42
+ } else {
43
+ metaDataObj.secondary.push(displayColumns[index].value);
44
+ }
45
+ }
46
+ return metaDataObj;
47
+ }
48
+
14
49
  interface IOption {
15
50
  key: string;
16
51
  value: string;
@@ -22,6 +57,11 @@ interface DropdownProps extends PConnFieldProps {
22
57
  datasource?: any[];
23
58
  onRecordChange?: any;
24
59
  fieldMetadata?: any;
60
+ listType?: string;
61
+ columns?: any[];
62
+ deferDatasource?: boolean;
63
+ datasourceMetadata?: any;
64
+ parameters?: any;
25
65
  }
26
66
 
27
67
  @Component({
@@ -53,7 +93,7 @@ export class DropdownComponent implements OnInit, OnDestroy {
53
93
  testId = '';
54
94
  helperText: string;
55
95
  hideLabel: any;
56
-
96
+ theDatasource: any[] | null;
57
97
  fieldControl = new FormControl('', null);
58
98
  fieldMetadata: any[];
59
99
  localeContext = '';
@@ -61,11 +101,14 @@ export class DropdownComponent implements OnInit, OnDestroy {
61
101
  localeName = '';
62
102
  localePath = '';
63
103
  localizedValue = '';
104
+ actionsApi: Object;
105
+ propName: string;
64
106
 
65
107
  constructor(
66
108
  private angularPConnect: AngularPConnectService,
67
109
  private cdRef: ChangeDetectorRef,
68
- private utils: Utils
110
+ private utils: Utils,
111
+ private dataPageService: DatapageService
69
112
  ) {}
70
113
 
71
114
  ngOnInit(): void {
@@ -76,8 +119,9 @@ export class DropdownComponent implements OnInit, OnDestroy {
76
119
  // Then, continue on with other initialization
77
120
 
78
121
  // call updateSelf when initializing
79
- // this.updateSelf();
80
122
  this.checkAndUpdate();
123
+ // this should get called afer checkAndUpdate
124
+ this.getDatapageData();
81
125
 
82
126
  if (this.formGroup$) {
83
127
  // add control to formGroup
@@ -120,7 +164,6 @@ export class DropdownComponent implements OnInit, OnDestroy {
120
164
  updateSelf(): void {
121
165
  // moved this from ngOnInit() and call this from there instead...
122
166
  this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as DropdownProps;
123
-
124
167
  if (this.configProps$.value != undefined) {
125
168
  this.value$ = this.configProps$.value;
126
169
  }
@@ -130,6 +173,7 @@ export class DropdownComponent implements OnInit, OnDestroy {
130
173
  this.label$ = this.configProps$.label;
131
174
  this.helperText = this.configProps$.helperText;
132
175
  this.hideLabel = this.configProps$.hideLabel;
176
+ const datasource = this.configProps$.datasource;
133
177
  // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
134
178
  setTimeout(() => {
135
179
  if (this.configProps$.required != null) {
@@ -138,6 +182,11 @@ export class DropdownComponent implements OnInit, OnDestroy {
138
182
  this.cdRef.detectChanges();
139
183
  });
140
184
 
185
+ if (!isEqual(datasource, this.theDatasource)) {
186
+ // inbound datasource is different, so update theDatasource
187
+ this.theDatasource = datasource || null;
188
+ }
189
+
141
190
  if (this.configProps$.visibility != null) {
142
191
  this.bVisible$ = this.utils.getBooleanValue(this.configProps$.visibility);
143
192
  }
@@ -159,16 +208,21 @@ export class DropdownComponent implements OnInit, OnDestroy {
159
208
 
160
209
  this.componentReference = this.pConn$.getStateProps().value;
161
210
 
162
- const optionsList = [...this.utils.getOptionList(this.configProps$, this.pConn$.getDataObject())];
163
- optionsList?.unshift({ key: 'Select', value: this.pConn$.getLocalizedValue('Select...', '', '') });
164
- this.options$ = optionsList;
165
211
  if (this.value$ === '' && !this.bReadonly$) {
166
212
  this.value$ = 'Select';
167
213
  }
168
214
 
169
- const propName = this.pConn$.getStateProps().value;
215
+ if (this.theDatasource) {
216
+ const optionsList = [...this.utils.getOptionList(this.configProps$, this.pConn$.getDataObject())];
217
+ optionsList?.unshift({ key: 'Select', value: this.pConn$.getLocalizedValue('Select...', '', '') });
218
+ this.options$ = optionsList;
219
+ }
220
+
221
+ this.actionsApi = this.pConn$.getActionsApi();
222
+
223
+ this.propName = this.pConn$.getStateProps().value;
170
224
  const className = this.pConn$.getCaseInfo().getClassName();
171
- const refName = propName?.slice(propName.lastIndexOf('.') + 1);
225
+ const refName = this.propName?.slice(this.propName.lastIndexOf('.') + 1);
172
226
 
173
227
  this.fieldMetadata = this.configProps$.fieldMetadata;
174
228
  const metaData = Array.isArray(this.fieldMetadata) ? this.fieldMetadata.filter(field => field?.classID === className)[0] : this.fieldMetadata;
@@ -196,6 +250,56 @@ export class DropdownComponent implements OnInit, OnDestroy {
196
250
  }
197
251
  }
198
252
 
253
+ getDatapageData() {
254
+ const configProps = this.pConn$.getConfigProps() as DropdownProps;
255
+ let { listType, parameters, datasource = [], columns = [] } = configProps;
256
+ const { deferDatasource, datasourceMetadata } = configProps;
257
+ const context = this.pConn$.getContextName();
258
+ if (deferDatasource && datasourceMetadata?.datasource?.name) {
259
+ listType = 'datapage';
260
+ datasource = datasourceMetadata.datasource.name;
261
+ const { parameters: dataSourceParameters, propertyForDisplayText, propertyForValue } = datasourceMetadata.datasource;
262
+ parameters = flattenParameters(dataSourceParameters);
263
+ const displayProp = propertyForDisplayText?.startsWith('@P') ? propertyForDisplayText.substring(3) : propertyForDisplayText;
264
+ const valueProp = propertyForValue?.startsWith('@P') ? propertyForValue.substring(3) : propertyForValue;
265
+ columns = [
266
+ {
267
+ key: 'true',
268
+ setProperty: 'Associated property',
269
+ value: valueProp
270
+ },
271
+ {
272
+ display: 'true',
273
+ primary: 'true',
274
+ useForSearch: true,
275
+ value: displayProp
276
+ }
277
+ ];
278
+ }
279
+
280
+ columns = preProcessColumns(columns) || [];
281
+ if (!this.displayMode$ && listType !== 'associated' && typeof datasource === 'string') {
282
+ this.getData(datasource, parameters, columns, context);
283
+ }
284
+ }
285
+
286
+ getData(datasource, parameters, columns, context) {
287
+ this.dataPageService.getDataPageData(datasource, parameters, context).then((results: any) => {
288
+ const optionsData: any[] = [];
289
+ const displayColumn = getDisplayFieldsMetaData(columns);
290
+ results?.forEach(element => {
291
+ const val = element[displayColumn.primary]?.toString();
292
+ const obj = {
293
+ key: element[displayColumn.key] || element.pyGUID,
294
+ value: val
295
+ };
296
+ optionsData.push(obj);
297
+ });
298
+ optionsData?.unshift({ key: 'Select', value: this.pConn$.getLocalizedValue('Select...', '', '') });
299
+ this.options$ = optionsData;
300
+ });
301
+ }
302
+
199
303
  isSelected(buttonValue: string): boolean {
200
304
  return this.value$ === buttonValue;
201
305
  }
@@ -204,17 +308,13 @@ export class DropdownComponent implements OnInit, OnDestroy {
204
308
  if (event?.value === 'Select') {
205
309
  event.value = '';
206
310
  }
207
- const actionsApi = this.pConn$?.getActionsApi();
208
- const propName = this.pConn$?.getStateProps().value;
209
- handleEvent(actionsApi, 'changeNblur', propName, event.value);
311
+ handleEvent(this.actionsApi, 'changeNblur', this.propName, event.value);
210
312
  if (this.configProps$?.onRecordChange) {
211
313
  this.configProps$.onRecordChange(event);
212
314
  }
213
- }
214
-
215
- fieldOnBlur(event: any) {
216
- // PConnect wants to use eventHandler for onBlur
217
- this.angularPConnectData.actions?.onBlur(this, event);
315
+ this.pConn$.clearErrorMessages({
316
+ property: this.propName
317
+ });
218
318
  }
219
319
 
220
320
  getLocalizedOptionValue(opt: IOption) {
@@ -8,6 +8,7 @@ import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-c
8
8
  import { Utils } from '@pega/angular-sdk-components';
9
9
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
10
  import { PConnFieldProps } from '@pega/angular-sdk-components';
11
+ import { handleEvent } from '@pega/angular-sdk-components';
11
12
 
12
13
  interface EmailProps extends PConnFieldProps {
13
14
  // If any, enter additional props that only exist on Email here
@@ -43,6 +44,8 @@ export class EmailComponent implements OnInit, OnDestroy {
43
44
  placeholder: string;
44
45
 
45
46
  fieldControl = new FormControl('', null);
47
+ actionsApi: Object;
48
+ propName: string;
46
49
 
47
50
  constructor(
48
51
  private angularPConnect: AngularPConnectService,
@@ -139,6 +142,9 @@ export class EmailComponent implements OnInit, OnDestroy {
139
142
  this.bReadonly$ = this.utils.getBooleanValue(this.configProps$.readOnly);
140
143
  }
141
144
 
145
+ this.actionsApi = this.pConn$.getActionsApi();
146
+ this.propName = this.pConn$.getStateProps().value;
147
+
142
148
  this.componentReference = this.pConn$.getStateProps().value;
143
149
 
144
150
  // trigger display of error message with field control
@@ -153,12 +159,16 @@ export class EmailComponent implements OnInit, OnDestroy {
153
159
  }
154
160
 
155
161
  fieldOnChange(event: any) {
156
- this.angularPConnectData.actions?.onChange(this, event);
162
+ const value = event?.target?.value;
163
+ handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
164
+ this.pConn$.clearErrorMessages({
165
+ property: this.propName
166
+ });
157
167
  }
158
168
 
159
169
  fieldOnBlur(event: any) {
160
- // PConnect wants to use eventHandler for onBlur
161
- this.angularPConnectData.actions?.onBlur(this, event);
170
+ const value = event?.target?.value;
171
+ handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
162
172
  }
163
173
 
164
174
  getErrorMessage() {
@@ -15,7 +15,7 @@
15
15
  [required]="bRequired$"
16
16
  [formControl]="fieldControl"
17
17
  [attr.data-test-id]="testId"
18
- (change)="fieldOnChange($event)"
18
+ (change)="fieldOnChange()"
19
19
  (blur)="fieldOnBlur($event)"
20
20
  />
21
21
  <mat-error *ngIf="fieldControl.invalid">{{ getErrorMessage() }}</mat-error>
@@ -8,6 +8,7 @@ import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-c
8
8
  import { Utils } from '@pega/angular-sdk-components';
9
9
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
10
  import { PConnFieldProps } from '@pega/angular-sdk-components';
11
+ import { handleEvent } from '@pega/angular-sdk-components';
11
12
 
12
13
  interface IntegerProps extends PConnFieldProps {
13
14
  // If any, enter additional props that only exist on Integer here
@@ -43,6 +44,8 @@ export class IntegerComponent implements OnInit, OnDestroy {
43
44
  placeholder: string;
44
45
 
45
46
  fieldControl = new FormControl<number | null>(null, null);
47
+ actionsApi: Object;
48
+ propName: string;
46
49
 
47
50
  constructor(
48
51
  private angularPConnect: AngularPConnectService,
@@ -115,6 +118,9 @@ export class IntegerComponent implements OnInit, OnDestroy {
115
118
  this.helperText = this.configProps$.helperText;
116
119
  this.placeholder = this.configProps$.placeholder || '';
117
120
 
121
+ this.actionsApi = this.pConn$.getActionsApi();
122
+ this.propName = this.pConn$.getStateProps().value;
123
+
118
124
  // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
119
125
  setTimeout(() => {
120
126
  if (this.configProps$.required != null) {
@@ -155,13 +161,15 @@ export class IntegerComponent implements OnInit, OnDestroy {
155
161
  }
156
162
  }
157
163
 
158
- fieldOnChange(event: any) {
159
- this.angularPConnectData.actions?.onChange(this, event);
164
+ fieldOnChange() {
165
+ this.pConn$.clearErrorMessages({
166
+ property: this.propName
167
+ });
160
168
  }
161
169
 
162
170
  fieldOnBlur(event: any) {
163
- // PConnect wants to use eventHandler for onBlur
164
- this.angularPConnectData.actions?.onBlur(this, event);
171
+ const value = event?.target?.value;
172
+ handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
165
173
  }
166
174
 
167
175
  getErrorMessage() {
@@ -1,7 +1,7 @@
1
1
  import { CommonModule } from '@angular/common';
2
2
  import { Component, forwardRef, Input, OnDestroy, OnInit } from '@angular/core';
3
3
  import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
4
- import { MatAutocompleteModule, MatAutocompleteSelectedEvent } from '@angular/material/autocomplete';
4
+ import { MatAutocompleteModule } from '@angular/material/autocomplete';
5
5
  import { MatChipsModule } from '@angular/material/chips';
6
6
  import { MatCheckboxModule } from '@angular/material/checkbox';
7
7
  import { MatOptionModule } from '@angular/material/core';
@@ -13,6 +13,7 @@ import { ComponentMapperComponent } from '@pega/angular-sdk-components';
13
13
  import { Utils } from '@pega/angular-sdk-components';
14
14
  import { doSearch, getDisplayFieldsMetaData, getGroupDataForItemsTree, preProcessColumns } from './utils';
15
15
  import { deleteInstruction, insertInstruction } from '@pega/angular-sdk-components';
16
+ import { handleEvent } from '@pega/angular-sdk-components';
16
17
 
17
18
  @Component({
18
19
  selector: 'app-multiselect',
@@ -73,6 +74,8 @@ export class MultiselectComponent implements OnInit, OnDestroy {
73
74
  dataApiObj: any;
74
75
  itemsTree: any[] = [];
75
76
  trigger: any;
77
+ actionsApi: Object;
78
+ propName: string;
76
79
 
77
80
  constructor(
78
81
  private angularPConnect: AngularPConnectService,
@@ -212,6 +215,9 @@ export class MultiselectComponent implements OnInit, OnDestroy {
212
215
  this.fieldControl.enable();
213
216
  }
214
217
 
218
+ this.actionsApi = this.pConn$.getActionsApi();
219
+ this.propName = this.pConn$.getStateProps().value;
220
+
215
221
  if (this.listType !== 'associated') {
216
222
  PCore.getDataApi()
217
223
  ?.init(dataConfig, contextName)
@@ -285,8 +291,10 @@ export class MultiselectComponent implements OnInit, OnDestroy {
285
291
  this.getCaseListBasedOnParams(this.value$, '', [...this.selectedItems], [...this.itemsTree], true);
286
292
  }
287
293
 
288
- optionChanged(event: MatAutocompleteSelectedEvent) {
289
- this.angularPConnectData.actions?.onChange(this, event);
294
+ optionChanged(event: any) {
295
+ let value = event?.target?.value;
296
+ value = value?.substring(1);
297
+ handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
290
298
  }
291
299
 
292
300
  optionClicked = (event: Event, data: any): void => {
@@ -1,5 +1,5 @@
1
1
  <div *ngIf="displayMode$; else noDisplayMode">
2
- <component-mapper *ngIf="bVisible$ !== false" name="FieldValueList" [props]="{ label$, value$, displayMode$ }"></component-mapper>
2
+ <component-mapper *ngIf="bVisible$ !== false" name="FieldValueList" [props]="{ label$, value$: formattedValue, displayMode$ }"></component-mapper>
3
3
  </div>
4
4
  <ng-template #noDisplayMode>
5
5
  <div *ngIf="bHasForm$; else noEdit">
@@ -13,8 +13,8 @@
13
13
  [options]="{
14
14
  prefix: '',
15
15
  suffix: '%',
16
- thousands: currSep,
17
- decimal: currDec,
16
+ thousands: thousandSeparator,
17
+ decimal: decimalSeparator,
18
18
  align: 'left',
19
19
  nullable: true,
20
20
  precision: decimalPrecision,
@@ -26,7 +26,7 @@
26
26
  [required]="bRequired$"
27
27
  [formControl]="fieldControl"
28
28
  [attr.data-test-id]="testId"
29
- (change)="fieldOnChange($event)"
29
+ (change)="fieldOnChange()"
30
30
  (blur)="fieldOnBlur($event)"
31
31
  [readonly]="bReadonly$"
32
32
  />
@@ -11,10 +11,12 @@ import { ComponentMapperComponent } from '@pega/angular-sdk-components';
11
11
  import { handleEvent } from '@pega/angular-sdk-components';
12
12
  import { getCurrencyCharacters } from '@pega/angular-sdk-components';
13
13
  import { PConnFieldProps } from '@pega/angular-sdk-components';
14
+ import { format } from '@pega/angular-sdk-components';
14
15
 
15
16
  interface PercentageProps extends PConnFieldProps {
16
17
  showGroupSeparators?: string;
17
18
  decimalPrecision?: number;
19
+ currencyISOCode?: string;
18
20
  // If any, enter additional props that only exist on Percentage here
19
21
  }
20
22
 
@@ -46,11 +48,14 @@ export class PercentageComponent implements OnInit, OnDestroy {
46
48
  testId: string;
47
49
  helperText: string;
48
50
  placeholder: string;
49
- currDec: string;
50
- currSep: string;
51
+ decimalSeparator: string;
52
+ thousandSeparator: string;
51
53
  inputMode: any;
52
54
  decimalPrecision: number | undefined;
53
55
  fieldControl = new FormControl<number | null>(null, null);
56
+ actionsApi: Object;
57
+ propName: string;
58
+ formattedValue: string;
54
59
 
55
60
  constructor(
56
61
  private angularPConnect: AngularPConnectService,
@@ -113,20 +118,25 @@ export class PercentageComponent implements OnInit, OnDestroy {
113
118
  this.label$ = this.configProps$.label;
114
119
  this.displayMode$ = this.configProps$.displayMode;
115
120
  this.inputMode = NgxCurrencyInputMode.Natural;
116
- let nValue: any = this.configProps$.value;
121
+ const nValue: any = this.configProps$.value;
117
122
  if (nValue) {
118
- if (typeof nValue === 'string') {
119
- nValue = parseInt(nValue, 10);
120
- }
121
123
  this.value$ = nValue;
124
+ this.fieldControl.setValue(nValue);
122
125
  }
123
126
  this.helperText = this.configProps$.helperText;
124
127
  this.placeholder = this.configProps$.placeholder || '';
125
128
  const showGroupSeparators = this.configProps$.showGroupSeparators;
126
129
 
127
130
  const theSymbols = getCurrencyCharacters('');
128
- this.currDec = theSymbols.theDecimalIndicator || '2';
129
- this.currSep = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
131
+ this.decimalSeparator = theSymbols.theDecimalIndicator;
132
+ this.thousandSeparator = showGroupSeparators ? theSymbols.theDigitGroupSeparator : '';
133
+
134
+ this.actionsApi = this.pConn$.getActionsApi();
135
+ this.propName = this.pConn$.getStateProps().value;
136
+
137
+ if (this.displayMode$ === 'DISPLAY_ONLY' || this.displayMode$ === 'STACKED_LARGE_VAL') {
138
+ this.formattedValue = nValue ? format(nValue, 'percentage') : '';
139
+ }
130
140
 
131
141
  // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
132
142
  setTimeout(() => {
@@ -169,22 +179,27 @@ export class PercentageComponent implements OnInit, OnDestroy {
169
179
  }
170
180
  }
171
181
 
172
- fieldOnChange(event: any) {
173
- this.angularPConnectData.actions?.onChange(this, event);
182
+ fieldOnChange() {
183
+ this.pConn$.clearErrorMessages({
184
+ property: this.propName
185
+ });
174
186
  }
175
187
 
176
188
  fieldOnBlur(event: any) {
177
- const actionsApi = this.pConn$?.getActionsApi();
178
- const propName = this.pConn$?.getStateProps()?.value;
179
189
  let value = event?.target?.value;
180
190
  value = value ? value.replace(/%/g, '') : '';
181
- if (this.currSep === ',') {
182
- value = value.replace(/,/g, '');
183
- } else {
184
- value = value?.replace(/\./g, '');
185
- value = value?.replace(/,/g, '.');
191
+ // replacing thousand separator with empty string as not required in api call
192
+ if (this.configProps$.showGroupSeparators) {
193
+ const thousandSep = this.thousandSeparator === '.' ? '\\.' : this.thousandSeparator;
194
+ const regExp = new RegExp(String.raw`${thousandSep}`, 'g');
195
+ value = value?.replace(regExp, '');
196
+ }
197
+ // replacing decimal separator with '.'
198
+ if (this.decimalSeparator !== '.') {
199
+ const regExp = new RegExp(String.raw`${this.decimalSeparator}`, 'g');
200
+ value = value.replace(regExp, '.');
186
201
  }
187
- handleEvent(actionsApi, 'changeNblur', propName, value);
202
+ handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
188
203
  }
189
204
 
190
205
  getErrorMessage() {
@@ -12,7 +12,7 @@
12
12
  [enablePlaceholder]="true"
13
13
  [enableSearch]="true"
14
14
  (change)="fieldOnChange()"
15
- (blur)="fieldOnBlur($event)"
15
+ (blur)="fieldOnBlur()"
16
16
  >
17
17
  </ngx-mat-intl-tel-input>
18
18
  <mat-label>{{ label$ }}</mat-label>
@@ -50,6 +50,9 @@ export class PhoneComponent implements OnInit, OnDestroy {
50
50
  phone: new FormControl<string | null>(null)
51
51
  });
52
52
 
53
+ actionsApi: Object;
54
+ propName: string;
55
+
53
56
  constructor(
54
57
  private angularPConnect: AngularPConnectService,
55
58
  private cdRef: ChangeDetectorRef,
@@ -117,6 +120,9 @@ export class PhoneComponent implements OnInit, OnDestroy {
117
120
  }
118
121
  this.helperText = this.configProps$.helperText;
119
122
 
123
+ this.actionsApi = this.pConn$.getActionsApi();
124
+ this.propName = this.pConn$.getStateProps().value;
125
+
120
126
  // timeout and detectChanges to avoid ExpressionChangedAfterItHasBeenCheckedError
121
127
  setTimeout(() => {
122
128
  if (this.configProps$.required != null) {
@@ -159,27 +165,18 @@ export class PhoneComponent implements OnInit, OnDestroy {
159
165
  }
160
166
  }
161
167
 
168
+ fieldOnBlur() {
169
+ // 'blur' isn't getting fired
170
+ }
171
+
162
172
  fieldOnChange() {
163
173
  if (this.formGroup$.controls[this.controlName$].value) {
164
- const actionsApi = this.pConn$?.getActionsApi();
165
- const propName = this.pConn$?.getStateProps().value;
166
174
  const value = this.formGroup$.controls[this.controlName$].value;
167
- const eventObj = {
168
- target: {
169
- value
170
- }
171
- };
172
175
  this.afterBlur = true;
173
- this.angularPConnectData.actions?.onChange(this, eventObj);
174
- handleEvent(actionsApi, 'blur', propName, value);
176
+ handleEvent(this.actionsApi, 'changeNblur', this.propName, value);
175
177
  }
176
178
  }
177
179
 
178
- fieldOnBlur(event: any) {
179
- // PConnect wants to use eventHandler for onBlur
180
- this.angularPConnectData.actions?.onBlur(this, event);
181
- }
182
-
183
180
  getErrorMessage() {
184
181
  let errMessage = '';
185
182
 
@@ -9,6 +9,7 @@ import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-c
9
9
  import { Utils } from '@pega/angular-sdk-components';
10
10
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
11
11
  import { PConnFieldProps } from '@pega/angular-sdk-components';
12
+ import { handleEvent } from '@pega/angular-sdk-components';
12
13
 
13
14
  interface IOption {
14
15
  key: string;
@@ -60,6 +61,8 @@ export class RadioButtonsComponent implements OnInit, OnDestroy {
60
61
  localeName = '';
61
62
  localePath = '';
62
63
  localizedValue = '';
64
+ actionsApi: Object;
65
+ propName: string;
63
66
 
64
67
  constructor(
65
68
  private angularPConnect: AngularPConnectService,
@@ -168,9 +171,11 @@ export class RadioButtonsComponent implements OnInit, OnDestroy {
168
171
 
169
172
  this.options$ = this.utils.getOptionList(this.configProps$, this.pConn$.getDataObject());
170
173
 
171
- const propName = this.pConn$.getStateProps().value;
174
+ this.actionsApi = this.pConn$.getActionsApi();
175
+ this.propName = this.pConn$.getStateProps().value;
176
+
172
177
  const className = this.pConn$.getCaseInfo().getClassName();
173
- const refName = propName?.slice(propName.lastIndexOf('.') + 1);
178
+ const refName = this.propName?.slice(this.propName.lastIndexOf('.') + 1);
174
179
 
175
180
  this.fieldMetadata = this.configProps$.fieldMetadata;
176
181
  const metaData = Array.isArray(this.fieldMetadata) ? this.fieldMetadata.filter(field => field?.classID === className)[0] : this.fieldMetadata;
@@ -203,12 +208,7 @@ export class RadioButtonsComponent implements OnInit, OnDestroy {
203
208
  }
204
209
 
205
210
  fieldOnChange(event: any) {
206
- this.angularPConnectData.actions?.onChange(this, event);
207
- }
208
-
209
- fieldOnBlur(event: any) {
210
- // PConnect wants to use eventHandler for onBlur
211
- this.angularPConnectData.actions?.onBlur(this, event);
211
+ handleEvent(this.actionsApi, 'changeNblur', this.propName, event.value);
212
212
  }
213
213
 
214
214
  getLocalizedOptionValue(opt: IOption) {
@@ -40,6 +40,8 @@ export class RichTextComponent implements OnInit, OnDestroy {
40
40
  info: any;
41
41
  error: boolean;
42
42
  status: any;
43
+ actionsApi: Object;
44
+ propName: string;
43
45
 
44
46
  constructor(
45
47
  private angularPConnect: AngularPConnectService,
@@ -94,6 +96,9 @@ export class RichTextComponent implements OnInit, OnDestroy {
94
96
  this.info = stateProps?.validatemessage || this.configProps$.helperText;
95
97
  this.error = stateProps?.status === 'error';
96
98
 
99
+ this.actionsApi = this.pConn$.getActionsApi();
100
+ this.propName = this.pConn$.getStateProps().value;
101
+
97
102
  if (this.configProps$.required != null) {
98
103
  this.bRequired$ = this.utils.getBooleanValue(this.configProps$.required);
99
104
  }
@@ -113,7 +118,7 @@ export class RichTextComponent implements OnInit, OnDestroy {
113
118
 
114
119
  fieldOnChange() {
115
120
  if (this.status === 'error') {
116
- const property = this.pConn$.getStateProps().value;
121
+ const property = this.propName;
117
122
  this.pConn$.clearErrorMessages({
118
123
  property,
119
124
  category: '',
@@ -123,9 +128,6 @@ export class RichTextComponent implements OnInit, OnDestroy {
123
128
  }
124
129
 
125
130
  fieldOnBlur(editorValue: any) {
126
- // PConnect wants to use eventHandler for onBlur
127
- const actionsApi = this.pConn$?.getActionsApi();
128
- const propName = this.pConn$?.getStateProps()?.value;
129
- handleEvent(actionsApi, 'changeNblur', propName, editorValue);
131
+ handleEvent(this.actionsApi, 'changeNblur', this.propName, editorValue);
130
132
  }
131
133
  }
@@ -1,5 +1,6 @@
1
1
  import { Component, OnInit, Input, forwardRef, OnDestroy } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
+ import { FormGroup } from '@angular/forms';
3
4
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
4
5
  import { Utils } from '@pega/angular-sdk-components';
5
6
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
@@ -18,6 +19,7 @@ interface TextProps extends PConnFieldProps {
18
19
  })
19
20
  export class TextComponent implements OnInit, OnDestroy {
20
21
  @Input() pConn$: typeof PConnect;
22
+ @Input() formGroup$: FormGroup;
21
23
  @Input() formatAs$: string;
22
24
 
23
25
  // Used with AngularPConnect