@pega/angular-sdk-overrides 24.2.10 → 24.2.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 (75) hide show
  1. package/lib/designSystemExtension/material-case-summary/material-case-summary.component.ts +0 -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 +6 -0
  4. package/lib/designSystemExtension/operator/operator.component.html +1 -1
  5. package/lib/designSystemExtension/operator/operator.component.scss +10 -2
  6. package/lib/designSystemExtension/operator/operator.component.ts +4 -3
  7. package/lib/field/auto-complete/auto-complete.component.html +0 -1
  8. package/lib/field/auto-complete/auto-complete.component.ts +15 -2
  9. package/lib/field/check-box/check-box.component.html +4 -0
  10. package/lib/field/currency/currency.component.ts +19 -13
  11. package/lib/field/date/date.component.html +2 -1
  12. package/lib/field/date-time/date-time.component.html +2 -2
  13. package/lib/field/date-time/date-time.component.ts +17 -3
  14. package/lib/field/decimal/decimal.component.html +1 -0
  15. package/lib/field/decimal/decimal.component.ts +38 -15
  16. package/lib/field/dropdown/dropdown.component.html +1 -0
  17. package/lib/field/dropdown/dropdown.component.ts +18 -4
  18. package/lib/field/email/email.component.ts +17 -7
  19. package/lib/field/integer/integer.component.html +1 -1
  20. package/lib/field/integer/integer.component.ts +16 -6
  21. package/lib/field/list-view-action-buttons/list-view-action-buttons.component.html +1 -1
  22. package/lib/field/list-view-action-buttons/list-view-action-buttons.component.ts +3 -2
  23. package/lib/field/percentage/percentage.component.html +1 -1
  24. package/lib/field/percentage/percentage.component.ts +27 -17
  25. package/lib/field/phone/config-ext.json +1 -1
  26. package/lib/field/phone/phone.component.html +3 -1
  27. package/lib/field/phone/phone.component.ts +6 -13
  28. package/lib/field/radio-buttons/radio-buttons.component.html +3 -6
  29. package/lib/field/rich-text/rich-text.component.ts +12 -3
  30. package/lib/field/text/text.component.ts +6 -4
  31. package/lib/field/text-area/text-area.component.html +4 -2
  32. package/lib/field/text-area/text-area.component.ts +16 -6
  33. package/lib/field/text-input/text-input.component.html +1 -1
  34. package/lib/field/text-input/text-input.component.ts +16 -6
  35. package/lib/field/time/time.component.html +2 -2
  36. package/lib/field/time/time.component.ts +21 -6
  37. package/lib/field/url/url.component.html +1 -1
  38. package/lib/field/url/url.component.ts +16 -6
  39. package/lib/field/user-reference/user-reference.component.html +40 -38
  40. package/lib/field/user-reference/user-reference.component.ts +70 -7
  41. package/lib/infra/Containers/flow-container/flow-container.component.ts +17 -43
  42. package/lib/infra/Containers/flow-container/helpers.ts +2 -2
  43. package/lib/infra/Containers/modal-view-container/modal-view-container.component.html +1 -11
  44. package/lib/infra/Containers/modal-view-container/modal-view-container.component.ts +0 -7
  45. package/lib/infra/action-buttons/action-buttons.component.html +1 -1
  46. package/lib/infra/assignment/assignment.component.html +1 -1
  47. package/lib/infra/assignment/assignment.component.ts +82 -39
  48. package/lib/infra/assignment-card/assignment-card.component.html +1 -0
  49. package/lib/infra/defer-load/defer-load.component.ts +4 -1
  50. package/lib/infra/navbar/navbar.component.ts +0 -2
  51. package/lib/infra/reference/reference.component.ts +77 -90
  52. package/lib/infra/root-container/root-container.component.html +2 -15
  53. package/lib/infra/root-container/root-container.component.ts +24 -27
  54. package/lib/template/base/form-template-base.ts +6 -0
  55. package/lib/template/confirmation/confirmation.component.html +1 -1
  56. package/lib/template/default-form/default-form.component.ts +35 -2
  57. package/lib/template/field-group-template/field-group-template.component.html +7 -7
  58. package/lib/template/field-group-template/field-group-template.component.scss +8 -0
  59. package/lib/template/field-group-template/field-group-template.component.ts +64 -41
  60. package/lib/template/field-value-list/field-value-list.component.html +2 -2
  61. package/lib/template/field-value-list/field-value-list.component.scss +4 -0
  62. package/lib/template/list-view/list-view.component.html +3 -1
  63. package/lib/template/list-view/list-view.component.ts +1 -3
  64. package/lib/template/list-view/listViewHelpers.ts +2 -5
  65. package/lib/template/list-view/utils.ts +2 -5
  66. package/lib/template/simple-table-manual/helpers.ts +9 -7
  67. package/lib/template/simple-table-manual/simple-table-manual.component.html +25 -6
  68. package/lib/template/simple-table-manual/simple-table-manual.component.scss +11 -3
  69. package/lib/template/simple-table-manual/simple-table-manual.component.ts +62 -24
  70. package/lib/template/utils.ts +16 -0
  71. package/lib/widget/feed-container/feed-container.component.ts +0 -2
  72. package/lib/widget/todo/todo.component.html +4 -5
  73. package/lib/widget/todo/todo.component.scss +9 -0
  74. package/lib/widget/todo/todo.component.ts +4 -3
  75. package/package.json +1 -1
