@pega/react-sdk-overrides 8.23.11 → 23.1.11

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 (233) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +17 -0
  3. package/SECURITY.md +10 -0
  4. package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +12 -16
  5. package/lib/designSystemExtension/Banner/Banner.tsx +21 -7
  6. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.css +0 -1
  7. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +36 -26
  8. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +21 -28
  9. package/lib/designSystemExtension/DetailsFields/index.tsx +1 -1
  10. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +50 -18
  11. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +14 -11
  12. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +18 -27
  13. package/lib/designSystemExtension/Operator/Operator.tsx +100 -84
  14. package/lib/designSystemExtension/Pulse/Pulse.tsx +21 -19
  15. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +122 -0
  16. package/lib/designSystemExtension/RichTextEditor/index.tsx +1 -0
  17. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +21 -12
  18. package/lib/field/AutoComplete/AutoComplete.tsx +33 -16
  19. package/lib/field/AutoComplete/config-ext.json +2 -3
  20. package/lib/field/CancelAlert/CancelAlert.tsx +100 -81
  21. package/lib/field/CancelAlert/index.tsx +1 -1
  22. package/lib/field/Checkbox/Checkbox.tsx +27 -16
  23. package/lib/field/Checkbox/config-ext.json +2 -3
  24. package/lib/field/Currency/Currency.tsx +30 -47
  25. package/lib/field/Currency/config-ext.json +2 -3
  26. package/lib/field/Currency/currency-utils.ts +10 -21
  27. package/lib/field/Date/Date.tsx +24 -13
  28. package/lib/field/Date/config-ext.json +2 -3
  29. package/lib/field/DateTime/DateTime.tsx +21 -10
  30. package/lib/field/DateTime/config-ext.json +1 -2
  31. package/lib/field/Decimal/Decimal.tsx +31 -40
  32. package/lib/field/Decimal/config-ext.json +1 -2
  33. package/lib/field/Decimal/index.tsx +1 -1
  34. package/lib/field/Dropdown/Dropdown.tsx +128 -31
  35. package/lib/field/Dropdown/config-ext.json +1 -2
  36. package/lib/field/Email/Email.tsx +16 -7
  37. package/lib/field/Email/config-ext.json +1 -2
  38. package/lib/field/Email/index.tsx +1 -1
  39. package/lib/field/Group/Group.tsx +39 -0
  40. package/lib/field/Group/config-ext.json +7 -0
  41. package/lib/field/Group/index.tsx +1 -0
  42. package/lib/field/Integer/Integer.tsx +15 -6
  43. package/lib/field/Integer/config-ext.json +1 -2
  44. package/lib/field/Percentage/Percentage.tsx +52 -39
  45. package/lib/field/Percentage/config-ext.json +1 -2
  46. package/lib/field/Phone/Phone.tsx +15 -6
  47. package/lib/field/Phone/index.tsx +1 -1
  48. package/lib/field/RadioButtons/RadioButtons.tsx +26 -34
  49. package/lib/field/RadioButtons/config-ext.json +1 -2
  50. package/lib/field/RichText/RichText.tsx +96 -0
  51. package/lib/field/RichText/index.tsx +1 -0
  52. package/lib/field/ScalarList/ScalarList.tsx +63 -0
  53. package/lib/field/ScalarList/config-ext.json +7 -0
  54. package/lib/field/ScalarList/index.tsx +1 -0
  55. package/lib/field/SemanticLink/SemanticLink.tsx +26 -25
  56. package/lib/field/SemanticLink/config-ext.json +1 -2
  57. package/lib/field/SemanticLink/utils.ts +8 -11
  58. package/lib/field/TextArea/TextArea.tsx +15 -5
  59. package/lib/field/TextArea/config-ext.json +1 -2
  60. package/lib/field/TextContent/TextContent.tsx +9 -2
  61. package/lib/field/TextContent/config-ext.json +1 -2
  62. package/lib/field/TextInput/TextInput.tsx +18 -7
  63. package/lib/field/TextInput/config-ext.json +1 -2
  64. package/lib/field/TextInput/index.tsx +1 -1
  65. package/lib/field/Time/Time.tsx +14 -19
  66. package/lib/field/Time/config-ext.json +1 -2
  67. package/lib/field/URL/URL.tsx +15 -6
  68. package/lib/field/URL/config-ext.json +1 -2
  69. package/lib/field/URL/index.tsx +1 -1
  70. package/lib/field/UserReference/UserReference.tsx +52 -60
  71. package/lib/field/UserReference/UserReferenceUtils.ts +2 -2
  72. package/lib/field/UserReference/config-ext.json +1 -2
  73. package/lib/helpers/attachmentHelpers.ts +15 -10
  74. package/lib/helpers/case-utils.tsx +5 -10
  75. package/lib/helpers/common-utils.ts +6 -2
  76. package/lib/helpers/data_page.ts +3 -7
  77. package/lib/helpers/date-format-utils.ts +4 -4
  78. package/lib/helpers/event-utils.ts +4 -4
  79. package/lib/helpers/field-group-utils.ts +6 -8
  80. package/lib/helpers/formatters/Boolean.ts +9 -26
  81. package/lib/helpers/formatters/Currency.ts +22 -28
  82. package/lib/helpers/formatters/CurrencyMap.ts +512 -505
  83. package/lib/helpers/formatters/Date.ts +20 -26
  84. package/lib/helpers/formatters/common.ts +2 -7
  85. package/lib/helpers/formatters/index.ts +29 -22
  86. package/lib/helpers/reactContextHelpers.ts +2 -2
  87. package/lib/helpers/simpleTableHelpers.ts +63 -87
  88. package/lib/helpers/state-utils.tsx +5 -12
  89. package/lib/helpers/template-utils.ts +4 -10
  90. package/lib/helpers/utils.ts +5 -5
  91. package/lib/helpers/versionHelpers.ts +1 -7
  92. package/lib/infra/ActionButtons/ActionButtons.tsx +44 -45
  93. package/lib/infra/ActionButtons/index.tsx +1 -1
  94. package/lib/infra/Assignment/Assignment.tsx +102 -86
  95. package/lib/infra/Assignment/index.tsx +1 -1
  96. package/lib/infra/AssignmentCard/AssignmentCard.tsx +19 -26
  97. package/lib/infra/AssignmentCard/index.tsx +1 -1
  98. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +93 -240
  99. package/lib/infra/Containers/FlowContainer/helpers.ts +34 -48
  100. package/lib/infra/Containers/FlowContainer/index.tsx +1 -1
  101. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +65 -0
  102. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/index.tsx +1 -0
  103. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +229 -223
  104. package/lib/infra/Containers/ModalViewContainer/index.tsx +1 -1
  105. package/lib/infra/Containers/SimpleView/SimpleView.tsx +48 -0
  106. package/lib/infra/Containers/SimpleView/helper.ts +125 -0
  107. package/lib/infra/Containers/SimpleView/index.tsx +1 -0
  108. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +47 -64
  109. package/lib/infra/Containers/helpers.ts +6 -0
  110. package/lib/infra/DashboardFilter/DashboardFilter.tsx +25 -54
  111. package/lib/infra/DashboardFilter/filterUtils.tsx +12 -42
  112. package/lib/infra/DeferLoad/DeferLoad.tsx +21 -33
  113. package/lib/infra/DeferLoad/index.tsx +1 -1
  114. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +21 -39
  115. package/lib/infra/MultiStep/MultiStep.css +11 -15
  116. package/lib/infra/MultiStep/MultiStep.tsx +180 -216
  117. package/lib/infra/MultiStep/index.tsx +1 -1
  118. package/lib/infra/NavBar/NavBar.css +103 -105
  119. package/lib/infra/NavBar/NavBar.tsx +26 -45
  120. package/lib/infra/Reference/Reference.tsx +16 -22
  121. package/lib/infra/Region/Region.tsx +9 -9
  122. package/lib/infra/RootContainer/RootContainer.tsx +75 -120
  123. package/lib/infra/RootContainer/index.tsx +1 -1
  124. package/lib/infra/Stages/Stages.tsx +36 -41
  125. package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +17 -10
  126. package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +29 -36
  127. package/lib/infra/View/View.tsx +25 -29
  128. package/lib/template/AppShell/AppShell.css +22 -23
  129. package/lib/template/AppShell/AppShell.tsx +47 -71
  130. package/lib/template/BannerPage/BannerPage.tsx +26 -33
  131. package/lib/template/CaseSummary/CaseSummary.tsx +66 -19
  132. package/lib/template/CaseSummary/config-ext.json +1 -2
  133. package/lib/template/CaseView/CaseView.tsx +44 -74
  134. package/lib/template/CaseView/config-ext.json +1 -2
  135. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +66 -31
  136. package/lib/template/Confirmation/Confirmation.tsx +24 -55
  137. package/lib/template/Confirmation/config-ext.json +1 -2
  138. package/lib/template/DataReference/DataReference.tsx +112 -142
  139. package/lib/template/DataReference/config-ext.json +1 -2
  140. package/lib/template/DefaultForm/DefaultForm.css +7 -3
  141. package/lib/template/DefaultForm/DefaultForm.tsx +15 -16
  142. package/lib/template/DefaultForm/config-ext.json +1 -2
  143. package/lib/template/Details/Details/Details.tsx +24 -28
  144. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +15 -22
  145. package/lib/template/Details/DetailsSubTabs/config-ext.json +1 -2
  146. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +25 -29
  147. package/lib/template/Details/DetailsThreeColumn/config-ext.json +1 -2
  148. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +25 -29
  149. package/lib/template/Details/DetailsTwoColumn/config-ext.json +1 -2
  150. package/lib/template/Details/DetailsTwoColumn/index.tsx +1 -1
  151. package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +79 -0
  152. package/lib/template/Details/DynamicTabs/config.json +36 -0
  153. package/lib/template/Details/DynamicTabs/index.tsx +1 -0
  154. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +22 -35
  155. package/lib/template/InlineDashboard/InlineDashboard.tsx +16 -14
  156. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +19 -21
  157. package/lib/template/ListPage/ListPage.tsx +12 -16
  158. package/lib/template/ListPage/config-ext.json +1 -2
  159. package/lib/template/ListView/DefaultViewMeta.ts +1 -3
  160. package/lib/template/ListView/ListView.tsx +247 -309
  161. package/lib/template/ListView/config-ext.json +1 -2
  162. package/lib/template/ListView/hooks.ts +24 -26
  163. package/lib/template/ListView/utils.ts +205 -94
  164. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +25 -34
  165. package/lib/template/NarrowWide/NarrowWide/NarrowWide.css +0 -2
  166. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +31 -29
  167. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +27 -31
  168. package/lib/template/NarrowWide/NarrowWideDetails/config-ext.json +1 -2
  169. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.css +0 -2
  170. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +17 -19
  171. package/lib/template/NarrowWide/NarrowWideForm/config-ext.json +1 -2
  172. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +16 -26
  173. package/lib/template/NarrowWide/NarrowWidePage/config-ext.json +1 -2
  174. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +17 -17
  175. package/lib/template/OneColumn/OneColumn/config-ext.json +1 -2
  176. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +9 -16
  177. package/lib/template/OneColumn/OneColumnPage/config-ext.json +1 -2
  178. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +8 -14
  179. package/lib/template/OneColumn/OneColumnTab/config-ext.json +1 -2
  180. package/lib/template/PromotedFilters/PromotedFilters.css +1 -1
  181. package/lib/template/PromotedFilters/PromotedFilters.tsx +39 -33
  182. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +113 -15
  183. package/lib/template/SimpleTable/SimpleTable/config-ext.json +1 -2
  184. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +187 -104
  185. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +33 -44
  186. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +45 -48
  187. package/lib/template/SubTabs/SubTabs.tsx +26 -45
  188. package/lib/template/SubTabs/config-ext.json +1 -2
  189. package/lib/template/SubTabs/tabUtils.ts +2 -9
  190. package/lib/template/TwoColumn/TwoColumn/TwoColumn.css +0 -1
  191. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +33 -36
  192. package/lib/template/TwoColumn/TwoColumn/config-ext.json +1 -2
  193. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +9 -16
  194. package/lib/template/TwoColumn/TwoColumnPage/config-ext.json +1 -2
  195. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +33 -33
  196. package/lib/template/TwoColumn/TwoColumnTab/config-ext.json +1 -2
  197. package/lib/template/WideNarrow/WideNarrow/WideNarrow.css +0 -2
  198. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +29 -27
  199. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +39 -33
  200. package/lib/template/WideNarrow/WideNarrowDetails/config-ext.json +1 -2
  201. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.css +0 -2
  202. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +16 -18
  203. package/lib/template/WideNarrow/WideNarrowForm/config-ext.json +1 -2
  204. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +15 -25
  205. package/lib/template/WideNarrow/WideNarrowPage/config-ext.json +1 -2
  206. package/lib/template/WideNarrow/WideNarrowPage/index.tsx +1 -1
  207. package/lib/template/WssNavBar/WssNavBar.tsx +24 -10
  208. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +34 -41
  209. package/lib/widget/AppAnnouncement/config-ext.json +1 -2
  210. package/lib/widget/Attachment/Attachment.css +60 -1
  211. package/lib/widget/Attachment/Attachment.tsx +379 -394
  212. package/lib/widget/Attachment/index.tsx +1 -1
  213. package/lib/widget/CaseHistory/CaseHistory.tsx +67 -67
  214. package/lib/widget/CaseHistory/config-ext.json +1 -2
  215. package/lib/widget/CaseHistory/index.tsx +1 -1
  216. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +19 -9
  217. package/lib/widget/FileUtility/FileUtility/FileUtility.css +2 -2
  218. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +322 -245
  219. package/lib/widget/FileUtility/FileUtility/config-ext.json +1 -2
  220. package/lib/widget/Followers/Followers.tsx +27 -25
  221. package/lib/widget/Followers/config-ext.json +1 -2
  222. package/lib/widget/QuickCreate/QuickCreate.tsx +71 -39
  223. package/lib/widget/SummaryItem/SummaryItem.css +9 -9
  224. package/lib/widget/SummaryItem/SummaryItem.tsx +62 -52
  225. package/lib/widget/SummaryItem/index.tsx +1 -1
  226. package/lib/widget/SummaryList/SummaryList.tsx +15 -4
  227. package/lib/widget/ToDo/ToDo.css +4 -4
  228. package/lib/widget/ToDo/ToDo.tsx +72 -116
  229. package/lib/widget/ToDo/config-ext.json +1 -2
  230. package/package.json +5 -2
  231. package/lib/helpers/auth.js +0 -483
  232. package/lib/helpers/authManager.js +0 -634
  233. package/lib/helpers/config_access.js +0 -259
