Skip to content

Commit 218638b

Browse files
authored
Merge branch 'master' into fix/attachments_25.1
2 parents 7583c2a + ef35796 commit 218638b

File tree

6 files changed

+179
-116
lines changed

6 files changed

+179
-116
lines changed

packages/react-sdk-components/src/bridge/react_pconnect.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,15 @@ const connectRedux = (component, c11nEnv) => {
100100
}
101101
}
102102
}
103+
// For CaseSummary, we need to compare changes in
104+
// primaryFields and secondary Fields
105+
if (next.template === 'CaseSummary') {
106+
for (const key of Object.keys(prev)) {
107+
if (!PCore.isDeepEqual(next[key], prev[key])) {
108+
return false;
109+
}
110+
}
111+
}
103112
/* TODO For some rawConfig we are not getting routingInfo under allStateProps */
104113
return !routingInfoCompare(next, prev);
105114
}

packages/react-sdk-components/src/components/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,8 @@ export default function CaseSummaryFields(props: CaseSummaryFieldsProps) {
123123
slotProps={{
124124
input: {
125125
readOnly: true,
126-
inputProps: {
127-
style: { cursor: 'pointer' },
128-
disableUnderline: true
129-
}
126+
disableUnderline: true,
127+
inputProps: { style: { cursor: 'pointer' } }
130128
}
131129
}}
132130
/>

packages/react-sdk-components/src/components/helpers/simpleTableHelpers.ts

Lines changed: 116 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,51 @@ export const getApiContext = (processedData, pConnect, reorderCB) => {
8989
};
9090
};
9191

