@pega/angular-sdk-overrides 0.25.15 → 0.26.2

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 (86) hide show
  1. package/lib/designSystemExtension/alert/alert.component.html +4 -1
  2. package/lib/designSystemExtension/alert/alert.component.scss +9 -10
  3. package/lib/designSystemExtension/alert/alert.component.ts +6 -2
  4. package/lib/designSystemExtension/material-details-fields/material-details-fields.component.html +30 -21
  5. package/lib/designSystemExtension/operator/operator.component.ts +2 -1
  6. package/lib/designSystemExtension/rich-text-editor/rich-text-editor.component.html +104 -10
  7. package/lib/designSystemExtension/rich-text-editor/rich-text-editor.component.scss +141 -1
  8. package/lib/designSystemExtension/rich-text-editor/rich-text-editor.component.ts +224 -72
  9. package/lib/field/auto-complete/auto-complete.component.html +2 -1
  10. package/lib/field/auto-complete/auto-complete.component.ts +2 -0
  11. package/lib/field/check-box/check-box.component.html +4 -2
  12. package/lib/field/check-box/check-box.component.ts +10 -1
  13. package/lib/field/currency/currency.component.html +2 -1
  14. package/lib/field/currency/currency.component.ts +10 -1
  15. package/lib/field/date/date.component.html +2 -1
  16. package/lib/field/date/date.component.ts +2 -0
  17. package/lib/field/date-time/date-time.component.html +2 -1
  18. package/lib/field/date-time/date-time.component.scss +46 -40
  19. package/lib/field/date-time/date-time.component.ts +2 -0
  20. package/lib/field/decimal/decimal.component.html +2 -1
  21. package/lib/field/decimal/decimal.component.ts +2 -0
  22. package/lib/field/dropdown/dropdown.component.html +2 -1
  23. package/lib/field/dropdown/dropdown.component.ts +10 -1
  24. package/lib/field/email/email.component.html +2 -1
  25. package/lib/field/email/email.component.ts +2 -2
  26. package/lib/field/embedded-data-multi/embedded-data-multi.component.html +3 -0
  27. package/lib/field/embedded-data-multi/embedded-data-multi.component.scss +0 -0
  28. package/lib/field/embedded-data-multi/embedded-data-multi.component.ts +173 -0
  29. package/lib/field/field.base.ts +27 -1
  30. package/lib/field/integer/integer.component.html +2 -1
  31. package/lib/field/integer/integer.component.ts +4 -2
  32. package/lib/field/location/location.component.html +2 -1
  33. package/lib/field/location/location.component.ts +3 -1
  34. package/lib/field/multiselect/multiselect.component.html +1 -1
  35. package/lib/field/multiselect/multiselect.component.ts +22 -3
  36. package/lib/field/multiselect/utils.ts +5 -3
  37. package/lib/field/object-reference/object-reference.component.html +30 -15
  38. package/lib/field/object-reference/object-reference.component.ts +819 -94
  39. package/lib/field/percentage/percentage.component.html +2 -1
  40. package/lib/field/percentage/percentage.component.ts +10 -1
  41. package/lib/field/phone/phone.component.html +2 -1
  42. package/lib/field/phone/phone.component.ts +2 -1
  43. package/lib/field/radio-buttons/radio-buttons.component.html +2 -1
  44. package/lib/field/radio-buttons/radio-buttons.component.ts +10 -1
  45. package/lib/field/rich-text/rich-text.component.scss +1 -166
  46. package/lib/field/rich-text/rich-text.component.ts +1 -1
  47. package/lib/field/selectable-card/selectable-card.component.html +1 -0
  48. package/lib/field/selectable-card/selectable-card.component.ts +31 -16
  49. package/lib/field/semantic-link/semantic-link.component.ts +9 -5
  50. package/lib/field/text-area/text-area.component.html +2 -1
  51. package/lib/field/text-area/text-area.component.ts +2 -1
  52. package/lib/field/text-input/text-input.component.html +2 -1
  53. package/lib/field/text-input/text-input.component.ts +2 -1
  54. package/lib/field/time/time.component.html +2 -1
  55. package/lib/field/time/time.component.ts +2 -1
  56. package/lib/field/url/url.component.html +2 -1
  57. package/lib/field/url/url.component.ts +2 -1
  58. package/lib/field/user-reference/user-reference.component.html +4 -2
  59. package/lib/field/user-reference/user-reference.component.ts +10 -5
  60. package/lib/infra/Containers/flow-container/flow-container.component.ts +35 -46
  61. package/lib/infra/Containers/modal-view-container/modal-view-container.component.ts +46 -50
  62. package/lib/infra/Containers/view-container/view-container.component.ts +32 -31
  63. package/lib/infra/navbar/navbar.component.ts +33 -35
  64. package/lib/infra/root-container/root-container.component.ts +33 -38
  65. package/lib/template/app-shell/app-shell.component.ts +12 -11
  66. package/lib/template/base/details-template-base.ts +2 -1
  67. package/lib/template/data-reference/data-reference.component.ts +18 -27
  68. package/lib/template/data-reference/search-form/search-form.component.ts +7 -1
  69. package/lib/template/default-form/default-form.component.html +19 -3
  70. package/lib/template/default-form/default-form.component.ts +13 -3
  71. package/lib/template/simple-table/simple-table.component.ts +6 -0
  72. package/lib/template/simple-table-manual/helpers.ts +5 -5
  73. package/lib/template/simple-table-manual/simple-table-manual.component.html +29 -11
  74. package/lib/template/simple-table-manual/simple-table-manual.component.scss +4 -2
  75. package/lib/template/simple-table-manual/simple-table-manual.component.ts +82 -24
  76. package/lib/template/single-reference-readonly/single-reference-readonly.component.html +1 -1
  77. package/lib/template/single-reference-readonly/single-reference-readonly.component.scss +4 -0
  78. package/lib/template/single-reference-readonly/single-reference-readonly.component.ts +4 -4
  79. package/lib/template/wss-nav-bar/wss-nav-bar.component.ts +18 -20
  80. package/lib/widget/attachment/AttachmentUtils.ts +18 -10
  81. package/lib/widget/attachment/attachment.component.html +16 -6
  82. package/lib/widget/attachment/attachment.component.ts +12 -2
  83. package/lib/widget/case-history/case-history.component.ts +6 -2
  84. package/lib/widget/file-utility/file-utility.component.ts +25 -29
  85. package/lib/widget/todo/todo.component.ts +7 -2
  86. package/package.json +1 -1
@@ -4,7 +4,19 @@ import { FormGroup } from '@angular/forms';
4
4
  import { ComponentMetadataConfig } from '@pega/pcore-pconnect-typedefs/interpreter/types';
5
5
  import { AngularPConnectData, AngularPConnectService } from '@pega/angular-sdk-components';
6
6
  import { ComponentMapperComponent } from '@pega/angular-sdk-components';