@@ -1,45 +1,86 @@
1
- import React, { useEffect, useRef, useState, createElement } from 'react';
2
- import PropTypes from 'prop-types';
3
- import isEqual from 'fast-deep-equal';
1
+ import { createElement, useEffect, useRef, useState } from 'react';
4
2
  import Dialog from '@material-ui/core/Dialog';
5
3
  import DialogContent from '@material-ui/core/DialogContent';
6
4
  import DialogTitle from '@material-ui/core/DialogTitle';
7
5
  import { makeStyles } from '@material-ui/core/styles';
6
+ import { MuiPickersUtilsProvider } from '@material-ui/pickers';
7
+ import DayjsUtils from '@date-io/dayjs';
8
+ import difference from 'lodash.difference';
9
+
8
10
  import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
9
11
  // Need to get correct implementation from component map for Assignment and CancelAlert
10
12
  import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
11
13
  import { getBanners } from '@pega/react-sdk-components/lib/components/helpers/case-utils';
12
- import { isEmptyObject } from '@pega/react-sdk-components/lib/components/helpers/common-utils';
14
+ import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
15
+
16
+ interface ModalViewContainerProps extends PConnProps {
17
+ // If any, enter additional props that only exist on this component
18
+ loadingInfo?: string;
19
+ routingInfo?: any;
20
+ pageMessages?: string[];
21
+ }
13
22
 
