@pega/angular-sdk-overrides 0.25.14 → 0.25.15

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.
@@ -10,7 +10,7 @@
10
10
  </ng-template>
11
11
 
12
12
  <ng-template #showDetails>
13
- <div class="psdk-grid-filter" *ngIf="field.config.label && getVisibility(field.config)">
13
+ <div class="psdk-grid-filter" *ngIf="field.config.label && _getVisibility(field.config)">
14
14
  <div class="psdk-details-fields-label">
15
15
  {{ field.config.label }}
16
16
  </div>
@@ -20,6 +20,18 @@
20
20
  <a *ngSwitchCase="'phone'" class="psdk-primary-color" as="a" href="tel: {{ field.config.value }}">{{ _getValue(field.config.value) }}</a>
21
21
  <a *ngSwitchCase="'email'" class="psdk-primary-color" href="mailto: {{ field.config.value }}">{{ _getValue(field.config.value) }}</a>
22
22
  <span *ngSwitchCase="'date'" class="psdk-details-text-style">{{ _formatDate(field.config.value, field.type) }}</span>
23
+ <span *ngSwitchCase="'decimal'" class="psdk-details-text-style">{{ _formatDecimal(field) }}</span>
24
+ <span *ngSwitchCase="'currency'" class="psdk-details-text-style">{{ _formatCurrency(field) }}</span>
25
+ <span *ngSwitchCase="'richtext'" class="psdk-details-text-style" [innerHTML]="_getValue(field.config.value)"></span>
26
+ <ng-container *ngSwitchCase="'scalarlist'">
27
+ <span *ngIf="field.config.componentType?.toLowerCase() === 'decimal'" class="psdk-details-text-style">{{ _formatDecimal(field) }}</span>
28
+ <span *ngIf="field.config.componentType?.toLowerCase() === 'currency'" class="psdk-details-text-style">{{ _formatCurrency(field) }}</span>
29
+ <span
30
+ *ngIf="field.config.componentType?.toLowerCase() !== 'decimal' && field.config.componentType?.toLowerCase() !== 'currency'"
31
+ class="psdk-details-text-style"
32
+ >{{ _getValue(field.config.value) }}</span
33
+ >
34
+ </ng-container>
23
35
  <span *ngSwitchCase="'caseoperator'"></span>
24
36
  <span *ngSwitchDefault>{{ _getValue(field.config.value, field) }}</span>
25
37
  </div>
@@ -2,6 +2,8 @@ import { Component, Input, forwardRef } from '@angular/core';
2
2
  import { Utils } from '@pega/angular-sdk-components';
3
3
  import { CommonModule } from '@angular/common';
4
4
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
5
+ import { getCurrencyOptions } from '@pega/angular-sdk-components';
6
+ import { format } from '@pega/angular-sdk-components';
5
7
 
