@pega/react-sdk-overrides 0.23.6
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/lib/designSystemExtensions/CaseSummaryFields/CaseSummaryFields.css +19 -0
- package/lib/designSystemExtensions/CaseSummaryFields/CaseSummaryFields.tsx +156 -0
- package/lib/designSystemExtensions/CaseSummaryFields/index.tsx +1 -0
- package/lib/designSystemExtensions/DetailsFields/DetailsFields.tsx +154 -0
- package/lib/designSystemExtensions/DetailsFields/index.tsx +1 -0
- package/lib/designSystemExtensions/FieldGroup/FieldGroup.tsx +113 -0
- package/lib/designSystemExtensions/FieldGroup/index.tsx +1 -0
- package/lib/designSystemExtensions/FieldGroupList/FieldGroupList.tsx +53 -0
- package/lib/designSystemExtensions/FieldGroupList/index.tsx +1 -0
- package/lib/designSystemExtensions/FieldValueList/FieldValueList.tsx +106 -0
- package/lib/designSystemExtensions/FieldValueList/index.tsx +1 -0
- package/lib/designSystemExtensions/Operator/Operator.tsx +195 -0
- package/lib/designSystemExtensions/Operator/index.tsx +1 -0
- package/lib/designSystemExtensions/Pulse/Pulse.tsx +31 -0
- package/lib/designSystemExtensions/Pulse/index.tsx +1 -0
- package/lib/forms/AutoComplete/AutoComplete.tsx +183 -0
- package/lib/forms/AutoComplete/index.tsx +1 -0
- package/lib/forms/CancelAlert/CancelAlert.css +24 -0
- package/lib/forms/CancelAlert/CancelAlert.tsx +126 -0
- package/lib/forms/CancelAlert/index.tsx +1 -0
- package/lib/forms/Checkbox/Checkbox.tsx +68 -0
- package/lib/forms/Checkbox/index.tsx +1 -0
- package/lib/forms/Currency/Currency.tsx +89 -0
- package/lib/forms/Currency/index.tsx +1 -0
- package/lib/forms/Date/Date.tsx +79 -0
- package/lib/forms/Date/index.tsx +1 -0
- package/lib/forms/DateTime/DateTime.tsx +75 -0
- package/lib/forms/DateTime/index.tsx +1 -0
- package/lib/forms/Decimal/Decimal.tsx +51 -0
- package/lib/forms/Decimal/index.tsx +1 -0
- package/lib/forms/Dropdown/Dropdown.tsx +82 -0
- package/lib/forms/Dropdown/index.tsx +1 -0
- package/lib/forms/Email/Email.tsx +68 -0
- package/lib/forms/Email/index.tsx +1 -0
- package/lib/forms/Integer/Integer.tsx +77 -0
- package/lib/forms/Integer/index.tsx +1 -0
- package/lib/forms/Percentage/Percentage.tsx +82 -0
- package/lib/forms/Percentage/index.tsx +1 -0
- package/lib/forms/Phone/Phone.tsx +90 -0
- package/lib/forms/Phone/index.tsx +1 -0
- package/lib/forms/RadioButtons/RadioButtons.tsx +73 -0
- package/lib/forms/RadioButtons/index.tsx +1 -0
- package/lib/forms/SemanticLink/SemanticLink.tsx +69 -0
- package/lib/forms/SemanticLink/index.tsx +1 -0
- package/lib/forms/SemanticLink/utils.ts +51 -0
- package/lib/forms/TextArea/TextArea.tsx +66 -0
- package/lib/forms/TextArea/index.tsx +1 -0
- package/lib/forms/TextContent/TextContent.tsx +40 -0
- package/lib/forms/TextContent/index.tsx +1 -0
- package/lib/forms/TextInput/TextInput.tsx +61 -0
- package/lib/forms/TextInput/index.tsx +1 -0
- package/lib/forms/Time/Time.tsx +71 -0
- package/lib/forms/Time/index.tsx +1 -0
- package/lib/forms/URL/URL.tsx +53 -0
- package/lib/forms/URL/index.tsx +1 -0
- package/lib/forms/UserReference/UserReference.tsx +197 -0
- package/lib/forms/UserReference/UserReferenceUtils.ts +13 -0
- package/lib/forms/UserReference/index.tsx +1 -0
- package/lib/helpers/auth.js +483 -0
- package/lib/helpers/authManager.js +630 -0
- package/lib/helpers/config_access.js +268 -0
- package/lib/helpers/data_page.ts +24 -0
- package/lib/helpers/event-utils.js +20 -0
- package/lib/helpers/field-group-utils.js +61 -0
- package/lib/helpers/formatters/Boolean.js +38 -0
- package/lib/helpers/formatters/Currency.js +74 -0
- package/lib/helpers/formatters/CurrencyMap.js +908 -0
- package/lib/helpers/formatters/Date.js +77 -0
- package/lib/helpers/formatters/common.js +10 -0
- package/lib/helpers/formatters/index.js +120 -0
- package/lib/helpers/utils.ts +334 -0
- package/lib/helpers/versionHelpers.ts +50 -0
- package/lib/infra/ActionButtons/ActionButtons.tsx +70 -0
- package/lib/infra/ActionButtons/index.tsx +1 -0
- package/lib/infra/Assignment/Assignment.tsx +301 -0
- package/lib/infra/Assignment/index.tsx +1 -0
- package/lib/infra/AssignmentCard/AssignmentCard.tsx +47 -0
- package/lib/infra/AssignmentCard/index.tsx +1 -0
- package/lib/infra/Attachment/Attachment.css +18 -0
- package/lib/infra/Attachment/Attachment.tsx +404 -0
- package/lib/infra/Attachment/AttachmentUtils.js +71 -0
- package/lib/infra/Attachment/index.tsx +1 -0
- package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +511 -0
- package/lib/infra/Containers/FlowContainer/helpers.js +147 -0
- package/lib/infra/Containers/FlowContainer/index.tsx +1 -0
- package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +320 -0
- package/lib/infra/Containers/ModalViewContainer/index.tsx +1 -0
- package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +216 -0
- package/lib/infra/Containers/ViewContainer/index.tsx +1 -0
- package/lib/infra/DashboardFilter/DashboardFilter.tsx +180 -0
- package/lib/infra/DashboardFilter/filterUtils.tsx +188 -0
- package/lib/infra/DashboardFilter/index.tsx +1 -0
- package/lib/infra/DeferLoad/DeferLoad.tsx +175 -0
- package/lib/infra/DeferLoad/index.tsx +1 -0
- package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +103 -0
- package/lib/infra/ErrorBoundary/index.tsx +1 -0
- package/lib/infra/MultiStep/MultiStep.css +261 -0
- package/lib/infra/MultiStep/MultiStep.tsx +225 -0
- package/lib/infra/MultiStep/index.tsx +1 -0
- package/lib/infra/NavBar/NavBar.css +170 -0
- package/lib/infra/NavBar/NavBar.tsx +393 -0
- package/lib/infra/NavBar/index.tsx +1 -0
- package/lib/infra/Reference/Reference.tsx +58 -0
- package/lib/infra/Reference/index.tsx +1 -0
- package/lib/infra/Region/Region.tsx +17 -0
- package/lib/infra/Region/index.tsx +1 -0
- package/lib/infra/RootContainer/RootContainer.tsx +336 -0
- package/lib/infra/RootContainer/index.tsx +1 -0
- package/lib/infra/Stages/Stages.tsx +120 -0
- package/lib/infra/Stages/index.tsx +1 -0
- package/lib/infra/ToDo/ToDo.css +87 -0
- package/lib/infra/ToDo/ToDo.tsx +285 -0
- package/lib/infra/ToDo/index.tsx +1 -0
- package/lib/infra/VerticalTabs/LeftAlignVerticalTab.tsx +27 -0
- package/lib/infra/VerticalTabs/VerticalTabs.tsx +75 -0
- package/lib/infra/VerticalTabs/index.tsx +1 -0
- package/lib/infra/View/View.css +8 -0
- package/lib/infra/View/View.tsx +175 -0
- package/lib/infra/View/index.tsx +1 -0
- package/lib/templates/AppShell/AppShell.css +40 -0
- package/lib/templates/AppShell/AppShell.tsx +439 -0
- package/lib/templates/AppShell/index.tsx +1 -0
- package/lib/templates/CaseSummary/CaseSummary.tsx +50 -0
- package/lib/templates/CaseSummary/index.tsx +1 -0
- package/lib/templates/CaseView/CaseView.tsx +261 -0
- package/lib/templates/CaseView/CaseViewActionsMenu.tsx +73 -0
- package/lib/templates/CaseView/index.tsx +1 -0
- package/lib/templates/DataReference/DataReference.tsx +290 -0
- package/lib/templates/DataReference/index.tsx +1 -0
- package/lib/templates/DefaultForm/DefaultForm.css +25 -0
- package/lib/templates/DefaultForm/DefaultForm.tsx +52 -0
- package/lib/templates/DefaultForm/index.tsx +1 -0
- package/lib/templates/Details/Details/Details.tsx +35 -0
- package/lib/templates/Details/Details/index.tsx +1 -0
- package/lib/templates/Details/DetailsSubTabs/DetailsSubTabs.tsx +65 -0
- package/lib/templates/Details/DetailsSubTabs/index.tsx +1 -0
- package/lib/templates/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +45 -0
- package/lib/templates/Details/DetailsThreeColumn/index.tsx +1 -0
- package/lib/templates/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +43 -0
- package/lib/templates/Details/DetailsTwoColumn/index.tsx +1 -0
- package/lib/templates/FieldGroupTemplate/FieldGroupTemplate.tsx +94 -0
- package/lib/templates/FieldGroupTemplate/index.tsx +1 -0
- package/lib/templates/InlineDashboard/InlineDashboard.tsx +72 -0
- package/lib/templates/InlineDashboard/index.tsx +1 -0
- package/lib/templates/InlineDashboardPage/InlineDashboardPage.tsx +41 -0
- package/lib/templates/InlineDashboardPage/index.tsx +1 -0
- package/lib/templates/ListPage/ListPage.tsx +20 -0
- package/lib/templates/ListPage/index.tsx +1 -0
- package/lib/templates/ListView/ListView.css +10 -0
- package/lib/templates/ListView/ListView.tsx +1230 -0
- package/lib/templates/ListView/index.tsx +1 -0
- package/lib/templates/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +42 -0
- package/lib/templates/MultiReferenceReadOnly/index.tsx +1 -0
- package/lib/templates/NarrowWide/NarrowWide/NarrowWide.css +21 -0
- package/lib/templates/NarrowWide/NarrowWide/NarrowWide.tsx +35 -0
- package/lib/templates/NarrowWide/NarrowWide/index.tsx +1 -0
- package/lib/templates/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +53 -0
- package/lib/templates/NarrowWide/NarrowWideDetails/index.tsx +1 -0
- package/lib/templates/NarrowWide/NarrowWideForm/NarrowWideForm.css +21 -0
- package/lib/templates/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +24 -0
- package/lib/templates/NarrowWide/NarrowWideForm/index.tsx +1 -0
- package/lib/templates/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +38 -0
- package/lib/templates/NarrowWide/NarrowWidePage/index.tsx +1 -0
- package/lib/templates/OneColumn/OneColumn/OneColumn.tsx +32 -0
- package/lib/templates/OneColumn/OneColumn/index.tsx +1 -0
- package/lib/templates/OneColumn/OneColumnPage/OneColumnPage.tsx +24 -0
- package/lib/templates/OneColumn/OneColumnPage/index.tsx +1 -0
- package/lib/templates/OneColumn/OneColumnTab/OneColumnTab.tsx +17 -0
- package/lib/templates/OneColumn/OneColumnTab/index.tsx +1 -0
- package/lib/templates/PromotedFilters/PromotedFilters.css +7 -0
- package/lib/templates/PromotedFilters/PromotedFilters.tsx +160 -0
- package/lib/templates/PromotedFilters/index.tsx +1 -0
- package/lib/templates/SimpleTable/SimpleTable/SimpleTable.tsx +28 -0
- package/lib/templates/SimpleTable/SimpleTable/index.tsx +1 -0
- package/lib/templates/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +719 -0
- package/lib/templates/SimpleTable/SimpleTableManual/index.tsx +1 -0
- package/lib/templates/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +129 -0
- package/lib/templates/SimpleTable/SimpleTableSelect/index.tsx +1 -0
- package/lib/templates/SimpleTable/helpers.ts +360 -0
- package/lib/templates/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +66 -0
- package/lib/templates/SingleReferenceReadOnly/index.tsx +1 -0
- package/lib/templates/SubTabs/SubTabs.tsx +65 -0
- package/lib/templates/SubTabs/index.tsx +1 -0
- package/lib/templates/SubTabs/tabUtils.ts +73 -0
- package/lib/templates/TwoColumn/TwoColumn/TwoColumn.css +13 -0
- package/lib/templates/TwoColumn/TwoColumn/TwoColumn.tsx +58 -0
- package/lib/templates/TwoColumn/TwoColumn/index.tsx +1 -0
- package/lib/templates/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +25 -0
- package/lib/templates/TwoColumn/TwoColumnPage/index.tsx +1 -0
- package/lib/templates/TwoColumn/TwoColumnTab/TwoColumnTab.css +12 -0
- package/lib/templates/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +55 -0
- package/lib/templates/TwoColumn/TwoColumnTab/index.tsx +1 -0
- package/lib/templates/WideNarrow/WideNarrow/WideNarrow.css +21 -0
- package/lib/templates/WideNarrow/WideNarrow/WideNarrow.tsx +35 -0
- package/lib/templates/WideNarrow/WideNarrow/index.tsx +1 -0
- package/lib/templates/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +54 -0
- package/lib/templates/WideNarrow/WideNarrowDetails/index.tsx +1 -0
- package/lib/templates/WideNarrow/WideNarrowForm/WideNarrowForm.css +21 -0
- package/lib/templates/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +24 -0
- package/lib/templates/WideNarrow/WideNarrowForm/index.tsx +1 -0
- package/lib/templates/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +38 -0
- package/lib/templates/WideNarrow/WideNarrowPage/index.tsx +1 -0
- package/lib/templates/utils.ts +23 -0
- package/lib/widgets/AppAnnouncement/AppAnnouncement.tsx +67 -0
- package/lib/widgets/AppAnnouncement/index.tsx +1 -0
- package/lib/widgets/CaseHistory/CaseHistory.tsx +169 -0
- package/lib/widgets/CaseHistory/index.tsx +1 -0
- package/lib/widgets/FileUtility/ActionButtonsForFileUtil.css +27 -0
- package/lib/widgets/FileUtility/ActionButtonsForFileUtil.tsx +22 -0
- package/lib/widgets/FileUtility/FileUtility.css +117 -0
- package/lib/widgets/FileUtility/FileUtility.tsx +567 -0
- package/lib/widgets/FileUtility/index.tsx +0 -0
- package/lib/widgets/Followers/Followers.tsx +43 -0
- package/lib/widgets/Followers/index.tsx +1 -0
- package/lib/widgets/SummaryItem/SummaryItem.css +78 -0
- package/lib/widgets/SummaryItem/SummaryItem.tsx +80 -0
- package/lib/widgets/SummaryItem/index.tsx +1 -0
- package/lib/widgets/SummaryList/SummaryList.tsx +12 -0
- package/lib/widgets/SummaryList/index.tsx +1 -0
- package/package.json +14 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState, createElement } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import isEqual from 'fast-deep-equal';
|
|
4
|
+
import Dialog from '@material-ui/core/Dialog';
|
|
5
|
+
import DialogContent from '@material-ui/core/DialogContent';
|
|
6
|
+
import DialogTitle from '@material-ui/core/DialogTitle';
|
|
7
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
8
|
+
import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
|
|
9
|
+
import Assignment from '@pega/react-sdk-components/lib/components/infra/Assignment';
|
|
10
|
+
import CancelAlert from '@pega/react-sdk-components/lib/components/forms/CancelAlert';
|
|
11
|
+
import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
|
|
12
|
+
|
|
13
|
+
declare const PCore;
|
|
14
|
+
|
|
15
|
+
function buildName(pConnect, name = '') {
|
|
16
|
+
const context = pConnect.getContextName();
|
|
17
|
+
return `${context}/${name}`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getKeyAndLatestItem(routinginfo, pConn) {
|
|
21
|
+
const containerName = pConn.getContainerName();
|
|
22
|
+
if (PCore.getContainerUtils().hasContainerItems(buildName(pConn, containerName))) {
|
|
23
|
+
const { accessedOrder, items } = routinginfo;
|
|
24
|
+
const key = accessedOrder[accessedOrder.length - 1];
|
|
25
|
+
const latestItem = items[key];
|
|
26
|
+
return { key, latestItem };
|
|
27
|
+
}
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getConfigObject(item, pConnect) {
|
|
32
|
+
if (item) {
|
|
33
|
+
const { context, view } = item;
|
|
34
|
+
const config = {
|
|
35
|
+
meta: view,
|
|
36
|
+
options: {
|
|
37
|
+
context,
|
|
38
|
+
pageReference: view.config.context || pConnect.getPageReference(),
|
|
39
|
+
hasForm: true
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return PCore.createPConnect(config);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const useStyles = makeStyles(theme => ({
|
|
48
|
+
dlgTitle: {
|
|
49
|
+
marginLeft: theme.spacing(2),
|
|
50
|
+
marginRight: theme.spacing(2),
|
|
51
|
+
marginTop: theme.spacing(2),
|
|
52
|
+
marginBottom: theme.spacing(0)
|
|
53
|
+
// paddingLeft: theme.spacing(0),
|
|
54
|
+
// paddingRight: theme.spacing(0),
|
|
55
|
+
// paddingTop: theme.spacing(0),
|
|
56
|
+
// paddingBottom: theme.spacing(0),
|
|
57
|
+
},
|
|
58
|
+
dlgContent: {
|
|
59
|
+
marginLeft: theme.spacing(2),
|
|
60
|
+
marginRight: theme.spacing(2),
|
|
61
|
+
marginTop: theme.spacing(0),
|
|
62
|
+
marginBottom: theme.spacing(2)
|
|
63
|
+
// paddingLeft: theme.spacing(0),
|
|
64
|
+
// paddingRight: theme.spacing(0),
|
|
65
|
+
// paddingTop: theme.spacing(0),
|
|
66
|
+
// paddingBottom: theme.spacing(0),
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
|
|
70
|
+
const ModalViewContainer = props => {
|
|
71
|
+
const classes = useStyles();
|
|
72
|
+
|
|
73
|
+
const routingInfoRef = useRef({});
|
|
74
|
+
const { getPConnect, routingInfo, loadingInfo } = props;
|
|
75
|
+
const pConn = getPConnect();
|
|
76
|
+
const {
|
|
77
|
+
CONTAINER_TYPE: { MULTIPLE },
|
|
78
|
+
PUB_SUB_EVENTS: { EVENT_SHOW_CANCEL_ALERT }
|
|
79
|
+
} = PCore.getConstants();
|
|
80
|
+
const { subscribe } = PCore.getPubSubUtils();
|
|
81
|
+
const [bShowModal, setShowModal] = useState(false);
|
|
82
|
+
const [bSubscribed, setSubscribed] = useState(false);
|
|
83
|
+
const [bShowCancelAlert, setShowCancelAlert] = useState(false);
|
|
84
|
+
const [oCaseInfo, setOCaseInfo] = useState({});
|
|
85
|
+
const [createdView, setCreatedView] = useState<any>(null);
|
|
86
|
+
const [title, setTitle] = useState('');
|
|
87
|
+
const [arNewChildrenAsReact, setArNewChildrenAsReact] = useState<Array<any>>([]);
|
|
88
|
+
const [itemKey, setItemKey] = useState('');
|
|
89
|
+
const [cancelPConn, setCancelPConn] = useState(null);
|
|
90
|
+
|
|
91
|
+
function showAlert(payload) {
|
|
92
|
+
const { latestItem } = getKeyAndLatestItem(routingInfoRef.current, pConn);
|
|
93
|
+
const { isModalAction } = payload;
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
If we are in create stage full page mode, created a new case and trying to click on cancel button
|
|
97
|
+
it will show two alert dialogs which is not expected. Hence isModalAction flag to avoid that.
|
|
98
|
+
*/
|
|
99
|
+
if (latestItem && isModalAction) {
|
|
100
|
+
const configObject = getConfigObject(latestItem, pConn);
|
|
101
|
+
setCancelPConn(configObject.getPConnect());
|
|
102
|
+
setShowCancelAlert(true);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function compareCaseInfoIsDifferent(oCurrentCaseInfo: Object): boolean {
|
|
107
|
+
let bRet = false;
|
|
108
|
+
|
|
109
|
+
// fast-deep-equal version
|
|
110
|
+
if (isEqual !== undefined) {
|
|
111
|
+
bRet = !isEqual(oCaseInfo, oCurrentCaseInfo);
|
|
112
|
+
} else {
|
|
113
|
+
const sCurrentCaseInfo = JSON.stringify(oCurrentCaseInfo);
|
|
114
|
+
const sOldCaseInfo = JSON.stringify(oCaseInfo);
|
|
115
|
+
// stringify compare version
|
|
116
|
+
if (sCurrentCaseInfo !== sOldCaseInfo) {
|
|
117
|
+
bRet = true;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// if different, save off new case info
|
|
122
|
+
if (bRet) {
|
|
123
|
+
setOCaseInfo(JSON.parse(JSON.stringify(oCurrentCaseInfo)));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return bRet;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const updateAlertState = modalFlag => {
|
|
130
|
+
setShowCancelAlert(false);
|
|
131
|
+
setShowModal(modalFlag);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
// Establish the necessary containers
|
|
136
|
+
const containerMgr = pConn.getContainerManager();
|
|
137
|
+
containerMgr.initializeContainers({ type: MULTIPLE });
|
|
138
|
+
}, [MULTIPLE, pConn]);
|
|
139
|
+
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
// Update routingInfoRef.current whenever routingInfo changes
|
|
142
|
+
routingInfoRef.current = routingInfo;
|
|
143
|
+
}, [routingInfo]);
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (routingInfoRef.current && !loadingInfo) {
|
|
147
|
+
const currentOrder = routingInfo.accessedOrder;
|
|
148
|
+
|
|
149
|
+
if (undefined === currentOrder) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const currentItems = routingInfo.items;
|
|
154
|
+
|
|
155
|
+
const { key, latestItem } = getKeyAndLatestItem(routingInfoRef.current, pConn);
|
|
156
|
+
|
|
157
|
+
// console.log(`ModalViewContainer: key: ${key} latestItem: ${JSON.stringify(latestItem)}`);
|
|
158
|
+
|
|
159
|
+
if (currentOrder.length > 0) {
|
|
160
|
+
if (
|
|
161
|
+
currentItems[key] &&
|
|
162
|
+
currentItems[key].view &&
|
|
163
|
+
!Utils.isEmptyObject(currentItems[key].view)
|
|
164
|
+
) {
|
|
165
|
+
const currentItem = currentItems[key];
|
|
166
|
+
const rootView = currentItem.view;
|
|
167
|
+
const { context } = rootView.config;
|
|
168
|
+
const config = { meta: rootView };
|
|
169
|
+
config['options'] = {
|
|
170
|
+
context: currentItem.context,
|
|
171
|
+
hasForm: true,
|
|
172
|
+
pageReference: context || pConn.getPageReference()
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
if (!bSubscribed) {
|
|
176
|
+
setSubscribed(true);
|
|
177
|
+
subscribe(
|
|
178
|
+
EVENT_SHOW_CANCEL_ALERT,
|
|
179
|
+
showAlert,
|
|
180
|
+
EVENT_SHOW_CANCEL_ALERT /* Unique string for subscription */
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const configObject = PCore.createPConnect(config);
|
|
185
|
+
|
|
186
|
+
// THIS is where the ViewContainer creates a View
|
|
187
|
+
// The config has meta.config.type = "view"
|
|
188
|
+
const newComp = configObject.getPConnect();
|
|
189
|
+
// const newCompName = newComp.getComponentName();
|
|
190
|
+
const caseInfo =
|
|
191
|
+
newComp && newComp.getDataObject() && newComp.getDataObject().caseInfo
|
|
192
|
+
? newComp.getDataObject().caseInfo
|
|
193
|
+
: null;
|
|
194
|
+
|
|
195
|
+
// console.log(`ModalViewContainer just created newComp: ${newCompName}`);
|
|
196
|
+
|
|
197
|
+
// The metadata for pyDetails changed such that the "template": "CaseView"
|
|
198
|
+
// is no longer a child of the created View but is in the created View's
|
|
199
|
+
// config. So, we DON'T want to replace this.pConn$ since the created
|
|
200
|
+
// component is a View (and not a ViewContainer). We now look for the
|
|
201
|
+
// "template" type directly in the created component (newComp) and NOT
|
|
202
|
+
// as a child of the newly created component.
|
|
203
|
+
// console.log(`---> ModalViewContainer created new ${newCompName}`);
|
|
204
|
+
|
|
205
|
+
// Use the newly created component (View) info but DO NOT replace
|
|
206
|
+
// this ModalViewContainer's pConn$, etc.
|
|
207
|
+
// Note that we're now using the newly created View's PConnect in the
|
|
208
|
+
// ViewContainer HTML template to guide what's rendered similar to what
|
|
209
|
+
// the React return of React.Fragment does
|
|
210
|
+
|
|
211
|
+
// right now need to check caseInfo for changes, to trigger redraw, not getting
|
|
212
|
+
// changes from angularPconnect except for first draw
|
|
213
|
+
if (newComp && caseInfo && compareCaseInfoIsDifferent(caseInfo)) {
|
|
214
|
+
setCreatedView(configObject);
|
|
215
|
+
|
|
216
|
+
const { actionName } = latestItem;
|
|
217
|
+
const theNewCaseInfo = newComp.getCaseInfo();
|
|
218
|
+
const caseName = theNewCaseInfo.getName();
|
|
219
|
+
const ID = theNewCaseInfo.getID();
|
|
220
|
+
|
|
221
|
+
setTitle(actionName || `New ${caseName} (${ID})`);
|
|
222
|
+
|
|
223
|
+
let arChildrenAsReact: Array<any> = [];
|
|
224
|
+
|
|
225
|
+
if (newComp.getComponentName() === 'reference') {
|
|
226
|
+
// Reference component doesn't have children. It can build the View we want.
|
|
227
|
+
// The Reference component getPConnect is in configObject
|
|
228
|
+
|
|
229
|
+
arChildrenAsReact.push(
|
|
230
|
+
createElement(createPConnectComponent(), {
|
|
231
|
+
...configObject,
|
|
232
|
+
key: `${caseName}-${ID}`
|
|
233
|
+
})
|
|
234
|
+
);
|
|
235
|
+
} else {
|
|
236
|
+
// This is the 8.6 implementation. Leaving it in for reference for now.
|
|
237
|
+
// And create a similar array of the children as React components
|
|
238
|
+
// passed to Assignment component when rendered
|
|
239
|
+
arChildrenAsReact = newComp.getChildren().map(child => {
|
|
240
|
+
// Use Case Summary ID as the React element's key
|
|
241
|
+
const caseSummaryID = child.getPConnect().getCaseSummary().ID;
|
|
242
|
+
return createElement(createPConnectComponent(), { ...child, key: caseSummaryID });
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (arChildrenAsReact.length > 0) setArNewChildrenAsReact(arChildrenAsReact);
|
|
247
|
+
|
|
248
|
+
setShowModal(true);
|
|
249
|
+
|
|
250
|
+
// save off itemKey to be used for finishAssignment, etc.
|
|
251
|
+
setItemKey(key);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
if (bShowModal) {
|
|
256
|
+
setShowModal(false);
|
|
257
|
+
}
|
|
258
|
+
if (!Utils.isEmptyObject(oCaseInfo)) {
|
|
259
|
+
setOCaseInfo({});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// function placeholderModalClose() {
|
|
266
|
+
// // Intentionally a no-op. Similar behavior in other SDKs.
|
|
267
|
+
// // Does NOT close the window. This forces the user to use
|
|
268
|
+
// // the cancel or submit button to close the modal (which, in turn, gets the right
|
|
269
|
+
// // Constellation code to run to clean up the containers, data, etc.)
|
|
270
|
+
|
|
271
|
+
// // console.log(`ModalViewContainer: placeholderModalClose setting bShowModal to false`) setShowModal(false);
|
|
272
|
+
// }
|
|
273
|
+
|
|
274
|
+
// if (bShowModal) {
|
|
275
|
+
// console.log(`ModalViewContainer about to show modal with`);
|
|
276
|
+
// console.log(`--> createdView: ${createdView} createdView.getPConnect: ${typeof createdView.getPConnect}`);
|
|
277
|
+
// console.log(`--> itemKey: ${itemKey}`);
|
|
278
|
+
// console.log(`--> arNewChildrenAsReact: ${JSON.stringify(arNewChildrenAsReact)}`);
|
|
279
|
+
// }
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<>
|
|
283
|
+
<Dialog open={bShowModal} aria-labelledby='form-dialog-title'>
|
|
284
|
+
<DialogTitle id='form-dialog-title' className={classes.dlgTitle}>
|
|
285
|
+
{title}
|
|
286
|
+
</DialogTitle>
|
|
287
|
+
<DialogContent className={classes.dlgContent}>
|
|
288
|
+
{bShowModal ? (
|
|
289
|
+
<Assignment getPConnect={createdView.getPConnect} itemKey={itemKey} isCreateStage>
|
|
290
|
+
{arNewChildrenAsReact}
|
|
291
|
+
</Assignment>
|
|
292
|
+
) : (
|
|
293
|
+
<></>
|
|
294
|
+
)}
|
|
295
|
+
</DialogContent>
|
|
296
|
+
</Dialog>
|
|
297
|
+
{bShowCancelAlert && (
|
|
298
|
+
<CancelAlert
|
|
299
|
+
pConn={cancelPConn}
|
|
300
|
+
showAlert={bShowCancelAlert}
|
|
301
|
+
updateAlertState={updateAlertState}
|
|
302
|
+
/>
|
|
303
|
+
)}
|
|
304
|
+
</>
|
|
305
|
+
);
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export default ModalViewContainer;
|
|
309
|
+
|
|
310
|
+
ModalViewContainer.defaultProps = {
|
|
311
|
+
getPConnect: null,
|
|
312
|
+
loadingInfo: false,
|
|
313
|
+
routingInfo: null
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
ModalViewContainer.propTypes = {
|
|
317
|
+
getPConnect: PropTypes.func,
|
|
318
|
+
loadingInfo: PropTypes.bool,
|
|
319
|
+
routingInfo: PropTypes.objectOf(PropTypes.any)
|
|
320
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ModalViewContainer';
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import React, { useEffect, useState, useContext, createElement } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { Box, CircularProgress } from "@material-ui/core";
|
|
4
|
+
import createPConnectComponent from "@pega/react-sdk-components/lib/bridge/react_pconnect";
|
|
5
|
+
import StoreContext from "@pega/react-sdk-components/lib/bridge/Context/StoreContext";
|
|
6
|
+
import Utils from '@pega/react-sdk-components/lib/components/helpers/utils';
|
|
7
|
+
|
|
8
|
+
// ViewContainer can emit View
|
|
9
|
+
// import View from '../View';
|
|
10
|
+
|
|
11
|
+
declare const PCore;
|
|
12
|
+
|
|
13
|
+
//
|
|
14
|
+
// WARNING: It is not expected that this file should be modified. It is part of infrastructure code that works with
|
|
15
|
+
// Redux and creation/update of Redux containers and PConnect. Modifying this code could have undesireable results and
|
|
16
|
+
// is totally at your own risk.
|
|
17
|
+
//
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
export default function ViewContainer(props) {
|
|
21
|
+
// const { getPConnect, children, routingInfo, name } = props;
|
|
22
|
+
const { getPConnect, name, mode, limit, loadingInfo, routingInfo } = props;
|
|
23
|
+
|
|
24
|
+
const { displayOnlyFA } = useContext(StoreContext);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const { CONTAINER_TYPE, APP } = PCore.getConstants();
|
|
28
|
+
const pConn = getPConnect();
|
|
29
|
+
const containerMgr: any = pConn.getContainerManager();
|
|
30
|
+
|
|
31
|
+
const [dispatchObjState, setDispatchObjState] = useState({
|
|
32
|
+
dispatchObject: {semanticURL: "", context: "", acName: ""},
|
|
33
|
+
visible: false,
|
|
34
|
+
loadingInfo: null,
|
|
35
|
+
isLoadingInfoChange: false
|
|
36
|
+
}); // was this.state in class-based ViewContainer avoiding use of just "state" as the name
|
|
37
|
+
|
|
38
|
+
let root;
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
const thePConn = ((typeof getPConnect) === 'function') ? getPConnect() : null;
|
|
42
|
+
|
|
43
|
+
// beginning of functions for use by ViewContainer
|
|
44
|
+
|
|
45
|
+
function buildName() {
|
|
46
|
+
const context = thePConn.getContextName();
|
|
47
|
+
let viewContainerName = name;
|
|
48
|
+
if (!viewContainerName) viewContainerName = "";
|
|
49
|
+
return `${context.toUpperCase()}/${viewContainerName.toUpperCase()}`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function prepareDispatchObject() {
|
|
53
|
+
const baseContext = pConn.getContextName();
|
|
54
|
+
const { acName = "primary" } = pConn.getContainerName();
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
semanticURL: "",
|
|
58
|
+
context: baseContext,
|
|
59
|
+
acName
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// determine if or not loadingInfo prop changed on next re-render
|
|
64
|
+
// function getDerivedStateFromProps(nextProps, prevState) {
|
|
65
|
+
// const { loadingInfo: prevLoadingInfo } = prevState;
|
|
66
|
+
// const { loadingInfo: nextLoadingIndfo } = nextProps;
|
|
67
|
+
// return {
|
|
68
|
+
// loadingInfo: nextLoadingIndfo,
|
|
69
|
+
// isLoadingInfoChange: prevLoadingInfo !== nextLoadingIndfo
|
|
70
|
+
// };
|
|
71
|
+
// }
|
|
72
|
+
|
|
73
|
+
// set the root component that is retrieved by PConnectHOC
|
|
74
|
+
function setRootComponent(configObject) {
|
|
75
|
+
|
|
76
|
+
const { isLoadingInfoChange } = dispatchObjState;
|
|
77
|
+
if (!isLoadingInfoChange) {
|
|
78
|
+
root = createElement(createPConnectComponent(), configObject);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// end of functions for use by ViewContainer
|
|
83
|
+
|
|
84
|
+
// useEffect on [] -> code that should be run once (as in old constructor and in componentDidMount)
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
|
|
87
|
+
// This is adapted from the class-based ViewContainer constructor
|
|
88
|
+
containerMgr.initializeContainers({
|
|
89
|
+
type:
|
|
90
|
+
mode === CONTAINER_TYPE.MULTIPLE
|
|
91
|
+
? CONTAINER_TYPE.MULTIPLE
|
|
92
|
+
: CONTAINER_TYPE.SINGLE
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
if (mode === CONTAINER_TYPE.MULTIPLE && limit) {
|
|
96
|
+
/* NOTE: setContainerLimit use is temporary. It is a non-public, unsupported API. */
|
|
97
|
+
PCore.getContainerUtils().setContainerLimit(`${APP.APP}/${name}`, limit);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const dispatchObject = prepareDispatchObject();
|
|
101
|
+
setDispatchObjState( {
|
|
102
|
+
dispatchObject,
|
|
103
|
+
// PCore is defined in pxBootstrapShell - eventually will be exported in place of constellationCore
|
|
104
|
+
visible: !PCore.checkIfSemanticURL(),
|
|
105
|
+
loadingInfo,
|
|
106
|
+
isLoadingInfoChange: false
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const { visible } = dispatchObjState;
|
|
110
|
+
if (visible) containerMgr.addContainerItem(dispatchObject);
|
|
111
|
+
|
|
112
|
+
// This is adapted from the class-based ViewContainer componentDidMount
|
|
113
|
+
let objectForAddContainer;
|
|
114
|
+
if (PCore.checkIfSemanticURL()) {
|
|
115
|
+
objectForAddContainer = prepareDispatchObject();
|
|
116
|
+
} else {
|
|
117
|
+
const { dispatchObject: theDispatchObject } = dispatchObjState;
|
|
118
|
+
objectForAddContainer = theDispatchObject;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Getting default view label
|
|
122
|
+
const navPages = pConn.getValue("pyPortal.pyPrimaryNavPages");
|
|
123
|
+
const defaultViewLabel =
|
|
124
|
+
Array.isArray(navPages) && navPages[0] ? navPages[0].pyLabel : "";
|
|
125
|
+
// TODO: Plan is to rename window.constellationCore to window.pega (or similar)
|
|
126
|
+
// And expose less via ui-bootstrap.js
|
|
127
|
+
// PCore is defined in pxBootstrapShell - eventually will be exported in place of constellationCore
|
|
128
|
+
|
|
129
|
+
if (!displayOnlyFA) {
|
|
130
|
+
// configureForBrowserBookmark not applicable in Embedded mode
|
|
131
|
+
PCore.configureForBrowserBookmark({
|
|
132
|
+
...objectForAddContainer,
|
|
133
|
+
defaultViewLabel
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
},
|
|
139
|
+
[]);
|
|
140
|
+
|
|
141
|
+
// This code (that's run every time the ViewContainer is called) is adapted from the class-based ViewContainer's render
|
|
142
|
+
|
|
143
|
+
// Looking for routingInfo
|
|
144
|
+
|
|
145
|
+
// debugging/investigation help
|
|
146
|
+
// console.log(`ViewContainer props: ${JSON.stringify(props)}`);
|
|
147
|
+
|
|
148
|
+
const theBuildName = buildName();
|
|
149
|
+
const { CREATE_DETAILS_VIEW_NAME } = PCore.getConstants();
|
|
150
|
+
if (routingInfo) {
|
|
151
|
+
const { accessedOrder, items } = routingInfo;
|
|
152
|
+
if (accessedOrder && items) {
|
|
153
|
+
const key = accessedOrder[accessedOrder.length - 1];
|
|
154
|
+
let componentVisible = accessedOrder.length > 0;
|
|
155
|
+
const { visible } = dispatchObjState;
|
|
156
|
+
componentVisible = visible || componentVisible;
|
|
157
|
+
if (
|
|
158
|
+
items[key] &&
|
|
159
|
+
items[key].view &&
|
|
160
|
+
!Utils.isEmptyObject(items[key].view)
|
|
161
|
+
) {
|
|
162
|
+
const latestItem = items[key];
|
|
163
|
+
const rootView = latestItem.view;
|
|
164
|
+
const { context, name: viewName } = rootView.config;
|
|
165
|
+
const config: any = { meta: rootView };
|
|
166
|
+
config.options = {
|
|
167
|
+
context: latestItem.context,
|
|
168
|
+
pageReference: context || getPConnect().getPageReference(),
|
|
169
|
+
containerName: getPConnect().getContainerName(),
|
|
170
|
+
containerItemName: key,
|
|
171
|
+
hasForm: viewName === CREATE_DETAILS_VIEW_NAME
|
|
172
|
+
};
|
|
173
|
+
const configObject = PCore.createPConnect(config);
|
|
174
|
+
|
|
175
|
+
// Add in displayOnlyFA if prop is on ViewContainer
|
|
176
|
+
if (displayOnlyFA) {
|
|
177
|
+
configObject["displayOnlyFA"] = true;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
setRootComponent(configObject);
|
|
181
|
+
return (
|
|
182
|
+
<React.Fragment key={theBuildName}>
|
|
183
|
+
{componentVisible && root}
|
|
184
|
+
{loadingInfo && <Box textAlign="center"><CircularProgress /></Box>}
|
|
185
|
+
</React.Fragment>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// fall through return if insufficient routingInfo
|
|
192
|
+
return (
|
|
193
|
+
<React.Fragment key={theBuildName}>
|
|
194
|
+
{loadingInfo && <Box textAlign="center"><CircularProgress /></Box>}
|
|
195
|
+
</React.Fragment>
|
|
196
|
+
);
|
|
197
|
+
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
ViewContainer.defaultProps = {
|
|
201
|
+
getPConnect: null,
|
|
202
|
+
name: "",
|
|
203
|
+
loadingInfo: false,
|
|
204
|
+
routingInfo: null,
|
|
205
|
+
mode: "single",
|
|
206
|
+
limit: 16
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
ViewContainer.propTypes = {
|
|
210
|
+
getPConnect: PropTypes.func,
|
|
211
|
+
name: PropTypes.string,
|
|
212
|
+
loadingInfo: PropTypes.bool,
|
|
213
|
+
routingInfo: PropTypes.objectOf(PropTypes.any),
|
|
214
|
+
mode: PropTypes.string,
|
|
215
|
+
limit: PropTypes.number
|
|
216
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './ViewContainer';
|