14
- // Remove this and use "real" PCore type once .d.ts is fixed (currently shows 8 errors)
15
- declare const PCore: any;
23
+ function isOpenModalAction(prevModalCollection, currentModalList) {
24
+ return prevModalCollection && currentModalList ? Object.keys(prevModalCollection).length < currentModalList.length : false;
25
+ }
26
+
27
+ function isUpdateModalAction(prevModalCollection, currentModalList) {
28
+ return prevModalCollection && currentModalList ? Object.keys(prevModalCollection).length === currentModalList.length : false;
29
+ }
16
30
 
31
+ function isCloseModalAction(prevModalCollection, currentModalList) {
32
+ return prevModalCollection && currentModalList ? Object.keys(prevModalCollection).length > currentModalList.length : false;
33
+ }
17
34
 
18
35
  function buildName(pConnect, name = '') {
19
36
  const context = pConnect.getContextName();
20
37
  return `${context}/${name}`;
21
38
  }
22
39
 
23
- function getKeyAndLatestItem(routinginfo, pConn) {
40
+ function getKeyAndLatestItem(routinginfo, pConn, options) {
24
41
  const containerName = pConn.getContainerName();
42
+ const { acTertiary = false } = options || {};
25
43
  if (PCore.getContainerUtils().hasContainerItems(buildName(pConn, containerName))) {
26
44
  const { accessedOrder, items } = routinginfo;
27
- const key = accessedOrder[accessedOrder.length - 1];
45
+ let key;
46
+ // eslint-disable-next-line no-plusplus
47
+ for (let i = accessedOrder.length - 1; i >= 0; i--) {
48
+ const tempkey = accessedOrder[i];
49
+ if ((acTertiary && items[tempkey].acTertiary) || (!acTertiary && !items[tempkey].acTertiary)) {
50
+ key = tempkey;
51
+ break;
52
+ }
53
+ }
28
54
  const latestItem = items[key];
29
55
  return { key, latestItem };
30
56
  }
31
57
  return {};
32
58
  }
33
59
 
34
- function getConfigObject(item, pConnect) {
60
+ function getConfigObject(item, pConnect, isReverseCoexistence = false) {
61
+ let config;
62
+ if (isReverseCoexistence) {
63
+ config = {
64
+ options: {
65
+ pageReference: pConnect?.getPageReference(),
66
+ hasForm: true,
67
+ containerName: pConnect?.getContainerName() || PCore.getConstants().MODAL
68
+ }
69
+ };
70
+ return PCore.createPConnect(config);
71
+ }
35
72
  if (item) {
36
- const { context, view } = item;
37
- const config = {
73
+ const { context, view, isBulkAction } = item;
74
+ const target = PCore.getContainerUtils().getTargetFromContainerItemID(context);
75
+ config = {
38
76
  meta: view,
39
77
  options: {
40
78
  context,
41
79
  pageReference: view.config.context || pConnect.getPageReference(),
42
- hasForm: true
80
+ hasForm: true,
81
+ ...(isBulkAction && { isBulkAction }),
82
+ containerName: pConnect?.getContainerName() || PCore.getConstants().MODAL,
83
+ target
43
84
  }
44
85
  };
45
86
  return PCore.createPConnect(config);
@@ -53,95 +94,111 @@ const useStyles = makeStyles(theme => ({
53
94
  marginRight: theme.spacing(2),
54
95
  marginTop: theme.spacing(2),
55
96
  marginBottom: theme.spacing(0)
56
- // paddingLeft: theme.spacing(0),
57
- // paddingRight: theme.spacing(0),
58
- // paddingTop: theme.spacing(0),
59
- // paddingBottom: theme.spacing(0),
60
97
  },
61
98
  dlgContent: {
62
99
  marginLeft: theme.spacing(2),
63
100
  marginRight: theme.spacing(2),
64
101
  marginTop: theme.spacing(0),
65
102
  marginBottom: theme.spacing(2)
66
- // paddingLeft: theme.spacing(0),
67
- // paddingRight: theme.spacing(0),
68
- // paddingTop: theme.spacing(0),
69
- // paddingBottom: theme.spacing(0),
70
103
  }
71
104
  }));
72
105
 
73
- const ModalViewContainer = props => {
106
+ export default function ModalViewContainer(props: ModalViewContainerProps) {
74
107
  // Get the proper implementation (local or Pega-provided) for these components that are emitted below
75
- const Assignment = getComponentFromMap("Assignment");
76
- const CancelAlert = getComponentFromMap("CancelAlert");
108
+ const Assignment = getComponentFromMap('Assignment');
109
+ const CancelAlert = getComponentFromMap('CancelAlert');
110
+ const ListViewActionButtons = getComponentFromMap('ListViewActionButtons');
77
111
 
78
112
  const classes = useStyles();
79
113
 
114
+ const modalCollection = useRef({});
80
115
  const routingInfoRef = useRef({});
81
- const { getPConnect, routingInfo, loadingInfo, pageMessages } = props;
116
+ const { getPConnect, routingInfo = null, pageMessages = [] } = props;
82
117
  const pConn = getPConnect();
118
+ const { acTertiary } = pConn.getConfigProps() as any;
83
119
  const {
84
120
  CONTAINER_TYPE: { MULTIPLE },
85
121
  PUB_SUB_EVENTS: { EVENT_SHOW_CANCEL_ALERT }
86
122
  } = PCore.getConstants();
87
- const { subscribe } = PCore.getPubSubUtils();
123
+ const { subscribe, unsubscribe } = PCore.getPubSubUtils();
88
124
  const [bShowModal, setShowModal] = useState(false);
89
- const [bSubscribed, setSubscribed] = useState(false);
90
125
  const [bShowCancelAlert, setShowCancelAlert] = useState(false);
91
- const [oCaseInfo, setOCaseInfo] = useState({});
92
126
  const [createdView, setCreatedView] = useState<any>(null);
93
127
  const [title, setTitle] = useState('');
94
- const [arNewChildrenAsReact, setArNewChildrenAsReact] = useState<Array<any>>([]);
128
+ const [arNewChildrenAsReact, setArNewChildrenAsReact] = useState<any[]>([]);
95
129
  const [itemKey, setItemKey] = useState('');
96
- const [cancelPConn, setCancelPConn] = useState(null);
97
-
130
+ const [cancelAlertProps, setCancelAlertProps] = useState({});
131
+ const [isMultiRecordData, setMultiRecordData] = useState(false);
98
132
  const localizedVal = PCore.getLocaleUtils().getLocaleValue;
99
133
  const localeCategory = 'Data Object';
100
134
 
135
+ const ERROR_WHILE_RENDERING = 'ERROR_WHILE_RENDERING';
101
136
 
102
137
  function showAlert(payload) {
103
- const { latestItem } = getKeyAndLatestItem(routingInfoRef.current, pConn);
104
- const { isModalAction } = payload;
138
+ const { latestItem } = getKeyAndLatestItem(routingInfoRef.current, pConn, { acTertiary });
139
+ const isReverseCoexistence = (PCore.getCoexistenceManager().getBroadcastUtils() as any).isReverseCoexistenceCaseLoaded();
140
+ const { isModalAction, hideDelete, isDataObject, skipReleaseLockRequest } = payload;
105
141
 
106
142
  /*
107
143
  If we are in create stage full page mode, created a new case and trying to click on cancel button
108
144
  it will show two alert dialogs which is not expected. Hence isModalAction flag to avoid that.
109
145
  */
110
146
  if (latestItem && isModalAction) {
111
- const configObject = getConfigObject(latestItem, pConn);
112
- setCancelPConn(configObject.getPConnect());
147
+ const configObject = getConfigObject(latestItem, pConn, isReverseCoexistence);
148
+ const contextName = configObject?.getPConnect().getContextName();
149
+ setCancelAlertProps({
150
+ heading: 'Discard unsaved changes?',
151
+ content: 'You have unsaved changes. You can discard them or go back to keep working.',
152
+ getPConnect: configObject?.getPConnect,
153
+ itemKey: contextName,
154
+ hideDelete,
155
+ isDataObject,
156
+ skipReleaseLockRequest
157
+ });
113
158
  setShowCancelAlert(true);
114
159
  }
115
160
  }
116
161
 
117
- function compareCaseInfoIsDifferent(oCurrentCaseInfo: Object): boolean {
118
- let bRet = false;
119
-
120
- // fast-deep-equal version
121
- if (isEqual !== undefined) {
122
- bRet = !isEqual(oCaseInfo, oCurrentCaseInfo);
123
- } else {
124
- const sCurrentCaseInfo = JSON.stringify(oCurrentCaseInfo);
125
- const sOldCaseInfo = JSON.stringify(oCaseInfo);
126
- // stringify compare version
127
- if (sCurrentCaseInfo !== sOldCaseInfo) {
128
- bRet = true;
129
- }
130
- }
162
+ function handleModalOpen(key) {
163
+ modalCollection.current = {
164
+ ...modalCollection.current,
165
+ [key]: {}
166
+ };
167
+ }
131
168
 
132
- // if different, save off new case info
133
- if (bRet) {
134
- setOCaseInfo(JSON.parse(JSON.stringify(oCurrentCaseInfo)));
135
- }
169
+ function handleModalClose(accessedOrder) {
170
+ const tempModalCollection = modalCollection.current;
171
+ const [closedModalKey] = difference(Object.keys(tempModalCollection), accessedOrder);
136
172
 
137
- return bRet;
173
+ if (closedModalKey && tempModalCollection[closedModalKey]) {
174
+ const modifiedModalCollection = { ...tempModalCollection };
175
+ delete modifiedModalCollection[closedModalKey];
176
+ modalCollection.current = modifiedModalCollection;
177
+ setShowModal(false);
178
+ }
138
179
  }
139
180
 
140
- const updateAlertState = modalFlag => {
181
+ const dismissCancelAlert = dismissAllModals => {
141
182
  setShowCancelAlert(false);
142
- setShowModal(modalFlag);
183
+
184
+ if (dismissAllModals) {
185
+ setShowModal(false);
186
+ }
143
187
  };
144
188
 
189
+ function getModalHeading(dataObjectAction) {
190
+ return dataObjectAction === PCore.getConstants().RESOURCE_STATUS.CREATE
191
+ ? localizedVal('Add Record', localeCategory)
192
+ : localizedVal('Edit Record', localeCategory);
193
+ }
194
+
195
+ function determineModalHeaderByAction(actionName, caseTypeName, ID, caseLocaleRef) {
196
+ if (actionName) {
197
+ return localizedVal(actionName, localeCategory);
198
+ }
199
+ return `${localizedVal('Create', localeCategory)} ${localizedVal(caseTypeName, undefined, caseLocaleRef)} (${ID})`;
200
+ }
201
+
145
202
  useEffect(() => {
146
203
  // Establish the necessary containers
147
204
  const containerMgr = pConn.getContainerManager();
@@ -149,191 +206,140 @@ const ModalViewContainer = props => {
149
206
  }, [MULTIPLE, pConn]);
150
207
 
151
208
  useEffect(() => {
152
- // Update routingInfoRef.current whenever routingInfo changes
209
+ // Persisting routing information between the renders in showAlert
153
210
  routingInfoRef.current = routingInfo;
154
- }, [routingInfo]);
211
+ });
155
212
 
156
213
  useEffect(() => {
157
- if (routingInfoRef.current && !loadingInfo) {
158
- const currentOrder = routingInfo.accessedOrder;
159
-
160
- if (undefined === currentOrder) {
161
- return;
162
- }
214
+ subscribe(EVENT_SHOW_CANCEL_ALERT, showAlert, EVENT_SHOW_CANCEL_ALERT /* Unique string for subscription */);
215
+ subscribe(
216
+ ERROR_WHILE_RENDERING,
217
+ error => {
218
+ // setError(true);
219
+ // eslint-disable-next-line no-console
220
+ console.error(error);
221
+ },
222
+ `${ERROR_WHILE_RENDERING}-mc-${getPConnect().getContextName()}`,
223
+ false,
224
+ getPConnect().getContextName()
225
+ );
226
+
227
+ // Unsubscribe on component unmount
228
+ return () => {
229
+ unsubscribe(EVENT_SHOW_CANCEL_ALERT, EVENT_SHOW_CANCEL_ALERT /* Should be same unique string passed during subscription */);
230
+ };
231
+ });
163
232
 
164
- const currentItems = routingInfo.items;
165
-
166
- const { key, latestItem } = getKeyAndLatestItem(routingInfoRef.current, pConn);
167
-
168
- // console.log(`ModalViewContainer: key: ${key} latestItem: ${JSON.stringify(latestItem)}`);
169
-
170
- if (currentOrder.length > 0) {
171
- if (
172
- currentItems[key] &&
173
- currentItems[key].view &&
174
- !isEmptyObject(currentItems[key].view)
175
- ) {
176
- const currentItem = currentItems[key];
177
- const rootView = currentItem.view;
178
- const { context } = rootView.config;
179
- const config = { meta: rootView };
180
- config['options'] = {
181
- context: currentItem.context,
182
- hasForm: true,
183
- pageReference: context || pConn.getPageReference()
184
- };
185
-
186
- if (!bSubscribed) {
187
- setSubscribed(true);
188
- subscribe(
189
- EVENT_SHOW_CANCEL_ALERT,
190
- showAlert,
191
- EVENT_SHOW_CANCEL_ALERT /* Unique string for subscription */
192
- );
193
- }
194
-
195
- const configObject = PCore.createPConnect(config);
196
-
197
- // THIS is where the ViewContainer creates a View
198
- // The config has meta.config.type = "view"
199
- const newComp = configObject.getPConnect();
200
- // const newCompName = newComp.getComponentName();
201
- const caseInfo =
202
- newComp && newComp.getDataObject() && newComp.getDataObject().caseInfo
203
- ? newComp.getDataObject().caseInfo
204
- : null;
205
-
206
- // console.log(`ModalViewContainer just created newComp: ${newCompName}`);
207
-
208
- // The metadata for pyDetails changed such that the "template": "CaseView"
209
- // is no longer a child of the created View but is in the created View's
210
- // config. So, we DON'T want to replace this.pConn$ since the created
211
- // component is a View (and not a ViewContainer). We now look for the
212
- // "template" type directly in the created component (newComp) and NOT
213
- // as a child of the newly created component.
214
- // console.log(`---> ModalViewContainer created new ${newCompName}`);
215
-
216
- // Use the newly created component (View) info but DO NOT replace
217
- // this ModalViewContainer's pConn$, etc.
218
- // Note that we're now using the newly created View's PConnect in the
219
- // ViewContainer HTML template to guide what's rendered similar to what
220
- // the React return of React.Fragment does
221
-
222
- // right now need to check caseInfo for changes, to trigger redraw, not getting
223
- // changes from angularPconnect except for first draw
224
- if (newComp && caseInfo && compareCaseInfoIsDifferent(caseInfo)) {
225
- setCreatedView(configObject);
226
-
227
- const { actionName } = latestItem;
228
- const theNewCaseInfo = newComp.getCaseInfo();
229
- const caseName = theNewCaseInfo.getName();
230
- const ID = theNewCaseInfo.getID();
231
-
232
- setTitle(actionName || `${localizedVal('New', localeCategory)} ${caseName} (${ID})`);
233
-
234
- let arChildrenAsReact: Array<any> = [];
235
-
236
- if (newComp.getComponentName() === 'reference') {
237
- // Reference component doesn't have children. It can build the View we want.
238
- // The Reference component getPConnect is in configObject
239
-
240
- arChildrenAsReact.push(
241
- createElement(createPConnectComponent(), {
242
- ...configObject,
243
- key: `${caseName}-${ID}`
244
- })
245
- );
246
- } else {
247
- // This is the 8.6 implementation. Leaving it in for reference for now.
248
- // And create a similar array of the children as React components
249
- // passed to Assignment component when rendered
250
- arChildrenAsReact = newComp.getChildren().map(child => {
251
- // Use Case Summary ID as the React element's key
252
- const caseSummaryID = child.getPConnect().getCaseSummary().ID;
253
- return createElement(createPConnectComponent(), { ...child, key: caseSummaryID });
254
- });
255
- }
256
-
257
- if (arChildrenAsReact.length > 0) setArNewChildrenAsReact(arChildrenAsReact);
258
-
259
- setShowModal(true);
260
-
261
- // save off itemKey to be used for finishAssignment, etc.
262
- setItemKey(key);
263
- }
264
- }
265
- } else {
266
- if (bShowModal) {
267
- setShowModal(false);
233
+ useEffect(() => {
234
+ if (routingInfo) {
235
+ const { accessedOrder, type } = routingInfo;
236
+ const { key, latestItem } = getKeyAndLatestItem(routingInfo, pConn, { acTertiary });
237
+
238
+ if (
239
+ latestItem &&
240
+ type === MULTIPLE &&
241
+ (isOpenModalAction(modalCollection.current, accessedOrder) || isUpdateModalAction(modalCollection.current, accessedOrder))
242
+ ) {
243
+ const { actionName } = latestItem;
244
+ // const { isDockable = false } = latestItem?.modalOptions || {};
245
+ const configObject: any = getConfigObject(latestItem, null, false);
246
+ const pConnect = configObject.getPConnect();
247
+ const caseInfo: any = pConnect.getCaseInfo();
248
+ const caseName = caseInfo.getName();
249
+ const caseTypeName = caseInfo.getCaseTypeName();
250
+ const ID = caseInfo.getBusinessID() || caseInfo.getID();
251
+ const isDataObject = routingInfo.items[latestItem.context].resourceType === PCore.getConstants().RESOURCE_TYPES.DATA;
252
+ const dataObjectAction = routingInfo.items[latestItem.context].resourceStatus;
253
+ const isMultiRecord = routingInfo.items[latestItem.context].isMultiRecordData;
254
+ const headingValue =
255
+ isDataObject || isMultiRecord
256
+ ? getModalHeading(dataObjectAction)
257
+ : determineModalHeaderByAction(actionName, caseTypeName, ID, `${caseInfo?.getClassName()}!CASE!${caseInfo.getName()}`.toUpperCase());
258
+
259
+ let arChildrenAsReact: any[] = [];
260
+
261
+ if (pConnect.getComponentName() === 'reference') {
262
+ // Reference component doesn't have children. It can build the View we want.
263
+ // The Reference component getPConnect is in configObject
264
+
265
+ arChildrenAsReact.push(
266
+ createElement(createPConnectComponent(), {
267
+ ...configObject,
268
+ key: `${caseName}-${ID}`
269
+ })
270
+ );
271
+ } else {
272
+ // This is the 8.6 implementation. Leaving it in for reference for now.
273
+ // And create a similar array of the children as React components
274
+ // passed to Assignment component when rendered
275
+ arChildrenAsReact = (pConnect.getChildren() as []).map((child: any) => {
276
+ // Use Case Summary ID as the React element's key
277
+ const caseSummaryID = child.getPConnect().getCaseSummary().ID;
278
+ return createElement(createPConnectComponent(), {
279
+ ...child,
280
+ key: caseSummaryID
281
+ });
282
+ });
268
283
  }
269
- if (!isEmptyObject(oCaseInfo)) {
270
- setOCaseInfo({});
284
+
285
+ if (arChildrenAsReact.length > 0) setArNewChildrenAsReact(arChildrenAsReact);
286
+ setMultiRecordData(isMultiRecord);
287
+ setTitle(headingValue);
288
+ setCreatedView({ configObject, latestItem });
289
+ setItemKey(key);
290
+ setShowModal(true);
291
+
292
+ // Update modal use case which happens when assignment in submitted in modal.
293
+ if (isUpdateModalAction(modalCollection.current, accessedOrder)) {
294
+ // handleModalUpdate(key);
295
+ } else if (isOpenModalAction(modalCollection.current, accessedOrder)) {
296
+ // New modal open scenario
297
+ handleModalOpen(key);
271
298
  }
299
+ } else if (isCloseModalAction(modalCollection.current, accessedOrder)) {
300
+ handleModalClose(accessedOrder);
272
301
  }
273
302
  }
274
- });
275
-
276
- // function placeholderModalClose() {
277
- // // Intentionally a no-op. Similar behavior in other SDKs.
278
- // // Does NOT close the window. This forces the user to use
279
- // // the cancel or submit button to close the modal (which, in turn, gets the right
280
- // // Constellation code to run to clean up the containers, data, etc.)
281
-
282
- // // console.log(`ModalViewContainer: placeholderModalClose setting bShowModal to false`) setShowModal(false);
283
- // }
303
+ }, [routingInfo]);
284
304
 
285
- // if (bShowModal) {
286
- // console.log(`ModalViewContainer about to show modal with`);
287
- // console.log(`--> createdView: ${createdView} createdView.getPConnect: ${typeof createdView.getPConnect}`);
288
- // console.log(`--> itemKey: ${itemKey}`);
289
- // console.log(`--> arNewChildrenAsReact: ${JSON.stringify(arNewChildrenAsReact)}`);
290
- // }
305
+ function closeActionsDialog() {
306
+ // actionsDialog.current = true;
307
+ setShowModal(false);
308
+ }
291
309
 
292
310
  return (
293
311
  <>
294
312
  <Dialog open={bShowModal} aria-labelledby='form-dialog-title'>
295
- <DialogTitle id='form-dialog-title' className={classes.dlgTitle}>
313
+ <DialogTitle id='form-dialog-title' className={`${classes.dlgTitle} psdk-dialog-title`}>
296
314
  {title}
297
315
  </DialogTitle>
298
- <DialogContent className={classes.dlgContent}>
316
+ <DialogContent className={`${classes.dlgContent} psdk-dialog-content`}>
299
317
  {bShowModal ? (
300
- <Assignment
301
- getPConnect={createdView.getPConnect}
302
- itemKey={itemKey}
303
- isInModal
304
- banners={getBanners({
305
- target: itemKey,
306
- pageMessages
307
- })}
308
- >
309
- {arNewChildrenAsReact}
310
- </Assignment>
311
- ) : (
312
- <></>
313
- )}
318
+ <MuiPickersUtilsProvider utils={DayjsUtils}>
319
+ <Assignment
320
+ getPConnect={createdView.configObject.getPConnect}
321
+ itemKey={itemKey}
322
+ isInModal
323
+ banners={getBanners({
324
+ target: itemKey,
325
+ pageMessages
326
+ })}
327
+ >
328
+ {arNewChildrenAsReact}
329
+ </Assignment>
330
+ </MuiPickersUtilsProvider>
331
+ ) : null}
314
332
  </DialogContent>
333
+
334
+ {isMultiRecordData && (
335
+ <ListViewActionButtons
336
+ getPConnect={createdView.configObject.getPConnect}
337
+ context={createdView.latestItem.context}
338
+ closeActionsDialog={closeActionsDialog}
339
+ />
340
+ )}
315
341
  </Dialog>
316
- {bShowCancelAlert && (
317
- <CancelAlert
318
- pConn={cancelPConn}
319
- showAlert={bShowCancelAlert}
320
- updateAlertState={updateAlertState}
321
- />
322
- )}
342
+ {bShowCancelAlert && <CancelAlert {...cancelAlertProps} dismiss={dismissCancelAlert} />}
323
343
  </>
324
344
  );
325
- };
326
-
327
- export default ModalViewContainer;
328
-
329
- ModalViewContainer.defaultProps = {
330
- getPConnect: null,
331
- loadingInfo: false,
332
- routingInfo: null
333
- };
334
-
335
- ModalViewContainer.propTypes = {
336
- getPConnect: PropTypes.func,
337
- loadingInfo: PropTypes.bool,
338
- routingInfo: PropTypes.objectOf(PropTypes.any)
339
- };
345
+ }
@@ -1 +1 @@
1
- export { default } from './ModalViewContainer';
1
+ export { default } from './ModalViewContainer';
@@ -0,0 +1,48 @@
1
+ import { useMemo } from 'react';
2
+
3
+ import { getActiveContainerItemID, getActiveContainerRootViewElement, getPConnectOfActiveContainerItem, useContainerInitializer } from './helper';
4
+
5
+ const SimpleViewContainer = props => {
6
+ const { CONTAINER_TYPE } = PCore.getConstants();
7
+
8
+ const { getPConnect, mode = CONTAINER_TYPE.SINGLE, routingInfo: containerInfo, isAssignmentView, options = {} } = props;
9
+
10
+ const rootViewElement = useMemo(() => {
11
+ return getActiveContainerRootViewElement(containerInfo, {
12
+ isAssignmentView,
13
+ parentGetPConnect: getPConnect
14
+ });
15
+ }, [containerInfo, isAssignmentView, getPConnect]);
16
+
17
+ useContainerInitializer(getPConnect, options.mode || mode);
18
+
19
+ return rootViewElement;
20
+ };
21
+
22
+ export const withSimpleViewContainerRenderer =
23
+ (Component, options: any = {}) =>
24
+ props => {
25
+ const { CONTAINER_TYPE } = PCore.getConstants();
26
+
27
+ const { getPConnect, mode = CONTAINER_TYPE.SINGLE, routingInfo: containerInfo, isAssignmentView } = props;
28
+
29
+ const rootViewElement = <SimpleViewContainer {...props} options={options} />;
30
+ const activeContainerItemID = getActiveContainerItemID(containerInfo);
31
+ const getPConnectOfActiveItem = getPConnectOfActiveContainerItem(containerInfo, {
32
+ isAssignmentView,
33
+ parentGetPConnect: getPConnect
34
+ });
35
+
36
+ useContainerInitializer(getPConnect, options.mode || mode);
37
+
38
+ return (
39
+ <Component
40
+ {...props}
41
+ rootViewElement={rootViewElement}
42
+ activeContainerItemID={activeContainerItemID}
43
+ getPConnectOfActiveContainerItem={getPConnectOfActiveItem}
44
+ />
45
+ );
46
+ };
47
+
48
+ export default SimpleViewContainer;