@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,22 @@
1
+ import React from "react";
2
+ import { Button } from '@material-ui/core';
3
+ import './ActionButtonsForFileUtil.css';
4
+
5
+ export default function ActionButtonsForFileUtil(props) {
6
+
7
+ return (
8
+ <div className="psdk-actions">
9
+ <div className="psdk-action-buttons">
10
+ {props.arSecondaryButtons.map(file => (
11
+ <Button className="secondary-button" key={file.actionID} onClick={props.secondaryAction}>{file.name}</Button>
12
+ ))}
13
+ </div>
14
+ <div className="psdk-action-buttons">
15
+ {props.arMainButtons.map(file => (
16
+ <Button className="primary-button" key={file.actionID} onClick={props.primaryAction}>{file.name}</Button>
17
+ ))}
18
+ </div>
19
+ </div>
20
+ )
21
+
22
+ }
@@ -0,0 +1,117 @@
1
+ .psdk-utility {
2
+ width: 100%;
3
+ padding: 0.625rem 0rem;
4
+ text-align: left;
5
+ background-color: white;
6
+ border-radius: 0.6125rem;
7
+ margin: 0.3125rem 0rem;
8
+ position: relative;
9
+ }
10
+
11
+ .psdk-header {
12
+ display: flex;
13
+ align-items: center;
14
+ }
15
+
16
+ .psdk-file-utility-card-svg-icon {
17
+ width: 1.4rem;
18
+ display: inline-block;
19
+ }
20
+
21
+ .header-text {
22
+ font-size: 1rem;
23
+ font-weight: bold;
24
+ padding: 0px 5px;
25
+ }
26
+
27
+ .psdk-utility-count {
28
+ background: #65b5f5;
29
+ border-radius: calc(1.125 * 0.5rem);
30
+ font-size: 0.75rem;
31
+ font-weight: bold;
32
+ text-align: center;
33
+ width: 1.25rem;
34
+ }
35
+
36
+ .psdk-dialog-background {
37
+ display: flex;
38
+ flex-direction: column;
39
+ justify-content: center;
40
+ align-items: center;
41
+ height: 100%;
42
+ width: 100%;
43
+ background-color: rgba(100,100,100, 0.4);
44
+ position: fixed;
45
+ z-index: 999;
46
+ top: 0px;
47
+ left: 0px;
48
+ }
49
+
50
+ .psdk-modal-file-top {
51
+ display: table;
52
+ margin: auto;
53
+ min-width: 650px;
54
+ background-color: white;
55
+ border: 1px solid black;
56
+ border-radius: 10px;
57
+ padding: 20px;
58
+ box-shadow: 0 0 10px 3px #777;
59
+ }
60
+
61
+ .psdk-modal-file-selector {
62
+ border: 1px dashed;
63
+ width: 100%;
64
+ padding: 0.3rem;
65
+ text-align: center;;
66
+ }
67
+
68
+ .psdk-modal-links-row {
69
+ display: flex;
70
+ flex-direction: row;
71
+ justify-content: space-between;
72
+ align-items: center;
73
+ }
74
+
75
+ .psdk-links-two-column {
76
+ display: grid;
77
+ grid-template-columns: repeat(2, 1fr);
78
+ gap: calc(1rem);
79
+ width: 83%;
80
+ }
81
+
82
+ .psdk-modal-link-data {
83
+ flex-grow: 3;
84
+ }
85
+
86
+ .psdk-modal-link-add {
87
+ flex-grow: 1;
88
+ margin-left: 10px;
89
+ }
90
+
91
+ .psdk-add-link-action {
92
+ text-transform: unset !important;
93
+ font-size: 14px;
94
+ }
95
+
96
+ .psdk-utility-view-all {
97
+ width: 100%;
98
+ display: flex;
99
+ justify-content: center;
100
+ }
101
+
102
+ .psdk-view-all-header {
103
+ display: flex;
104
+ justify-content: space-between;
105
+ }
106
+
107
+ .psdk-close-button {
108
+ border: none;
109
+ background: none;
110
+ cursor: pointer;
111
+ }
112
+
113
+ .psdk-view-all-body {
114
+ max-height: 500px;
115
+ overflow-y: auto;
116
+ overflow-x: hidden;
117
+ }
@@ -0,0 +1,567 @@
1
+ import React, { useEffect, useState } from "react";
2
+ import TextField from '@material-ui/core/TextField';
3
+ import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
4
+ import download from "downloadjs";
5
+ import SummaryList from '@pega/react-sdk-components/lib/components/widgets/SummaryList';
6
+ import ActionButtonsForFileUtil from './ActionButtonsForFileUtil';
7
+ import './FileUtility.css';
8
+ import { IconButton, Menu, MenuItem } from '@material-ui/core';
9
+ import MoreVertIcon from '@material-ui/icons/MoreVert';
10
+ import { Button } from '@material-ui/core';
11
+ import { validateMaxSize } from '@pega/react-sdk-components/lib/components/infra/Attachment/AttachmentUtils';
12
+ import { CircularProgress } from "@material-ui/core";
13
+
14
+ declare const PCore;
15
+
16
+ export default function FileUtility(props) {
17
+ const { getPConnect } = props;
18
+ const thePConn = getPConnect();
19
+ const required = true;
20
+ const listTemp = {
21
+ data: [],
22
+ count: 0
23
+ };
24
+ const [list, setList] = useState(listTemp);
25
+ const headerSvgIcon$ = Utils.getImageSrc('paper-clip', PCore.getAssetLoader().getStaticServerUrl());
26
+ const closeSvgIcon = Utils.getImageSrc("times", PCore.getAssetLoader().getStaticServerUrl());
27
+ const configProps: any = thePConn.resolveConfigProps(thePConn.getConfigProps());
28
+
29
+ const header = configProps.label;
30
+ const fileTemp = {
31
+ showfileModal: false,
32
+ fileList: [],
33
+ attachedFiles: [],
34
+ fileMainButtons: [{ actionID: "attach", jsAction: "attachFiles", name: "Attach files"}],
35
+ fileSecondaryButtons: [{ actionID: "cancel", jsAction: "cancel", name: "Cancel"}]
36
+ };
37
+ const [fileData, setFileData] = useState(fileTemp);
38
+ const linkTemp = {
39
+ showLinkModal: false,
40
+ linksList: [],
41
+ attachedLinks: [],
42
+ linkMainButtons: [{ actionID: "attach", jsAction: "attachLinks", name: "Attach links"}],
43
+ linkSecondaryButtons: [{ actionID: "cancel", jsAction: "cancel", name: "Cancel"}]
44
+ };
45
+ const [linkData, setLinkData] = useState(linkTemp);
46
+ const [anchorEl, setAnchorEl] = useState(null);
47
+ const open = Boolean(anchorEl);
48
+ const [link, setLink] = useState({title: '', url: '', disable: true});
49
+ const [inProgress, setProgress] = useState(false);
50
+ const [showViewAllModal, setViewAll] = useState(false);
51
+ const [vaItems, setFullAttachments] = useState([]);
52
+
53
+ function addAttachments(attsFromResp: Array<any> = []) {
54
+ attsFromResp = attsFromResp.map((respAtt) => {
55
+ const updatedAtt = {
56
+ ...respAtt,
57
+ meta: `${respAtt.category} . ${Utils.generateDateTime(respAtt.createTime, "DateTime-Since")}, ${
58
+ respAtt.createdBy
59
+ }`
60
+ };
61
+ if (updatedAtt.type === "FILE") {
62
+ updatedAtt.nameWithExt = updatedAtt.fileName;
63
+ }
64
+ return updatedAtt;
65
+ });
66
+ return attsFromResp;
67
+ }
68
+
69
+ function getListUtilityItemProps({
70
+ att,
71
+ cancelFile,
72
+ downloadFile,
73
+ deleteFile,
74
+ removeFile
75
+ }) {
76
+ let actions;
77
+
78
+
79
+ if (att.progress && att.progress !== 100) {
80
+ actions = [
81
+ {
82
+ id: `Cancel-${att.ID}`,
83
+ text: "Cancel",
84
+ icon: "times",
85
+ onClick: cancelFile
86
+ }
87
+ ];
88
+ } else if (att.links) {
89
+ const isFile = att.type === "FILE";
90
+ const ID = att.ID.replace(/\s/gi, "");
91
+ const actionsMap = new Map([
92
+ [
93
+ "download",
94
+ {
95
+ id: `download-${ID}`,
96
+ text: isFile ? "Download" : "Open",
97
+ icon: isFile ? "download" : "open",
98
+ onClick: downloadFile
99
+ }
100
+ ],
101
+ [
102
+ "delete",
103
+ {
104
+ id: `Delete-${ID}`,
105
+ text: "Delete",
106
+ icon: "trash",
107
+ onClick: deleteFile
108
+ }
109
+ ]
110
+ ]);
111
+ actions = [];
112
+ actionsMap.forEach((action, actionKey) => {
113
+ if (att.links[actionKey]) {
114
+ actions.push(action);
115
+ }
116
+ });
117
+ } else if (att.error) {
118
+ actions = [
119
+ {
120
+ id: `Remove-${att.ID}`,
121
+ text: "Remove",
122
+ icon: "trash",
123
+ onClick: removeFile
124
+ }
125
+ ];
126
+ }
127
+
128
+ return {
129
+ id: att.ID,
130
+ visual: {
131
+ icon: Utils.getIconForAttachment(att),
132
+ progress: att.progress === 100 ? undefined: att.progress,
133
+ },
134
+ primary: {
135
+ type: att.type,
136
+ name: att.name,
137
+ icon: "open",
138
+ click: downloadFile,
139
+ },
140
+ secondary: {
141
+ text: att.meta
142
+ },
143
+ actions
144
+ };
145
+ }
146
+
147
+ function fileDownload(data, fileName, ext) {
148
+ const file = ext ? `${fileName}.${ext}` : fileName;
149
+ download(atob(data), file);
150
+ };
151
+
152
+ function downloadAttachedFile(att: any) {
153
+ const attachUtils = PCore.getAttachmentUtils();
154
+ const {ID, name, extension, type} = att;
155
+ const context = thePConn.getContextName();
156
+
157
+ attachUtils
158
+ .downloadAttachment(ID, context)
159
+ .then((content) => {
160
+ if (type === "FILE") {
161
+ fileDownload(content.data, name, extension);
162
+ } else if (type === "URL") {
163
+ let { data } = content;
164
+ if (!/^(http|https):\/\//.test(data)) {
165
+ data = `//${data}`;
166
+ }
167
+ window.open(content.data, "_blank");
168
+ }
169
+ })
170
+ .catch();
171
+ }
172
+
173
+ function deleteAttachedFile(att: any) {
174
+ const attachUtils = PCore.getAttachmentUtils();
175
+ const {ID} = att;
176
+ const context = thePConn.getContextName();
177
+
178
+ attachUtils.deleteAttachment(ID, context)
179
+ .then(() => {
180
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
181
+ getAttachments();
182
+ })
183
+ .catch();
184
+ }
185
+
186
+ const getAttachments = () => {
187
+
188
+ const attachmentUtils = PCore.getAttachmentUtils();
189
+ const caseID = thePConn.getValue(PCore.getConstants().CASE_INFO.CASE_INFO_ID);
190
+
191
+ if (caseID && caseID !== "") {
192
+ const attPromise = attachmentUtils.getCaseAttachments(caseID, thePConn.getContextName());
193
+
194
+ attPromise
195
+ .then( (resp) => {
196
+ const arFullListAttachments = addAttachments(resp);
197
+ const attachmentsCount = arFullListAttachments.length;
198
+ const arItems: any = arFullListAttachments.slice(0, 3).map((att) => {
199
+ return getListUtilityItemProps({
200
+ att,
201
+ downloadFile: !att.progress ? () => downloadAttachedFile(att) : null,
202
+ cancelFile: null,
203
+ deleteFile: !att.progress ? () => deleteAttachedFile(att) : null,
204
+ removeFile: null
205
+ });
206
+ });
207
+ const viewAllarItems: any = arFullListAttachments.map((att) => {
208
+ return getListUtilityItemProps({
209
+ att,
210
+ downloadFile: !att.progress ? () => downloadAttachedFile(att) : null,
211
+ cancelFile: null,
212
+ deleteFile: !att.progress ? () => deleteAttachedFile(att) : null,
213
+ removeFile: null
214
+ });
215
+ });
216
+ setProgress(false);
217
+ setList((current) => {
218
+ return {...current, count: attachmentsCount, data: arItems}
219
+ });
220
+ setFullAttachments(viewAllarItems);
221
+ });
222
+ }
223
+ }
224
+
225
+ useEffect(() => {
226
+ getAttachments();
227
+ }, []);
228
+
229
+
230
+ useEffect(() => {
231
+ PCore.getPubSubUtils().subscribe(
232
+ PCore.getEvents().getCaseEvent().CASE_ATTACHMENTS_UPDATED_FROM_CASEVIEW,
233
+ getAttachments,
234
+ "caseAttachmentsUpdateFromCaseview"
235
+ );
236
+
237
+ return () => {
238
+ PCore.getPubSubUtils().unsubscribe(
239
+ PCore.getEvents().getCaseEvent().CASE_ATTACHMENTS_UPDATED_FROM_CASEVIEW,
240
+ "caseAttachmentsUpdateFromCaseview"
241
+ );
242
+ };
243
+ }, []);
244
+
245
+ function setNewFiles(arFiles) {
246
+ let index = 0;
247
+ for (const file of arFiles) {
248
+ if (!validateMaxSize(file, 5)) {
249
+ file.error = true;
250
+ file.meta = "File is too big. Max allowed size is 5MB.";
251
+ }
252
+ file.mimeType = file.type;
253
+ file.icon = Utils.getIconFromFileType(file.type);
254
+ file.ID = `${new Date().getTime()}I${index}`;
255
+ index+=1;
256
+ }
257
+ return arFiles;
258
+ }
259
+
260
+ function getFiles(arFiles: Array<any>): Array<any> {
261
+ return setNewFiles(arFiles);
262
+ }
263
+
264
+ function uploadMyFiles(event) {
265
+ // alert($event.target.files[0]); // outputs the first file
266
+ const arFiles = getFiles(event.target.files);
267
+ // convert FileList to an array
268
+ const myFiles: any = Array.from(arFiles);
269
+
270
+ const arFileList$: any = myFiles.map((att: any) => {
271
+ return getListUtilityItemProps({
272
+ att,
273
+ downloadFile: !att.progress ? () => downloadAttachedFile(att) : null,
274
+ cancelFile: null,
275
+ deleteFile: !att.progress ? () => deleteAttachedFile(att) : null,
276
+ removeFile: null
277
+ });
278
+ });
279
+ setFileData((current) => {
280
+ return {...current, fileList: arFileList$, attachedFiles: myFiles}
281
+ });
282
+ }
283
+
284
+
285
+
286
+ const handleClick = (event) => {
287
+ setAnchorEl(event.currentTarget);
288
+ };
289
+
290
+ const handleClose = () => {
291
+ setAnchorEl(null);
292
+ };
293
+
294
+ function onAddFilesClick() {
295
+ setFileData((current) => {
296
+ return {...current, showfileModal: true}
297
+ });
298
+ setAnchorEl(null);
299
+ }
300
+
301
+ function removeFileFromList(item: any) {
302
+ let attachedFiles: any = fileData.attachedFiles;
303
+ let fileList: any = fileData.fileList;
304
+ if (item !== null) {
305
+ attachedFiles = attachedFiles.filter(ele => ele.ID !== item.id);
306
+ fileList = fileList.filter(ele => ele.id !== item.id);
307
+ setFileData((current) => {
308
+ return {...current, fileList, attachedFiles}
309
+ });
310
+ }
311
+ }
312
+
313
+ function closeFilePopup() {
314
+ setFileData((current) => {
315
+ return {...current, showfileModal: false}
316
+ });
317
+ }
318
+
319
+ function onAttachFiles() {
320
+ const attachmentUtils = PCore.getAttachmentUtils();
321
+ const caseID = thePConn.getValue(PCore.getConstants().CASE_INFO.CASE_INFO_ID);
322
+ const onUploadProgress = () => {};
323
+ const errorHandler = () => {};
324
+ closeFilePopup()
325
+ if (fileData.attachedFiles && fileData.attachedFiles.length > 0 ) {
326
+ setProgress(true);
327
+ }
328
+ for (const file of fileData.attachedFiles) {
329
+ attachmentUtils
330
+ .uploadAttachment(
331
+ file,
332
+ onUploadProgress,
333
+ errorHandler,
334
+ thePConn.getContextName()
335
+ )
336
+ .then((fileResponse) => {
337
+ if (fileResponse.type === "File") {
338
+ attachmentUtils.linkAttachmentsToCase(
339
+ caseID,
340
+ [ fileResponse ],
341
+ "File",
342
+ thePConn.getContextName()
343
+ )
344
+ .then(() => {
345
+ setFileData((current) => {
346
+ return {...current, fileList: [], attachedFiles: []};
347
+ });
348
+ getAttachments();
349
+ })
350
+ .catch();
351
+ }
352
+ })
353
+ .catch();
354
+ }
355
+ }
356
+
357
+ function onAddLinksClick() {
358
+ setLinkData((current) => {
359
+ return {...current, showLinkModal: true}
360
+ });
361
+ setAnchorEl(null);
362
+ }
363
+
364
+ function closeAddLinksPopup() {
365
+ setLinkData((current) => {
366
+ return {...current, showLinkModal: false}
367
+ });
368
+ }
369
+
370
+ const fieldlinkOnChange = (event) => {
371
+ const title = event.target.value;
372
+ setLink((current) => {
373
+ const updatedData = {...current, title};
374
+ updatedData.disable = !(updatedData.title && updatedData.url);
375
+ return updatedData;
376
+ });
377
+ }
378
+
379
+ function fieldurlOnChange(event) {
380
+ const url = event.target.value;
381
+ setLink((current) => {
382
+ const updatedData = {...current, url}
383
+ updatedData.disable = !(updatedData.title && updatedData.url);
384
+ return updatedData;
385
+ });
386
+ }
387
+
388
+ function addLink() {
389
+ // copy list locally
390
+ const localList: any = linkData.linksList.slice();
391
+ const url = link.url;
392
+ if (!/^(http|https):\/\//.test(link.url)) {
393
+ link.url = `http://${link.url}`;
394
+ }
395
+
396
+ // list for display
397
+ let oLink: any = {};
398
+ oLink.icon = "chain";
399
+ oLink.ID = `${new Date().getTime()}`;
400
+ oLink = getListUtilityItemProps({
401
+ att: oLink,
402
+ downloadFile: null,
403
+ cancelFile: null,
404
+ deleteFile: null,
405
+ removeFile: null
406
+ });
407
+ oLink.type = "URL";
408
+ oLink.primary.type = oLink.type;
409
+ oLink.visual.icon = "chain";
410
+ oLink.primary.name = link.title;
411
+ oLink.primary.icon = "open";
412
+ oLink.secondary.text = url;
413
+
414
+ localList.push(oLink);
415
+
416
+ // list for actually attachments
417
+ const attachedListTemp: any = linkData.attachedLinks.slice();
418
+ const attachedLink: any = {};
419
+ attachedLink.id = oLink.id;
420
+ attachedLink.linkTitle = link.title;
421
+ attachedLink.type = oLink.type;
422
+ attachedLink.url = url;
423
+
424
+ attachedListTemp.push(attachedLink);
425
+ setLinkData((current) => {
426
+ return {...current, linksList: localList, attachedLinks: attachedListTemp}
427
+ });
428
+ // clear values
429
+ setLink({title: '', url: '', disable: true});
430
+ }
431
+
432
+ function removeLinksFromList(item: any) {
433
+ let attachedLinks: any = linkData.attachedLinks;
434
+ let linksList: any = linkData.linksList;
435
+ if (item !== null) {
436
+ attachedLinks = attachedLinks.filter(ele => ele.id !== item.id);
437
+ linksList = linksList.filter(ele => ele.id !== item.id);
438
+ setLinkData((current) => {
439
+ return {...current, linksList, attachedLinks}
440
+ });
441
+ }
442
+ }
443
+
444
+ function onAttachLinks() {
445
+ const attachmentUtils = PCore.getAttachmentUtils();
446
+ const caseID = thePConn.getValue(PCore.getConstants().CASE_INFO.CASE_INFO_ID);
447
+ const links = linkData.attachedLinks;
448
+ closeAddLinksPopup();
449
+ const linksToAttach = links.map((item: any) => ({
450
+ type: "URL",
451
+ category: "URL",
452
+ url: item.url,
453
+ name: item.linkTitle
454
+ }));
455
+
456
+ if (linksToAttach && linksToAttach.length > 0) {
457
+ setProgress(true);
458
+ attachmentUtils
459
+ .linkAttachmentsToCase(caseID, linksToAttach, "URL", thePConn.getContextName())
460
+ .then( () => {
461
+ setLinkData((current) => {
462
+ return {...current, linksList: [], attachedLinks: []};
463
+ });
464
+ getAttachments();
465
+ })
466
+ .catch(setProgress(false));
467
+ }
468
+ }
469
+
470
+ return (
471
+ <div className="psdk-utility">
472
+ {inProgress && (<div className="progress-div"><CircularProgress /></div>)}
473
+ <div className="psdk-header">
474
+ <img className="psdk-file-utility-card-svg-icon" src={headerSvgIcon$}></img>
475
+ <div className="header-text">{header}</div>
476
+ <div className="psdk-utility-count" id="attachments-count">{list.count}</div>
477
+ <div style={{flexGrow: 1}}></div>
478
+ <div>
479
+ <IconButton
480
+ id="long-button"
481
+ aria-controls={open ? 'simple-menu' : undefined}
482
+ aria-expanded={open ? 'true' : undefined}
483
+ aria-haspopup="true"
484
+ onClick={handleClick}
485
+ >
486
+ <MoreVertIcon />
487
+ </IconButton>
488
+ <Menu style={{marginTop: '3rem'}}
489
+ id="simple-menu"
490
+ anchorEl={anchorEl}
491
+ keepMounted
492
+ open={Boolean(anchorEl)}
493
+ onClose={handleClose}
494
+ >
495
+ <MenuItem style={{fontSize: '14px'}} onClick={onAddFilesClick}>Add Files</MenuItem>
496
+ <MenuItem style={{fontSize: '14px'}} onClick={onAddLinksClick}>Add Links</MenuItem>
497
+ </Menu>
498
+ </div>
499
+ </div>
500
+ {list.data.length > 0 && (<div style={{marginTop: '1rem'}}>
501
+ <SummaryList arItems$={list.data}></SummaryList>
502
+ </div>)}
503
+ {list.count > 3 && (<div className="psdk-utility-view-all">
504
+ <Button style={{textTransform: 'none'}} color="primary" onClick = {() => setViewAll(true)}>View all</Button>
505
+ </div>)}
506
+ {fileData.showfileModal && (
507
+ <div className="psdk-dialog-background">
508
+ <div className="psdk-modal-file-top">
509
+ <h3>Add local files</h3>
510
+ <div className="psdk-modal-body">
511
+ <div className="psdk-modal-file-selector">
512
+ <label htmlFor='upload-files'>
513
+ <input style={{ display: 'none' }} id='upload-files' name='upload-files' type='file' multiple onChange={uploadMyFiles}/>
514
+ <Button variant='outlined' color='primary' component="span">Upload file(s)</Button>
515
+ </label>
516
+ </div>
517
+ {fileData.fileList.length > 0 && (<div style={{marginTop: '1rem'}}>
518
+ <SummaryList menuIconOverride$='trash' arItems$={fileData.fileList} menuIconOverrideAction$={removeFileFromList}></SummaryList>
519
+ </div>)}
520
+ {fileData.fileList.length === 0 && (<div></div>)}
521
+ <ActionButtonsForFileUtil arMainButtons={fileData.fileMainButtons} arSecondaryButtons={fileData.fileSecondaryButtons}
522
+ primaryAction={onAttachFiles} secondaryAction={closeFilePopup}></ActionButtonsForFileUtil>
523
+ </div>
524
+ </div>
525
+ </div>
526
+ )}
527
+ {linkData.showLinkModal && (
528
+ <div className="psdk-dialog-background">
529
+ <div className="psdk-modal-file-top">
530
+ <h3>Add links</h3>
531
+ <div className="psdk-modal-body">
532
+ <div className="psdk-modal-links-row">
533
+ <div className="psdk-links-two-column">
534
+ <div className="psdk-modal-link-data">
535
+ <TextField fullWidth variant="outlined" label="Link title" size="small" required={required} value={link.title} onChange={fieldlinkOnChange}/>
536
+ </div>
537
+ <div className="psdk-modal-link-data">
538
+ <TextField fullWidth variant="outlined" label="URL" size="small" required={required} value={link.url} onChange={fieldurlOnChange}/>
539
+ </div>
540
+ </div>
541
+ <div className="psdk-modal-link-add">
542
+ <Button className="psdk-add-link-action" color="primary" variant="contained" component="span" onClick={addLink} disabled={link.disable}>Add Link</Button>
543
+ </div>
544
+ </div>
545
+ {linkData.linksList.length > 0 && (<div style={{marginTop: '1rem'}}>
546
+ <SummaryList menuIconOverride$='trash' arItems$={linkData.linksList} menuIconOverrideAction$={removeLinksFromList}></SummaryList>
547
+ </div>)}
548
+ <ActionButtonsForFileUtil arMainButtons={linkData.linkMainButtons} arSecondaryButtons={linkData.linkSecondaryButtons}
549
+ primaryAction={onAttachLinks} secondaryAction={closeAddLinksPopup}></ActionButtonsForFileUtil>
550
+ </div>
551
+ </div>
552
+ </div>
553
+ )}
554
+ {showViewAllModal && (<div className="psdk-dialog-background">
555
+ <div className="psdk-modal-file-top">
556
+ <div className="psdk-view-all-header">
557
+ <h3>Attachments</h3>
558
+ {/* eslint-disable-next-line jsx-a11y/control-has-associated-label */}
559
+ <button type="button" className="psdk-close-button" onClick = {() => setViewAll(false)}><img className="psdk-utility-card-actions-svg-icon" src={closeSvgIcon}></img></button>
560
+ </div>
561
+ <div className="psdk-view-all-body"><SummaryList arItems$={vaItems}></SummaryList></div>
562
+ </div>
563
+ </div>)}
564
+ </div>
565
+
566
+ )
567
+ }
File without changes