@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.
Files changed (220) hide show
  1. package/lib/designSystemExtensions/CaseSummaryFields/CaseSummaryFields.css +19 -0
  2. package/lib/designSystemExtensions/CaseSummaryFields/CaseSummaryFields.tsx +156 -0
  3. package/lib/designSystemExtensions/CaseSummaryFields/index.tsx +1 -0
  4. package/lib/designSystemExtensions/DetailsFields/DetailsFields.tsx +154 -0
  5. package/lib/designSystemExtensions/DetailsFields/index.tsx +1 -0
  6. package/lib/designSystemExtensions/FieldGroup/FieldGroup.tsx +113 -0
  7. package/lib/designSystemExtensions/FieldGroup/index.tsx +1 -0
  8. package/lib/designSystemExtensions/FieldGroupList/FieldGroupList.tsx +53 -0
  9. package/lib/designSystemExtensions/FieldGroupList/index.tsx +1 -0
  10. package/lib/designSystemExtensions/FieldValueList/FieldValueList.tsx +106 -0
  11. package/lib/designSystemExtensions/FieldValueList/index.tsx +1 -0
  12. package/lib/designSystemExtensions/Operator/Operator.tsx +195 -0
  13. package/lib/designSystemExtensions/Operator/index.tsx +1 -0
  14. package/lib/designSystemExtensions/Pulse/Pulse.tsx +31 -0
  15. package/lib/designSystemExtensions/Pulse/index.tsx +1 -0
  16. package/lib/forms/AutoComplete/AutoComplete.tsx +183 -0
  17. package/lib/forms/AutoComplete/index.tsx +1 -0
  18. package/lib/forms/CancelAlert/CancelAlert.css +24 -0
  19. package/lib/forms/CancelAlert/CancelAlert.tsx +126 -0
  20. package/lib/forms/CancelAlert/index.tsx +1 -0
  21. package/lib/forms/Checkbox/Checkbox.tsx +68 -0
  22. package/lib/forms/Checkbox/index.tsx +1 -0
  23. package/lib/forms/Currency/Currency.tsx +89 -0
  24. package/lib/forms/Currency/index.tsx +1 -0
  25. package/lib/forms/Date/Date.tsx +79 -0
  26. package/lib/forms/Date/index.tsx +1 -0
  27. package/lib/forms/DateTime/DateTime.tsx +75 -0
  28. package/lib/forms/DateTime/index.tsx +1 -0
  29. package/lib/forms/Decimal/Decimal.tsx +51 -0
  30. package/lib/forms/Decimal/index.tsx +1 -0
  31. package/lib/forms/Dropdown/Dropdown.tsx +82 -0
  32. package/lib/forms/Dropdown/index.tsx +1 -0
  33. package/lib/forms/Email/Email.tsx +68 -0
  34. package/lib/forms/Email/index.tsx +1 -0
  35. package/lib/forms/Integer/Integer.tsx +77 -0
  36. package/lib/forms/Integer/index.tsx +1 -0
  37. package/lib/forms/Percentage/Percentage.tsx +82 -0
  38. package/lib/forms/Percentage/index.tsx +1 -0
  39. package/lib/forms/Phone/Phone.tsx +90 -0
  40. package/lib/forms/Phone/index.tsx +1 -0
  41. package/lib/forms/RadioButtons/RadioButtons.tsx +73 -0
  42. package/lib/forms/RadioButtons/index.tsx +1 -0
  43. package/lib/forms/SemanticLink/SemanticLink.tsx +69 -0
  44. package/lib/forms/SemanticLink/index.tsx +1 -0
  45. package/lib/forms/SemanticLink/utils.ts +51 -0
  46. package/lib/forms/TextArea/TextArea.tsx +66 -0
  47. package/lib/forms/TextArea/index.tsx +1 -0
  48. package/lib/forms/TextContent/TextContent.tsx +40 -0
  49. package/lib/forms/TextContent/index.tsx +1 -0
  50. package/lib/forms/TextInput/TextInput.tsx +61 -0
  51. package/lib/forms/TextInput/index.tsx +1 -0
  52. package/lib/forms/Time/Time.tsx +71 -0
  53. package/lib/forms/Time/index.tsx +1 -0
  54. package/lib/forms/URL/URL.tsx +53 -0
  55. package/lib/forms/URL/index.tsx +1 -0
  56. package/lib/forms/UserReference/UserReference.tsx +197 -0
  57. package/lib/forms/UserReference/UserReferenceUtils.ts +13 -0
  58. package/lib/forms/UserReference/index.tsx +1 -0
  59. package/lib/helpers/auth.js +483 -0
  60. package/lib/helpers/authManager.js +630 -0
  61. package/lib/helpers/config_access.js +268 -0
  62. package/lib/helpers/data_page.ts +24 -0
  63. package/lib/helpers/event-utils.js +20 -0
  64. package/lib/helpers/field-group-utils.js +61 -0
  65. package/lib/helpers/formatters/Boolean.js +38 -0
  66. package/lib/helpers/formatters/Currency.js +74 -0
  67. package/lib/helpers/formatters/CurrencyMap.js +908 -0
  68. package/lib/helpers/formatters/Date.js +77 -0
  69. package/lib/helpers/formatters/common.js +10 -0
  70. package/lib/helpers/formatters/index.js +120 -0
  71. package/lib/helpers/utils.ts +334 -0
  72. package/lib/helpers/versionHelpers.ts +50 -0
  73. package/lib/infra/ActionButtons/ActionButtons.tsx +70 -0
  74. package/lib/infra/ActionButtons/index.tsx +1 -0
  75. package/lib/infra/Assignment/Assignment.tsx +301 -0
  76. package/lib/infra/Assignment/index.tsx +1 -0
  77. package/lib/infra/AssignmentCard/AssignmentCard.tsx +47 -0
  78. package/lib/infra/AssignmentCard/index.tsx +1 -0
  79. package/lib/infra/Attachment/Attachment.css +18 -0
  80. package/lib/infra/Attachment/Attachment.tsx +404 -0
  81. package/lib/infra/Attachment/AttachmentUtils.js +71 -0
  82. package/lib/infra/Attachment/index.tsx +1 -0
  83. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +511 -0
  84. package/lib/infra/Containers/FlowContainer/helpers.js +147 -0
  85. package/lib/infra/Containers/FlowContainer/index.tsx +1 -0
  86. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +320 -0
  87. package/lib/infra/Containers/ModalViewContainer/index.tsx +1 -0
  88. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +216 -0
  89. package/lib/infra/Containers/ViewContainer/index.tsx +1 -0
  90. package/lib/infra/DashboardFilter/DashboardFilter.tsx +180 -0
  91. package/lib/infra/DashboardFilter/filterUtils.tsx +188 -0
  92. package/lib/infra/DashboardFilter/index.tsx +1 -0
  93. package/lib/infra/DeferLoad/DeferLoad.tsx +175 -0
  94. package/lib/infra/DeferLoad/index.tsx +1 -0
  95. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +103 -0
  96. package/lib/infra/ErrorBoundary/index.tsx +1 -0
  97. package/lib/infra/MultiStep/MultiStep.css +261 -0
  98. package/lib/infra/MultiStep/MultiStep.tsx +225 -0
  99. package/lib/infra/MultiStep/index.tsx +1 -0
  100. package/lib/infra/NavBar/NavBar.css +170 -0
  101. package/lib/infra/NavBar/NavBar.tsx +393 -0
  102. package/lib/infra/NavBar/index.tsx +1 -0
  103. package/lib/infra/Reference/Reference.tsx +58 -0
  104. package/lib/infra/Reference/index.tsx +1 -0
  105. package/lib/infra/Region/Region.tsx +17 -0
  106. package/lib/infra/Region/index.tsx +1 -0
  107. package/lib/infra/RootContainer/RootContainer.tsx +336 -0
  108. package/lib/infra/RootContainer/index.tsx +1 -0
  109. package/lib/infra/Stages/Stages.tsx +120 -0
  110. package/lib/infra/Stages/index.tsx +1 -0
  111. package/lib/infra/ToDo/ToDo.css +87 -0
  112. package/lib/infra/ToDo/ToDo.tsx +285 -0
  113. package/lib/infra/ToDo/index.tsx +1 -0
  114. package/lib/infra/VerticalTabs/LeftAlignVerticalTab.tsx +27 -0
  115. package/lib/infra/VerticalTabs/VerticalTabs.tsx +75 -0
  116. package/lib/infra/VerticalTabs/index.tsx +1 -0
  117. package/lib/infra/View/View.css +8 -0
  118. package/lib/infra/View/View.tsx +175 -0
  119. package/lib/infra/View/index.tsx +1 -0
  120. package/lib/templates/AppShell/AppShell.css +40 -0
  121. package/lib/templates/AppShell/AppShell.tsx +439 -0
  122. package/lib/templates/AppShell/index.tsx +1 -0
  123. package/lib/templates/CaseSummary/CaseSummary.tsx +50 -0
  124. package/lib/templates/CaseSummary/index.tsx +1 -0
  125. package/lib/templates/CaseView/CaseView.tsx +261 -0
  126. package/lib/templates/CaseView/CaseViewActionsMenu.tsx +73 -0
  127. package/lib/templates/CaseView/index.tsx +1 -0
  128. package/lib/templates/DataReference/DataReference.tsx +290 -0
  129. package/lib/templates/DataReference/index.tsx +1 -0
  130. package/lib/templates/DefaultForm/DefaultForm.css +25 -0
  131. package/lib/templates/DefaultForm/DefaultForm.tsx +52 -0
  132. package/lib/templates/DefaultForm/index.tsx +1 -0
  133. package/lib/templates/Details/Details/Details.tsx +35 -0
  134. package/lib/templates/Details/Details/index.tsx +1 -0
  135. package/lib/templates/Details/DetailsSubTabs/DetailsSubTabs.tsx +65 -0
  136. package/lib/templates/Details/DetailsSubTabs/index.tsx +1 -0
  137. package/lib/templates/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +45 -0
  138. package/lib/templates/Details/DetailsThreeColumn/index.tsx +1 -0
  139. package/lib/templates/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +43 -0
  140. package/lib/templates/Details/DetailsTwoColumn/index.tsx +1 -0
  141. package/lib/templates/FieldGroupTemplate/FieldGroupTemplate.tsx +94 -0
  142. package/lib/templates/FieldGroupTemplate/index.tsx +1 -0
  143. package/lib/templates/InlineDashboard/InlineDashboard.tsx +72 -0
  144. package/lib/templates/InlineDashboard/index.tsx +1 -0
  145. package/lib/templates/InlineDashboardPage/InlineDashboardPage.tsx +41 -0
  146. package/lib/templates/InlineDashboardPage/index.tsx +1 -0
  147. package/lib/templates/ListPage/ListPage.tsx +20 -0
  148. package/lib/templates/ListPage/index.tsx +1 -0
  149. package/lib/templates/ListView/ListView.css +10 -0
  150. package/lib/templates/ListView/ListView.tsx +1230 -0
  151. package/lib/templates/ListView/index.tsx +1 -0
  152. package/lib/templates/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +42 -0
  153. package/lib/templates/MultiReferenceReadOnly/index.tsx +1 -0
  154. package/lib/templates/NarrowWide/NarrowWide/NarrowWide.css +21 -0
  155. package/lib/templates/NarrowWide/NarrowWide/NarrowWide.tsx +35 -0
  156. package/lib/templates/NarrowWide/NarrowWide/index.tsx +1 -0
  157. package/lib/templates/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +53 -0
  158. package/lib/templates/NarrowWide/NarrowWideDetails/index.tsx +1 -0
  159. package/lib/templates/NarrowWide/NarrowWideForm/NarrowWideForm.css +21 -0
  160. package/lib/templates/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +24 -0
  161. package/lib/templates/NarrowWide/NarrowWideForm/index.tsx +1 -0
  162. package/lib/templates/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +38 -0
  163. package/lib/templates/NarrowWide/NarrowWidePage/index.tsx +1 -0
  164. package/lib/templates/OneColumn/OneColumn/OneColumn.tsx +32 -0
  165. package/lib/templates/OneColumn/OneColumn/index.tsx +1 -0
  166. package/lib/templates/OneColumn/OneColumnPage/OneColumnPage.tsx +24 -0
  167. package/lib/templates/OneColumn/OneColumnPage/index.tsx +1 -0
  168. package/lib/templates/OneColumn/OneColumnTab/OneColumnTab.tsx +17 -0
  169. package/lib/templates/OneColumn/OneColumnTab/index.tsx +1 -0
  170. package/lib/templates/PromotedFilters/PromotedFilters.css +7 -0
  171. package/lib/templates/PromotedFilters/PromotedFilters.tsx +160 -0
  172. package/lib/templates/PromotedFilters/index.tsx +1 -0
  173. package/lib/templates/SimpleTable/SimpleTable/SimpleTable.tsx +28 -0
  174. package/lib/templates/SimpleTable/SimpleTable/index.tsx +1 -0
  175. package/lib/templates/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +719 -0
  176. package/lib/templates/SimpleTable/SimpleTableManual/index.tsx +1 -0
  177. package/lib/templates/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +129 -0
  178. package/lib/templates/SimpleTable/SimpleTableSelect/index.tsx +1 -0
  179. package/lib/templates/SimpleTable/helpers.ts +360 -0
  180. package/lib/templates/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +66 -0
  181. package/lib/templates/SingleReferenceReadOnly/index.tsx +1 -0
  182. package/lib/templates/SubTabs/SubTabs.tsx +65 -0
  183. package/lib/templates/SubTabs/index.tsx +1 -0
  184. package/lib/templates/SubTabs/tabUtils.ts +73 -0
  185. package/lib/templates/TwoColumn/TwoColumn/TwoColumn.css +13 -0
  186. package/lib/templates/TwoColumn/TwoColumn/TwoColumn.tsx +58 -0
  187. package/lib/templates/TwoColumn/TwoColumn/index.tsx +1 -0
  188. package/lib/templates/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +25 -0
  189. package/lib/templates/TwoColumn/TwoColumnPage/index.tsx +1 -0
  190. package/lib/templates/TwoColumn/TwoColumnTab/TwoColumnTab.css +12 -0
  191. package/lib/templates/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +55 -0
  192. package/lib/templates/TwoColumn/TwoColumnTab/index.tsx +1 -0
  193. package/lib/templates/WideNarrow/WideNarrow/WideNarrow.css +21 -0
  194. package/lib/templates/WideNarrow/WideNarrow/WideNarrow.tsx +35 -0
  195. package/lib/templates/WideNarrow/WideNarrow/index.tsx +1 -0
  196. package/lib/templates/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +54 -0
  197. package/lib/templates/WideNarrow/WideNarrowDetails/index.tsx +1 -0
  198. package/lib/templates/WideNarrow/WideNarrowForm/WideNarrowForm.css +21 -0
  199. package/lib/templates/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +24 -0
  200. package/lib/templates/WideNarrow/WideNarrowForm/index.tsx +1 -0
  201. package/lib/templates/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +38 -0
  202. package/lib/templates/WideNarrow/WideNarrowPage/index.tsx +1 -0
  203. package/lib/templates/utils.ts +23 -0
  204. package/lib/widgets/AppAnnouncement/AppAnnouncement.tsx +67 -0
  205. package/lib/widgets/AppAnnouncement/index.tsx +1 -0
  206. package/lib/widgets/CaseHistory/CaseHistory.tsx +169 -0
  207. package/lib/widgets/CaseHistory/index.tsx +1 -0
  208. package/lib/widgets/FileUtility/ActionButtonsForFileUtil.css +27 -0
  209. package/lib/widgets/FileUtility/ActionButtonsForFileUtil.tsx +22 -0
  210. package/lib/widgets/FileUtility/FileUtility.css +117 -0
  211. package/lib/widgets/FileUtility/FileUtility.tsx +567 -0
  212. package/lib/widgets/FileUtility/index.tsx +0 -0
  213. package/lib/widgets/Followers/Followers.tsx +43 -0
  214. package/lib/widgets/Followers/index.tsx +1 -0
  215. package/lib/widgets/SummaryItem/SummaryItem.css +78 -0
  216. package/lib/widgets/SummaryItem/SummaryItem.tsx +80 -0
  217. package/lib/widgets/SummaryItem/index.tsx +1 -0
  218. package/lib/widgets/SummaryList/SummaryList.tsx +12 -0
  219. package/lib/widgets/SummaryList/index.tsx +1 -0
  220. package/package.json +14 -0