7
- import { generateColumns, getDataRelationshipContextFromKey } from '@pega/angular-sdk-components';
7
+ import {
8
+ SELECTION_MODE,
9
+ SIMPLE_TABLE_MANUAL_READONLY,
10
+ generateColumns,
11
+ addCompositeKeysToConfig,
12
+ getDataRelationshipContextFromKey,
13
+ generateDetailsDisplay,
14
+ createNewRecord,
15
+ getAdditionalInfo,
16
+ camelCase
17
+ } from '@pega/angular-sdk-components';
18
+ import { componentCachePersistUtils, getMappedKey } from '@pega/angular-sdk-components';
19
+ import { DataReferenceAdvancedSearchService } from '@pega/angular-sdk-components';
8
20
  import { PConnFieldProps } from '@pega/angular-sdk-components';
9
21
 
10
22
  interface ObjectReferenceProps extends PConnFieldProps {
@@ -14,8 +26,17 @@ interface ObjectReferenceProps extends PConnFieldProps {
14
26
  mode: string;
15
27
  targetObjectType: any;
16
28
  allowAndPersistChangesInReviewMode: boolean;
29
+ allowCreatingRecords?: boolean;
30
+ linkReference?: boolean;
31
+ matchPosition?: string;
32
+ additionalFields?: any;
17
33
  }
18
34
 
35
+ /**
36
+ * Rendering modes for the template
37
+ */
38
+ type RenderMode = 'singleReferenceReadonly' | 'multiReferenceReadonly' | 'semanticLink' | 'searchAndSelect' | 'dynamicComponent';
39
+
19
40
  @Component({
20
41
  selector: 'app-object-reference',
21
42
  imports: [CommonModule, forwardRef(() => ComponentMapperComponent)],
@@ -25,20 +46,38 @@ interface ObjectReferenceProps extends PConnFieldProps {
25
46
  export class ObjectReferenceComponent implements OnInit, OnDestroy {
26
47
  @Input() pConn$: typeof PConnect;
27
48
  @Input() formGroup$: FormGroup;
49
+ @Input() isDetails$ = false;
28
50
 
29
51
  angularPConnectData: AngularPConnectData = {};
30
52
  configProps: ObjectReferenceProps;
31
- value: { [key: string]: any };
32
53
  readOnly: boolean;
33
- isForm: boolean;
34
54
  type: string;
35
55
  isDisplayModeEnabled: boolean;
36
56
  canBeChangedInReviewMode: boolean;
37
57
  newComponentName: string;
38
58
  newPconn: typeof PConnect;
39
59
  rawViewMetadata: ComponentMetadataConfig | undefined;
60
+ dataRelationshipContext: string | null = null;
61
+
62
+ // Rendering mode
63
+ renderMode: RenderMode = 'dynamicComponent';
64
+
65
+ // Whether the dynamic component supports @Output() onRecordChange binding
66
+ useOutputEvents = false;
67
+
68
+ // Visibility flag — prevents rendering when platform sets visibility to false
69
+ bVisible$ = true;
70
+
71
+ // For SearchAndSelect
72
+ searchSelectCacheKey: string;
73
+
74
+ // For parameterized CheckboxGroup datasource
75
+ parameterizedDataSource: any[] = [];
40
76
 
41
- constructor(private angularPConnect: AngularPConnectService) {}
77
+ constructor(
78
+ private angularPConnect: AngularPConnectService,
79
+ private dataRefAdvancedSearchService: DataReferenceAdvancedSearchService
80
+ ) {}
42
81
 
43
82
  ngOnInit() {
44
83
  this.angularPConnectData = this.angularPConnect.registerAndSubscribeComponent(this, this.onStateChange);
@@ -63,85 +102,263 @@ export class ObjectReferenceComponent implements OnInit, OnDestroy {
63
102
  }
64
103
 
65
104
  updateSelf() {
105
+ this.useOutputEvents = false;
66
106
  this.configProps = this.pConn$.resolveConfigProps(this.pConn$.getConfigProps()) as ObjectReferenceProps;
107
+
108
+ const { visibility = true } = this.configProps;
109
+ this.bVisible$ = visibility !== false;
67
110
  const {
68
- displayMode,
69
111
  allowAndPersistChangesInReviewMode: editableInReview = false,
112
+ allowCreatingRecords,
70
113
  targetObjectType,
71
- mode,
114
+ mode = '',
72
115
  parameters,
73
- hideLabel,
74
- inline,
75
- showPromotedFilters
116
+ hideLabel = false,
117
+ inline = false,
118
+ showPromotedFilters = false,
119
+ linkReference,
120
+ matchPosition = 'contains'
76
121
  } = this.configProps;
77
122
 
78
- const referenceType: string = targetObjectType === 'case' ? 'Case' : 'Data';
123
+ let displayMode = this.configProps.displayMode ?? '';
124
+
125
+ const referenceType: string = targetObjectType?.toLowerCase() === 'case' ? 'Case' : 'Data';
79
126
  this.rawViewMetadata = this.pConn$.getRawMetadata();
80
- const refFieldMetadata = this.pConn$.getFieldMetadata(this.rawViewMetadata?.config?.value?.split('.', 2)[1] ?? '');
81
- const propsToUse = { ...this.pConn$.getInheritedProps(), ...this.configProps };
127
+ const rawConfig = this.rawViewMetadata?.config as any;
128
+
129
+ const refFieldMetadata = this.pConn$.getFieldMetadata(
130
+ rawConfig?.mode === SELECTION_MODE.SINGLE ? rawConfig?.value?.split('.', 2)[1] : rawConfig?.pagelistValue?.substring(4)
131
+ );
132
+
133
+ const propsToUse: any = { ...this.pConn$.getInheritedProps(), ...this.configProps };
134
+ if (!propsToUse.label) {
135
+ propsToUse.label = this.configProps.label;
136
+ }
137
+
138
+ this.normalizeComboboxType(rawConfig, mode);
139
+
140
+ if (rawConfig?.parameters && ['CheckboxGroup'].includes(rawConfig.componentType)) {
141
+ this.loadParameterizedDataSource(rawConfig, parameters ?? {});
142
+ }
143
+
144
+ displayMode = this.resolveDisplayMode(rawConfig, displayMode, mode);
82
145
 
83
146
  this.isDisplayModeEnabled = displayMode === 'DISPLAY_ONLY';
84
- this.type = this.getComponentType();
85
- this.canBeChangedInReviewMode = editableInReview && ['Autocomplete', 'Dropdown'].includes(this.type);
86
-
87
- if (this.type === 'SemanticLink' && !this.canBeChangedInReviewMode) {
88
- const config: any = {
89
- ...this.rawViewMetadata?.config,
90
- primaryField: (this.rawViewMetadata?.config as any).displayField,
91
- caseClass: (this.rawViewMetadata?.config as any).targetObjectClass,
92
- text: (this.rawViewMetadata?.config as any).displayField,
93
- caseID: (this.rawViewMetadata?.config as any).value,
94
- contextPage: `@P .${(this.rawViewMetadata?.config as any).displayField ? getDataRelationshipContextFromKey((this.rawViewMetadata?.config as any).displayField) : null}`,
95
- resourceParams: { workID: (this.rawViewMetadata?.config as any).value },
96
- resourcePayload: { caseClassName: (this.rawViewMetadata?.config as any).targetObjectClass }
97
- };
98
- this.createSemanticLinkPConnect(config, displayMode ?? '', referenceType, hideLabel);
147
+ this.type = rawConfig?.componentType;
148
+ this.dataRelationshipContext = rawConfig?.displayField ? getDataRelationshipContextFromKey(rawConfig.displayField) : null;
149
+ this.canBeChangedInReviewMode = editableInReview && ['AutoComplete', 'Dropdown'].includes(this.type);
150
+
151
+ if (this.handleReadOnlyMode(rawConfig, mode)) {
99
152
  return;
100
153
  }
101
154
 
102
- if (this.type !== 'SemanticLink' && !this.isDisplayModeEnabled) {
103
- const config: any = { ...this.rawViewMetadata?.config };
104
- generateColumns(config, this.pConn$, referenceType);
105
- config.deferDatasource = true;
106
- config.listType = 'datapage';
107
- if (['Dropdown', 'AutoComplete'].includes(this.type) && !config.placeholder) {
108
- config.placeholder = '@L Select...';
109
- }
110
- config.showPromotedFilters = showPromotedFilters;
111
- if (!this.canBeChangedInReviewMode) {
112
- config.displayMode = displayMode;
155
+ this.routeToEditableComponent(
156
+ rawConfig,
157
+ mode,
158
+ refFieldMetadata,
159
+ propsToUse,
160
+ referenceType,
161
+ displayMode,
162
+ parameters,
163
+ hideLabel,
164
+ inline,
165
+ showPromotedFilters,
166
+ matchPosition,
167
+ linkReference,
168
+ targetObjectType,
169
+ allowCreatingRecords
170
+ );
171
+ }
172
+
173
+ private normalizeComboboxType(rawConfig: any, mode: string): void {
174
+ if (rawConfig?.componentType === 'Combobox') {
175
+ rawConfig.componentType = mode === SELECTION_MODE.MULTI ? 'Multiselect' : 'AutoComplete';
176
+ }
177
+ }
178
+
179
+ private resolveDisplayMode(rawConfig: any, displayMode: string, mode: string): string {
180
+ if (displayMode === 'DISPLAY_ONLY' || !this.configProps.readOnly) {
181
+ return displayMode;
182
+ }
183
+ if (rawConfig?.componentType === 'Multiselect') {
184
+ rawConfig.componentType = 'SemanticLink';
185
+ return displayMode;
186
+ }
187
+ if (mode === 'readonly-single') {
188
+ return this.configProps.displayMode ?? displayMode;
189
+ }
190
+ return 'DISPLAY_ONLY';
191
+ }
192
+
193
+ private handleReadOnlyMode(rawConfig: any, mode: string): boolean {
194
+ const isReadOnlyOrSemanticLink = (this.configProps.readOnly || this.type === 'SemanticLink') && !this.canBeChangedInReviewMode;
195
+ if (isReadOnlyOrSemanticLink) {
196
+ if (mode !== 'readonly-multi') {
197
+ this.buildSingleReferenceReadonly(rawConfig);
198
+ } else {
199
+ this.buildMultiReferenceReadonly();
113
200
  }
114
- config.parameters = parameters;
201
+ return true;
202
+ }
203
+ if (this.isDisplayModeEnabled && !this.canBeChangedInReviewMode) {
204
+ this.buildSingleReferenceReadonly(rawConfig);
205
+ return true;
206
+ }
207
+ return false;
208
+ }
115
209
 
116
- this.createOtherComponentPConnect(config, propsToUse, mode, refFieldMetadata, referenceType, hideLabel, inline);
210
+ private resolveCreatePermissions(rawConfig: any, allowCreatingRecords: boolean | undefined) {
211
+ const { disableStartingFieldsForReference = false } = (PCore as any).getEnvironmentInfo().environmentInfoObject?.features?.form || {};
212
+ const contextClass = rawConfig.targetObjectClass;
213
+ const formFeaturesAvailable = (PCore as any).getEnvironmentInfo().environmentInfoObject?.features?.form;
214
+ const createAuthoringEnabled = allowCreatingRecords ?? formFeaturesAvailable?.isCreateNewReferenceEnabled;
215
+ const userHasCreateAccess = formFeaturesAvailable
216
+ ? formFeaturesAvailable.isCreateNewReferenceEnabled && PCore.getAccessPrivilege().hasCreateAccess(contextClass)
217
+ : PCore.getAccessPrivilege().hasCreateAccess(contextClass);
218
+ return {
219
+ isCreateNewReferenceEnabled: createAuthoringEnabled && userHasCreateAccess,
220
+ disableStartingFieldsForReference,
221
+ contextClass
222
+ };
223
+ }
224
+
225
+ private routeToEditableComponent(
226
+ rawConfig: any,
227
+ mode: string,
228
+ refFieldMetadata: any,
229
+ propsToUse: any,
230
+ referenceType: string,
231
+ displayMode: string,
232
+ parameters: any,
233
+ hideLabel: boolean,
234
+ inline: boolean,
235
+ showPromotedFilters: boolean,
236
+ matchPosition: string,
237
+ linkReference: any,
238
+ targetObjectType: any,
239
+ allowCreatingRecords: boolean | undefined
240
+ ): void {
241
+ if (this.type === 'EmbeddedInsightTable') {
242
+ this.buildEmbeddedInsightTableChild(rawConfig, referenceType, propsToUse);
243
+ this.renderMode = 'dynamicComponent';
244
+ return;
245
+ }
246
+ if (this.type === 'Cards') {
247
+ this.buildCardsChild(rawConfig);
248
+ this.renderMode = 'dynamicComponent';
249
+ return;
117
250
  }
251
+ if (this.type === 'Map') {
252
+ this.buildMapChild(rawConfig, targetObjectType);
253
+ this.renderMode = 'dynamicComponent';
254
+ return;
255
+ }
256
+ if (this.type === 'CheckboxGroup') {
257
+ this.buildCheckboxGroupChild(rawConfig, mode, refFieldMetadata, propsToUse, hideLabel);
258
+ this.renderMode = 'dynamicComponent';
259
+ return;
260
+ }
261
+ if (this.type === 'Table' || this.type === 'SimpleTable') {
262
+ this.buildTableChild(this.type, rawConfig, mode, referenceType, propsToUse);
263
+ this.renderMode = 'dynamicComponent';
264
+ return;
265
+ }
266
+
267
+ generateColumns(rawConfig, this.pConn$, referenceType);
268
+ addCompositeKeysToConfig(rawConfig, this.pConn$);
269
+ rawConfig.deferDatasource = true;
270
+ rawConfig.listType = 'datapage';
271
+ if (['Dropdown', 'AutoComplete'].includes(this.type) && !rawConfig.placeholder) {
272
+ rawConfig.placeholder = '@L Select...';
273
+ }
274
+ rawConfig.showPromotedFilters = showPromotedFilters;
275
+ if (!this.canBeChangedInReviewMode) {
276
+ rawConfig.displayMode = displayMode;
277
+ }
278
+
279
+ const fieldMetaData = this.buildFieldMetaData(rawConfig, parameters);
280
+ const { isCreateNewReferenceEnabled, disableStartingFieldsForReference, contextClass } = this.resolveCreatePermissions(
281
+ rawConfig,
282
+ allowCreatingRecords
283
+ );
284
+
285
+ if (this.type === 'SearchAndSelect') {
286
+ this.buildSearchAndSelectChild(
287
+ rawConfig,
288
+ refFieldMetadata,
289
+ propsToUse,
290
+ referenceType,
291
+ hideLabel,
292
+ inline,
293
+ matchPosition,
294
+ isCreateNewReferenceEnabled,
295
+ disableStartingFieldsForReference
296
+ );
297
+ this.renderMode = 'searchAndSelect';
298
+ return;
299
+ }
300
+ if (this.type === 'Multiselect') {
301
+ this.buildMultiselectChild(
302
+ rawConfig,
303
+ mode,
304
+ refFieldMetadata,
305
+ fieldMetaData,
306
+ propsToUse,
307
+ referenceType,
308
+ hideLabel,
309
+ inline,
310
+ isCreateNewReferenceEnabled,
311
+ disableStartingFieldsForReference,
312
+ contextClass
313
+ );
314
+ this.renderMode = 'dynamicComponent';
315
+ return;
316
+ }
317
+ this.buildDefaultChild(
318
+ rawConfig,
319
+ mode,
320
+ refFieldMetadata,
321
+ fieldMetaData,
322
+ propsToUse,
323
+ referenceType,
324
+ hideLabel,
325
+ inline,
326
+ isCreateNewReferenceEnabled,
327
+ disableStartingFieldsForReference,
328
+ contextClass,
329
+ linkReference
330
+ );
331
+ this.renderMode = 'dynamicComponent';
118
332
  }
119
333
 
120
- onRecordChange(value) {
121
- const caseKey = this.pConn$.getCaseInfo().getKey() ?? '';
122
- const refreshOptions = { autoDetectRefresh: true, propertyName: '' };
123
- refreshOptions.propertyName = this.rawViewMetadata?.config?.value ?? '';
334
+ onRecordChange = event => {
335
+ const pConn = this.pConn$;
336
+ const caseKey = pConn.getCaseInfo().getKey() ?? '';
337
+ const refreshOptions: any = { autoDetectRefresh: true, propertyName: '' };
338
+ refreshOptions.propertyName = (this.rawViewMetadata?.config as any)?.value ?? '';
339
+
340
+ const { allowImplicitRefresh } = (PCore as any).getFieldDefaultUtils().fieldDefaults.DataReference || {};
124
341
 
125
- if (!this.canBeChangedInReviewMode || !this.pConn$.getValue('__currentPageTabViewName')) {
126
- const pgRef = this.pConn$.getPageReference().replace('caseInfo.content', '') ?? '';
342
+ if (!this.canBeChangedInReviewMode || !pConn.getValue('__currentPageTabViewName') || allowImplicitRefresh) {
343
+ const pgRef = pConn.getPageReference().replace('caseInfo.content', '') ?? '';
127
344
  const viewName = this.rawViewMetadata?.name;
128
345
  if (viewName && viewName.length > 0) {
129
- getPConnect().getActionsApi().refreshCaseView(caseKey, viewName, pgRef, refreshOptions);
346
+ pConn.getActionsApi().refreshCaseView(caseKey, viewName, pgRef, refreshOptions);
130
347
  }
131
348
  }
132
349
 
133
- const propValue = value;
350
+ const propValue = event?.id || event?.target?.value || event;
134
351
  const propName =
135
- this.rawViewMetadata?.type === 'SimpleTableSelect' && this.configProps.mode === 'multi'
136
- ? PCore.getAnnotationUtils().getPropertyName(this.rawViewMetadata?.config?.selectionList ?? '')
137
- : PCore.getAnnotationUtils().getPropertyName(this.rawViewMetadata?.config?.value ?? '');
352
+ this.rawViewMetadata?.type === 'SimpleTableSelect' && this.configProps.mode === SELECTION_MODE.MULTI
353
+ ? PCore.getAnnotationUtils().getPropertyName((this.rawViewMetadata?.config as any)?.selectionList ?? '')
354
+ : PCore.getAnnotationUtils().getPropertyName((this.rawViewMetadata?.config as any)?.value ?? '');
138
355
 
139
356
  if (propValue && this.canBeChangedInReviewMode && this.isDisplayModeEnabled) {
140
357
  PCore.getCaseUtils()
141
358
  .getCaseEditLock(caseKey, '')
142
359
  .then(caseResponse => {
143
- const pageTokens = this.pConn$.getPageReference().replace('caseInfo.content', '').split('.');
144
- let curr = {};
360
+ const pageTokens = pConn.getPageReference().replace('caseInfo.content', '').split('.');
361
+ let curr: any = {};
145
362
  const commitData = curr;
146
363
 
147
364
  pageTokens?.forEach(el => {
@@ -151,7 +368,6 @@ export class ObjectReferenceComponent implements OnInit, OnDestroy {
151
368
  }
152
369
  });
153
370
 
154
- // expecting format like {Customer: {pyID:"C-100"}}
155
371
  const propArr = propName.split('.');
156
372
  propArr.forEach((element, idx) => {
157
373
  if (idx + 1 === propArr.length) {
@@ -163,75 +379,584 @@ export class ObjectReferenceComponent implements OnInit, OnDestroy {
163
379
  });
164
380
 
165
381
  PCore.getCaseUtils()
166
- .updateCaseEditFieldsData(caseKey, { [caseKey]: commitData }, caseResponse.headers.etag, this.pConn$?.getContextName() ?? '')
382
+ .updateCaseEditFieldsData(caseKey, { [caseKey]: commitData }, caseResponse.headers.etag, pConn.getContextName() ?? '')
167
383
  .then(response => {
168
- PCore.getContainerUtils().updateParentLastUpdateTime(this.pConn$.getContextName() ?? '', response.data.data.caseInfo.lastUpdateTime);
169
- PCore.getContainerUtils().updateRelatedContextEtag(this.pConn$.getContextName() ?? '', response.headers.etag);
384
+ PCore.getContainerUtils().updateParentLastUpdateTime(pConn.getContextName() ?? '', (response.data as any).data.caseInfo.lastUpdateTime);
385
+ PCore.getContainerUtils().updateRelatedContextEtag(pConn.getContextName() ?? '', response.headers.etag);
170
386
  });
171
387
  });
172
388
  }
389
+ };
390
+
391
+ private loadParameterizedDataSource(rawConfig: any, parameters: any) {
392
+ const { value, key, text } = {
393
+ key: `@P ${rawConfig.selectionKey}`,
394
+ text: `@P ${rawConfig.displayField}`,
395
+ value: `@P ${rawConfig.selectionKey}`
396
+ };
397
+ const refList = rawConfig.referenceList;
398
+ (PCore as any)
399
+ .getDataApiUtils()
400
+ .getData(refList, { dataViewParameters: parameters })
401
+ .then((res: any) => {
402
+ if (res.data.data !== null) {
403
+ this.parameterizedDataSource = res.data.data
404
+ .map((listItem: any) => ({
405
+ key: listItem[key.split(' .', 2)[1]],
406
+ text: listItem[text.split(' .', 2)[1]],
407
+ value: listItem[value.split(' .', 2)[1]]
408
+ }))
409
+ .filter((item: any) => item.key);
410
+ } else {
411
+ this.parameterizedDataSource = [];
412
+ }
413
+ })
414
+ .catch(() => {
415
+ this.parameterizedDataSource = [];
416
+ });
417
+ }
418
+
419
+ private buildFieldMetaData(rawConfig: any, parameters: any) {
420
+ const fieldMetaData: any = {
421
+ datasourceMetadata: { datasource: { parameters: {} } }
422
+ };
423
+ if (rawConfig.parameters) {
424
+ fieldMetaData.datasourceMetadata.datasource.parameters = parameters;
425
+ }
426
+ fieldMetaData.datasourceMetadata.datasource.propertyForDisplayText = rawConfig.datasource?.fields?.text?.startsWith('@P')
427
+ ? rawConfig.datasource.fields.text.substring(3)
428
+ : rawConfig.datasource?.fields?.text;
429
+ fieldMetaData.datasourceMetadata.datasource.propertyForValue = rawConfig.datasource?.fields?.value?.startsWith('@P')
430
+ ? rawConfig.datasource.fields.value.substring(3)
431
+ : rawConfig.datasource?.fields?.value;
432
+ fieldMetaData.datasourceMetadata.datasource.name = rawConfig.referenceList;
433
+ return fieldMetaData;
173
434
  }
174
435
 
175
- private getComponentType(): string {
176
- // componentType is not defined in ComponentMetadataConfig type so using any
177
- return (this.rawViewMetadata?.config as any)?.componentType;
436
+ private buildSingleReferenceReadonly(rawConfig: any) {
437
+ // SingleReferenceReadonly is rendered via component-mapper with pConn$ which internally resolves config
438
+ // Setting properties needed by the child component on config
439
+ rawConfig.primaryField = rawConfig.displayField;
440
+ rawConfig.text = rawConfig.displayField;
441
+ rawConfig.caseClass = rawConfig.targetObjectClass;
442
+ rawConfig.caseID = rawConfig.value;
443
+ rawConfig.contextPage = `@P .${rawConfig.displayField ? getDataRelationshipContextFromKey(rawConfig.displayField) : null}`;
444
+ this.renderMode = 'singleReferenceReadonly';
178
445
  }
179
446
 
180
- private createSemanticLinkPConnect(config: any, displayMode: string, referenceType: string, hideLabel: boolean) {
181
- const semanticLinkConfig = {
182
- ...config,
183
- displayMode,
184
- referenceType,
185
- hideLabel,
186
- dataRelationshipContext: config.displayField ? getDataRelationshipContextFromKey(config.displayField) : null
447
+ private buildMultiReferenceReadonly() {
448
+ this.renderMode = 'multiReferenceReadonly';
449
+ }
450
+
451
+ private buildCardsChild(rawConfig: any) {
452
+ const selectionMode = rawConfig.mode;
453
+ const datasourceKeyField =
454
+ rawConfig.selectionKey || (rawConfig.isCalculated ? '.pzInsKey' : `.${rawConfig.value.trim().split('.').pop()?.trim()}`);
455
+
456
+ const componentMeta = {
457
+ type: selectionMode === 'single' ? 'RadioButtons' : 'Checkbox',
458
+ config: {
459
+ ...rawConfig,
460
+ label: rawConfig.label,
461
+ value: selectionMode === 'single' ? rawConfig.value : undefined,
462
+ referenceList: rawConfig.referenceList,
463
+ contextClass: rawConfig.targetObjectClass,
464
+ referenceType: rawConfig.targetObjectType === 'case' ? 'Case' : 'Data',
465
+ readonlyContextList: selectionMode.includes('multi') ? rawConfig.pagelistValue : undefined,
466
+ ...(selectionMode.includes('multi')
467
+ ? {
468
+ selectionList: rawConfig.pagelistValue.substring(3),
469
+ selectionKey: rawConfig.selectionKey || (rawConfig.isCalculated ? '.pzInsKey' : undefined)
470
+ }
471
+ : { selectionList: rawConfig.contextPage?.substring(3) }),
472
+ selectionMode: selectionMode.includes('multi') ? 'multi' : undefined,
473
+ displayMode: rawConfig.isCalculated ? 'DISPLAY_ONLY' : undefined,
474
+ renderMode: !rawConfig.isCalculated && rawConfig.mode === 'readonly-multi' ? 'ReadOnly' : undefined,
475
+ variant: 'card',
476
+ inlineDisplay: rawConfig.inlineDisplay ?? true,
477
+ hideFieldLabels: rawConfig.hideFieldLabels,
478
+ presets: [
479
+ {
480
+ children: [
481
+ {
482
+ children: rawConfig.secondaryFields,
483
+ name: 'AdditionalDetails',
484
+ type: 'Region'
485
+ }
486
+ ],
487
+ config: {},
488
+ id: 'P_',
489
+ label: '',
490
+ name: 'presets',
491
+ template: 'Cards'
492
+ }
493
+ ],
494
+ datasource: {
495
+ fields: {
496
+ key: `@P ${datasourceKeyField}`,
497
+ text:
498
+ typeof rawConfig.displayField === 'string' && rawConfig.displayField.trim()
499
+ ? `@P .${rawConfig.displayField.trim().split('.').pop()?.trim()}`
500
+ : `@P ${datasourceKeyField}`,
501
+ value: `@P ${datasourceKeyField}`
502
+ },
503
+ filterDownloadedFields: true,
504
+ source: `@DATASOURCE ${rawConfig.referenceList}.pxResults`
505
+ },
506
+ displayAs: 'cards',
507
+ hideLabel: rawConfig.hideLabel,
508
+ imagePosition: rawConfig.imagePosition,
509
+ image: rawConfig.image,
510
+ imageSize: rawConfig.imageSize,
511
+ showImageDescription: rawConfig.showImageDescription,
512
+ imageDescription: rawConfig.imageDescription,
513
+ required: rawConfig.required,
514
+ readOnly: !!rawConfig.isCalculated,
515
+ disabled: rawConfig.disabled,
516
+ labelOption: rawConfig.labelOption,
517
+ primaryField: rawConfig.displayField || datasourceKeyField,
518
+ dataRelationshipContext: rawConfig.displayField ? getDataRelationshipContextFromKey(rawConfig.displayField) : null
519
+ }
187
520
  };
188
521
 
189
- const component = this.pConn$.createComponent({ type: 'SemanticLink', config: semanticLinkConfig }, '', 0, {});
522
+ const component = this.pConn$.createComponent(componentMeta as any, '', 0, {});
523
+ this.newComponentName = component?.getPConnect().getComponentName();
190
524
  this.newPconn = component?.getPConnect();
525
+
526
+ // For multi-mode, pre-set the reference list on the child PConnect so that
527
+ // getListActions() resolves the correct path even if the child's updateSelf()
528
+ // doesn't re-run after a setInput update.
529
+ if (selectionMode.includes('multi') && this.newPconn) {
530
+ const selectionList = rawConfig.pagelistValue.substring(3);
531
+ this.newPconn.setReferenceList(selectionList);
532
+ }
191
533
  }
192
534
 
193
- private createOtherComponentPConnect(
194
- config: any,
195
- propsToUse: any,
196
- mode: string,
535
+ private buildMapChild(rawConfig: any, targetObjectType: any) {
536
+ const displayField = getDataRelationshipContextFromKey(rawConfig.displayField);
537
+ const displayFieldMetadata = this.pConn$.getFieldMetadata(displayField);
538
+
539
+ const componentMeta = {
540
+ type: 'MapView',
541
+ config: {
542
+ contextClass: rawConfig.targetObjectClass,
543
+ displayAs: 'map',
544
+ hideLabel: false,
545
+ label: rawConfig.label,
546
+ referenceType: targetObjectType?.toLowerCase() === 'case' ? 'Case' : 'Data',
547
+ localeReference: rawConfig.localeReference,
548
+ classId: SIMPLE_TABLE_MANUAL_READONLY,
549
+ detailsDisplay: generateDetailsDisplay({
550
+ isCaseType: targetObjectType?.toLowerCase() === 'case',
551
+ fieldForDisplay: displayField,
552
+ fieldNameForKey: rawConfig.selectionKey,
553
+ displayFieldMetadata
554
+ }),
555
+ presets: [
556
+ {
557
+ children: [
558
+ {
559
+ children: [],
560
+ name: 'Columns',
561
+ type: 'Region'
562
+ },
563
+ {
564
+ children: rawConfig.secondaryFields,
565
+ name: 'AdditionalDetails',
566
+ type: 'Region'
567
+ }
568
+ ],
569
+ config: {},
570
+ id: 'P_',
571
+ label: '',
572
+ name: 'presets',
573
+ locationDetails: rawConfig.locationDetails,
574
+ template: 'Map'
575
+ }
576
+ ],
577
+ readonlyContextList: rawConfig.pagelistValue,
578
+ referenceList: rawConfig.pagelistValue,
579
+ renderMode: 'ReadOnly',
580
+ selectionMode: 'multi',
581
+ required: rawConfig.required,
582
+ readOnly: false,
583
+ disabled: rawConfig.disabled,
584
+ visibility: rawConfig.visibility
585
+ }
586
+ };
587
+
588
+ const component = this.pConn$.createComponent(componentMeta as any, '', 0, {});
589
+ this.newComponentName = component?.getPConnect().getComponentName();
590
+ this.newPconn = component?.getPConnect();
591
+ }
592
+
593
+ private buildCheckboxGroupChild(rawConfig: any, mode: string, refFieldMetadata: any, propsToUse: any, hideLabel: boolean) {
594
+ const displayField = rawConfig.displayField;
595
+ const primaryField = displayField?.startsWith('@P') ? displayField?.substring(3) : displayField;
596
+ const readOnly = !(mode === 'multi' || mode === 'single');
597
+ const pageListValueFromConfig = rawConfig.pagelistValue;
598
+ const selectionList = pageListValueFromConfig?.startsWith('@P') ? pageListValueFromConfig?.substring(3) : pageListValueFromConfig;
599
+
600
+ const component = this.pConn$.createComponent(
601
+ {
602
+ type: 'Checkbox',
603
+ config: {
604
+ ...rawConfig,
605
+ contextClass: rawConfig.targetObjectClass,
606
+ datasource: {
607
+ fields: {
608
+ key: `@P ${rawConfig.selectionKey}`,
609
+ text: `@P ${rawConfig.displayField}`,
610
+ value: `@P ${rawConfig.selectionKey}`
611
+ },
612
+ source: !rawConfig.parameters ? `@DATASOURCE ${rawConfig.referenceList}.pxResults` : this.parameterizedDataSource
613
+ },
614
+ descriptors: mode === SELECTION_MODE.SINGLE ? refFieldMetadata?.descriptors : null,
615
+ displayAs: 'checkboxgroup',
616
+ hideLabel,
617
+ inline: rawConfig.inline ?? false,
618
+ label: propsToUse.label,
619
+ primaryField,
620
+ readOnly,
621
+ readonlyContextList: pageListValueFromConfig,
622
+ referenceType: rawConfig.targetObjectType,
623
+ selectionKey: rawConfig.selectionKey,
624
+ selectionList,
625
+ selectionMode: mode,
626
+ disabled: propsToUse.disabled,
627
+ required: propsToUse.required,
628
+ visibility: propsToUse.visibility,
629
+ additionalInfo: refFieldMetadata?.additionalInformation ? { content: refFieldMetadata.additionalInformation } : undefined
630
+ }
631
+ } as any,
632
+ '',
633
+ 0,
634
+ {}
635
+ );
636
+ this.newComponentName = component?.getPConnect().getComponentName();
637
+ this.newPconn = component?.getPConnect();
638
+
639
+ // For multi-mode, pre-set the reference list on the child PConnect so that
640
+ // getListActions() resolves the correct path on every re-render.
641
+ if (mode === 'multi' && this.newPconn && selectionList) {
642
+ this.newPconn.setReferenceList(selectionList);
643
+ }
644
+ }
645
+
646
+ private buildTableChild(type: string, rawConfig: any, mode: string, referenceType: string, propsToUse: any) {
647
+ const presets = [
648
+ {
649
+ children: [{ children: rawConfig.columns, name: 'Columns', type: 'Region' }],
650
+ config: { filterExpression: rawConfig.filterExpression },
651
+ id: 'P_',
652
+ label: '',
653
+ name: 'presets',
654
+ template: 'Table'
655
+ }
656
+ ];
657
+ const tableDisplayAs = camelCase(type);
658
+
659
+ let componentConfig: any;
660
+
661
+ if (mode === 'readonly-multi') {
662
+ componentConfig = {
663
+ type: 'SimpleTableSelect',
664
+ config: {
665
+ contextClass: rawConfig.targetObjectClass,
666
+ defaultRowHeight: rawConfig.defaultRowHeight,
667
+ displayAs: tableDisplayAs,
668
+ hideLabel: false,
669
+ label: propsToUse.label,
670
+ localeReference: rawConfig.localeReference,
671
+ presets,
672
+ readOnly: true,
673
+ readonlyContextList: rawConfig.pagelistValue,
674
+ referenceList: rawConfig.pagelistValue,
675
+ referenceType,
676
+ renderMode: 'ReadOnly',
677
+ rowHeader: rawConfig.rowHeader,
678
+ selectionMode: 'multi',
679
+ required: propsToUse.required,
680
+ visibility: propsToUse.visibility,
681
+ disabled: propsToUse.disabled,
682
+ toggleFieldVisibility: rawConfig.toggleFieldVisibility
683
+ }
684
+ };
685
+ } else if (mode === 'single' || mode === 'multi') {
686
+ const contextPageFromConfig = mode === 'single' ? rawConfig.contextPage : rawConfig.pagelistValue;
687
+ const contextPageValue = contextPageFromConfig?.startsWith('@P') ? contextPageFromConfig?.substring(3) : contextPageFromConfig;
688
+
689
+ componentConfig = {
690
+ type: 'SimpleTableSelect',
691
+ config: {
692
+ ...(mode === 'single' ? { selectionKey: rawConfig.value, value: rawConfig.value } : {}),
693
+ dataRelationshipContext: contextPageValue,
694
+ defaultRowHeight: rawConfig.defaultRowHeight,
695
+ displayAs: tableDisplayAs,
696
+ hideLabel: false,
697
+ inline: false,
698
+ label: propsToUse.label,
699
+ localeReference: rawConfig.localeReference,
700
+ presets,
701
+ readOnly: false,
702
+ referenceList: rawConfig.referenceList,
703
+ referenceType,
704
+ rowHeader: rawConfig.rowHeader,
705
+ parameters: rawConfig.parameters,
706
+ selectionList: contextPageValue,
707
+ selectionMode: mode,
708
+ showPromotedFilters: false,
709
+ required: propsToUse.required,
710
+ visibility: propsToUse.visibility,
711
+ disabled: propsToUse.disabled,
712
+ toggleFieldVisibility: rawConfig.toggleFieldVisibility
713
+ }
714
+ };
715
+ }
716
+
717
+ if (componentConfig) {
718
+ const component = this.pConn$.createComponent(componentConfig, '', 0, {});
719
+ this.newComponentName = component?.getPConnect().getComponentName();
720
+ this.newPconn = component?.getPConnect();
721
+ }
722
+ }
723
+
724
+ private buildSearchAndSelectChild(
725
+ rawConfig: any,
197
726
  refFieldMetadata: any,
727
+ propsToUse: any,
198
728
  referenceType: string,
199
729
  hideLabel: boolean,
200
- inline: boolean
730
+ inline: boolean,
731
+ matchPosition: string,
732
+ isCreateNewReferenceEnabled: boolean,
733
+ disableStartingFieldsForReference: boolean
201
734
  ) {
202
- const fieldMetaData = {
203
- datasourceMetadata: {
204
- datasource: {
205
- parameters: config.parameters ?? {},
206
- propertyForDisplayText: config.datasource?.fields?.text?.substring(3) ?? config.datasource?.fields?.text,
207
- propertyForValue: config.datasource?.fields?.value?.substring(3) ?? config.datasource?.fields?.value,
208
- name: config.referenceList ?? ''
209
- }
210
- }
211
- };
735
+ const selectionMode = rawConfig.mode;
736
+ const firstChildMeta = structuredClone((this.rawViewMetadata as any)?.children?.[0]);
737
+ const pyID = getMappedKey('pyID');
738
+ const additionalInfo = refFieldMetadata?.additionalInformation ? { content: refFieldMetadata.additionalInformation } : undefined;
739
+ const pageListValueFromConfig = rawConfig.pagelistValue;
740
+ const selectionList = pageListValueFromConfig?.startsWith('@P') ? pageListValueFromConfig?.substring(3) : pageListValueFromConfig;
741
+ const contextPageFromConfig = rawConfig.contextPage;
742
+ const unannotatedContextPageFromConfig = contextPageFromConfig?.startsWith('@P') ? contextPageFromConfig?.substring(3) : contextPageFromConfig;
743
+ const name = (selectionList ?? unannotatedContextPageFromConfig)?.replace(/^\./, '');
212
744
 
213
- const componentConfig = {
214
- ...config,
215
- descriptors: mode === 'single' ? refFieldMetadata?.descriptors : null,
216
- datasourceMetadata: fieldMetaData.datasourceMetadata,
745
+ const dataReferenceConfigToChild: any = {
746
+ selectionMode,
747
+ additionalInfo,
748
+ descriptors: selectionMode === SELECTION_MODE.SINGLE ? refFieldMetadata?.descriptors : null,
217
749
  required: propsToUse.required,
218
750
  visibility: propsToUse.visibility,
219
751
  disabled: propsToUse.disabled,
220
752
  label: propsToUse.label,
753
+ displayAs: 'advancedSearch',
221
754
  readOnly: false,
222
- ...(mode === 'single' && { referenceType }),
223
- contextClass: config.targetObjectClass,
224
- primaryField: config.displayField,
225
- dataRelationshipContext: config.displayField ? getDataRelationshipContextFromKey(config.displayField) : null,
755
+ matchPosition,
756
+ ...(selectionMode === SELECTION_MODE.SINGLE && { referenceType }),
757
+ ...(selectionMode === SELECTION_MODE.SINGLE && {
758
+ value: rawConfig.value,
759
+ contextPage: contextPageFromConfig
760
+ }),
761
+ ...(selectionMode === SELECTION_MODE.MULTI && {
762
+ selectionList,
763
+ readonlyContextList: pageListValueFromConfig,
764
+ referenceType: referenceType || firstChildMeta?.config?.referenceType
765
+ }),
766
+ dataRelationshipContext: rawConfig.targetObjectClass && name ? name : null,
226
767
  hideLabel,
768
+ onRecordChange: this.onRecordChange,
769
+ getAdditionalInfo: getAdditionalInfo.bind(this, this.pConn$, rawConfig?.authorContext),
770
+ createNewRecord: isCreateNewReferenceEnabled ? createNewRecord : undefined,
227
771
  inline
228
772
  };
229
773
 
230
- const component = this.pConn$.createComponent({ type: this.type, config: componentConfig }, '', 0, {});
774
+ this.searchSelectCacheKey = componentCachePersistUtils.getComponentStateKey(this.pConn$, name);
775
+
776
+ // Set advanced search context via service
777
+ this.dataRefAdvancedSearchService.setConfig({
778
+ dataReferenceConfigToChild,
779
+ isCreateNewReferenceEnabled,
780
+ disableStartingFieldsForReference,
781
+ pyID,
782
+ searchSelectKey: this.searchSelectCacheKey
783
+ });
784
+ }
785
+
786
+ private buildMultiselectChild(
787
+ rawConfig: any,
788
+ mode: string,
789
+ refFieldMetadata: any,
790
+ fieldMetaData: any,
791
+ propsToUse: any,
792
+ referenceType: string,
793
+ hideLabel: boolean,
794
+ inline: boolean,
795
+ isCreateNewReferenceEnabled: boolean,
796
+ disableStartingFieldsForReference: boolean,
797
+ contextClass: string
798
+ ) {
799
+ const component = this.pConn$.createComponent(
800
+ {
801
+ type: 'Multiselect',
802
+ config: {
803
+ ...rawConfig,
804
+ descriptors: refFieldMetadata?.descriptors,
805
+ datasourceMetadata: fieldMetaData?.datasourceMetadata,
806
+ selectionList: rawConfig.pagelistValue?.substring(3),
807
+ readonlyContextList: rawConfig.pagelistValue,
808
+ selectionKey: rawConfig.selectionKey,
809
+ selectionMode: SELECTION_MODE.MULTI,
810
+ required: propsToUse.required,
811
+ visibility: propsToUse.visibility,
812
+ disabled: propsToUse.disabled,
813
+ label: propsToUse.label,
814
+ parameters: rawConfig.parameters,
815
+ readOnly: false,
816
+ localeReference: rawConfig.localeReference,
817
+ ...(mode === SELECTION_MODE.MULTI ? { referenceType } : {}),
818
+ contextClass: rawConfig.targetObjectClass,
819
+ primaryField: rawConfig.displayField?.startsWith('@P') ? rawConfig.displayField.slice(3) : rawConfig.displayField,
820
+ dataRelationshipContext: rawConfig.pagelistValue?.substring(4),
821
+ hideLabel: hideLabel ?? false,
822
+ onRecordChange: this.onRecordChange,
823
+ createNewRecord: isCreateNewReferenceEnabled
824
+ ? () =>
825
+ createNewRecord({
826
+ referenceType: rawConfig.targetObjectType === 'case' ? 'Case' : 'Data',
827
+ pConn: this.pConn$,
828
+ getPConnect: () => this.pConn$,
829
+ disableStartingFieldsForReference,
830
+ startingFields: {},
831
+ contextClass
832
+ })
833
+ : undefined,
834
+ inline,
835
+ columnsFormatter: rawConfig.secondaryFields,
836
+ additionalInfo: refFieldMetadata?.additionalInformation ? { content: refFieldMetadata.additionalInformation } : undefined
837
+ }
838
+ } as any,
839
+ '',
840
+ 0,
841
+ {}
842
+ );
231
843
  this.newComponentName = component?.getPConnect().getComponentName();
232
844
  this.newPconn = component?.getPConnect();
233
- if (this.rawViewMetadata?.config) {
234
- this.rawViewMetadata.config = { ...config };
845
+
846
+ // Pre-set the reference list on the child PConnect so that
847
+ // getListActions() resolves the correct path on every re-render.
848
+ const selectionList = rawConfig.pagelistValue?.substring(3);
849
+ if (this.newPconn && selectionList) {
850
+ this.newPconn.setReferenceList(selectionList);
235
851
  }
236
852
  }
853
+
854
+ private buildEmbeddedInsightTableChild(rawConfig: any, referenceType: string, propsToUse: any) {
855
+ // Extract columns from insightModel.query.columns and convert to presets format
856
+ const insightModel = propsToUse.insightModel;
857
+ const insightColumns: any[] = insightModel?.query?.columns ?? [];
858
+
859
+ const columnChildren = insightColumns
860
+ .filter((col: any) => col.type === 'column' && col.field)
861
+ .map((col: any) => ({
862
+ type: 'TextInput',
863
+ config: {
864
+ value: `@P .${col.field.fieldID}`,
865
+ label: col.field.name || col.field.fieldID
866
+ }
867
+ }));
868
+
869
+ const presets = [
870
+ {
871
+ children: [{ children: columnChildren, name: 'Columns', type: 'Region' }],
872
+ config: {},
873
+ id: 'P_',
874
+ label: '',
875
+ name: 'presets',
876
+ template: 'Table'
877
+ }
878
+ ];
879
+
880
+ const componentConfig = {
881
+ type: 'SimpleTableManual',
882
+ config: {
883
+ contextClass: rawConfig.targetObjectClass,
884
+ presets,
885
+ label: propsToUse.label,
886
+ readonlyContextList: rawConfig.pagelistValue,
887
+ referenceList: rawConfig.pagelistValue,
888
+ renderMode: 'ReadOnly',
889
+ dataPageName: rawConfig.referenceList,
890
+ fieldMetadata: {
891
+ datasource: {
892
+ parameters: this.configProps.parameters ?? {}
893
+ }
894
+ }
895
+ }
896
+ };
897
+
898
+ const component = this.pConn$.createComponent(componentConfig as any, '', 0, {});
899
+ this.newComponentName = component?.getPConnect().getComponentName();
900
+ this.newPconn = component?.getPConnect();
901
+ }
902
+
903
+ private buildDefaultChild(
904
+ rawConfig: any,
905
+ mode: string,
906
+ refFieldMetadata: any,
907
+ fieldMetaData: any,
908
+ propsToUse: any,
909
+ referenceType: string,
910
+ hideLabel: boolean,
911
+ inline: boolean,
912
+ isCreateNewReferenceEnabled: boolean,
913
+ disableStartingFieldsForReference: boolean,
914
+ contextClass: string,
915
+ linkReference: any
916
+ ) {
917
+ this.useOutputEvents = true;
918
+ const component = this.pConn$.createComponent(
919
+ {
920
+ type: this.type,
921
+ config: {
922
+ ...rawConfig,
923
+ descriptors: mode === SELECTION_MODE.SINGLE ? refFieldMetadata?.descriptors : null,
924
+ datasourceMetadata: fieldMetaData?.datasourceMetadata,
925
+ required: propsToUse.required,
926
+ visibility: propsToUse.visibility,
927
+ disabled: propsToUse.disabled,
928
+ label: propsToUse.label,
929
+ parameters: rawConfig.parameters,
930
+ readOnly: false,
931
+ localeReference: rawConfig.localeReference,
932
+ ...(mode === SELECTION_MODE.SINGLE ? { referenceType } : {}),
933
+ contextClass: rawConfig.targetObjectClass,
934
+ primaryField: rawConfig.displayField,
935
+ dataRelationshipContext: rawConfig.displayField ? getDataRelationshipContextFromKey(rawConfig.displayField) : null,
936
+ hideLabel,
937
+ onRecordChange: this.onRecordChange,
938
+ createNewRecord: isCreateNewReferenceEnabled
939
+ ? () =>
940
+ createNewRecord({
941
+ referenceType: rawConfig.targetObjectType === 'case' ? 'Case' : 'Data',
942
+ pConn: this.pConn$,
943
+ getPConnect: () => this.pConn$,
944
+ disableStartingFieldsForReference,
945
+ startingFields: {},
946
+ contextClass
947
+ })
948
+ : undefined,
949
+ inline,
950
+ columnsFormatter: rawConfig.secondaryFields,
951
+ getAdditionalInfo: getAdditionalInfo.bind(this, this.pConn$, rawConfig.displayField),
952
+ linkReference: this.type === 'AutoComplete' ? linkReference : undefined
953
+ }
954
+ } as any,
955
+ '',
956
+ 0,
957
+ {}
958
+ );
959
+ this.newComponentName = component?.getPConnect().getComponentName();
960
+ this.newPconn = component?.getPConnect();
961
+ }
237
962
  }