@pega/sdk 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -6
- package/dist/index.js +50 -24
- package/package.json +42 -3
- package/templates/angular-sdk-reference/angular.json +1 -2
- package/templates/angular-sdk-reference/extra-webpack.config.cjs +23 -0
- package/templates/angular-sdk-reference/index.html +12 -0
- package/templates/angular-sdk-reference/package.json +0 -1
- package/templates/angular-sdk-reference/src/app/app.component.ts +15 -232
- package/templates/angular-sdk-reference/src/app/pconnect-renderer.component.ts +153 -0
- package/templates/angular-sdk-reference/src/components/fields/auto-complete/auto-complete.component.ts +58 -21
- package/templates/angular-sdk-reference/src/components/fields/checkbox/checkbox.component.ts +8 -3
- package/templates/angular-sdk-reference/src/components/fields/currency/currency.component.ts +22 -7
- package/templates/angular-sdk-reference/src/components/fields/date-input/date-input.component.ts +19 -6
- package/templates/angular-sdk-reference/src/components/fields/dropdown/dropdown.component.ts +24 -7
- package/templates/angular-sdk-reference/src/components/fields/email/email.component.ts +19 -6
- package/templates/angular-sdk-reference/src/components/fields/integer/integer.component.ts +19 -6
- package/templates/angular-sdk-reference/src/components/fields/phone/phone.component.ts +19 -6
- package/templates/angular-sdk-reference/src/components/fields/radio-buttons/radio-buttons.component.ts +16 -5
- package/templates/angular-sdk-reference/src/components/fields/text-area/text-area.component.ts +19 -6
- package/templates/angular-sdk-reference/src/components/fields/text-input/text-input.component.ts +19 -6
- package/templates/angular-sdk-reference/src/components/fields/url-input/url-input.component.ts +26 -7
- package/templates/angular-sdk-reference/src/components/helpers/sdk-helpers.ts +93 -0
- package/templates/angular-sdk-reference/src/components/infra/case-summary/case-summary.component.ts +8 -9
- package/templates/angular-sdk-reference/src/components/infra/case-view/case-view.component.ts +24 -12
- package/templates/angular-sdk-reference/src/components/infra/root-container/root-container.component.ts +21 -15
- package/templates/angular-sdk-reference/src/components/infra/stages/stages.component.ts +21 -10
- package/templates/angular-sdk-reference/src/components/infra/view/view.component.ts +14 -9
- package/templates/angular-sdk-reference/src/components/templates/default-form/default-form.component.ts +12 -8
- package/templates/angular-sdk-reference/tsconfig.app.json +13 -0
- package/templates/angular-sdk-reference/tsconfig.json +2 -5
- package/templates/react-sdk-reference/.ai-common/agents/embedded-flow-expert.md +65 -31
- package/templates/react-sdk-reference/.ai-common/agents/implementation-expert.md +74 -38
- package/templates/react-sdk-reference/.ai-common/global/ai-agent-instructions-embedded.md +33 -1
- package/templates/react-sdk-reference/.ai-common/global/ai-agent-instructions.md +57 -22
- package/templates/react-sdk-reference/.ai-common/instructions/embedded-component.md +25 -10
- package/templates/react-sdk-reference/.ai-common/prompts/add-component.md +40 -19
- package/templates/react-sdk-reference/.ai-common/prompts/component-manifest.json +55 -1
- package/templates/react-sdk-reference/.ai-common/prompts/embedded-component-manifest.md +26 -4
- package/templates/react-sdk-reference/.ai-common/prompts/generate-all-components.md +82 -33
- package/templates/react-sdk-reference/.ai-common/prompts/generate-dse-components.md +46 -26
- package/templates/react-sdk-reference/.ai-common/prompts/generate-embedded-components.md +28 -15
- package/templates/react-sdk-reference/.ai-common/prompts/generate-field-components.md +24 -6
- package/templates/react-sdk-reference/.ai-common/prompts/generate-infra-components.md +24 -6
- package/templates/react-sdk-reference/.ai-common/prompts/generate-template-components.md +24 -6
- package/templates/react-sdk-reference/.ai-common/prompts/generate-widget-components.md +24 -6
- package/templates/react-sdk-reference/.ai-common/prompts/identify-components.md +2 -0
- package/templates/react-sdk-reference/.ai-common/prompts/replace-design-system.md +44 -17
- package/templates/react-sdk-reference/.ai-common/skills/connect-pega-server.md +14 -1
- package/templates/react-sdk-reference/.ai-common/skills/design-system-extension-skills/AssignmentHeader.md +79 -0
- package/templates/react-sdk-reference/.ai-common/skills/design-system-extension-skills/Toast.md +96 -0
- package/templates/react-sdk-reference/.ai-common/skills/design-system-extension.md +56 -35
- package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/analyze-customer-repo.md +29 -3
- package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/run-and-verify-integration.md +97 -37
- package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/wire-integration.md +91 -60
- package/templates/react-sdk-reference/.ai-common/skills/field-components.md +13 -1
- package/templates/react-sdk-reference/.ai-common/skills/infra-components.md +13 -1
- package/templates/react-sdk-reference/.ai-common/skills/portal-flow/run-and-verify-portal.md +290 -0
- package/templates/react-sdk-reference/.ai-common/skills/template-components.md +13 -1
- package/templates/react-sdk-reference/.ai-common/skills/widget-components.md +13 -1
- package/templates/react-sdk-reference/assets/icons/trash.svg +3 -0
- package/templates/react-sdk-reference/index.html +0 -1
- package/templates/react-sdk-reference/package.json +2 -2
- package/templates/react-sdk-reference/package.minimal.json +2 -2
- package/templates/react-sdk-reference/sdk-config.json +3 -3
- package/templates/react-sdk-reference/src/FallbackComponent.tsx +1 -1
- package/templates/react-sdk-reference/src/MashupApp.tsx +33 -78
- package/templates/react-sdk-reference/src/PortalApp.tsx +23 -100
- package/templates/react-sdk-reference/src/components/component-map.ts +15 -1
- package/templates/react-sdk-reference/src/components/designSystemExtension/AssignmentHeader/AssignmentHeader.tsx +15 -0
- package/templates/react-sdk-reference/src/components/designSystemExtension/AssignmentHeader/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/designSystemExtension/FieldGroup/FieldGroup.tsx +1 -1
- package/templates/react-sdk-reference/src/components/designSystemExtension/FieldGroupList/FieldGroupList.tsx +1 -1
- package/templates/react-sdk-reference/src/components/designSystemExtension/FieldValueList/FieldValueList.tsx +16 -4
- package/templates/react-sdk-reference/src/components/designSystemExtension/ModalDialog/ModalDialog.tsx +26 -0
- package/templates/react-sdk-reference/src/components/designSystemExtension/ModalDialog/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/designSystemExtension/Toast/Toast.tsx +35 -0
- package/templates/react-sdk-reference/src/components/designSystemExtension/Toast/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/field/AutoComplete/AutoComplete.tsx +362 -24
- package/templates/react-sdk-reference/src/components/field/CancelAlert/CancelAlert.tsx +1 -1
- package/templates/react-sdk-reference/src/components/field/Checkbox/Checkbox.tsx +3 -1
- package/templates/react-sdk-reference/src/components/field/Currency/Currency.tsx +6 -3
- package/templates/react-sdk-reference/src/components/field/Date/Date.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/DateTime/DateTime.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/Decimal/Decimal.tsx +4 -3
- package/templates/react-sdk-reference/src/components/field/Dropdown/Dropdown.tsx +2 -0
- package/templates/react-sdk-reference/src/components/field/Email/Email.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/EmbeddedDataMulti/EmbeddedDataMulti.tsx +121 -0
- package/templates/react-sdk-reference/src/components/field/EmbeddedDataMulti/config-ext.json +7 -0
- package/templates/react-sdk-reference/src/components/field/EmbeddedDataMulti/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/field/Integer/Integer.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/Location/Location.tsx +1 -1
- package/templates/react-sdk-reference/src/components/field/Multiselect/Multiselect.tsx +40 -20
- package/templates/react-sdk-reference/src/components/field/ObjectReference/ObjectReference.tsx +554 -49
- package/templates/react-sdk-reference/src/components/field/ObjectReference/utils.ts +111 -20
- package/templates/react-sdk-reference/src/components/field/Percentage/Percentage.tsx +4 -3
- package/templates/react-sdk-reference/src/components/field/Phone/Phone.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/SelectableCard/SelectableCard.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/TextArea/TextArea.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/TextInput/TextInput.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/Time/Time.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/URL/URL.tsx +2 -1
- package/templates/react-sdk-reference/src/components/field/UserReference/UserReference.tsx +1 -1
- package/templates/react-sdk-reference/src/components/helpers/field-utils.ts +44 -0
- package/templates/react-sdk-reference/src/components/helpers/simpleTableHelpers.ts +19 -7
- package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/DataViewActionButtons/DataViewActionButtons.tsx +97 -0
- package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/DataViewActionButtons/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +53 -0
- package/templates/react-sdk-reference/src/components/infra/ModalViewContainer/ListViewActionButtons/index.tsx +1 -0
- package/templates/react-sdk-reference/src/components/template/AdvancedSearch/SearchGroups/SearchGroups.tsx +2 -2
- package/templates/react-sdk-reference/src/components/template/CaseSummary/CaseSummary.tsx +3 -1
- package/templates/react-sdk-reference/src/components/template/DataReference/SearchForm.tsx +4 -4
- package/templates/react-sdk-reference/src/components/template/HierarchicalForm/HierarchicalForm.tsx +2 -2
- package/templates/react-sdk-reference/src/components/template/InlineDashboard/InlineDashboard.tsx +1 -1
- package/templates/react-sdk-reference/src/components/template/ListView/ListView.tsx +7 -3
- package/templates/react-sdk-reference/src/components/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +173 -99
- package/templates/react-sdk-reference/src/components/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +63 -56
- package/templates/react-sdk-reference/src/components/widget/ToDo/ToDo.tsx +1 -1
- package/templates/react-sdk-reference/vite.config.ts +26 -4
- package/templates/angular-sdk-reference/pega-constellationjs-0.26.3-local.tgz +0 -0
- package/templates/angular-sdk-reference/src/helpers/event-utils.ts +0 -18
- package/templates/angular-sdk-reference/src/helpers/utils.ts +0 -38
- package/templates/angular-sdk-reference/src/helpers/versionHelpers.ts +0 -14
- package/templates/react-sdk-reference/.ai-common/instructions/dse-component.md +0 -47
- package/templates/react-sdk-reference/.ai-common/instructions/field-component.md +0 -50
- package/templates/react-sdk-reference/.ai-common/instructions/infra-component.md +0 -76
- package/templates/react-sdk-reference/.ai-common/instructions/template-component.md +0 -43
- package/templates/react-sdk-reference/.ai-common/instructions/widget-component.md +0 -45
- package/templates/react-sdk-reference/.ai-common/skills/embedded-flow/authenticate.md +0 -311
- package/templates/react-sdk-reference/pega-constellationjs-0.26.3-local.tgz +0 -0
- package/templates/react-sdk-reference/pega-sdk-react-0.1.0.tgz +0 -0
package/templates/react-sdk-reference/src/components/field/ObjectReference/ObjectReference.tsx
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
1
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import Grid from '@mui/material/Grid';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
SELECTION_MODE,
|
|
7
|
+
generateColumns,
|
|
8
|
+
getDataRelationshipContextFromKey,
|
|
9
|
+
addCompositeKeysToConfig,
|
|
10
|
+
createNewRecord,
|
|
11
|
+
getAdditionalInfo,
|
|
12
|
+
camelCase,
|
|
13
|
+
} from './utils';
|
|
6
14
|
import { getComponentFromRegistry } from '@pega/sdk-react';
|
|
7
15
|
import type { PConnFieldProps } from '@pega/sdk-react';
|
|
16
|
+
import componentCachePersistUtils from '../../template/AdvancedSearch/SearchGroup/persistUtils';
|
|
17
|
+
import DataReferenceAdvancedSearchContext from '../../template/DataReference/DataReferenceAdvancedSearchContext';
|
|
18
|
+
import { Utils } from '../../helpers/utils';
|
|
8
19
|
|
|
9
20
|
interface ObjectReferenceProps extends Omit<PConnFieldProps, 'value'> {
|
|
10
21
|
// If any, enter additional props that only exist on ObjectReference here
|
|
11
22
|
getPConnect: any;
|
|
12
|
-
displayMode;
|
|
23
|
+
displayMode: string;
|
|
13
24
|
allowAndPersistChangesInReviewMode: any;
|
|
25
|
+
allowCreatingRecords?: boolean;
|
|
14
26
|
targetObjectType: any;
|
|
15
27
|
mode: string;
|
|
16
28
|
parameters: object;
|
|
@@ -18,12 +30,16 @@ interface ObjectReferenceProps extends Omit<PConnFieldProps, 'value'> {
|
|
|
18
30
|
inline: boolean;
|
|
19
31
|
showPromotedFilters: boolean;
|
|
20
32
|
additionalFields: any;
|
|
33
|
+
linkReference?: boolean;
|
|
34
|
+
matchPosition?: string;
|
|
35
|
+
children?: any;
|
|
21
36
|
}
|
|
22
37
|
|
|
23
38
|
export default function ObjectReference(props: ObjectReferenceProps) {
|
|
24
39
|
const {
|
|
25
40
|
getPConnect,
|
|
26
|
-
|
|
41
|
+
children,
|
|
42
|
+
allowCreatingRecords,
|
|
27
43
|
allowAndPersistChangesInReviewMode: editableInReview = false,
|
|
28
44
|
targetObjectType,
|
|
29
45
|
mode = '',
|
|
@@ -32,23 +48,84 @@ export default function ObjectReference(props: ObjectReferenceProps) {
|
|
|
32
48
|
inline = false,
|
|
33
49
|
showPromotedFilters = false,
|
|
34
50
|
additionalFields,
|
|
51
|
+
linkReference,
|
|
52
|
+
matchPosition = 'contains',
|
|
35
53
|
} = props;
|
|
36
54
|
|
|
55
|
+
let displayMode = props.displayMode;
|
|
56
|
+
|
|
37
57
|
const SingleReferenceReadonly = getComponentFromRegistry('SingleReferenceReadOnly');
|
|
58
|
+
const MultiReferenceReadonly = getComponentFromRegistry('MultiReferenceReadOnly');
|
|
59
|
+
const SearchForm = getComponentFromRegistry('SearchForm');
|
|
38
60
|
|
|
39
61
|
// Configs
|
|
40
62
|
const pConn = getPConnect();
|
|
41
|
-
const referenceType = targetObjectType === 'case' ? 'Case' : 'Data';
|
|
63
|
+
const referenceType = targetObjectType?.toLowerCase() === 'case' ? 'Case' : 'Data';
|
|
42
64
|
const rawViewMetadata = pConn.getRawMetadata();
|
|
43
|
-
const refFieldMetadata = pConn.getFieldMetadata(
|
|
65
|
+
const refFieldMetadata = pConn.getFieldMetadata(
|
|
66
|
+
rawViewMetadata.config.mode === SELECTION_MODE.SINGLE
|
|
67
|
+
? rawViewMetadata?.config?.value?.split('.', 2)[1]
|
|
68
|
+
: rawViewMetadata?.config?.pagelistValue?.substring(4),
|
|
69
|
+
);
|
|
44
70
|
|
|
45
71
|
// Destructured properties
|
|
46
|
-
const propsToUse = { ...pConn.getInheritedProps(), ...props };
|
|
72
|
+
const propsToUse: any = { ...pConn.getInheritedProps(), ...props };
|
|
73
|
+
const [parameterizedDataSource, setParameterizedDataSource] = useState<any[]>([]);
|
|
74
|
+
|
|
75
|
+
const { allowImplicitRefresh } = (PCore as any).getFieldDefaultUtils?.()?.fieldDefaults?.DataReference || {};
|
|
76
|
+
|
|
77
|
+
// "Combobox" is an authoring value only; no component is registered under that name
|
|
78
|
+
if (rawViewMetadata.config.componentType === 'Combobox') {
|
|
79
|
+
rawViewMetadata.config.componentType = mode === SELECTION_MODE.MULTI ? 'Multiselect' : 'AutoComplete';
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (rawViewMetadata.config?.parameters && ['CheckboxGroup'].includes(rawViewMetadata.config.componentType)) {
|
|
84
|
+
const { value, key, text } = {
|
|
85
|
+
key: `@P ${rawViewMetadata.config.selectionKey}`,
|
|
86
|
+
text: `@P ${rawViewMetadata.config.displayField}`,
|
|
87
|
+
value: `@P ${rawViewMetadata.config.selectionKey}`,
|
|
88
|
+
};
|
|
89
|
+
const refList = rawViewMetadata.config.referenceList;
|
|
90
|
+
(PCore as any)
|
|
91
|
+
.getDataApiUtils()
|
|
92
|
+
.getData(refList, {
|
|
93
|
+
dataViewParameters: parameters,
|
|
94
|
+
})
|
|
95
|
+
.then((res: any) => {
|
|
96
|
+
if (res.data.data !== null) {
|
|
97
|
+
const ddDataSource = res.data.data
|
|
98
|
+
.map((listItem: any) => ({
|
|
99
|
+
key: listItem[key.split(' .', 2)[1]],
|
|
100
|
+
text: listItem[text.split(' .', 2)[1]],
|
|
101
|
+
value: listItem[value.split(' .', 2)[1]],
|
|
102
|
+
}))
|
|
103
|
+
.filter((item: any) => item.key);
|
|
104
|
+
setParameterizedDataSource(ddDataSource);
|
|
105
|
+
} else {
|
|
106
|
+
setParameterizedDataSource([]);
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
.catch(() => {
|
|
110
|
+
return Promise.resolve({
|
|
111
|
+
data: { data: [] },
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}, [rawViewMetadata, parameters]);
|
|
116
|
+
|
|
117
|
+
if (displayMode !== 'DISPLAY_ONLY' && props.readOnly) {
|
|
118
|
+
if (rawViewMetadata.config.componentType === 'Multiselect') {
|
|
119
|
+
rawViewMetadata.config.componentType = 'SemanticLink';
|
|
120
|
+
} else {
|
|
121
|
+
displayMode = 'DISPLAY_ONLY';
|
|
122
|
+
}
|
|
123
|
+
}
|
|
47
124
|
|
|
48
125
|
// Computed variables
|
|
49
126
|
const isDisplayModeEnabled = displayMode === 'DISPLAY_ONLY';
|
|
50
127
|
const canBeChangedInReviewMode =
|
|
51
|
-
editableInReview && ['
|
|
128
|
+
editableInReview && ['AutoComplete', 'Dropdown'].includes(rawViewMetadata.config.componentType);
|
|
52
129
|
|
|
53
130
|
// Editable first child on change handler
|
|
54
131
|
const onRecordChange = (event) => {
|
|
@@ -56,7 +133,7 @@ export default function ObjectReference(props: ObjectReferenceProps) {
|
|
|
56
133
|
const refreshOptions = { autoDetectRefresh: true, propertyName: '' };
|
|
57
134
|
refreshOptions.propertyName = rawViewMetadata.config?.value;
|
|
58
135
|
|
|
59
|
-
if (!canBeChangedInReviewMode || !pConn.getValue('__currentPageTabViewName')) {
|
|
136
|
+
if (!canBeChangedInReviewMode || !pConn.getValue('__currentPageTabViewName') || allowImplicitRefresh) {
|
|
60
137
|
const pgRef = pConn.getPageReference().replace('caseInfo.content', '');
|
|
61
138
|
const viewName = rawViewMetadata.name;
|
|
62
139
|
if (viewName && viewName.length > 0) {
|
|
@@ -111,17 +188,20 @@ export default function ObjectReference(props: ObjectReferenceProps) {
|
|
|
111
188
|
(response.data as any).data.caseInfo.lastUpdateTime,
|
|
112
189
|
);
|
|
113
190
|
PCore.getContainerUtils().updateRelatedContextEtag(pConn.getContextName(), response.headers.etag);
|
|
191
|
+
})
|
|
192
|
+
.catch((e) => {
|
|
193
|
+
console.error(e);
|
|
114
194
|
});
|
|
195
|
+
})
|
|
196
|
+
.catch((e) => {
|
|
197
|
+
console.error(e);
|
|
115
198
|
});
|
|
116
199
|
}
|
|
117
200
|
};
|
|
118
201
|
|
|
119
202
|
// Prepare first child
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
/* Read-only variants */
|
|
124
|
-
if (type === 'SemanticLink' && !canBeChangedInReviewMode) {
|
|
203
|
+
const buildSemanticLinkChild = () => {
|
|
204
|
+
if (mode !== 'readonly-multi') {
|
|
125
205
|
const config = {
|
|
126
206
|
...rawViewMetadata.config,
|
|
127
207
|
primaryField: rawViewMetadata.config.displayField,
|
|
@@ -134,26 +214,354 @@ export default function ObjectReference(props: ObjectReferenceProps) {
|
|
|
134
214
|
? getDataRelationshipContextFromKey(rawViewMetadata.config.displayField)
|
|
135
215
|
: null
|
|
136
216
|
}`;
|
|
137
|
-
config.resourceParams = {
|
|
138
|
-
|
|
139
|
-
};
|
|
140
|
-
config.resourcePayload = {
|
|
141
|
-
caseClassName: config.caseClass,
|
|
142
|
-
};
|
|
217
|
+
config.resourceParams = { workID: config.value };
|
|
218
|
+
config.resourcePayload = { caseClassName: config.caseClass };
|
|
143
219
|
|
|
144
220
|
return getPConnect().createComponent({
|
|
145
|
-
type: 'SemanticLink',
|
|
221
|
+
type: linkReference === false ? 'TextInput' : 'SemanticLink',
|
|
222
|
+
config:
|
|
223
|
+
linkReference === false
|
|
224
|
+
? { value: config.primaryField, label: propsToUse.label, hideLabel, readOnly: true, displayMode }
|
|
225
|
+
: {
|
|
226
|
+
...config,
|
|
227
|
+
displayMode,
|
|
228
|
+
referenceType,
|
|
229
|
+
hideLabel,
|
|
230
|
+
dataRelationshipContext: rawViewMetadata.config?.displayField
|
|
231
|
+
? getDataRelationshipContextFromKey(rawViewMetadata.config.displayField)
|
|
232
|
+
: null,
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
const displayField = rawViewMetadata.config.displayField;
|
|
237
|
+
const primaryField = displayField?.startsWith('@P') ? displayField?.substring(3) : displayField;
|
|
238
|
+
const presets = [
|
|
239
|
+
{
|
|
240
|
+
children: [{ children: rawViewMetadata.config.columns, name: 'Columns', type: 'Region' }],
|
|
241
|
+
config: {},
|
|
242
|
+
id: 'P_',
|
|
243
|
+
label: '',
|
|
244
|
+
name: 'presets',
|
|
245
|
+
template: 'Table',
|
|
246
|
+
},
|
|
247
|
+
];
|
|
248
|
+
return (
|
|
249
|
+
<MultiReferenceReadonly
|
|
250
|
+
config={{
|
|
251
|
+
contextClass: rawViewMetadata.config.targetObjectClass,
|
|
252
|
+
defaultRowHeight: rawViewMetadata.config.defaultRowHeight,
|
|
253
|
+
label: propsToUse.label,
|
|
254
|
+
presets,
|
|
255
|
+
primaryField,
|
|
256
|
+
readonlyContextList: rawViewMetadata.config.pagelistValue,
|
|
257
|
+
referenceList: rawViewMetadata.config.pagelistValue,
|
|
258
|
+
referenceType,
|
|
259
|
+
renderMode: 'ReadOnly',
|
|
260
|
+
selectionKey: rawViewMetadata.config.selectionKey,
|
|
261
|
+
}}
|
|
262
|
+
displayAs="readonlyMulti"
|
|
263
|
+
displayMode={displayMode}
|
|
264
|
+
getPConnect={getPConnect}
|
|
265
|
+
hideLabel={hideLabel}
|
|
266
|
+
label={propsToUse.label}
|
|
267
|
+
linkReference={linkReference}
|
|
268
|
+
/>
|
|
269
|
+
);
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
const buildTableChild = (type: string) => {
|
|
273
|
+
const presets = [
|
|
274
|
+
{
|
|
275
|
+
children: [{ children: rawViewMetadata.config.columns, name: 'Columns', type: 'Region' }],
|
|
276
|
+
config: { filterExpression: rawViewMetadata.config.filterExpression },
|
|
277
|
+
id: 'P_',
|
|
278
|
+
label: '',
|
|
279
|
+
name: 'presets',
|
|
280
|
+
template: 'Table',
|
|
281
|
+
},
|
|
282
|
+
];
|
|
283
|
+
const tableDisplayAs = camelCase(type);
|
|
284
|
+
|
|
285
|
+
if (mode === 'readonly-multi') {
|
|
286
|
+
return getPConnect().createComponent({
|
|
287
|
+
type: 'SimpleTableSelect',
|
|
146
288
|
config: {
|
|
147
|
-
|
|
148
|
-
|
|
289
|
+
contextClass: rawViewMetadata.config.targetObjectClass,
|
|
290
|
+
defaultRowHeight: rawViewMetadata.config.defaultRowHeight,
|
|
291
|
+
displayAs: tableDisplayAs,
|
|
292
|
+
hideLabel: false,
|
|
293
|
+
label: propsToUse.label,
|
|
294
|
+
localeReference: rawViewMetadata.config.localeReference,
|
|
295
|
+
presets,
|
|
296
|
+
readOnly: true,
|
|
297
|
+
readonlyContextList: rawViewMetadata.config.pagelistValue,
|
|
298
|
+
referenceList: rawViewMetadata.config.pagelistValue,
|
|
149
299
|
referenceType,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
300
|
+
renderMode: 'ReadOnly',
|
|
301
|
+
rowHeader: rawViewMetadata.config.rowHeader,
|
|
302
|
+
selectionMode: 'multi',
|
|
303
|
+
required: propsToUse.required,
|
|
304
|
+
visibility: propsToUse.visibility,
|
|
305
|
+
disabled: propsToUse.disabled,
|
|
306
|
+
toggleFieldVisibility: rawViewMetadata.config.toggleFieldVisibility,
|
|
154
307
|
},
|
|
155
308
|
});
|
|
156
309
|
}
|
|
310
|
+
const contextPageFromConfig =
|
|
311
|
+
mode === 'single' ? rawViewMetadata.config.contextPage : rawViewMetadata.config.pagelistValue;
|
|
312
|
+
const contextPageValue = contextPageFromConfig?.startsWith('@P')
|
|
313
|
+
? contextPageFromConfig?.substring(3)
|
|
314
|
+
: contextPageFromConfig;
|
|
315
|
+
|
|
316
|
+
return getPConnect().createComponent({
|
|
317
|
+
type: 'SimpleTableSelect',
|
|
318
|
+
config: {
|
|
319
|
+
...(mode === 'single'
|
|
320
|
+
? {
|
|
321
|
+
selectionKey: rawViewMetadata.config.value,
|
|
322
|
+
value: rawViewMetadata.config.value,
|
|
323
|
+
contextPage: rawViewMetadata.config.contextPage,
|
|
324
|
+
}
|
|
325
|
+
: {
|
|
326
|
+
readonlyContextList: rawViewMetadata.config.pagelistValue,
|
|
327
|
+
}),
|
|
328
|
+
dataRelationshipContext: contextPageValue,
|
|
329
|
+
defaultRowHeight: rawViewMetadata.config.defaultRowHeight,
|
|
330
|
+
displayAs: tableDisplayAs,
|
|
331
|
+
hideLabel: false,
|
|
332
|
+
inline: false,
|
|
333
|
+
label: propsToUse.label,
|
|
334
|
+
localeReference: rawViewMetadata.config.localeReference,
|
|
335
|
+
presets,
|
|
336
|
+
readOnly: false,
|
|
337
|
+
referenceList: rawViewMetadata.config.referenceList,
|
|
338
|
+
referenceType,
|
|
339
|
+
rowHeader: rawViewMetadata.config.rowHeader,
|
|
340
|
+
parameters: rawViewMetadata.config.parameters,
|
|
341
|
+
selectionList: contextPageValue,
|
|
342
|
+
selectionMode: mode,
|
|
343
|
+
showPromotedFilters: false,
|
|
344
|
+
required: propsToUse.required,
|
|
345
|
+
visibility: propsToUse.visibility,
|
|
346
|
+
disabled: propsToUse.disabled,
|
|
347
|
+
toggleFieldVisibility: rawViewMetadata.config.toggleFieldVisibility,
|
|
348
|
+
},
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
const buildFieldMetaData = () => {
|
|
353
|
+
const fieldMetaData: any = {
|
|
354
|
+
datasourceMetadata: { datasource: { parameters: {} } },
|
|
355
|
+
};
|
|
356
|
+
if (rawViewMetadata.config?.parameters) {
|
|
357
|
+
fieldMetaData.datasourceMetadata.datasource.parameters = parameters;
|
|
358
|
+
}
|
|
359
|
+
fieldMetaData.datasourceMetadata.datasource.propertyForDisplayText =
|
|
360
|
+
rawViewMetadata?.config?.datasource?.fields?.text.startsWith('@P')
|
|
361
|
+
? rawViewMetadata?.config?.datasource?.fields?.text?.substring(3)
|
|
362
|
+
: rawViewMetadata?.config?.datasource?.fields?.text;
|
|
363
|
+
fieldMetaData.datasourceMetadata.datasource.propertyForValue =
|
|
364
|
+
rawViewMetadata?.config?.datasource?.fields?.value.startsWith('@P')
|
|
365
|
+
? rawViewMetadata?.config?.datasource?.fields?.value?.substring(3)
|
|
366
|
+
: rawViewMetadata?.config?.datasource?.fields?.value;
|
|
367
|
+
fieldMetaData.datasourceMetadata.datasource.name = rawViewMetadata.config?.referenceList;
|
|
368
|
+
return fieldMetaData;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
const buildSearchAndSelectChild = (
|
|
372
|
+
isCreateNewReferenceEnabled: boolean,
|
|
373
|
+
disableStartingFieldsForReference: boolean,
|
|
374
|
+
) => {
|
|
375
|
+
const rawConfig = rawViewMetadata.config;
|
|
376
|
+
const selectionMode = rawConfig.mode;
|
|
377
|
+
const [firstChildMeta] = structuredClone(rawViewMetadata.children ?? []);
|
|
378
|
+
const pyID = Utils.getMappedKey('pyID');
|
|
379
|
+
|
|
380
|
+
const additionalInfo = refFieldMetadata?.additionalInformation
|
|
381
|
+
? { content: refFieldMetadata.additionalInformation }
|
|
382
|
+
: undefined;
|
|
383
|
+
const pageListValueFromConfig = rawConfig.pagelistValue;
|
|
384
|
+
const selectionList = pageListValueFromConfig?.startsWith('@P')
|
|
385
|
+
? pageListValueFromConfig?.substring(3)
|
|
386
|
+
: pageListValueFromConfig;
|
|
387
|
+
const contextPageFromConfig = rawConfig.contextPage;
|
|
388
|
+
const unannotatedContextPageFromConfig = contextPageFromConfig?.startsWith('@P')
|
|
389
|
+
? contextPageFromConfig?.substring(3)
|
|
390
|
+
: contextPageFromConfig;
|
|
391
|
+
const name = (selectionList ?? unannotatedContextPageFromConfig)?.replace(/^\./, '');
|
|
392
|
+
|
|
393
|
+
const dataReferenceConfigToChild: any = {
|
|
394
|
+
selectionMode,
|
|
395
|
+
additionalInfo,
|
|
396
|
+
descriptors: selectionMode === SELECTION_MODE.SINGLE ? refFieldMetadata?.descriptors : null,
|
|
397
|
+
required: propsToUse.required,
|
|
398
|
+
visibility: propsToUse.visibility,
|
|
399
|
+
disabled: propsToUse.disabled,
|
|
400
|
+
label: propsToUse.label,
|
|
401
|
+
displayAs: 'advancedSearch',
|
|
402
|
+
readOnly: false,
|
|
403
|
+
matchPosition,
|
|
404
|
+
...(selectionMode === SELECTION_MODE.SINGLE && { referenceType }),
|
|
405
|
+
...(selectionMode === SELECTION_MODE.SINGLE && {
|
|
406
|
+
value: rawConfig.value,
|
|
407
|
+
contextPage: contextPageFromConfig,
|
|
408
|
+
}),
|
|
409
|
+
...(selectionMode === SELECTION_MODE.MULTI && {
|
|
410
|
+
selectionList,
|
|
411
|
+
readonlyContextList: pageListValueFromConfig,
|
|
412
|
+
referenceType: referenceType || firstChildMeta?.config?.referenceType,
|
|
413
|
+
}),
|
|
414
|
+
dataRelationshipContext: rawConfig.targetObjectClass && name ? name : null,
|
|
415
|
+
hideLabel,
|
|
416
|
+
onRecordChange,
|
|
417
|
+
getAdditionalInfo: getAdditionalInfo.bind(null, pConn, rawConfig?.authorContext),
|
|
418
|
+
createNewRecord: isCreateNewReferenceEnabled ? createNewRecord : undefined,
|
|
419
|
+
inline,
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const searchSelectKey = componentCachePersistUtils.getComponentStateKey(getPConnect, name);
|
|
423
|
+
|
|
424
|
+
const dataReferenceAdvancedSearchContext = {
|
|
425
|
+
dataReferenceConfigToChild,
|
|
426
|
+
isCreateNewReferenceEnabled,
|
|
427
|
+
disableStartingFieldsForReference,
|
|
428
|
+
pyID,
|
|
429
|
+
searchSelectKey,
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
return (
|
|
433
|
+
<DataReferenceAdvancedSearchContext.Provider value={dataReferenceAdvancedSearchContext as any}>
|
|
434
|
+
<SearchForm
|
|
435
|
+
getPConnect={getPConnect}
|
|
436
|
+
searchSelectCacheKey={searchSelectKey}
|
|
437
|
+
type="ObjectReference"
|
|
438
|
+
label={propsToUse.label}
|
|
439
|
+
>
|
|
440
|
+
{children}
|
|
441
|
+
</SearchForm>
|
|
442
|
+
</DataReferenceAdvancedSearchContext.Provider>
|
|
443
|
+
);
|
|
444
|
+
};
|
|
445
|
+
|
|
446
|
+
const buildCardsChild = () => {
|
|
447
|
+
const rawConfig = rawViewMetadata.config;
|
|
448
|
+
const selectionMode = rawConfig.mode;
|
|
449
|
+
|
|
450
|
+
const componentMeta = {
|
|
451
|
+
type: selectionMode === 'single' ? 'RadioButtons' : 'Checkbox',
|
|
452
|
+
config: {
|
|
453
|
+
...rawConfig,
|
|
454
|
+
label: rawConfig.label,
|
|
455
|
+
value: selectionMode === 'single' ? rawConfig.value : undefined,
|
|
456
|
+
referenceList: rawConfig.referenceList,
|
|
457
|
+
contextClass: rawConfig.targetObjectClass,
|
|
458
|
+
referenceType: rawConfig.targetObjectType === 'case' ? 'Case' : 'Data',
|
|
459
|
+
readonlyContextList: selectionMode.includes('multi') ? rawConfig.pagelistValue : undefined,
|
|
460
|
+
...(selectionMode.includes('multi')
|
|
461
|
+
? {
|
|
462
|
+
selectionList: rawConfig.pagelistValue.substring(3),
|
|
463
|
+
selectionKey: rawConfig.selectionKey,
|
|
464
|
+
}
|
|
465
|
+
: { selectionList: rawConfig.contextPage?.substring(3) }),
|
|
466
|
+
selectionMode: selectionMode.includes('multi') ? 'multi' : undefined,
|
|
467
|
+
renderMode: rawConfig.mode === 'readonly-multi' ? 'ReadOnly' : '',
|
|
468
|
+
variant: 'card',
|
|
469
|
+
inlineDisplay: rawConfig.inlineDisplay,
|
|
470
|
+
hideFieldLabels: rawConfig.hideFieldLabels,
|
|
471
|
+
presets: [
|
|
472
|
+
{
|
|
473
|
+
children: [
|
|
474
|
+
{
|
|
475
|
+
children: rawConfig.secondaryFields,
|
|
476
|
+
name: 'AdditionalDetails',
|
|
477
|
+
type: 'Region',
|
|
478
|
+
},
|
|
479
|
+
],
|
|
480
|
+
config: {},
|
|
481
|
+
id: 'P_',
|
|
482
|
+
label: '',
|
|
483
|
+
name: 'presets',
|
|
484
|
+
template: 'Cards',
|
|
485
|
+
},
|
|
486
|
+
],
|
|
487
|
+
datasource: {
|
|
488
|
+
fields: {
|
|
489
|
+
key: `@P ${rawConfig.selectionKey || `.${rawConfig.value.trim().split('.').pop()?.trim()}`}`,
|
|
490
|
+
text: `@P .${rawConfig.displayField.trim().split('.').pop()?.trim()}`,
|
|
491
|
+
value: `@P ${rawConfig.selectionKey || `.${rawConfig.value.trim().split('.').pop()?.trim()}`}`,
|
|
492
|
+
},
|
|
493
|
+
filterDownloadedFields: true,
|
|
494
|
+
source: `@DATASOURCE ${rawConfig.referenceList}.pxResults`,
|
|
495
|
+
},
|
|
496
|
+
displayAs: 'cards',
|
|
497
|
+
hideLabel: rawConfig.hideLabel,
|
|
498
|
+
imagePosition: rawConfig.imagePosition,
|
|
499
|
+
image: rawConfig.image,
|
|
500
|
+
imageSize: rawConfig.imageSize,
|
|
501
|
+
showImageDescription: rawConfig.showImageDescription,
|
|
502
|
+
imageDescription: rawConfig.imageDescription,
|
|
503
|
+
required: rawConfig.required,
|
|
504
|
+
readOnly: false,
|
|
505
|
+
disabled: rawConfig.disabled,
|
|
506
|
+
labelOption: rawConfig.labelOption,
|
|
507
|
+
primaryField: rawConfig.displayField,
|
|
508
|
+
dataRelationshipContext: rawConfig.displayField
|
|
509
|
+
? getDataRelationshipContextFromKey(rawConfig.displayField)
|
|
510
|
+
: null,
|
|
511
|
+
},
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
return getPConnect().createComponent(componentMeta);
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
const buildEmbeddedInsightTableChild = (rawConfig: any) => {
|
|
518
|
+
const insightColumns: any[] = propsToUse.insightModel?.query?.columns ?? [];
|
|
519
|
+
|
|
520
|
+
const columnChildren = insightColumns
|
|
521
|
+
.filter((col: any) => col.type === 'column' && col.field)
|
|
522
|
+
.map((col: any) => ({
|
|
523
|
+
type: 'TextInput',
|
|
524
|
+
config: {
|
|
525
|
+
value: `@P .${col.field.fieldID}`,
|
|
526
|
+
label: col.field.name || col.field.fieldID,
|
|
527
|
+
},
|
|
528
|
+
}));
|
|
529
|
+
|
|
530
|
+
const presets = [
|
|
531
|
+
{
|
|
532
|
+
children: [{ children: columnChildren, name: 'Columns', type: 'Region' }],
|
|
533
|
+
config: {},
|
|
534
|
+
id: 'P_',
|
|
535
|
+
label: '',
|
|
536
|
+
name: 'presets',
|
|
537
|
+
template: 'Table',
|
|
538
|
+
},
|
|
539
|
+
];
|
|
540
|
+
return getPConnect().createComponent({
|
|
541
|
+
type: 'SimpleTableManual',
|
|
542
|
+
config: {
|
|
543
|
+
contextClass: rawConfig.targetObjectClass,
|
|
544
|
+
presets,
|
|
545
|
+
label: propsToUse.label,
|
|
546
|
+
readonlyContextList: rawConfig.pagelistValue,
|
|
547
|
+
referenceList: rawConfig.pagelistValue,
|
|
548
|
+
renderMode: 'ReadOnly',
|
|
549
|
+
dataPageName: rawConfig.referenceList,
|
|
550
|
+
fieldMetadata: {
|
|
551
|
+
datasource: {
|
|
552
|
+
parameters: rawConfig.parameters ?? {},
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
},
|
|
556
|
+
});
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
const recreatedFirstChild = useMemo(() => {
|
|
560
|
+
const type = rawViewMetadata.config.componentType;
|
|
561
|
+
|
|
562
|
+
if (type === 'SemanticLink' && !canBeChangedInReviewMode) {
|
|
563
|
+
return buildSemanticLinkChild();
|
|
564
|
+
}
|
|
157
565
|
if (isDisplayModeEnabled && !canBeChangedInReviewMode) {
|
|
158
566
|
return (
|
|
159
567
|
<SingleReferenceReadonly
|
|
@@ -169,6 +577,7 @@ export default function ObjectReference(props: ObjectReferenceProps) {
|
|
|
169
577
|
activeViewRuleClass={rawViewMetadata.config.targetObjectClass} // for older views which may not have context class set, fall back to previous behavior
|
|
170
578
|
referenceType={referenceType}
|
|
171
579
|
hideLabel={hideLabel}
|
|
580
|
+
linkReference={linkReference}
|
|
172
581
|
dataRelationshipContext={
|
|
173
582
|
rawViewMetadata.config?.displayField
|
|
174
583
|
? getDataRelationshipContextFromKey(rawViewMetadata.config.displayField)
|
|
@@ -179,43 +588,133 @@ export default function ObjectReference(props: ObjectReferenceProps) {
|
|
|
179
588
|
);
|
|
180
589
|
}
|
|
181
590
|
|
|
182
|
-
|
|
591
|
+
if (type === 'Cards') {
|
|
592
|
+
return buildCardsChild();
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
if (type === 'EmbeddedInsightTable') {
|
|
596
|
+
return buildEmbeddedInsightTableChild(rawViewMetadata.config);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
if (type === 'CheckboxGroup') {
|
|
600
|
+
const displayField = rawViewMetadata.config.displayField;
|
|
601
|
+
const primaryField = displayField?.startsWith('@P') ? displayField?.substring(3) : displayField;
|
|
602
|
+
const readOnly = !(mode === 'multi' || mode === 'single');
|
|
603
|
+
const pageListValueFromConfig = rawViewMetadata.config.pagelistValue;
|
|
604
|
+
const selectionList = pageListValueFromConfig?.startsWith('@P')
|
|
605
|
+
? pageListValueFromConfig?.substring(3)
|
|
606
|
+
: pageListValueFromConfig;
|
|
607
|
+
return getPConnect().createComponent({
|
|
608
|
+
type: 'Checkbox',
|
|
609
|
+
config: {
|
|
610
|
+
...rawViewMetadata.config,
|
|
611
|
+
contextClass: rawViewMetadata.config.targetObjectClass,
|
|
612
|
+
datasource: {
|
|
613
|
+
fields: {
|
|
614
|
+
key: `@P ${rawViewMetadata.config.selectionKey}`,
|
|
615
|
+
text: `@P ${rawViewMetadata.config.displayField}`,
|
|
616
|
+
value: `@P ${rawViewMetadata.config.selectionKey}`,
|
|
617
|
+
},
|
|
618
|
+
source: !rawViewMetadata.config?.parameters
|
|
619
|
+
? `@DATASOURCE ${rawViewMetadata.config.referenceList}.pxResults`
|
|
620
|
+
: parameterizedDataSource,
|
|
621
|
+
},
|
|
622
|
+
descriptors: mode === SELECTION_MODE.SINGLE ? refFieldMetadata?.descriptors : null,
|
|
623
|
+
displayAs: 'checkboxgroup',
|
|
624
|
+
hideLabel,
|
|
625
|
+
inline: rawViewMetadata.config.inline ?? false,
|
|
626
|
+
label: propsToUse.label,
|
|
627
|
+
primaryField,
|
|
628
|
+
readOnly,
|
|
629
|
+
readonlyContextList: pageListValueFromConfig,
|
|
630
|
+
referenceType: rawViewMetadata.config.targetObjectType,
|
|
631
|
+
selectionKey: rawViewMetadata.config.selectionKey,
|
|
632
|
+
selectionList,
|
|
633
|
+
selectionMode: mode,
|
|
634
|
+
disabled: propsToUse.disabled,
|
|
635
|
+
required: propsToUse.required,
|
|
636
|
+
visibility: propsToUse.visibility,
|
|
637
|
+
},
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
if (type === 'Table' || type === 'SimpleTable') {
|
|
642
|
+
return buildTableChild(type);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// Set datasource
|
|
183
646
|
generateColumns(rawViewMetadata.config, pConn, referenceType);
|
|
647
|
+
addCompositeKeysToConfig(rawViewMetadata.config, pConn);
|
|
184
648
|
rawViewMetadata.config.deferDatasource = true;
|
|
185
649
|
rawViewMetadata.config.listType = 'datapage';
|
|
186
650
|
if (['Dropdown', 'AutoComplete'].includes(type) && !rawViewMetadata.config.placeholder) {
|
|
187
651
|
rawViewMetadata.config.placeholder = '@L Select...';
|
|
188
652
|
}
|
|
189
653
|
|
|
190
|
-
// 2) Pass through configs
|
|
191
654
|
rawViewMetadata.config.showPromotedFilters = showPromotedFilters;
|
|
192
655
|
|
|
193
656
|
if (!canBeChangedInReviewMode) {
|
|
194
657
|
rawViewMetadata.config.displayMode = displayMode;
|
|
195
658
|
}
|
|
196
659
|
|
|
197
|
-
|
|
198
|
-
let fieldMetaData: any = null;
|
|
660
|
+
const fieldMetaData = buildFieldMetaData();
|
|
199
661
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
662
|
+
const formFeatures = (PCore as any).getEnvironmentInfo().environmentInfoObject?.features?.form;
|
|
663
|
+
const { disableStartingFieldsForReference = false } = formFeatures || {};
|
|
664
|
+
const contextClass = rawViewMetadata.config.targetObjectClass;
|
|
665
|
+
|
|
666
|
+
const createAuthoringEnabled = allowCreatingRecords ?? formFeatures?.isCreateNewReferenceEnabled;
|
|
667
|
+
const userHasCreateAccess = formFeatures
|
|
668
|
+
? formFeatures.isCreateNewReferenceEnabled && PCore.getAccessPrivilege().hasCreateAccess(contextClass)
|
|
669
|
+
: PCore.getAccessPrivilege().hasCreateAccess(contextClass);
|
|
670
|
+
const isCreateNewReferenceEnabled = createAuthoringEnabled && userHasCreateAccess;
|
|
671
|
+
|
|
672
|
+
const buildCreateNewRecord = () =>
|
|
673
|
+
createNewRecord({
|
|
674
|
+
referenceType: rawViewMetadata.config.targetObjectType === 'case' ? 'Case' : 'Data',
|
|
675
|
+
pConn,
|
|
676
|
+
getPConnect,
|
|
677
|
+
disableStartingFieldsForReference,
|
|
678
|
+
startingFields: {},
|
|
679
|
+
contextClass,
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
if (type === 'SearchAndSelect') {
|
|
683
|
+
return buildSearchAndSelectChild(isCreateNewReferenceEnabled, disableStartingFieldsForReference);
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
if (type === 'Multiselect') {
|
|
687
|
+
return getPConnect().createComponent({
|
|
688
|
+
type,
|
|
689
|
+
config: {
|
|
690
|
+
...rawViewMetadata.config,
|
|
691
|
+
descriptors: refFieldMetadata?.descriptors,
|
|
692
|
+
datasourceMetadata: fieldMetaData?.datasourceMetadata,
|
|
693
|
+
selectionList: rawViewMetadata.config?.pagelistValue.substring(3),
|
|
694
|
+
readonlyContextList: rawViewMetadata.config?.pagelistValue,
|
|
695
|
+
selectionKey: rawViewMetadata.config?.selectionKey,
|
|
696
|
+
selectionMode: SELECTION_MODE.MULTI,
|
|
697
|
+
required: propsToUse.required,
|
|
698
|
+
visibility: propsToUse.visibility,
|
|
699
|
+
disabled: propsToUse.disabled,
|
|
700
|
+
label: propsToUse.label,
|
|
701
|
+
parameters: rawViewMetadata.config.parameters,
|
|
702
|
+
readOnly: false,
|
|
703
|
+
localeReference: rawViewMetadata.config.localeReference,
|
|
704
|
+
...(mode === SELECTION_MODE.MULTI ? { referenceType } : ''),
|
|
705
|
+
contextClass: rawViewMetadata.config.targetObjectClass,
|
|
706
|
+
primaryField: rawViewMetadata.config?.displayField?.startsWith('@P')
|
|
707
|
+
? rawViewMetadata.config.displayField.slice(3)
|
|
708
|
+
: rawViewMetadata.config?.displayField,
|
|
709
|
+
dataRelationshipContext: rawViewMetadata.config?.pagelistValue.substring(4),
|
|
710
|
+
hideLabel: hideLabel ?? false,
|
|
711
|
+
onRecordChange,
|
|
712
|
+
createNewRecord: isCreateNewReferenceEnabled ? buildCreateNewRecord : undefined,
|
|
713
|
+
inline,
|
|
714
|
+
columnsFormatter: rawViewMetadata.config.secondaryFields,
|
|
204
715
|
},
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
if (rawViewMetadata.config?.parameters) {
|
|
208
|
-
fieldMetaData.datasourceMetadata.datasource.parameters = parameters;
|
|
716
|
+
});
|
|
209
717
|
}
|
|
210
|
-
fieldMetaData.datasourceMetadata.datasource.propertyForDisplayText =
|
|
211
|
-
rawViewMetadata?.config?.datasource?.fields?.text.startsWith('@P')
|
|
212
|
-
? rawViewMetadata?.config?.datasource?.fields?.text?.substring(3)
|
|
213
|
-
: rawViewMetadata?.config?.datasource?.fields?.text;
|
|
214
|
-
fieldMetaData.datasourceMetadata.datasource.propertyForValue =
|
|
215
|
-
rawViewMetadata?.config?.datasource?.fields?.value.startsWith('@P')
|
|
216
|
-
? rawViewMetadata?.config?.datasource?.fields?.value?.substring(3)
|
|
217
|
-
: rawViewMetadata?.config?.datasource?.fields?.value;
|
|
218
|
-
fieldMetaData.datasourceMetadata.datasource.name = rawViewMetadata.config?.referenceList;
|
|
219
718
|
|
|
220
719
|
return getPConnect().createComponent({
|
|
221
720
|
type,
|
|
@@ -238,12 +737,17 @@ export default function ObjectReference(props: ObjectReferenceProps) {
|
|
|
238
737
|
: null,
|
|
239
738
|
hideLabel,
|
|
240
739
|
onRecordChange,
|
|
740
|
+
createNewRecord: isCreateNewReferenceEnabled ? buildCreateNewRecord : undefined,
|
|
241
741
|
inline,
|
|
742
|
+
columnsFormatter: rawViewMetadata.config.secondaryFields,
|
|
743
|
+
getAdditionalInfo: getAdditionalInfo.bind(null, pConn, rawViewMetadata.config.displayField),
|
|
744
|
+
linkReference: type === 'AutoComplete' ? linkReference : undefined,
|
|
242
745
|
},
|
|
243
746
|
});
|
|
244
747
|
}, [
|
|
245
748
|
rawViewMetadata.config?.datasource?.source,
|
|
246
749
|
parameters,
|
|
750
|
+
parameterizedDataSource,
|
|
247
751
|
propsToUse.required,
|
|
248
752
|
propsToUse.disabled,
|
|
249
753
|
getPConnect().getPageReference(),
|
|
@@ -252,7 +756,8 @@ export default function ObjectReference(props: ObjectReferenceProps) {
|
|
|
252
756
|
// Prepare children to render
|
|
253
757
|
return (
|
|
254
758
|
<Grid container>
|
|
255
|
-
|
|
759
|
+
{/* MUI 9 Grid has no column direction; size 12 gives the full width mature gets from direction='column' */}
|
|
760
|
+
<Grid size={12}>{recreatedFirstChild}</Grid>
|
|
256
761
|
</Grid>
|
|
257
762
|
);
|
|
258
763
|
}
|