@@ -0,0 +1,261 @@
1
+ /* eslint-disable react/jsx-boolean-value */
2
+
3
+ import React, { useState, useEffect, useContext } from "react";
4
+ import PropTypes from "prop-types";
5
+ import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
6
+ import { Card, CardHeader, Avatar, Typography, Divider } from "@material-ui/core";
7
+ import { makeStyles } from '@material-ui/core/styles';
8
+ import Box from '@material-ui/core/Box';
9
+ import Button from '@material-ui/core/Button';
10
+ import Grid from '@material-ui/core/Grid';
11
+
12
+ import StoreContext from "@pega/react-sdk-components/lib/bridge/Context/StoreContext";
13
+ import CaseViewActionsMenu from "./CaseViewActionsMenu";
14
+ import VerticalTabs from '@pega/react-sdk-components/lib/components/infra/VerticalTabs';
15
+ import DeferLoad from '@pega/react-sdk-components/lib/components/infra/DeferLoad';
16
+
17
+
18
+ declare const PCore;
19
+
20
+ const useStyles = makeStyles((theme) => ({
21
+ root: {
22
+ paddingRight: theme.spacing(1),
23
+ paddingLeft: theme.spacing(1),
24
+ paddingTop: theme.spacing(1),
25
+ paddingBottom: theme.spacing(1),
26
+ marginRight: theme.spacing(1),
27
+ marginLeft: theme.spacing(1),
28
+ marginTop: theme.spacing(1),
29
+ marginBottom: theme.spacing(1),
30
+ },
31
+ caseViewHeader: {
32
+ backgroundColor: theme.palette.info.light,
33
+ color: theme.palette.getContrastText(theme.palette.info.light),
34
+ borderRadius: "inherit",
35
+ },
36
+ caseViewIconBox: {
37
+ backgroundColor: theme.palette.info.dark,
38
+ width: theme.spacing(8),
39
+ height: theme.spacing(8),
40
+ padding: theme.spacing(1),
41
+ },
42
+ caseViewIconImage: {
43
+ filter: 'invert(100%)'
44
+ }
45
+ }));
46
+
47
+ export default function CaseView(props) {
48
+ const {
49
+ getPConnect,
50
+ icon,
51
+ header,
52
+ subheader,
53
+ children,
54
+ caseInfo: { availableActions = [], availableProcesses = [], hasNewAttachments }
55
+ } = props;
56
+ const currentCaseID = props.caseInfo.ID;
57
+ let isComponentMounted = true;
58
+
59
+ const { displayOnlyFA } = useContext(StoreContext);
60
+
61
+ const thePConn = getPConnect();
62
+
63
+ const classes = useStyles();
64
+
65
+
66
+ /**
67
+ *
68
+ * @param inName the metadata <em>name</em> that will cause a region to be returned
69
+ */
70
+ function getChildRegionByName(inName: string): any {
71
+
72
+ for (const child of children) {
73
+ const theMetadataType: string = child.props.getPConnect().getRawMetadata()['type'].toLowerCase();
74
+ const theMetadataName: string = child.props.getPConnect().getRawMetadata()['name'].toLowerCase();
75
+
76
+ if ((theMetadataType === "region") && (theMetadataName === inName )) {
77
+ return child;
78
+ }
79
+ }
80
+
81
+ return null;
82
+ }
83
+
84
+
85
+ const theSummaryRegion = getChildRegionByName("summary");
86
+ const theStagesRegion = getChildRegionByName("stages");
87
+ const theTodoRegion = getChildRegionByName("todo");
88
+ const theUtilitiesRegion = getChildRegionByName("utilities");
89
+ const theTabsRegion = getChildRegionByName("tabs");
90
+
91
+ const svgCase = Utils.getImageSrc(icon, PCore.getAssetLoader().getStaticServerUrl());
92
+
93
+ const [activeVertTab, setActiveVertTab] = useState(0);
94
+
95
+ // const tmpLoadData1 = { config: { label: "Details", name: "pyDetailsTabContent" }, type: "DeferLoad" };
96
+ // const tmpLoadData2 = { config: { label: "Case History", name: "CaseHistory" }, type: "DeferLoad" };
97
+
98
+ // Extract the tabs we need to display from theTabsRegion (one tab per entry in theTabsRegionChildren)
99
+ const theTabsRegionChildren = theTabsRegion.props.getPConnect().getChildren();
100
+
101
+ // vertTabInfo is sent to VerticalTabs component
102
+ const vertTabInfo: Array<Object> = [];
103
+
104
+ // deferLoadInfo is sent to DeferLoad component (currently selected entry)
105
+ const deferLoadInfo: Array<any> = [];
106
+
107
+ if (theTabsRegionChildren) {
108
+ // populate vertTabInfo and deferLoadInfo
109
+ theTabsRegionChildren.forEach((tabComp, index) => {
110
+ const theTabCompConfig = tabComp.getPConnect().getConfigProps();
111
+ // eslint-disable-next-line prefer-const
112
+ let { label, inheritedProps } = theTabCompConfig;
113
+ // For some tabs, "label" property is not avaialable in theTabCompConfig, so will get them from inheritedProps
114
+ if (!label) {
115
+ inheritedProps.forEach(inheritedProp => {
116
+ if (inheritedProp.prop === 'label') {
117
+ label = inheritedProp.value;
118
+ }
119
+ });
120
+ }
121
+ // We'll display the tabs when either visibility property doesn't exist or is true(if exists)
122
+ if (theTabCompConfig.visibility === undefined || theTabCompConfig.visibility === true) {
123
+ vertTabInfo.push({ name: label, id: index });
124
+ deferLoadInfo.push({ type: 'DeferLoad', config: theTabCompConfig });
125
+ }
126
+ });
127
+ }
128
+
129
+
130
+
131
+ function handleVerticalTabClick(eventDetail: any) {
132
+ const theItem = parseInt(eventDetail.additionalData.itemClicked, 10);
133
+
134
+ // only call useEffectSetter if the component is mounted
135
+ if (isComponentMounted) {
136
+ setActiveVertTab(theItem);
137
+ }
138
+ }
139
+
140
+
141
+ // Add and Remove event listener for VerticalTabClick only at startup and teardown
142
+ useEffect(() => {
143
+ document.addEventListener('VerticalTabClick', (event: any) => {
144
+ handleVerticalTabClick(event.detail);
145
+ });
146
+
147
+ return ():void => {
148
+ // inform that the component is unmounted so other code can
149
+ // know not to try to call useState setters (to avoid console warnings)
150
+ isComponentMounted = false;
151
+
152
+ document.removeEventListener('VerticalTabClick', (event: any) => {
153
+ handleVerticalTabClick(event.detail);
154
+ });
155
+ }
156
+ }, [])
157
+
158
+ useEffect(() => {
159
+ if (hasNewAttachments) {
160
+ PCore.getPubSubUtils().publish(PCore.getEvents().getCaseEvent().CASE_ATTACHMENTS_UPDATED_FROM_CASEVIEW, true);
161
+ }
162
+ }, [hasNewAttachments]);
163
+
164
+ function _editClick() {
165
+
166
+ const editAction = availableActions.find(
167
+ (action) => action.ID === "pyUpdateCaseDetails"
168
+ );
169
+ const actionsAPI = thePConn.getActionsApi();
170
+ const openLocalAction = actionsAPI.openLocalAction.bind(actionsAPI);
171
+
172
+ openLocalAction( editAction.ID, { ...editAction});
173
+ }
174
+
175
+
176
+ function getActionButtonsHtml(): any {
177
+
178
+ const aBHtml = <Box>
179
+ <Button onClick={() => {_editClick()}}>Edit</Button>
180
+ &nbsp;
181
+ <CaseViewActionsMenu getPConnect={getPConnect} availableActions={availableActions} availableProcesses={availableProcesses} />
182
+ </Box>;
183
+
184
+
185
+ return aBHtml;
186
+
187
+ }
188
+
189
+
190
+ function getContainerContents() {
191
+
192
+ if (!displayOnlyFA) {
193
+ // show full portal
194
+ return (
195
+ <Grid container>
196
+ <Grid item xs={3}>
197
+ <div hidden={true} id="current-caseID">{currentCaseID}</div>
198
+ <Card className={classes.root} >
199
+ <CardHeader className={classes.caseViewHeader}
200
+ title={<Typography variant="h6" component="div">{header}</Typography>}
201
+ subheader={<Typography variant="body1" component="div" id="caseId">{subheader}</Typography>}
202
+ avatar={
203
+ <Avatar className={classes.caseViewIconBox} variant="square">
204
+ <img src={svgCase} className={classes.caseViewIconImage}/>
205
+ </Avatar>
206
+ }
207
+ />
208
+ {getActionButtonsHtml()}
209
+ <Divider />
210
+ {theSummaryRegion}
211
+ <Divider />
212
+ { vertTabInfo.length > 1 && <VerticalTabs tabconfig={vertTabInfo} />}
213
+ </Card>
214
+ </Grid>
215
+
216
+ <Grid item xs={6}>
217
+ {theStagesRegion}
218
+ {theTodoRegion}
219
+ { deferLoadInfo.length > 0 && <DeferLoad getPConnect={getPConnect} name={deferLoadInfo[activeVertTab].config.name } isTab />}
220
+ </Grid>
221
+
222
+ <Grid item xs={3}>
223
+ {theUtilitiesRegion}
224
+ </Grid>
225
+ </Grid>
226
+ )
227
+ } else {
228
+ // displayOnlyFA - only show the "todo" region
229
+ return (
230
+ <Grid container>
231
+ <Grid item xs={12}>
232
+ {theTodoRegion}
233
+ </Grid>
234
+ </Grid>
235
+ )
236
+ }
237
+ }
238
+
239
+
240
+ return (
241
+ getContainerContents()
242
+ );
243
+ }
244
+
245
+ CaseView.defaultProps = {
246
+ icon: "",
247
+ children: [],
248
+ caseInfo: {},
249
+ showIconInHeader: true,
250
+ getPConnect: null
251
+ };
252
+
253
+ CaseView.propTypes = {
254
+ icon: PropTypes.string,
255
+ children: PropTypes.arrayOf(PropTypes.node),
256
+ subheader: PropTypes.string.isRequired,
257
+ header: PropTypes.string.isRequired,
258
+ showIconInHeader: PropTypes.bool,
259
+ caseInfo: PropTypes.objectOf(PropTypes.any),
260
+ getPConnect: PropTypes.func
261
+ };
@@ -0,0 +1,73 @@
1
+ import React, { useState } from 'react';
2
+ import PropTypes from "prop-types";
3
+ import Button from '@material-ui/core/Button';
4
+ import Menu from '@material-ui/core/Menu';
5
+ import MenuItem from '@material-ui/core/MenuItem';
6
+
7
+ export default function CaseViewActionsMenu(props) {
8
+ const {getPConnect, availableActions, availableProcesses} = props;
9
+ const thePConn = getPConnect();
10
+
11
+
12
+ const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
13
+
14
+ const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
15
+ setAnchorEl(event.currentTarget);
16
+ };
17
+
18
+ const handleClose = () => {
19
+ setAnchorEl(null);
20
+ };
21
+
22
+ const arMenuItems: Array<any> = [];
23
+
24
+
25
+ function _actionMenuActionsClick(data) {
26
+
27
+ const actionsAPI = thePConn.getActionsApi();
28
+ const openLocalAction = actionsAPI.openLocalAction.bind(actionsAPI);
29
+
30
+ openLocalAction( data.ID, { ...data});
31
+ // after doing the action, close the menu...
32
+ handleClose();
33
+
34
+ }
35
+
36
+
37
+ availableActions.forEach( (action) => {
38
+ arMenuItems.push( <MenuItem key={action.ID} onClick={() => _actionMenuActionsClick(action)}>{action.name}</MenuItem> )
39
+ });
40
+
41
+ availableProcesses.forEach( (process) => {
42
+ arMenuItems.push( <MenuItem onClick={handleClose}>{process.name}</MenuItem> )
43
+ });
44
+
45
+
46
+ return (
47
+ <React.Fragment>
48
+ <Button aria-controls="simple-menu" aria-haspopup="true" onClick={handleClick}>
49
+ Actions...
50
+ </Button>
51
+ <Menu
52
+ id="simple-menu"
53
+ anchorEl={anchorEl}
54
+ keepMounted
55
+ open={Boolean(anchorEl)}
56
+ onClose={handleClose}
57
+ >
58
+ {arMenuItems}
59
+ </Menu>
60
+ </React.Fragment>
61
+ );
62
+ }
63
+
64
+ CaseViewActionsMenu.defaultProps = {
65
+ availableActions: [],
66
+ availableProcesses: []
67
+ }
68
+
69
+ CaseViewActionsMenu.propTypes = {
70
+ getPConnect: PropTypes.func.isRequired,
71
+ availableActions: PropTypes.arrayOf(PropTypes.object),
72
+ availableProcesses: PropTypes.arrayOf(PropTypes.any)
73
+ };
@@ -0,0 +1 @@
1
+ export { default } from './CaseView';
@@ -0,0 +1,290 @@
1
+ import React, { useMemo, useState, useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import SingleReferenceReadonly from '@pega/react-sdk-components/lib/components/templates/SingleReferenceReadOnly';
4
+ import MultiReferenceReadonly from '@pega/react-sdk-components/lib/components/templates/MultiReferenceReadOnly';
5
+
6
+ const SELECTION_MODE = { SINGLE: 'single', MULTI: 'multi' };
7
+
8
+ declare const PCore: any;
9
+
10
+ export default function DataReference(props) {
11
+ const {
12
+ children,
13
+ getPConnect,
14
+ label,
15
+ showLabel,
16
+ displayMode,
17
+ allowAndPersistChangesInReviewMode,
18
+ referenceType,
19
+ selectionMode,
20
+ displayAs,
21
+ ruleClass,
22
+ parameters,
23
+ hideLabel
24
+ } = props;
25
+ let childrenToRender = children;
26
+ const pConn = getPConnect();
27
+ const [dropDownDataSource, setDropDownDataSource] = useState(null);
28
+ const propsToUse = { label, showLabel, ...pConn.getInheritedProps() };
29
+ if (propsToUse.showLabel === false) {
30
+ propsToUse.label = '';
31
+ }
32
+ const rawViewMetadata = pConn.getRawMetadata();
33
+ const viewName = rawViewMetadata.name;
34
+ const [firstChildMeta] = rawViewMetadata.children;
35
+ const refList = rawViewMetadata.config.referenceList;
36
+ const canBeChangedInReviewMode = allowAndPersistChangesInReviewMode && (displayAs === 'autocomplete' || displayAs === 'dropdown');
37
+ let propName;
38
+ const isDisplayModeEnabled = ['LABELS_LEFT', 'STACKED_LARGE_VAL'].includes(displayMode);
39
+ let firstChildPConnect;
40
+
41
+ /* Only for dropdown when it has param use data api to get the data back and add it to datasource */
42
+ useEffect(() => {
43
+ if (
44
+ firstChildMeta?.type === "Dropdown" &&
45
+ rawViewMetadata.config?.parameters
46
+ ) {
47
+ const { value, key, text } = firstChildMeta.config.datasource.fields;
48
+ PCore.getDataApiUtils()
49
+ .getData(refList, {
50
+ dataViewParameters: parameters
51
+ })
52
+ .then((res) => {
53
+ if (res.data.data !== null) {
54
+ const ddDataSource = res.data.data
55
+ .map((listItem) => ({
56
+ key: listItem[key.split(" .", 2)[1]],
57
+ text: listItem[text.split(" .", 2)[1]],
58
+ value: listItem[value.split(" .", 2)[1]]
59
+ }))
60
+ .filter((item) => item.key);
61
+ // Filtering out undefined entries that will break preview
62
+ setDropDownDataSource(ddDataSource);
63
+ } else {
64
+ const ddDataSource: any = []
65
+ setDropDownDataSource(ddDataSource);
66
+ }
67
+ })
68
+ .catch((err) => {
69
+ // eslint-disable-next-line no-console
70
+ console.error(err?.stack);
71
+ return Promise.resolve({
72
+ data: { data: [] }
73
+ });
74
+ });
75
+ }
76
+ }, [firstChildMeta, rawViewMetadata, parameters]);
77
+
78
+ if (firstChildMeta?.type !== 'Region') {
79
+ firstChildPConnect = getPConnect().getChildren()[0].getPConnect;
80
+ /* remove refresh When condition from those old view so that it will not be used for runtime */
81
+ if (firstChildMeta.config?.readOnly) {
82
+ delete firstChildMeta.config.readOnly;
83
+ }
84
+ if (firstChildMeta?.type === 'Dropdown') {
85
+ firstChildMeta.config.datasource.source = rawViewMetadata.config?.parameters
86
+ ? dropDownDataSource
87
+ : '@DATASOURCE '.concat(refList).concat('.pxResults');
88
+ } else if (firstChildMeta?.type === 'AutoComplete') {
89
+ firstChildMeta.config.datasource = refList;
90
+
91
+ /* Insert the parameters to the component only if present */
92
+ if (rawViewMetadata.config?.parameters) {
93
+ firstChildMeta.config.parameters = parameters;
94
+ }
95
+ }
96
+ // set displayMode conditionally
97
+ if (!canBeChangedInReviewMode) {
98
+ firstChildMeta.config.displayMode = displayMode;
99
+ }
100
+ if (firstChildMeta.type === 'SimpleTableSelect' && selectionMode === SELECTION_MODE.MULTI) {
101
+ propName = PCore.getAnnotationUtils().getPropertyName(firstChildMeta.config.selectionList);
102
+ } else {
103
+ propName = PCore.getAnnotationUtils().getPropertyName(firstChildMeta.config.value);
104
+ }
105
+ }
106
+
107
+ const handleSelection = event => {
108
+ const caseKey = pConn.getCaseInfo().getKey();
109
+ const refreshOptions = { autoDetectRefresh: true };
110
+ if (canBeChangedInReviewMode && pConn.getValue('__currentPageTabViewName')) {
111
+ getPConnect()
112
+ .getActionsApi()
113
+ .refreshCaseView(caseKey, pConn.getValue('__currentPageTabViewName'), null, refreshOptions);
114
+ PCore.getDeferLoadManager().refreshActiveComponents(pConn.getContextName());
115
+ } else {
116
+ const pgRef = pConn.getPageReference().replace('caseInfo.content', '');
117
+ getPConnect().getActionsApi().refreshCaseView(caseKey, viewName, pgRef, refreshOptions);
118
+ }
119
+
120
+ // AutoComplete sets value on event.id whereas Dropdown sets it on event.target.value
121
+ const propValue = event?.id || event?.target.value;
122
+ if (propValue && canBeChangedInReviewMode && isDisplayModeEnabled) {
123
+ PCore.getDataApiUtils()
124
+ .getCaseEditLock(caseKey)
125
+ .then(caseResponse => {
126
+ const pageTokens = pConn.getPageReference().replace('caseInfo.content', '').split('.');
127
+ let curr = {};
128
+ const commitData = curr;
129
+
130
+ pageTokens.forEach(el => {
131
+ if (el !== '') {
132
+ curr[el] = {};
133
+ curr = curr[el];
134
+ }
135
+ });
136
+
137
+ // expecting format like {Customer: {pyID:"C-100"}}
138
+ const propArr = propName.split('.');
139
+ propArr.forEach((element, idx) => {
140
+ if (idx + 1 === propArr.length) {
141
+ curr[element] = propValue;
142
+ } else {
143
+ curr[element] = {};
144
+ curr = curr[element];
145
+ }
146
+ });
147
+
148
+ PCore.getDataApiUtils()
149
+ .updateCaseEditFieldsData(
150
+ caseKey,
151
+ { [caseKey]: commitData },
152
+ caseResponse.headers.etag,
153
+ pConn.getContextName()
154
+ )
155
+ .then(response => {
156
+ PCore.getContainerUtils().updateChildContainersEtag(
157
+ pConn.getContextName(),
158
+ response.headers.etag
159
+ );
160
+ });
161
+ });
162
+ }
163
+ };
164
+
165
+ // Re-create first child with overridden props
166
+ // Memoized child in order to stop unmount and remount of the child component when data reference
167
+ // rerenders without any actual change
168
+ const recreatedFirstChild = useMemo(() => {
169
+ const { type, config } = firstChildMeta;
170
+ if (firstChildMeta?.type !== 'Region') {
171
+ pConn.clearErrorMessages({
172
+ property: propName
173
+ });
174
+ if (!canBeChangedInReviewMode && isDisplayModeEnabled && selectionMode === SELECTION_MODE.SINGLE) {
175
+ return (
176
+ <SingleReferenceReadonly
177
+ config={config}
178
+ getPConnect={firstChildPConnect}
179
+ label={propsToUse.label}
180
+ type={type}
181
+ displayAs={displayAs}
182
+ displayMode={displayMode}
183
+ ruleClass={ruleClass}
184
+ referenceType={referenceType}
185
+ hideLabel={hideLabel}
186
+ dataRelationshipContext={
187
+ rawViewMetadata.config.contextClass && rawViewMetadata.config.name ? rawViewMetadata.config.name : null
188
+ }
189
+ />
190
+ );
191
+ }
192
+
193
+ if (isDisplayModeEnabled && selectionMode === SELECTION_MODE.MULTI) {
194
+ return (
195
+ <MultiReferenceReadonly
196
+ config={config}
197
+ getPConnect={firstChildPConnect}
198
+ label={propsToUse.label}
199
+ hideLabel={hideLabel}
200
+ />
201
+ );
202
+ }
203
+
204
+ // In the case of a datasource with parameters you cannot load the dropdown before the parameters
205
+ if (
206
+ type === 'Dropdown' &&
207
+ rawViewMetadata.config?.parameters &&
208
+ dropDownDataSource === null
209
+ ) {
210
+ return null;
211
+ }
212
+
213
+ return firstChildPConnect().createComponent({
214
+ type,
215
+ config: {
216
+ ...config,
217
+ required: propsToUse.required,
218
+ visibility: propsToUse.visibility,
219
+ disabled: propsToUse.disabled,
220
+ label: propsToUse.label,
221
+ viewName: getPConnect().getCurrentView(),
222
+ parameters: rawViewMetadata.config.parameters,
223
+ readOnly: false,
224
+ localeReference: rawViewMetadata.config.localeReference,
225
+ ...(selectionMode === SELECTION_MODE.SINGLE ? { referenceType } : ''),
226
+ dataRelationshipContext:
227
+ rawViewMetadata.config.contextClass && rawViewMetadata.config.name
228
+ ? rawViewMetadata.config.name
229
+ : null,
230
+ hideLabel,
231
+ onRecordChange: handleSelection
232
+ }
233
+ });
234
+ }
235
+ }, [
236
+ firstChildMeta.config?.datasource?.source,
237
+ parameters,
238
+ dropDownDataSource,
239
+ propsToUse.required,
240
+ propsToUse.disabled
241
+ ]);
242
+
243
+ // Only include the views region for rendering when it has content
244
+ if (firstChildMeta?.type !== 'Region') {
245
+ const viewsRegion = rawViewMetadata.children[1];
246
+ if (viewsRegion?.name === 'Views' && viewsRegion.children.length) {
247
+ childrenToRender = [recreatedFirstChild, ...children.slice(1)];
248
+ } else {
249
+ childrenToRender = [recreatedFirstChild];
250
+ }
251
+ }
252
+
253
+ return childrenToRender.length === 1 ? (
254
+ childrenToRender[0] ?? null
255
+ ) : (
256
+ <div>
257
+ {childrenToRender.map(child => (
258
+ <React.Fragment>{child}</React.Fragment>
259
+ ))}
260
+ </div>
261
+ );
262
+ }
263
+
264
+ DataReference.defaultProps = {
265
+ label: undefined,
266
+ showLabel: undefined,
267
+ displayMode: undefined,
268
+ allowAndPersistChangesInReviewMode: false,
269
+ referenceType: '',
270
+ selectionMode: '',
271
+ displayAs: '',
272
+ ruleClass: '',
273
+ parameters: undefined,
274
+ hideLabel: false
275
+ };
276
+
277
+ DataReference.propTypes = {
278
+ children: PropTypes.arrayOf(PropTypes.node).isRequired,
279
+ getPConnect: PropTypes.func.isRequired,
280
+ label: PropTypes.string,
281
+ showLabel: PropTypes.func,
282
+ displayMode: PropTypes.string,
283
+ allowAndPersistChangesInReviewMode: PropTypes.bool,
284
+ referenceType: PropTypes.string,
285
+ selectionMode: PropTypes.string,
286
+ displayAs: PropTypes.string,
287
+ ruleClass: PropTypes.string,
288
+ parameters: PropTypes.arrayOf(PropTypes.string), // need to fix
289
+ hideLabel: PropTypes.bool
290
+ };
@@ -0,0 +1 @@
1
+ export { default } from './DataReference';
@@ -0,0 +1,25 @@
1
+ .psdk-default-form-one-column {
2
+ display: grid;
3
+ grid-template-columns: repeat(1, minmax(0, 1fr));
4
+ gap: calc(1rem);
5
+ }
6
+
7
+ .psdk-default-form-two-column {
8
+ display: grid;
9
+ grid-template-columns: repeat(2, 1fr);
10
+ gap: calc(1rem);
11
+ }
12
+
13
+ .psdk-default-form-three-column {
14
+ display: grid;
15
+ grid-template-columns: repeat(3, 1fr);
16
+ gap: calc(1rem);
17
+ }
18
+
19
+ .psdk-default-form-two-column .grid-column {
20
+ grid-column: 1 / span 2;
21
+ }
22
+
23
+ .psdk-default-form-three-column .grid-column {
24
+ grid-column: 1 / span 3;
25
+ }