@pega/angular-sdk-overrides 0.23.9 → 0.23.10

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.
@@ -301,7 +301,9 @@ export class AutoCompleteComponent implements OnInit, OnDestroy {
301
301
  // this.angularPConnect.changeHandler( this, event);
302
302
  this.filterValue = (event.target as HTMLInputElement).value;
303
303
 
304
- this.angularPConnectData.actions?.onChange(this, event);
304
+ const actionsApi = this.pConn$?.getActionsApi();
305
+ const propName = (this.pConn$?.getStateProps() as any).value;
306
+ handleEvent(actionsApi, 'change', propName, this.filterValue);
305
307
  }
306
308
 
307
309
  optionChanged(event: MatAutocompleteSelectedEvent) {
@@ -9,8 +9,8 @@ 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 { deleteInstruction, insertInstruction, updateNewInstructions } from '@pega/angular-sdk-components';
13
12
  import { handleEvent } from '@pega/angular-sdk-components';
13
+ import { deleteInstruction, insertInstruction, updateNewInstructions } from '@pega/angular-sdk-components';
14
14
 
15
15
  interface CheckboxProps extends Omit<PConnFieldProps, 'value'> {
16
16
  // If any, enter additional props that only exist on Checkbox here
@@ -234,8 +234,9 @@ export class CheckBoxComponent implements OnInit, OnDestroy {
234
234
  if (this.selectionMode === 'multi') {
235
235
  this.pConn$.getValidationApi().validate(this.selectedvalues, this.selectionList);
236
236
  } else {
237
- event.value = event.checked;
238
- this.angularPConnectData.actions?.onBlur(this, event);
237
+ const actionsApi = this.pConn$?.getActionsApi();
238
+ const propName = (this.pConn$?.getStateProps() as any).value;
239
+ handleEvent(actionsApi, 'changeNblur', propName, event.checked);
239
240
  }
240
241
  }
241
242
 
@@ -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 { getCurrencyCharacters } from '@pega/angular-sdk-components';
11
+ import { handleEvent } from '@pega/angular-sdk-components';
11
12
  import { PConnFieldProps } from '@pega/angular-sdk-components';
12
13
 
13
14
  interface CurrrencyProps extends PConnFieldProps {
@@ -175,7 +176,9 @@ export class CurrencyComponent implements OnInit, OnDestroy {
175
176
  fieldOnBlur(event: any) {
176
177
  // PConnect wants to use eventHandler for onBlur
177
178
 
178
- this.angularPConnectData.actions?.onBlur(this, event);
179
+ const actionsApi = this.pConn$?.getActionsApi();
180
+ const propName = (this.pConn$?.getStateProps() as any).value;
181
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
179
182
  }
180
183
 
181
184
  getErrorMessage() {
@@ -13,8 +13,9 @@ import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-c
13
13
  import { Utils } from '@pega/angular-sdk-components';
14
14
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
15
15
  import { dateFormatInfoDefault, getDateFormatInfo } from '@pega/angular-sdk-components';
16
- import { PConnFieldProps } from '@pega/angular-sdk-components';
16
+ import { handleEvent } from '@pega/angular-sdk-components';
17
17
  import { format } from '@pega/angular-sdk-components';
18
+ import { PConnFieldProps } from '@pega/angular-sdk-components';
18
19
 
19
20
  interface DateProps extends PConnFieldProps {
20
21
  // If any, enter additional props that only exist on Date here
@@ -222,7 +223,9 @@ export class DateComponent implements OnInit, OnDestroy {
222
223
  // convert date to pega "date" format
223
224
  event.value = event.value?.toISOString();
224
225
  }
225
- this.angularPConnectData.actions?.onBlur(this, { value: event.value });
226
+ const actionsApi = this.pConn$?.getActionsApi();
227
+ const propName = (this.pConn$?.getStateProps() as any).value;
228
+ handleEvent(actionsApi, 'changeNblur', propName, event?.value);
226
229
  }
227
230
 
228
231
  hasErrors() {
@@ -202,10 +202,9 @@ export class DateTimeComponent implements OnInit, OnDestroy {
202
202
  }
203
203
 
204
204
  fieldOnBlur(event: any) {
205
- // PConnect wants to use eventHandler for onBlur
206
- if (event.target.value) event.value = event.target.value;
207
-
208
- this.angularPConnectData.actions?.onBlur(this, event);
205
+ const actionsApi = this.pConn$?.getActionsApi();
206
+ const propName = (this.pConn$?.getStateProps() as any).value;
207
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
209
208
  }
210
209
 
211
210
  getErrorMessage() {
@@ -214,11 +214,6 @@ export class DropdownComponent implements OnInit, OnDestroy {
214
214
  }
215
215
  }
216
216
 
217
- fieldOnBlur(event: any) {
218
- // PConnect wants to use eventHandler for onBlur
219
- this.angularPConnectData.actions?.onBlur(this, event);
220
- }
221
-
222
217
  getLocalizedOptionValue(opt: IOption) {
223
218
  return this.pConn$.getLocalizedValue(
224
219
  opt.value,
@@ -7,6 +7,7 @@ import { interval } from 'rxjs';
7
7
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
8
8
  import { Utils } from '@pega/angular-sdk-components';
9
9
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
+ import { handleEvent } from '@pega/angular-sdk-components';
10
11
  import { PConnFieldProps } from '@pega/angular-sdk-components';
11
12
 
12
13
  interface EmailProps extends PConnFieldProps {
@@ -157,8 +158,9 @@ export class EmailComponent implements OnInit, OnDestroy {
157
158
  }
158
159
 
159
160
  fieldOnBlur(event: any) {
160
- // PConnect wants to use eventHandler for onBlur
161
- this.angularPConnectData.actions?.onBlur(this, event);
161
+ const actionsApi = this.pConn$?.getActionsApi();
162
+ const propName = (this.pConn$?.getStateProps() as any).value;
163
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
162
164
  }
163
165
 
164
166
  getErrorMessage() {
@@ -7,6 +7,7 @@ import { interval } from 'rxjs';
7
7
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
8
8
  import { Utils } from '@pega/angular-sdk-components';
9
9
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
+ import { handleEvent } from '@pega/angular-sdk-components';
10
11
  import { PConnFieldProps } from '@pega/angular-sdk-components';
11
12
 
12
13
  interface IntegerProps extends PConnFieldProps {
@@ -160,8 +161,9 @@ export class IntegerComponent implements OnInit, OnDestroy {
160
161
  }
161
162
 
162
163
  fieldOnBlur(event: any) {
163
- // PConnect wants to use eventHandler for onBlur
164
- this.angularPConnectData.actions?.onBlur(this, event);
164
+ const actionsApi = this.pConn$?.getActionsApi();
165
+ const propName = (this.pConn$?.getStateProps() as any).value;
166
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
165
167
  }
166
168
 
167
169
  getErrorMessage() {
@@ -7,6 +7,7 @@ import { interval } from 'rxjs';
7
7
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
8
8
  import { Utils } from '@pega/angular-sdk-components';
9
9
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
+ import { handleEvent } from '@pega/angular-sdk-components';
10
11
  import { PConnFieldProps } from '@pega/angular-sdk-components';
11
12
 
12
13
  interface PercentageProps extends PConnFieldProps {
@@ -158,9 +159,9 @@ export class PercentageComponent implements OnInit, OnDestroy {
158
159
  }
159
160
 
160
161
  fieldOnBlur(event: any) {
161
- // PConnect wants to use eventHandler for onBlur
162
-
163
- this.angularPConnectData.actions?.onBlur(this, event);
162
+ const actionsApi = this.pConn$?.getActionsApi();
163
+ const propName = (this.pConn$?.getStateProps() as any).value;
164
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
164
165
  }
165
166
 
166
167
  getErrorMessage() {
@@ -176,8 +176,9 @@ export class PhoneComponent implements OnInit, OnDestroy {
176
176
  }
177
177
 
178
178
  fieldOnBlur(event: any) {
179
- // PConnect wants to use eventHandler for onBlur
180
- this.angularPConnectData.actions?.onBlur(this, event);
179
+ const actionsApi = this.pConn$?.getActionsApi();
180
+ const propName = (this.pConn$?.getStateProps() as any).value;
181
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
181
182
  }
182
183
 
183
184
  getErrorMessage() {
@@ -8,6 +8,7 @@ import { interval } from 'rxjs';
8
8
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
9
9
  import { Utils } from '@pega/angular-sdk-components';
10
10
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
11
+ import { handleEvent } from '@pega/angular-sdk-components';
11
12
  import { PConnFieldProps } from '@pega/angular-sdk-components';
12
13
 
13
14
  interface IOption {
@@ -205,12 +206,9 @@ export class RadioButtonsComponent implements OnInit, OnDestroy {
205
206
  }
206
207
 
207
208
  fieldOnChange(event: any) {
208
- this.angularPConnectData.actions?.onChange(this, event);
209
- }
210
-
211
- fieldOnBlur(event: any) {
212
- // PConnect wants to use eventHandler for onBlur
213
- this.angularPConnectData.actions?.onBlur(this, event);
209
+ const actionsApi = this.pConn$?.getActionsApi();
210
+ const propName = (this.pConn$?.getStateProps() as any).value;
211
+ handleEvent(actionsApi, 'changeNblur', propName, event?.value);
214
212
  }
215
213
 
216
214
  getLocalizedOptionValue(opt: IOption) {
@@ -7,6 +7,7 @@ import { interval } from 'rxjs';
7
7
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
8
8
  import { Utils } from '@pega/angular-sdk-components';
9
9
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
+ import { handleEvent } from '@pega/angular-sdk-components';
10
11
  import { PConnFieldProps } from '@pega/angular-sdk-components';
11
12
 
12
13
  interface TextAreaProps extends PConnFieldProps {
@@ -156,13 +157,9 @@ export class TextAreaComponent implements OnInit, OnDestroy {
156
157
  }
157
158
 
158
159
  fieldOnChange(event: any) {
159
- // PConnect wants to use changeHandler for onChange
160
- this.angularPConnectData.actions?.onChange(this, event);
161
- }
162
-
163
- fieldOnBlur(event: any) {
164
- // PConnect wants to use eventHandler for onBlur
165
- this.angularPConnectData.actions?.onBlur(this, event);
160
+ const actionsApi = this.pConn$?.getActionsApi();
161
+ const propName = (this.pConn$?.getStateProps() as any).value;
162
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
166
163
  }
167
164
 
168
165
  getErrorMessage() {
@@ -7,6 +7,7 @@ import { interval } from 'rxjs';
7
7
  import { AngularPConnectService, AngularPConnectData } from '@pega/angular-sdk-components';
8
8
  import { Utils } from '@pega/angular-sdk-components';
9
9
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
+ import { handleEvent } from '@pega/angular-sdk-components';
10
11
  import { PConnFieldProps } from '@pega/angular-sdk-components';
11
12
 
12
13
  interface TextInputProps extends PConnFieldProps {
@@ -160,8 +161,9 @@ export class TextInputComponent implements OnInit, OnDestroy {
160
161
  }
161
162
 
162
163
  fieldOnBlur(event: any) {
163
- // PConnect wants to use eventHandler for onBlur
164
- this.angularPConnectData.actions?.onBlur(this, event);
164
+ const actionsApi = this.pConn$?.getActionsApi();
165
+ const propName = (this.pConn$?.getStateProps() as any).value;
166
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
165
167
  }
166
168
 
167
169
  getErrorMessage() {
@@ -7,6 +7,7 @@ import { interval } from 'rxjs';
7
7
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
8
8
  import { Utils } from '@pega/angular-sdk-components';
9
9
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
+ import { handleEvent } from '@pega/angular-sdk-components';
10
11
  import { PConnFieldProps } from '@pega/angular-sdk-components';
11
12
 
12
13
  interface TimeProps extends PConnFieldProps {
@@ -157,9 +158,9 @@ export class TimeComponent implements OnInit, OnDestroy {
157
158
  }
158
159
 
159
160
  fieldOnBlur(event: any) {
160
- // PConnect wants to use eventHandler for onBlur
161
- event.value = event.target.value;
162
- this.angularPConnectData.actions?.onBlur(this, event);
161
+ const actionsApi = this.pConn$?.getActionsApi();
162
+ const propName = (this.pConn$?.getStateProps() as any).value;
163
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
163
164
  }
164
165
 
165
166
  getErrorMessage() {
@@ -7,6 +7,7 @@ import { interval } from 'rxjs';
7
7
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
8
8
  import { Utils } from '@pega/angular-sdk-components';
9
9
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
10
+ import { handleEvent } from '@pega/angular-sdk-components';
10
11
  import { PConnFieldProps } from '@pega/angular-sdk-components';
11
12
 
12
13
  interface URLProps extends PConnFieldProps {
@@ -158,8 +159,9 @@ export class UrlComponent implements OnInit, OnDestroy {
158
159
  }
159
160
 
160
161
  fieldOnBlur(event: any) {
161
- // PConnect wants to use eventHandler for onBlur
162
- this.angularPConnectData.actions?.onBlur(this, event);
162
+ const actionsApi = this.pConn$?.getActionsApi();
163
+ const propName = (this.pConn$?.getStateProps() as any).value;
164
+ handleEvent(actionsApi, 'changeNblur', propName, event?.target?.value);
163
165
  }
164
166
 
165
167
  getErrorMessage() {
@@ -9,6 +9,7 @@ import { MatFormFieldModule } from '@angular/material/form-field';
9
9
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
10
10
  import { Utils } from '@pega/angular-sdk-components';
11
11
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
12
+ import { handleEvent } from '@pega/angular-sdk-components';
12
13
  import { PConnFieldProps } from '@pega/angular-sdk-components';
13
14
 
14
15
  const OPERATORS_DP = 'D_pyGetOperatorsForCurrentApplication';
@@ -189,11 +190,9 @@ export class UserReferenceComponent implements OnInit, OnDestroy {
189
190
  key = index > -1 ? (key = this.options$[index].key) : event.target.value;
190
191
  }
191
192
 
192
- const eve = {
193
- value: key
194
- };
195
- // PConnect wants to use eventHandler for onBlur
196
- this.angularPConnectData.actions?.onChange(this, eve);
193
+ const actionsApi = this.pConn$?.getActionsApi();
194
+ const propName = (this.pConn$?.getStateProps() as any).value;
195
+ handleEvent(actionsApi, 'changeNblur', propName, key);
197
196
  }
198
197
 
199
198
  getErrorMessage() {
@@ -23,7 +23,6 @@ import { ReferenceComponent } from '@pega/angular-sdk-components';
23
23
  })
24
24
  export class ModalViewContainerComponent implements OnInit, OnDestroy {
25
25
  @Input() pConn$: typeof PConnect;
26
- @Input() displayOnlyFA$: boolean;
27
26
 
28
27
  // for when non modal
29
28
  @Output() modalVisibleChange = new EventEmitter<boolean>();
@@ -73,11 +72,6 @@ export class ModalViewContainerComponent implements OnInit, OnDestroy {
73
72
  }
74
73
 
75
74
  ngOnInit(): void {
76
- if (this.displayOnlyFA$) {
77
- // for when non modal
78
- this.bShowAsModal$ = false;
79
- }
80
-
81
75
  // First thing in initialization is registering and subscribing to the AngularPConnect service
82
76
  this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
83
77
 
@@ -33,13 +33,9 @@ export class ReferenceComponent {
33
33
  static createFullReferencedViewFromRef(inPConn: any) {
34
34
  // BAIL and ERROR if inPConn is NOT a reference!
35
35
  if (inPConn.getComponentName() !== 'reference') {
36
- // debugger;
37
-
38
36
  console.error(`Reference component: createFullReferencedViewFromRef inPConn is NOT a reference! ${inPConn.getComponentName()}`);
39
37
  }
40
38
 
41
- const theResolvedConfigProps = inPConn.resolveConfigProps(inPConn.getConfigProps());
42
-
43
39
  const referenceConfig = { ...inPConn.getComponentConfig() } || {};
44
40
 
45
41
  // Since SDK-A implements Reference as static methods and we don't rely on
@@ -47,8 +43,8 @@ export class ReferenceComponent {
47
43
  // (and also leaving the others in for now) so the referenced View can act on
48
44
  // the visibility prop. (The following 3 lines were carried over from React SDK)
49
45
  delete referenceConfig?.name;
50
- // delete referenceConfig?.type;
51
- // delete referenceConfig?.visibility;
46
+ delete referenceConfig?.type;
47
+ delete referenceConfig?.visibility;
52
48
 
53
49
  const viewMetadata = inPConn.getReferencedView();
54
50
 
@@ -67,13 +63,15 @@ export class ReferenceComponent {
67
63
  ...referenceConfig
68
64
  }
69
65
  };
66
+ const theResolvedConfigProps = inPConn.resolveConfigProps(inPConn.getConfigProps());
67
+ const { visibility = true, context, readOnly = false, displayMode = '' } = theResolvedConfigProps;
70
68
 
71
69
  if (ReferenceComponent.bLogging) {
72
- console.log(`Reference: about to call createComponent with pageReference: context: ${theResolvedConfigProps.context}`);
70
+ console.log(`Reference: about to call createComponent with pageReference: context: ${inPConn.getContextName()}`);
73
71
  }
74
72
 
75
73
  const viewComponent = inPConn.createComponent(viewObject, null, null, {
76
- pageReference: theResolvedConfigProps.context
74
+ pageReference: context && context.startsWith('@CLASS') ? '' : context
77
75
  });
78
76
 
79
77
  // updating the referencedComponent should trigger a render
@@ -81,8 +79,8 @@ export class ReferenceComponent {
81
79
 
82
80
  newCompPConnect.setInheritedConfig({
83
81
  ...referenceConfig,
84
- readOnly: theResolvedConfigProps.readOnly ? theResolvedConfigProps.readOnly : false,
85
- displayMode: theResolvedConfigProps.displayMode ? theResolvedConfigProps.displayMode : null
82
+ readOnly,
83
+ displayMode
86
84
  });
87
85
 
88
86
  if (ReferenceComponent.bLogging) {
@@ -93,7 +91,11 @@ export class ReferenceComponent {
93
91
  );
94
92
  }
95
93
 
96
- return newCompPConnect;
94
+ if (visibility !== false) {
95
+ return newCompPConnect;
96
+ }
97
+
98
+ return null;
97
99
  }
98
100
 
99
101
  // STATIC method that other components can call to normalize
@@ -130,7 +132,7 @@ export class ReferenceComponent {
130
132
  // debugger;
131
133
  let theRefViewPConn = this.createFullReferencedViewFromRef(inPConn.getPConnect());
132
134
  // now return its PConnect
133
- theRefViewPConn = theRefViewPConn.getComponent();
135
+ theRefViewPConn = theRefViewPConn?.getComponent();
134
136
 
135
137
  // const theFullReference = theRefViewPConn.getPConnect().getFullReference();
136
138
  // console.log(`theFullReference: ${theFullReference}`);
@@ -5,20 +5,11 @@
5
5
  <div *ngIf="bShowRoot$">
6
6
  <div [ngSwitch]="componentName$">
7
7
  <component-mapper *ngSwitchCase="'View'" name="View" [props]="{ pConn$, displayOnlyFA$ }"></component-mapper>
8
- <!-- <app-reference *ngSwitchCase="'reference'" [pConn$]="pConn$" [displayOnlyFA$]="displayOnlyFA$"></app-reference> -->
9
8
  <component-mapper
10
9
  *ngSwitchCase="'ViewContainer'"
11
10
  name="ViewContainer"
12
- [props]="{ pConn$: displayOnlyFA$ ? viewContainerPConn$ : pConn$, displayOnlyFA$ }"
11
+ [props]="{ pConn$: viewContainerPConn$, displayOnlyFA$ }"
13
12
  ></component-mapper>
14
- <app-hybrid-view-container *ngSwitchCase="'HybridViewContainer'" [pConn$]="pConn$" [displayOnlyFA$]="displayOnlyFA$"></app-hybrid-view-container>
15
- <app-modal-view-container
16
- *ngSwitchCase="'ModalViewContainer'"
17
- [pConn$]="pConn$"
18
- [displayOnlyFA$]="displayOnlyFA$"
19
- (modalVisibleChange)="modalVisibleChanged($event)"
20
- ></app-modal-view-container>
21
- <div *ngSwitchCase="''"></div>
22
13
  <div *ngSwitchDefault>{{ localizedVal('RootContainer Missing: ' + componentName$, localeCategory) }}.</div>
23
14
  </div>
24
15
  </div>
@@ -28,9 +19,5 @@
28
19
  </div>
29
20
 
30
21
  <div *ngIf="mConn$ != null">
31
- <app-modal-view-container
32
- [pConn$]="mConn$"
33
- [displayOnlyFA$]="displayOnlyFA$"
34
- (modalVisibleChange)="modalVisibleChanged($event)"
35
- ></app-modal-view-container>
22
+ <app-modal-view-container [pConn$]="mConn$"></app-modal-view-container>
36
23
  </div>
@@ -128,16 +128,6 @@ export class RootContainerComponent implements OnInit, OnDestroy {
128
128
  }
129
129
  }
130
130
 
131
- modalVisibleChanged(isVisible) {
132
- if (this.displayOnlyFA$) {
133
- if (isVisible) {
134
- this.bShowRoot$ = false;
135
- } else {
136
- this.bShowRoot$ = true;
137
- }
138
- }
139
- }
140
-
141
131
  updateSelf() {
142
132
  // need to call this.getCurrentCompleteProps (not this.thePConn.getConfigProps)
143
133
  // to get full set of props that affect this component in Redux
@@ -1,10 +1,22 @@
1
- import { Component, OnInit, Input, forwardRef } from '@angular/core';
1
+ import { Component, OnInit, Input, forwardRef, OnDestroy } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { FormGroup } from '@angular/forms';
4
4
  import { ReferenceComponent } from '@pega/angular-sdk-components';
5
+ import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
5
6
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
6
7
  import { TemplateUtils } from '@pega/angular-sdk-components';
7
8
 
9
+ function areViewsChanged(oldViews: any[], newViews: any[]): boolean {
10
+ if (oldViews.length !== newViews.length) {
11
+ return true;
12
+ }
13
+
14
+ return !oldViews.every((oldView, index) => {
15
+ const newView = newViews[index];
16
+ return oldView.getPConnect().viewName === newView.getPConnect().viewName;
17
+ });
18
+ }
19
+
8
20
  interface DefaultFormProps {
9
21
  // If any, enter additional props that only exist on this component
10
22
  NumCols: string;
@@ -19,11 +31,14 @@ interface DefaultFormProps {
19
31
  standalone: true,
20
32
  imports: [CommonModule, forwardRef(() => ComponentMapperComponent)]
21
33
  })
22
- export class DefaultFormComponent implements OnInit {
34
+ export class DefaultFormComponent implements OnInit, OnDestroy {
23
35
  @Input() pConn$: typeof PConnect;
24
36
  @Input() formGroup$: FormGroup;
25
37
 
26
- arChildren$: any[];
38
+ // Used with AngularPConnect
39
+ angularPConnectData: AngularPConnectData = {};
40
+
41
+ arChildren$: any[] = [];
27
42
  divClass$: string;
28
43
  template: any;
29
44
  showLabel: any;
@@ -41,9 +56,29 @@ export class DefaultFormComponent implements OnInit {
41
56
  'Confirmation'
42
57
  ];
43
58
 
44
- constructor(private templateUtils: TemplateUtils) {}
59
+ constructor(
60
+ private angularPConnect: AngularPConnectService,
61
+ private templateUtils: TemplateUtils
62
+ ) {}
45
63
 
46
64
  ngOnInit(): void {
65
+ // First thing in initialization is registering and subscribing to the AngularPConnect service
66
+ this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
67
+
68
+ this.updateSelf();
69
+ }
70
+
71
+ ngOnDestroy() {
72
+ if (this.angularPConnectData.unsubscribeFn) {
73
+ this.angularPConnectData.unsubscribeFn();
74
+ }
75
+ }
76
+
77
+ onStateChange() {
78
+ this.updateSelf();
79
+ }
80
+
81
+ updateSelf() {
47
82
  const configProps = this.pConn$.getConfigProps() as DefaultFormProps;
48
83
  this.template = configProps?.template;
49
84
  const propToUse: any = { ...this.pConn$.getInheritedProps() };
@@ -71,6 +106,12 @@ export class DefaultFormComponent implements OnInit {
71
106
  // repoint children before getting templateArray
72
107
  // Children may contain 'reference' component, so we need to
73
108
  // normalize them
74
- this.arChildren$ = ReferenceComponent.normalizePConnArray(kids[0].getPConnect().getChildren());
109
+ const children = ReferenceComponent.normalizePConnArray(kids[0].getPConnect().getChildren());
110
+
111
+ const visibleChildren = children.filter(child => child !== undefined);
112
+
113
+ if (areViewsChanged(this.arChildren$, visibleChildren)) {
114
+ this.arChildren$ = visibleChildren;
115
+ }
75
116
  }
76
117
  }
@@ -117,7 +117,7 @@ export class FieldGroupTemplateComponent implements OnInit, OnDestroy, OnChanges
117
117
  this.pConn$.setInheritedProp('displayMode', 'LABELS_LEFT');
118
118
  }
119
119
  this.referenceList = this.configProps$.referenceList;
120
- if (this.prevRefLength != this.referenceList.length) {
120
+ if (this.prevRefLength != this.referenceList?.length) {
121
121
  // eslint-disable-next-line sonarjs/no-collapsible-if
122
122
  if (!this.readonlyMode) {
123
123
  if (this.referenceList?.length === 0 && this.allowAddEdit !== false) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/angular-sdk-overrides",
3
- "version": "0.23.9",
3
+ "version": "0.23.10",
4
4
  "description": "Angular SDK - Code for overriding components",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"