6
8
  @Component({
7
9
  selector: 'app-material-details-fields',
@@ -29,7 +31,29 @@ export class MaterialDetailsFieldsComponent {
29
31
  return this.utils.generateDate(dateValue, dateFormat);
30
32
  }
31
33
 
32
- getVisibility(config): boolean {
34
+ _formatDecimal(field: any): string {
35
+ const { currencyISOCode = '', formatter } = field.config;
36
+
37
+ const theCurrencyOptions = getCurrencyOptions(currencyISOCode);
38
+ const formatterLower = formatter?.toLowerCase() || 'decimal';
39
+ const formattedValue = format(field.config.value, formatterLower, theCurrencyOptions);
40
+
41
+ return formattedValue;
42
+ }
43
+
44
+ _formatCurrency(field: any): string {
45
+ const { currencyISOCode = 'USD', formatter } = field.config;
46
+
47
+ const formattedValue = format(
48
+ field.config.value,
49
+ formatter ? (formatter.toLowerCase() === 'defaultcurrency' ? 'currency' : formatter.toLowerCase()) : 'currency',
50
+ getCurrencyOptions(currencyISOCode)
51
+ );
52
+
53
+ return formattedValue;
54
+ }
55
+
56
+ _getVisibility(config): boolean {
33
57
  const { visibility = true } = config;
34
58
 
35
59
  return this.utils.getBooleanValue(visibility);
@@ -94,12 +94,6 @@ export class AutoCompleteComponent extends FieldBase implements OnInit {
94
94
  // Set component specific properties
95
95
  const { value, listType, parameters } = this.configProps$;
96
96
 
97
- if (value != undefined) {
98
- const index = this.options$?.findIndex(element => element.key === value);
99
- this.value$ = index > -1 ? this.options$[index].value : value;
100
- this.fieldControl.setValue(this.value$);
101
- }
102
-
103
97
  this.listType = listType;
104
98
  this.parameters = parameters;
105
99
 
@@ -119,6 +113,12 @@ export class AutoCompleteComponent extends FieldBase implements OnInit {
119
113
  const results = await this.dataPageService.getDataPageData(datasource, this.parameters, context);
120
114
  this.fillOptions(results);
121
115
  }
116
+
117
+ if (value != undefined) {
118
+ const index = this.options$?.findIndex(element => element.key === value);
119
+ this.value$ = index > -1 ? this.options$[index].value : value;
120
+ this.fieldControl.setValue(this.value$);
121
+ }
122
122
  }
123
123
 
124
124
  generateColumnsAndDataSource() {
@@ -1,5 +1,5 @@
1
1
  import { CommonModule } from '@angular/common';
2
- import { Component, forwardRef, Input, OnInit } from '@angular/core';
2
+ import { Component, forwardRef, Input, OnDestroy, OnInit } from '@angular/core';
3
3
  import { FormGroup } from '@angular/forms';
4
4
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
5
5
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
@@ -19,7 +19,7 @@ interface GroupProps extends PConnFieldProps {
19
19
  styleUrls: ['./group.component.scss'],
20
20
  imports: [CommonModule, forwardRef(() => ComponentMapperComponent)]
21
21
  })
22
- export class GroupComponent implements OnInit {
22
+ export class GroupComponent implements OnInit, OnDestroy {
23
23
  @Input() pConn$: typeof PConnect;
24
24
  @Input() formGroup$: FormGroup;
25
25
 
@@ -42,6 +42,12 @@ export class GroupComponent implements OnInit {
42
42
  this.checkAndUpdate();
43
43
  }
44
44
 
45
+ additionalProps() {
46
+ return {
47
+ visibility: this.pConn$.getComputedVisibility()
48
+ };
49
+ }
50
+
45
51
  // Callback passed when subscribing to store change
46
52
  onStateChange() {
47
53
  this.checkAndUpdate();
@@ -86,4 +92,10 @@ export class GroupComponent implements OnInit {
86
92
  });
87
93
  }
88
94
  }
95
+
96
+ ngOnDestroy(): void {
97
+ if (this.angularPConnectData.unsubscribeFn) {
98
+ this.angularPConnectData.unsubscribeFn();
99
+ }
100
+ }
89
101
  }
@@ -1,7 +1,7 @@
1
1
  <div [formGroup]="formGroup$">
2
2
  <mat-form-field class="psdk-full-width" subscriptSizing="dynamic">
3
3
  <mat-label>{{ label$ }}</mat-label>
4
- <mat-chip-grid #chipGrid>
4
+ <mat-chip-grid #chipGrid [required]="bRequired$">
5
5
  <ng-container *ngFor="let select of selectedItems">
6
6
  <mat-chip-row (removed)="removeChip(select)">
7
7
  {{ select.primary }}
@@ -279,8 +279,12 @@ export class FlowContainerComponent extends FlowContainerBaseComponent implement
279
279
 
280
280
  // this.containerName$ = oWorkMeta["name"];
281
281
  if (bLoadChildren && oWorkData) {
282
- this.containerName$ = this.localizedVal(this.getActiveViewLabel() || oWorkData.caseInfo.assignments?.[0].name, undefined, this.localeReference);
283
- this.isMultiStep = this.utils.getBooleanValue(oWorkData.caseInfo.assignments?.[0].isMultiStep);
282
+ this.containerName$ = this.localizedVal(
283
+ this.getActiveViewLabel() || oWorkData.caseInfo.assignments?.[0]?.name,
284
+ undefined,
285
+ this.localeReference
286
+ );
287
+ this.isMultiStep = this.utils.getBooleanValue(oWorkData.caseInfo.assignments?.[0]?.isMultiStep);
284
288
  }
285
289
 
286
290
  // turn off spinner
@@ -146,7 +146,6 @@ export class ViewComponent implements OnInit, OnDestroy, OnChanges {
146
146
 
147
147
  this.configProps$ = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as ViewProps;
148
148
  this.inheritedProps$ = this.pConn$.getInheritedProps();
149
-
150
149
  // NOTE: this.configProps$.visibility'] is used in view.component.ts such that
151
150
  // the View will only be rendered when this.configProps$.visibility'] is false.
152
151
  // It WILL render if true or undefined.
@@ -155,7 +154,10 @@ export class ViewComponent implements OnInit, OnDestroy, OnChanges {
155
154
  this.title$ = this.configProps$.title || '';
156
155
  // label & showLabel within inheritedProps takes precedence over configProps
157
156
  this.label$ = this.inheritedProps$.label || this.configProps$.label || '';
158
- this.showLabel$ = this.inheritedProps$.showLabel || this.configProps$.showLabel || isDetailsTemplate(this.templateName$);
157
+ this.showLabel$ =
158
+ this.inheritedProps$.showLabel !== undefined
159
+ ? this.inheritedProps$.showLabel
160
+ : this.configProps$.showLabel || isDetailsTemplate(this.templateName$);
159
161
  this.arChildren$ = this.pConn$.getChildren();
160
162
  this.visibility$ = this.configProps$.visibility ?? this.visibility$;
161
163
 
@@ -1,9 +1,11 @@
1
1
  import { Directive, OnInit, OnDestroy, Injector, Input } from '@angular/core';
2
+ import { FormGroup } from '@angular/forms';
2
3
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
3
4
 
4
5
  @Directive()
5
6
  export class DetailsTemplateBase implements OnInit, OnDestroy {
6
7
  @Input() pConn$: typeof PConnect;
8
+ @Input() formGroup$: FormGroup;
7
9
 
8
10
  // For interaction with AngularPConnect
9
11
  protected angularPConnectData: AngularPConnectData = {};
@@ -64,4 +66,47 @@ export class DetailsTemplateBase implements OnInit, OnDestroy {
64
66
  return pConnect.resolveConfigProps(pConnect.getRawMetadata());
65
67
  });
66
68
  }
69
+
70
+ processDetailFields(kid: any): any[] {
71
+ const pKid = kid.getPConnect();
72
+ const fields = pKid.getChildren();
73
+ const processedFields: any[] = [];
74
+
75
+ fields?.forEach(field => {
76
+ const thePConn = field.getPConnect();
77
+ const theCompType = thePConn.getComponentName().toLowerCase();
78
+ if (theCompType === 'reference' || theCompType === 'group') {
79
+ const configProps = thePConn.getConfigProps();
80
+ configProps.readOnly = true;
81
+ configProps.displayMode = 'DISPLAY_ONLY';
82
+ const propToUse = { ...thePConn.getInheritedProps() };
83
+ configProps.label = propToUse?.label;
84
+ const options = {
85
+ context: thePConn.getContextName(),
86
+ pageReference: thePConn.getPageReference(),
87
+ referenceList: thePConn.getReferenceList()
88
+ };
89
+ const viewContConfig = {
90
+ meta: {
91
+ ...thePConn.getMetadata(),
92
+ type: theCompType,
93
+ config: configProps
94
+ },
95
+ options
96
+ };
97
+ const theViewCont = PCore.createPConnect(viewContConfig);
98
+ processedFields.push({
99
+ type: theCompType,
100
+ pConn: theViewCont?.getPConnect()
101
+ });
102
+ } else {
103
+ processedFields.push({
104
+ type: theCompType,
105
+ config: thePConn.getConfigProps()
106
+ });
107
+ }
108
+ });
109
+
110
+ return processedFields;
111
+ }
67
112
  }
@@ -58,6 +58,7 @@ export class DataReferenceComponent implements OnInit, OnDestroy {
58
58
  dataRelationshipContext: any;
59
59
  imagePosition: any;
60
60
  showImageDescription: any;
61
+ private isUpdatingFromDataCallback = false;
61
62
 
62
63
  constructor(
63
64
  private angularPConnect: AngularPConnectService,
@@ -69,7 +70,30 @@ export class DataReferenceComponent implements OnInit, OnDestroy {
69
70
  this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
70
71
  this.children = this.pConn$.getChildren();
71
72
  this.updateSelf();
73
+ }
74
+
75
+ ngOnDestroy(): void {
76
+ if (this.angularPConnectData.unsubscribeFn) {
77
+ this.angularPConnectData.unsubscribeFn();
78
+ }
79
+ }
80
+
81
+ // Callback passed when subscribing to store change
82
+ onStateChange() {
83
+ // Should always check the bridge to see if the component should
84
+ // update itself (re-render)
85
+ const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
86
+
87
+ // ONLY call updateSelf when the component should update
88
+ if (bUpdateSelf) {
89
+ this.updateSelf();
90
+ }
91
+ }
72
92
 
93
+ getData() {
94
+ if (this.isUpdatingFromDataCallback) {
95
+ return;
96
+ }
73
97
  if (
74
98
  this.rawViewMetadata.config?.parameters &&
75
99
  !this.isDDSourceDeferred &&
@@ -94,7 +118,9 @@ export class DataReferenceComponent implements OnInit, OnDestroy {
94
118
  }))
95
119
  .filter(item => item.key); // Filtering out undefined entries
96
120
  this.dropDownDataSource = ddDataSource;
121
+ this.isUpdatingFromDataCallback = true;
97
122
  this.updateSelf();
123
+ this.isUpdatingFromDataCallback = false;
98
124
  } else {
99
125
  const ddDataSource: any = [];
100
126
  this.dropDownDataSource = ddDataSource;
@@ -110,24 +136,6 @@ export class DataReferenceComponent implements OnInit, OnDestroy {
110
136
  }
111
137
  }
112
138
 
113
- ngOnDestroy(): void {
114
- if (this.angularPConnectData.unsubscribeFn) {
115
- this.angularPConnectData.unsubscribeFn();
116
- }
117
- }
118
-
119
- // Callback passed when subscribing to store change
120
- onStateChange() {
121
- // Should always check the bridge to see if the component should
122
- // update itself (re-render)
123
- const bUpdateSelf = this.angularPConnect.shouldComponentUpdate(this);
124
-
125
- // ONLY call updateSelf when the component should update
126
- if (bUpdateSelf) {
127
- this.updateSelf();
128
- }
129
- }
130
-
131
139
  updateSelf() {
132
140
  // Update properties based on configProps
133
141
  const theConfigProps = this.pConn$.getConfigProps();
@@ -186,6 +194,7 @@ export class DataReferenceComponent implements OnInit, OnDestroy {
186
194
 
187
195
  this.generateChildrenToRender();
188
196
  this.displayChild = !(this.displaySingleRef || this.displayMultiRef);
197
+ this.getData();
189
198
  }
190
199
 
191
200
  updatePropertiesFromProps(theConfigProps) {
@@ -35,45 +35,7 @@ export class DetailsComponent extends DetailsTemplateBase {
35
35
 
36
36
  const kids = this.pConn$.getChildren() as any[];
37
37
  for (const kid of kids) {
38
- this.arFields$ = [];
39
- const pKid = kid.getPConnect();
40
- const fields = pKid.getChildren();
41
- fields?.forEach(field => {
42
- const thePConn = field.getPConnect();
43
- const theCompType = thePConn.getComponentName().toLowerCase();
44
- if (theCompType === 'reference' || theCompType === 'group') {
45
- const configProps = thePConn.getConfigProps();
46
- configProps.readOnly = true;
47
- configProps.displayMode = 'DISPLAY_ONLY';
48
- const propToUse = { ...thePConn.getInheritedProps() };
49
- configProps.label = propToUse?.label;
50
- const options = {
51
- context: thePConn.getContextName(),
52
- pageReference: thePConn.getPageReference(),
53
- referenceList: thePConn.getReferenceList()
54
- };
55
- const viewContConfig = {
56
- meta: {
57
- ...thePConn.getMetadata(),
58
- type: theCompType,
59
- config: configProps
60
- },
61
- options
62
- };
63
- const theViewCont = PCore.createPConnect(viewContConfig);
64
- const data = {
65
- type: theCompType,
66
- pConn: theViewCont?.getPConnect()
67
- };
68
- this.arFields$.push(data);
69
- } else {
70
- const data = {
71
- type: theCompType,
72
- config: thePConn.getConfigProps()
73
- };
74
- this.arFields$.push(data);
75
- }
76
- });
38
+ this.arFields$ = this.processDetailFields(kid);
77
39
  }
78
40
  }
79
41
  }
@@ -36,12 +36,10 @@ export class DetailsNarrowWideComponent extends DetailsTemplateBase {
36
36
 
37
37
  const kids = this.pConn$.getChildren() as any[];
38
38
  for (const kid of kids) {
39
- const pKid = kid.getPConnect();
40
- const pKidData = pKid.resolveConfigProps(pKid.getRawMetadata());
41
39
  if (kids.indexOf(kid) == 0) {
42
- this.arFields$ = pKidData.children;
40
+ this.arFields$ = this.processDetailFields(kid);
43
41
  } else {
44
- this.arFields2$ = pKidData.children;
42
+ this.arFields2$ = this.processDetailFields(kid);
45
43
  }
46
44
  }
47
45
  }
@@ -39,10 +39,8 @@ export class DetailsOneColumnComponent extends DetailsTemplateBase {
39
39
 
40
40
  const kids = this.pConn$.getChildren() as any[];
41
41
  for (const kid of kids) {
42
- const pKid = kid.getPConnect();
43
- const pKidData = pKid.resolveConfigProps(pKid.getRawMetadata());
44
42
  if (kids.indexOf(kid) == 0) {
45
- this.arFields$ = pKidData.children;
43
+ this.arFields$ = this.processDetailFields(kid);
46
44
  }
47
45
  }
48
46
  }
@@ -43,14 +43,12 @@ export class DetailsThreeColumnComponent extends DetailsTemplateBase {
43
43
 
44
44
  const kids = this.pConn$.getChildren() as any[];
45
45
  for (const kid of kids) {
46
- const pKid = kid.getPConnect();
47
- const pKidData = pKid.resolveConfigProps(pKid.getRawMetadata());
48
46
  if (kids.indexOf(kid) == 0) {
49
- this.arFields$ = pKidData.children;
47
+ this.arFields$ = this.processDetailFields(kid);
50
48
  } else if (kids.indexOf(kid) == 1) {
51
- this.arFields2$ = pKidData.children;
49
+ this.arFields2$ = this.processDetailFields(kid);
52
50
  } else {
53
- this.arFields3$ = pKidData.children;
51
+ this.arFields3$ = this.processDetailFields(kid);
54
52
  }
55
53
  }
56
54
  }
@@ -43,12 +43,10 @@ export class DetailsTwoColumnComponent extends DetailsTemplateBase {
43
43
 
44
44
  const kids = this.pConn$.getChildren() as any[];
45
45
  for (const kid of kids) {
46
- const pKid = kid.getPConnect();
47
- const pKidData = pKid.resolveConfigProps(pKid.getRawMetadata());
48
46
  if (kids.indexOf(kid) == 0) {
49
- this.arFields$ = pKidData.children;
47
+ this.arFields$ = this.processDetailFields(kid);
50
48
  } else {
51
- this.arFields2$ = pKidData.children;
49
+ this.arFields2$ = this.processDetailFields(kid);
52
50
  }
53
51
  }
54
52
  }
@@ -40,12 +40,10 @@ export class DetailsWideNarrowComponent extends DetailsTemplateBase {
40
40
 
41
41
  const kids = this.pConn$.getChildren() as any[];
42
42
  for (const kid of kids) {
43
- const pKid = kid.getPConnect();
44
- const pKidData = pKid.resolveConfigProps(pKid.getRawMetadata());
45
43
  if (kids.indexOf(kid) == 0) {
46
- this.arFields$ = pKidData.children;
44
+ this.arFields$ = this.processDetailFields(kid);
47
45
  } else {
48
- this.arFields2$ = pKidData.children;
46
+ this.arFields2$ = this.processDetailFields(kid);
49
47
  }
50
48
  }
51
49
  }
@@ -43,6 +43,7 @@ export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges
43
43
  readonlyMode: boolean;
44
44
  contextClass: any;
45
45
  heading: any;
46
+ headingPath: string[] = [];
46
47
  children: any;
47
48
  menuIconOverride$: any;
48
49
  referenceListLength = signal<number | null>(null);
@@ -150,11 +151,24 @@ export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges
150
151
  return `${heading} ${index + 1}`;
151
152
  };
152
153
 
153
- getDynamicHeader = (item, index) => {
154
- if (this.heading && item[this.heading.substring(1)]) {
155
- return item[this.heading.substring(1)];
154
+ getDynamicHeader = (item: Record<string, unknown>, index: number): string => {
155
+ if (this.heading) {
156
+ let value: any = item;
157
+ this.headingPath = this.heading.substring(1).split('.');
158
+
159
+ for (const key of this.headingPath) {
160
+ if (value === null || typeof value !== 'object' || !(key in value)) {
161
+ value = undefined;
162
+ break;
163
+ }
164
+ value = Reflect.get(value, key);
165
+ }
166
+
167
+ if (value !== undefined && value !== null && value !== '') {
168
+ return value.toString();
169
+ }
156
170
  }
157
- return `Row ${index + 1}`;
171
+ return `${PCore.getLocaleUtils().getLocaleValue('Row', 'SimpleTable')} ${index + 1}`;
158
172
  };
159
173
 
160
174
  addFieldGroupItem() {
@@ -930,7 +930,7 @@ export class SimpleTableManualComponent implements OnInit, OnDestroy {
930
930
  const refKeys: string[] = inColKey.split('.');
931
931
  let valBuilder = inRowData;
932
932
  for (const key of refKeys) {
933
- valBuilder = valBuilder[key];
933
+ valBuilder = valBuilder[key] ? valBuilder[key] : valBuilder;
934
934
  }
935
935
  return valBuilder;
936
936
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/angular-sdk-overrides",
3
- "version": "0.25.14",
3
+ "version": "0.25.15",
4
4
  "description": "Angular SDK - Code for overriding components",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"