@pega/react-sdk-overrides 23.1.10 → 23.1.12

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