@@ -13,53 +13,42 @@ import { Component } from '@angular/core';
13
13
  standalone: true
14
14
  })
15
15
  export class ReferenceComponent {
16
- referencedComponent: any = null;
17
-
18
16
  /* Used to toggle some class-wide logging */
19
17
  private static bLogging = false;
20
18
 
21
- constructor() {
22
- // With new static method approach, this shouldn't be called any more
23
- window.alert(`in ReferenceComponent constructor!`);
24
-
25
- console.error(`in ReferenceComponent constructor!`);
26
- }
27
-
28
- // onStateChange and updateSelf methods removed from original implementation
29
- // when we moved to the static method implementation.
30
-
31
- // STATIC method to create a normalized PConn (a fully realized View that the 'reference'
32
- // component refers to) from the given pConn. Has to add in some stuff as in the constructor
33
- static createFullReferencedViewFromRef(inPConn: any) {
34
- // BAIL and ERROR if inPConn is NOT a reference!
19
+ /**
20
+ * Creates a normalized PConn from a reference component.
21
+ * Resolves the reference to its fully realized View with proper configuration.
22
+ *
23
+ * @param inPConn - The PConn object that represents a reference component
24
+ * @returns The dereferenced PConnect object, or null if reference can't be resolved
25
+ */
26
+ static createFullReferencedViewFromRef(inPConn: any): any {
27
+ // Validate that inPConn is a reference component
35
28
  if (inPConn.getComponentName() !== 'reference') {
36
- // debugger;
37
-
38
29
  console.error(`Reference component: createFullReferencedViewFromRef inPConn is NOT a reference! ${inPConn.getComponentName()}`);
30
+ return null;
39
31
  }
40
32
 
41
- const theResolvedConfigProps = inPConn.resolveConfigProps(inPConn.getConfigProps());
42
-
43
- const referenceConfig = { ...inPConn.getComponentConfig() } || {};
33
+ // Get reference configuration and make a copy
34
+ const referenceConfig = { ...inPConn.getComponentConfig() };
44
35
 
45
- // Since SDK-A implements Reference as static methods and we don't rely on
46
- // the Reference component's handling of the visibility prop, we leave it in
47
- // (and also leaving the others in for now) so the referenced View can act on
48
- // the visibility prop. (The following 3 lines were carried over from React SDK)
36
+ // Remove properties that should not be inherited by the referenced view
37
+ // (Maintained from React SDK implementation)
49
38
  delete referenceConfig?.name;
50
- // delete referenceConfig?.type;
51
- // delete referenceConfig?.visibility;
39
+ delete referenceConfig?.type;
40
+ delete referenceConfig?.visibility;
52
41
 
42
+ // Get the metadata for the referenced view
53
43
  const viewMetadata = inPConn.getReferencedView();
54
44
 
45
+ // Return null if view metadata is not found
55
46
  if (!viewMetadata) {
56
47
  console.log('View not found ', inPConn.getComponentConfig());
57
48
  return null;
58
49
  }
59
50
 
60
- // If we get here, we have metadata for a View component...
61
- // const referencedComponentName = viewMetadata.type;
62
-
51
+ // Create the view object by merging metadata with reference config
63
52
  const viewObject = {
64
53
  ...viewMetadata,
65
54
  config: {
@@ -68,23 +57,31 @@ export class ReferenceComponent {
68
57
  }
69
58
  };
70
59
 
60
+ // Resolve configuration properties
61
+ const resolvedConfigProps = inPConn.resolveConfigProps(inPConn.getConfigProps());
62
+ const { visibility = true, context, readOnly = false, displayMode = '' } = resolvedConfigProps;
63
+
64
+ // Log debug information if logging is enabled
71
65
  if (ReferenceComponent.bLogging) {
72
- console.log(`Reference: about to call createComponent with pageReference: context: ${theResolvedConfigProps.context}`);
66
+ console.log(`Reference: about to call createComponent with pageReference: context: ${inPConn.getContextName()}`);
73
67
  }
74
68
 
69
+ // Create the component with the right context
75
70
  const viewComponent = inPConn.createComponent(viewObject, null, null, {
76
- pageReference: theResolvedConfigProps.context
71
+ pageReference: context && context.startsWith('@CLASS') ? '' : context
77
72
  });
78
73
 
79
- // updating the referencedComponent should trigger a render
74
+ // Get the PConnect object from the created component
80
75
  const newCompPConnect = viewComponent.getPConnect();
81
76
 
77
+ // Set inherited configuration on the new component
82
78
  newCompPConnect.setInheritedConfig({
83
79
  ...referenceConfig,
84
- readOnly: theResolvedConfigProps.readOnly ? theResolvedConfigProps.readOnly : false,
85
- displayMode: theResolvedConfigProps.displayMode ? theResolvedConfigProps.displayMode : null
80
+ readOnly,
81
+ displayMode
86
82
  });
87
83
 
84
+ // Log debug information if logging is enabled
88
85
  if (ReferenceComponent.bLogging) {
89
86
  console.log(
90
87
  `Angular Reference component: createFullReferencedViewFromRef -> newCompPConnect configProps: ${JSON.stringify(
@@ -93,73 +90,63 @@ export class ReferenceComponent {
93
90
  );
94
91
  }
95
92
 
96
- return newCompPConnect;
93
+ // Return the component if it should be visible, otherwise null
94
+ return visibility !== false ? newCompPConnect : null;
97
95
  }
98
96
 
99
- // STATIC method that other components can call to normalize
100
- // a pConn object that might be a 'reference'. If the incoming
101
- // pConn is a reference, return its dereferenced View PConnect's
102
- // getPConnect. Otherwise, return the passed in pConn unchanged
103
- // inPConn = a PConn object (ex: { getPConnect()} )
104
- static normalizePConn(inPConn: any) {
105
- // debugger;
106
-
107
- let returnObj = false;
108
- let thePConnType = '';
109
-
110
- if (inPConn.getPConnect) {
111
- // inPConn is an object (ex: { getPConnect()} ), so we want to return
112
- // any referenced view as the object containing the
113
- // the getPConnect function
114
- returnObj = true;
115
- thePConnType = inPConn.getPConnect().getComponentName();
116
- } else {
117
- // inPConn is an object with the PConnect function, so we want
118
- // to return any referenced view as the object containing the
119
- // the c11n function
120
- returnObj = false;
121
- thePConnType = inPConn.getComponentName();
97
+ /**
98
+ * Normalizes a PConn object that might be a 'reference'.
99
+ * If the incoming PConn is a reference, returns its dereferenced View.
100
+ * Otherwise, returns the passed in PConn unchanged.
101
+ *
102
+ * @param inPConn - A PConn object (ex: { getPConnect() } or direct PConnect)
103
+ * @returns The normalized PConn object with references resolved
104
+ */
105
+ static normalizePConn(inPConn: any): any {
106
+ // Early return for null or undefined input
107
+ if (!inPConn) {
108
+ return inPConn;
122
109
  }
123
110
 
124
- if (thePConnType === 'reference') {
125
- if (returnObj) {
126
- // WAS...
127
- // const theRefViewPConn = inPConn.getPConnect().getReferencedViewPConnect(true);
128
- // Now: ALWAYS calling createFullReferencedViewFromRef to have options, PageReference, etc.
129
- // set correctly in the C11nEnv (PConnect) object
130
- // debugger;
131
- let theRefViewPConn = this.createFullReferencedViewFromRef(inPConn.getPConnect());
132
- // now return its PConnect
133
- theRefViewPConn = theRefViewPConn.getComponent();
134
-
135
- // const theFullReference = theRefViewPConn.getPConnect().getFullReference();
136
- // console.log(`theFullReference: ${theFullReference}`);
137
-
138
- return theRefViewPConn;
111
+ // Determine if we have an object with getPConnect method or direct PConnect
112
+ const hasGetPConnectMethod = !!inPConn.getPConnect;
113
+
114
+ // Get the component name in the appropriate way based on the object type
115
+ const componentName = hasGetPConnectMethod ? inPConn.getPConnect().getComponentName() : inPConn.getComponentName();
116
+
117
+ // Only process if this is a reference component
118
+ if (componentName === 'reference') {
119
+ if (hasGetPConnectMethod) {
120
+ // For objects with getPConnect method, get the referenced view and its component
121
+ const refViewPConn = this.createFullReferencedViewFromRef(inPConn.getPConnect());
122
+ return refViewPConn?.getComponent();
139
123
  }
140
- // console.log(`created theFullRefView full reference: ${theFullRefView.getFullReference()}`);
141
- // debugger;
142
124
 
125
+ // For direct PConnect objects, just create the referenced view
143
126
  return this.createFullReferencedViewFromRef(inPConn);
144
127
  }
128
+
129
+ // Not a reference component, return unchanged
145
130
  return inPConn;
146
131
  }
147
132
 
148
- // STATIC method that other components can call to normalize
149
- // an array of pConn objects where any of the children might
150
- // be a 'reference'. The array returns an array of children
151
- // where any 'reference' is replaced with its ReferencedView
152
- // inPConnArray is an array of PConn objects or functions.
153
- // Its value is passed to normalizePConn
154
-
155
- static normalizePConnArray(inPConnArray: any) {
156
- if (!(inPConnArray?.length > 0)) {
157
- // null or empty array, return what was passed in
158
- return inPConnArray;
133
+ /**
134
+ * Normalizes an array of PConn objects by replacing any 'reference' components
135
+ * with their referenced views.
136
+ *
137
+ * @param inPConnArray - Array of PConn objects to normalize
138
+ * @returns Normalized array with references resolved, or empty array if input is invalid
139
+ */
140
+ static normalizePConnArray(inPConnArray: any[]): any[] {
141
+ // Handle null, undefined, or empty array case
142
+ if (!inPConnArray?.length) {
143
+ return inPConnArray || [];
159
144
  }
160
145
 
161
- return inPConnArray.map(child => {
162
- return ReferenceComponent.normalizePConn(child);
163
- });
146
+ // Process array: normalize each item and filter out any null/undefined results
147
+ const normalizedArray = inPConnArray.map(child => ReferenceComponent.normalizePConn(child)).filter(Boolean);
148
+
149
+ // Ensure we always return an array (even if filter removes all items)
150
+ return normalizedArray || [];
164
151
  }
165
152
  }
@@ -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>
@@ -1,8 +1,9 @@
1
- import { Component, OnInit, Input, NgZone, forwardRef, OnDestroy } from '@angular/core';
1
+ import { Component, OnInit, Input, NgZone, forwardRef, OnDestroy, inject } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
4
4
  import { interval, Subscription } from 'rxjs';
5
5
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
6
+ import { ServerConfigService } from '@pega/angular-sdk-components';
6
7
  import { ProgressSpinnerService } from '@pega/angular-sdk-components';
7
8
  import { ReferenceComponent } from '@pega/angular-sdk-components';
8
9
  import { PreviewViewContainerComponent } from '@pega/angular-sdk-components';
@@ -37,6 +38,8 @@ export class RootContainerComponent implements OnInit, OnDestroy {
37
38
  @Input() displayOnlyFA$: boolean;
38
39
  @Input() isMashup$: boolean;
39
40
 
41
+ scService = inject(ServerConfigService);
42
+
40
43
  // For interaction with AngularPConnect
41
44
  angularPConnectData: AngularPConnectData = {};
42
45
 
@@ -62,8 +65,6 @@ export class RootContainerComponent implements OnInit, OnDestroy {
62
65
  ) {}
63
66
 
64
67
  ngOnInit(): void {
65
- const myContext = 'app';
66
-
67
68
  const { containers } = PCore.getStore().getState();
68
69
  const items = Object.keys(containers).filter(item => item.includes('root'));
69
70
 
@@ -84,24 +85,11 @@ export class RootContainerComponent implements OnInit, OnDestroy {
84
85
 
85
86
  this.pvConn$ = configObjPreview.getPConnect();
86
87
 
87
- const configObjModal = PCore.createPConnect({
88
- meta: {
89
- type: 'ModalViewContainer',
90
- config: {
91
- name: 'modal'
92
- }
93
- },
94
- options: {
95
- pageReference: 'pyPortal',
96
- context: myContext
97
- }
98
- });
88
+ this.configureModalContainer();
99
89
 
100
90
  // clear out hasViewContainer
101
91
  sessionStorage.setItem('hasViewContainer', 'false');
102
92
 
103
- this.mConn$ = configObjModal.getPConnect();
104
-
105
93
  // First thing in initialization is registering and subscribing to the AngularPConnect service
106
94
  this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
107
95
 
@@ -128,16 +116,6 @@ export class RootContainerComponent implements OnInit, OnDestroy {
128
116
  }
129
117
  }
130
118
 
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
119
  updateSelf() {
142
120
  // need to call this.getCurrentCompleteProps (not this.thePConn.getConfigProps)
143
121
  // to get full set of props that affect this component in Redux
@@ -191,6 +169,25 @@ export class RootContainerComponent implements OnInit, OnDestroy {
191
169
  }
192
170
  }
193
171
 
172
+ async configureModalContainer() {
173
+ const sdkConfig = await this.scService.getSdkConfig();
174
+ const showModalsInEmbeddedMode = sdkConfig.serverConfig.showModalsInEmbeddedMode;
175
+
176
+ if (!this.displayOnlyFA$ || showModalsInEmbeddedMode) {
177
+ const configObjModal = PCore.createPConnect({
178
+ meta: {
179
+ type: 'ModalViewContainer',
180
+ config: {
181
+ name: 'modal'
182
+ }
183
+ },
184
+ options
185
+ });
186
+
187
+ this.mConn$ = configObjModal.getPConnect();
188
+ }
189
+ }
190
+
194
191
  generateViewContainerForNoPortal() {
195
192
  // bootstrap loadMashup resolves to here
196
193
  const arChildren = this.pConn$.getChildren() as any[];
@@ -1,10 +1,16 @@
1
1
  import { Directive, OnDestroy } from '@angular/core';
2
+ import { AngularPConnectData } from '@pega/angular-sdk-components';
2
3
 
3
4
  @Directive()
4
5
  export class FormTemplateBase implements OnDestroy {
5
6
  pConn$: any;
7
+ angularPConnectData: AngularPConnectData;
6
8
 
7
9
  ngOnDestroy(): void {
8
10
  PCore.getContextTreeManager().removeContextTreeNode(this.pConn$.getContextName());
11
+
12
+ if (this.angularPConnectData?.unsubscribeFn) {
13
+ this.angularPConnectData.unsubscribeFn();
14
+ }
9
15
  }
10
16
  }
@@ -14,7 +14,7 @@
14
14
  <button mat-raised-button color="primary" (click)="onConfirmViewClose()">Done</button>
15
15
  </div>
16
16
  </div>
17
- <div *ngIf="toDoList?.length > 0">
17
+ <div *ngIf="!showConfirmView && toDoList?.length > 0">
18
18
  <component-mapper
19
19
  name="Todo"
20
20
  [props]="{ pConn$, datasource$: { source: toDoList }, headerText$: 'Tasks', type$: CONSTS.TODO, isConfirm: true }"
@@ -1,11 +1,23 @@
1
1
  import { Component, OnInit, Input, forwardRef } from '@angular/core';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import { FormGroup } from '@angular/forms';
4
+ import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
4
5
  import { ReferenceComponent } 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
  import { FormTemplateBase } from '@pega/angular-sdk-components';
8
9
 
10
+ function areViewsChanged(oldViews: any[], newViews: any[]): boolean {
11
+ if (oldViews?.length !== newViews?.length) {
12
+ return true;
13
+ }
14
+
15
+ return !oldViews?.every((oldView, index) => {
16
+ const newView = newViews[index];
17
+ return oldView.getPConnect().viewName === newView.getPConnect().viewName;
18
+ });
19
+ }
20
+
9
21
  interface DefaultFormProps {
10
22
  // If any, enter additional props that only exist on this component
11
23
  NumCols: string;
@@ -23,15 +35,32 @@ export class DefaultFormComponent extends FormTemplateBase implements OnInit {
23
35
  @Input() override pConn$: typeof PConnect;
24
36
  @Input() formGroup$: FormGroup;
25
37
 
38
+ // Used with AngularPConnect
39
+ override angularPConnectData: AngularPConnectData = {};
40
+
26
41
  arChildren$: any[];
27
42
  divClass$: string;
28
43
  instructions: string;
29
44
 
30
- constructor(private templateUtils: TemplateUtils) {
45
+ constructor(
46
+ private angularPConnect: AngularPConnectService,
47
+ private templateUtils: TemplateUtils
48
+ ) {
31
49
  super();
32
50
  }
33
51
 
34
52
  ngOnInit(): void {
53
+ // First thing in initialization is registering and subscribing to the AngularPConnect service
54
+ this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
55
+
56
+ this.updateSelf();
57
+ }
58
+
59
+ onStateChange() {
60
+ this.updateSelf();
61
+ }
62
+
63
+ updateSelf() {
35
64
  const configProps = this.pConn$.getConfigProps() as DefaultFormProps;
36
65
  const kids = this.pConn$.getChildren();
37
66
  this.instructions = this.templateUtils.getInstructions(this.pConn$, configProps?.instructions);
@@ -55,6 +84,10 @@ export class DefaultFormComponent extends FormTemplateBase implements OnInit {
55
84
  // repoint children before getting templateArray
56
85
  // Children may contain 'reference' component, so we need to
57
86
  // normalize them
58
- this.arChildren$ = ReferenceComponent.normalizePConnArray(kids[0].getPConnect().getChildren());
87
+ const children = ReferenceComponent.normalizePConnArray(kids[0].getPConnect().getChildren());
88
+
89
+ if (areViewsChanged(this.arChildren$, children)) {
90
+ this.arChildren$ = children;
91
+ }
59
92
  }
60
93
  }
@@ -1,5 +1,5 @@
1
1
  <div id="field-group">
2
- <h3 *ngIf="showLabel$" className="label" style="font-weight: bold">
2
+ <h3 *ngIf="showLabel$" class="field-group-template-header" style="font-weight: bold">
3
3
  {{ label$ }}
4
4
  </h3>
5
5
  <div *ngIf="readonlyMode; else editable">
@@ -11,23 +11,23 @@
11
11
  </div>
12
12
  <ng-template #editable>
13
13
  <div *ngIf="children && children.length > 0">
14
- <div *ngFor="let kid of children; let i = index">
14
+ <div class="field-group-template-item" *ngFor="let child of children; let i = index">
15
15
  <div class="header-div">
16
16
  <div style="width: 80%">
17
- <b>{{ kid.name }}</b>
17
+ <b>{{ child.name }}</b>
18
18
  </div>
19
- <div *ngIf="allowAddEdit !== false" style="width: 20%; text-align: right">
19
+ <div *ngIf="allowDelete && child.allowRowDelete" style="width: 20%; text-align: right">
20
20
  <button id="delete-button" mat-icon-button (click)="deleteFieldGroupItem(i)">
21
21
  <img class="psdk-utility-card-action-svg-icon" src="{{ menuIconOverride$ }}" />
22
22
  </button>
23
23
  </div>
24
24
  </div>
25
25
 
26
- <div *ngIf="kid.children.getPConnect().getRawMetadata().type.toLowerCase() == 'region'">
27
- <component-mapper name="Region" [props]="{ pConn$: kid.children.getPConnect(), formGroup$ }"></component-mapper>
26
+ <div *ngIf="child.children.getPConnect().getRawMetadata().type.toLowerCase() == 'region'">
27
+ <component-mapper name="Region" [props]="{ pConn$: child.children.getPConnect(), formGroup$ }"></component-mapper>
28
28
  </div>
29
29
  </div>
30
- <button *ngIf="allowAddEdit !== false" mat-button color="primary" style="font-size: 16px" (click)="addFieldGroupItem()">+ Add</button>
31
30
  </div>
31
+ <button *ngIf="allowAdd" mat-button color="primary" style="font-size: 16px" (click)="addFieldGroupItem()">{{ getAddBtnLabel() }}</button>
32
32
  </ng-template>
33
33
  </div>
@@ -6,3 +6,11 @@
6
6
  display: flex;
7
7
  align-items: center;
8
8
  }
9
+
10
+ .field-group-template-header {
11
+ margin-left: 0;
12
+ }
13
+
14
+ .field-group-template-item {
15
+ padding-block: 1rem;
16
+ }