92+
const PRIMARY_FIELDS = 'pyPrimaryFields';
93+
const SUPPORTED_FIELD_TYPES = [
94+
'Address',
95+
'TextArea',
96+
'TextInput',
97+
'Phone',
98+
'Email',
99+
'Time',
100+
'URL',
101+
'Percentage',
102+
'Integer',
103+
'Decimal',
104+
'Date',
105+
'DateTime',
106+
'Currency',
107+
'Checkbox',
108+
'Dropdown',
109+
'AutoComplete',
110+
'UserReference',
111+
'RichText'
112+
];
113+
114+
export const getConfigFields = (rawFields, contextClass, primaryFieldsViewIndex) => {
115+
let primaryFields: any = [];
116+
let configFields: any = [];
117+
118+
if (primaryFieldsViewIndex > -1) {
119+
let primaryFieldVMD: any = PCore.getMetadataUtils().resolveView(PRIMARY_FIELDS);
120+
if (Array.isArray(primaryFieldVMD)) {
121+
primaryFieldVMD = primaryFieldVMD.find(primaryFieldView => primaryFieldView.classID === contextClass);
122+
primaryFields = primaryFieldVMD?.children?.[0]?.children || [];
123+
} else if (primaryFieldVMD?.classID === contextClass) {
124+
primaryFields = primaryFieldVMD?.children?.[0]?.children || [];
125+
}
126+
127+
if (primaryFields.length) {
128+
primaryFields = primaryFields.filter(primaryField => SUPPORTED_FIELD_TYPES.includes(primaryField.type));
129+
}
130+
}
131+
132+
configFields = [...rawFields.slice(0, primaryFieldsViewIndex), ...primaryFields, ...rawFields.slice(primaryFieldsViewIndex + 1)];
133+
// filter duplicate fields after combining raw fields and primary fields
134+
return configFields.filter((field, index) => configFields.findIndex(_field => field.config?.value === _field.config?.value) === index);
135+
};
136+
92137
export const buildMetaForListView = (fieldMetadata, fields, type, ruleClass, name, propertyLabel, isDataObject, parameters) => {
93138
return {
94139
name,
@@ -126,11 +171,80 @@ export const buildMetaForListView = (fieldMetadata, fields, type, ruleClass, nam
126171
};
127172
};
128173

129-
export const buildFieldsForTable = (configFields, fields, showDeleteButton) => {
174+
export function isFLProperty(label) {
175+
return label?.startsWith('@FL');
176+
}
177+
178+
/**
179+
* [getFieldLabel]
180+
* Description - A utility that returns resolved field label for "@FL" annotation i.e from data model.
181+
* @param {Object} fieldConfig
182+
* @returns {string} resolved label string
183+
*
184+
* example:
185+
* fieldConfig = {label: "@FL .pyID", classID: "TestCase-Work"};
186+
* return "Case ID"
187+
*/
188+
export function getFieldLabel(fieldConfig) {
189+
const { label, classID, caption } = fieldConfig;
190+
let fieldLabel = (label ?? caption)?.substring(4);
191+
const labelSplit = fieldLabel?.split('.');
192+
const propertyName = labelSplit?.pop();
193+
const fieldMetaData: any = PCore.getMetadataUtils().getPropertyMetadata(propertyName, classID) ?? {};
194+
fieldLabel = fieldMetaData.label ?? fieldMetaData.caption ?? propertyName;
195+
return fieldLabel;
196+
}
197+
198+
export const updateFieldLabels = (fields, configFields, primaryFieldsViewIndex, pConnect, options) => {
199+
const labelsOfFields: any = [];
200+
const { columnsRawConfig = [] } = options;
201+
fields.forEach((field, idx) => {
202+
const rawColumnConfig = columnsRawConfig[idx]?.config;
203+
if (field.config.value === PRIMARY_FIELDS) {
204+
labelsOfFields.push('');
205+
} else if (isFLProperty(rawColumnConfig?.label ?? rawColumnConfig?.caption)) {
206+
labelsOfFields.push(getFieldLabel(rawColumnConfig) || field.config.label || field.config.caption);
207+
} else {
208+
labelsOfFields.push(field.config.label || field.config.caption);
209+
}
210+
});
211+
212+
if (primaryFieldsViewIndex > -1) {
213+
const totalPrimaryFieldsColumns = configFields.length - fields.length + 1;
214+
if (totalPrimaryFieldsColumns) {
215+
const primaryFieldLabels: any = [];
216+
for (let i = primaryFieldsViewIndex; i < primaryFieldsViewIndex + totalPrimaryFieldsColumns; i += 1) {
217+
let label = configFields[i].config?.label;
218+
if (isFLProperty(label)) {
219+
label = getFieldLabel(configFields[i].config);
220+
} else if (label.startsWith('@')) {
221+
label = label.substring(3);
222+
}
223+
if (pConnect) {
224+
label = pConnect.getLocalizedValue(label);
225+
}
226+
primaryFieldLabels.push(label);
227+
}
228+
labelsOfFields.splice(primaryFieldsViewIndex, 1, ...primaryFieldLabels);
229+
} else {
230+
labelsOfFields.splice(primaryFieldsViewIndex, 1);
231+
}
232+
}
233+
return labelsOfFields;
234+
};
235+
236+
export const buildFieldsForTable = (configFields, pConnect, showDeleteButton, options) => {
237+
const { primaryFieldsViewIndex, fields } = options;
238+
239+
// get resolved field labels for primary fields raw config included in configFields
240+
const fieldsLabels = updateFieldLabels(fields, configFields, primaryFieldsViewIndex, pConnect, {
241+
columnsRawConfig: pConnect.getRawConfigProps()?.children.find(item => item?.name === 'Columns')?.children
242+
});
243+
130244
const fieldDefs = configFields.map((field, index) => {
131245
return {
132246
type: 'text',
133-
label: fields[index].config.label || fields[index].config.caption,
247+
label: fieldsLabels[index],
134248
fillAvailableSpace: !!field.config.fillAvailableSpace,
135249
id: `${index}`,
136250
name: field.config.value.substr(4),

packages/react-sdk-components/src/components/infra/Containers/FlowContainer/FlowContainer.tsx

Lines changed: 12 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export const FlowContainer = (props: FlowContainerProps) => {
5858
const AlertBanner = getComponentFromMap('AlertBanner');
5959

6060
const pCoreConstants = PCore.getConstants();
61-
const PCoreVersion = PCore.getPCoreVersion();
6261
const { TODO } = pCoreConstants;
6362
const todo_headerText = 'To do';
6463

@@ -78,6 +77,7 @@ export const FlowContainer = (props: FlowContainerProps) => {
7877
const getPConnect = getPConnectOfActiveContainerItem || getPConnectOfFlowContainer;
7978
const thePConn = getPConnect();
8079
const containerName = assignmentNames && assignmentNames.length > 0 ? assignmentNames[0] : '';
80+
const bShowBanner = showBanner(getPConnect);
8181
// const [init, setInit] = useState(true);
8282
// const [fcState, setFCState] = useState({ hasError: false });
8383

@@ -104,7 +104,6 @@ export const FlowContainer = (props: FlowContainerProps) => {
104104
function getBuildName(): string {
105105
const ourPConn = getPConnect();
106106

107-
// let { getPConnect, name } = this.pConn$.pConn;
108107
const context = ourPConn.getContextName();
109108
let viewContainerName = ourPConn.getContainerName();
110109

@@ -113,7 +112,7 @@ export const FlowContainer = (props: FlowContainerProps) => {
113112
}
114113

115114
function getTodoVisibility() {
116-
const caseViewMode = getPConnect().getValue('context_data.caseViewMode', ''); // 2nd arg empty string until typedefs properly allow optional
115+
const caseViewMode = getPConnect().getValue('context_data.caseViewMode');
117116
if (caseViewMode && caseViewMode === 'review') {
118117
return true;
119118
}
@@ -123,16 +122,6 @@ export const FlowContainer = (props: FlowContainerProps) => {
123122
function initComponent() {
124123
const ourPConn = getPConnect();
125124

126-
// debugging/investigation help
127-
// console.log(`${ourPConn.getComponentName()}: children update for main draw`);
128-
129-
// const oData = ourPConn.getDataObject();
130-
131-
// const activeActionLabel = "";
132-
// const child0_getPConnect = arNewChildren[0].getPConnect();
133-
134-
// this.templateName$ = this.configProps$["template"];
135-
136125
// debugger;
137126
setShowTodo(getTodoVisibility());
138127

@@ -156,63 +145,6 @@ export const FlowContainer = (props: FlowContainerProps) => {
156145
}
157146
}, [isInitialized, hasItems]);
158147

159-
function isCaseWideLocalAction() {
160-
const ourPConn = getPConnect();
161-
162-
const actionID = ourPConn.getValue(pCoreConstants.CASE_INFO.ACTIVE_ACTION_ID, ''); // 2nd arg empty string until typedefs properly allow optional
163-
const caseActions = ourPConn.getValue(pCoreConstants.CASE_INFO.AVAILABLEACTIONS, ''); // 2nd arg empty string until typedefs properly allow optional
164-
let bCaseWideAction = false;
165-
if (caseActions && actionID) {
166-
const actionObj = caseActions.find(caseAction => caseAction.ID === actionID);
167-
if (actionObj) {
168-
bCaseWideAction = actionObj.type === 'Case';
169-
}
170-
}
171-
return bCaseWideAction;
172-
}
173-
174-
function hasChildCaseAssignments() {
175-
const ourPConn = getPConnect();
176-
177-
const childCases = ourPConn.getValue(pCoreConstants.CASE_INFO.CHILD_ASSIGNMENTS, ''); // 2nd arg empty string until typedefs properly allow optional
178-
// const allAssignments = [];
179-
return !!(childCases && childCases.length > 0);
180-
}
181-
182-
function hasAssignments() {
183-
const ourPConn = getPConnect();
184-
185-
let bHasAssignments = false;
186-
const assignmentsList: any[] = ourPConn.getValue(pCoreConstants.CASE_INFO.D_CASE_ASSIGNMENTS_RESULTS, ''); // 2nd arg empty string until typedefs properly allow optional
187-
const isEmbedded = window.location.href.includes('embedded');
188-
let bAssignmentsForThisOperator = false;
189-
// 8.7 includes assignments in Assignments List that may be assigned to
190-
// a different operator. So, see if there are any assignments for
191-
// the current operator
192-
if (PCoreVersion?.includes('8.7') || isEmbedded) {
193-
const thisOperator = PCore.getEnvironmentInfo().getOperatorIdentifier();
194-
for (const assignment of assignmentsList) {
195-
if (assignment.assigneeInfo.ID === thisOperator) {
196-
bAssignmentsForThisOperator = true;
197-
}
198-
}
199-
} else {
200-
bAssignmentsForThisOperator = true;
201-
}
202-
// Bail out if there isn't an assignmentsList
203-
if (!assignmentsList) {
204-
return bHasAssignments;
205-
}
206-
207-
const bHasChildCaseAssignments = hasChildCaseAssignments();
208-
209-
if (bAssignmentsForThisOperator || bHasChildCaseAssignments || isCaseWideLocalAction()) {
210-
bHasAssignments = true;
211-
}
212-
213-
return bHasAssignments;
214-
}
215-
216148
// From SDK-WC updateSelf - so do this in useEffect that's run only when the props change...
217149
useEffect(() => {
218150
setBuildName(getBuildName());
@@ -222,29 +154,21 @@ export const FlowContainer = (props: FlowContainerProps) => {
222154

223155
let loadingInfo: any;
224156
try {
225-
loadingInfo = thePConn.getLoadingStatus(''); // 1st arg empty string until typedefs properly allow optional
157+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
158+
loadingInfo = thePConn.getLoadingStatus();
226159
} catch (ex) {
227160
// eslint-disable-next-line no-console
228161
console.error(`${thePConn.getComponentName()}: loadingInfo catch block`);
229162
}
230163

231-
// let configProps = this.thePConn.resolveConfigProps(this.thePConn.getConfigProps());
232-
233-
if (!loadingInfo) {
234-
// turn off spinner
235-
// this.psService.sendMessage(false);
236-
}
237-
238-
const caseViewMode = thePConn.getValue('context_data.caseViewMode', ''); // 2nd arg empty string until typedefs properly allow optional
164+
const caseViewMode = thePConn.getValue('context_data.caseViewMode');
239165
const { CASE_INFO: CASE_CONSTS } = pCoreConstants;
240166
if (caseViewMode && caseViewMode === 'review') {
241167
setTimeout(() => {
242168
// updated for 8.7 - 30-Mar-2022
243169
const todoAssignments = getToDoAssignments(thePConn);
244-
if (todoAssignments && todoAssignments.length > 0) {
245-
setCaseInfoID(thePConn.getValue(CASE_CONSTS.CASE_INFO_ID, '')); // 2nd arg empty string until typedefs properly allow optional
246-
setTodoDatasource({ source: todoAssignments });
247-
}
170+
setCaseInfoID(thePConn.getValue(CASE_CONSTS.CASE_INFO_ID));
171+
setTodoDatasource({ source: todoAssignments });
248172
setShowTodo(true);
249173
setShowTodoList(false);
250174
}, 100);
@@ -255,11 +179,12 @@ export const FlowContainer = (props: FlowContainerProps) => {
255179
}
256180

257181
// if have caseMessage show message and end
258-
const theCaseMessages = localizedVal(thePConn.getValue('caseMessages', ''), localeCategory); // 2nd arg empty string until typedefs properly allow optional
182+
const theCaseMessages = localizedVal(thePConn.getValue('caseMessages'), localeCategory);
259183

260-
// caseMessages's behavior has changed in 24.2, and hence it doesn't let Optional Action work.
261-
// Changing the below condition for now. Was: (theCaseMessages || !hasAssignments())
262-
if (!hasAssignments()) {
184+
const rootInfo = PCore.getContainerUtils().getContainerItemData(getPConnect().getTarget(), itemKey);
185+
const bConfirmView = rootInfo && bShowBanner;
186+
187+
if (bConfirmView) {
263188
// Temp fix for 8.7 change: confirmationNote no longer coming through in caseMessages$.
264189
// So, if we get here and caseMessages$ is empty, use default value in DX API response
265190
setCaseMessages(theCaseMessages || localizedVal('Thank you! The next step in this case has been routed appropriately.', localeCategory));
@@ -279,8 +204,6 @@ export const FlowContainer = (props: FlowContainerProps) => {
279204
const urgency = getPConnect().getCaseSummary().assignments ? getPConnect().getCaseSummary().assignments?.[0].urgency : '';
280205
const operatorInitials = Utils.getInitials(PCore.getEnvironmentInfo().getOperatorName() || '');
281206

282-
const bShowBanner = showBanner(getPConnect);
283-
284207
const displayPageMessages = () => {
285208
let hasBanner = false;
286209
const messages = pageMessages ? pageMessages.map(msg => localizedVal(msg.message, 'Messages')) : pageMessages;

0 commit comments

Comments
 (0)