@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,268 @@
1
+ // Helper singleton class to assist with loading and accessing
2
+ // the SDK Config JSON
3
+ import {sdkGetAuthHeader} from './authManager';
4
+ import Utils from './utils';
5
+
6
+ // Create a singleton for this class (with async loading of config file) and export it
7
+ // Note: Initialzing SdkConfigAccess to null seems to cause lots of compile issues with references
8
+ // within other components and the value potentially being null (so try to leave it undefined)
9
+ let SdkConfigAccess;
10
+ let SdkConfigAccessCreateInProgress = false;
11
+
12
+
13
+ class ConfigAccess {
14
+
15
+ constructor() {
16
+ // sdkConfig is the JSON object read from the sdk-config.json file
17
+ this.sdkConfig = {};
18
+ // isConfigLoaded will be updated to true after the async load is complete
19
+ this.isConfigLoaded = false;
20
+
21
+ // The "work" to load the config file is done (asynchronously) via the initialize
22
+ // (Factory function) below)
23
+ }
24
+
25
+ /**
26
+ * Asynchronous initialization of the config file contents.
27
+ * @returns Promise of config file fetch
28
+ */
29
+ async readSdkConfig() {
30
+ if(Utils.isEmptyObject(this.sdkConfig)) {
31
+ return fetch("./sdk-config.json")
32
+ .then ( (response) => {
33
+ if( response.ok ) {
34
+ return response.json();
35
+ } else {
36
+ throw new Error(`Failed with status:${response.status}`);
37
+ }
38
+ })
39
+ .then ( (data) => {
40
+ this.sdkConfig = data;
41
+ this.fixupConfigSettings();
42
+ return Promise.resolve(this.sdkConfig);
43
+ }).catch(err => {
44
+ console.error("Fetch for sdk-config.js failed.");
45
+ console.error(err);
46
+ return Promise.reject(err);
47
+ });
48
+ } else {
49
+ return Promise.resolve(this.sdkConfig);
50
+ }
51
+ }
52
+
53
+ // Adjust any settings like setting up defaults or making sure URIs have a trailing slash
54
+ fixupConfigSettings() {
55
+ const oServerConfig = this.sdkConfig["serverConfig"];
56
+ // If not present, then use current root path
57
+ oServerConfig.sdkContentServerUrl = oServerConfig.sdkContentServerUrl || window.location.origin;
58
+ // Needs a trailing slash so add one if not there
59
+ if( !oServerConfig.sdkContentServerUrl.endsWith('/') ) {
60
+ oServerConfig.sdkContentServerUrl = `${oServerConfig.sdkContentServerUrl}/`;
61
+ }
62
+ console.log(`Using sdkContentServerUrl: ${this.sdkConfig["serverConfig"].sdkContentServerUrl}`);
63
+
64
+ // Don't want a trailing slash for infinityRestServerUrl
65
+ if( oServerConfig.infinityRestServerUrl.endsWith('/') ) {
66
+ oServerConfig.infinityRestServerUrl = oServerConfig.infinityRestServerUrl.slice(0, -1)
67
+ }
68
+
69
+ // Specify our own internal list of well known portals to exclude (if one not specified)
70
+ if( !oServerConfig.excludePortals ) {
71
+ oServerConfig.excludePortals = ["pxExpress", "Developer", "pxPredictionStudio", "pxAdminStudio", "pyCaseWorker", "pyCaseManager7"];
72
+ console.warn(`No exludePortals entry found within serverConfig section of sdk-config.json. Using the following default list: ["pxExpress", "Developer", "pxPredictionStudio", "pxAdminStudio", "pyCaseWorker", "pyCaseManager7"]`);
73
+ }
74
+ }
75
+
76
+ /**
77
+ *
78
+ * @returns the sdk-config JSON object
79
+ */
80
+ getSdkConfig = async () => {
81
+ if(Utils.isEmptyObject(this.sdkConfig)) {
82
+ await getSdkConfig();
83
+ }
84
+ return this.sdkConfig;
85
+ }
86
+
87
+
88
+ /**
89
+ *
90
+ * @returns the authConfig block in the SDK Config object
91
+ */
92
+ getSdkConfigAuth = () => {
93
+ if(Utils.isEmptyObject(this.sdkConfig)) {
94
+ const config = this.getSdkConfig();
95
+ }
96
+ return this.sdkConfig["authConfig"];
97
+ }
98
+
99
+ /**
100
+ *
101
+ * @returns the serverConfig bloc from the sdk-config.json file
102
+ */
103
+ getSdkConfigServer = () => {
104
+ if(Utils.isEmptyObject(this.sdkConfig)) {
105
+ const config = this.getSdkConfig();
106
+ }
107
+ return this.sdkConfig["serverConfig"];
108
+ }
109
+
110
+
111
+ /**
112
+ * @param {String} key the key to be inserted/updated in serverConfig
113
+ * @param {String} value the value to be assigned to the given key
114
+ */
115
+ setSdkConfigServer = (key, value) => {
116
+
117
+ this.sdkConfig.serverConfig[key] = value;
118
+
119
+ }
120
+
121
+ /**
122
+ * If this.sdkConfig.serverConfig.appPortal is set, leave it and the specified portal will be used.
123
+ * If not set, set this.sdkConfig.serverConfig.appPortal to default portal of currently logged in user
124
+ */
125
+ async selectPortal() {
126
+
127
+ if(Utils.isEmptyObject(this.sdkConfig)) {
128
+ await getSdkConfig();
129
+ }
130
+
131
+ const serverConfig = this.sdkConfig.serverConfig;
132
+
133
+ if ((serverConfig.appPortal !== "") &&
134
+ (serverConfig.appPortal !== undefined) ) {
135
+ // use the specified portal
136
+ console.log(`Using appPortal: ${serverConfig.appPortal}`);
137
+ return;
138
+ }
139
+
140
+ const userAccessGroup = PCore.getEnvironmentInfo().getAccessGroup();
141
+ const dataPageName = "D_OperatorAccessGroups";
142
+ const serverUrl = serverConfig.infinityRestServerUrl;
143
+ const appAlias = serverConfig.appAlias;
144
+ const appAliasPath = appAlias ? `/app/${appAlias}` : '';
145
+ const arExcludedPortals = serverConfig["excludePortals"];
146
+
147
+ // Using v1 API here as v2 data_views is not able to access same data page currently. Should move to avoid having this logic to find
148
+ // a default portal or constellation portal and rather have Constellation JS Engine API just load the default portal
149
+ await fetch ( `${serverUrl}${appAliasPath}/api/v1/data/${dataPageName}`,
150
+ {
151
+ method: 'GET',
152
+ headers: {
153
+ 'Content-Type' : 'application/json',
154
+ 'Authorization' : sdkGetAuthHeader()
155
+ }
156
+ })
157
+ .then( response => {
158
+ if( response.ok && response.status === 200) {
159
+ return response.json();
160
+ } else {
161
+ if( response.status === 401 ) {
162
+ // Might be either a real token expiration or revoke, but more likely that the "api" service package is misconfigured
163
+ throw( new Error(`Attempt to access ${dataPageName} failed. The "api" service package is likely not configured to use "OAuth 2.0"`));
164
+ };
165
+ throw( new Error(`HTTP Error: ${response.status}`));
166
+ }
167
+ })
168
+ .then( async (agData) => {
169
+
170
+ let arAccessGroups = agData.pxResults;
171
+ let selectedPortal = null;
172
+
173
+ for (let ag of arAccessGroups) {
174
+ if (ag.pyAccessGroup === userAccessGroup) {
175
+ // Check if default portal works
176
+ if( !arExcludedPortals.includes(ag.pyPortal) ) {
177
+ selectedPortal = ag.pyPortal;
178
+ } else {
179
+ console.error(`Default portal for current operator (${ag.pyPortal}) is not compatible with SDK.\nConsider using a different operator, adjusting the default portal for this operator, or using "appPortal" setting within sdk-config.json to specify a specific portal to load.`);
180
+ // Find first portal that is not excluded (might work)
181
+ for (let portal of ag.pyUserPortals ) {
182
+ if( !arExcludedPortals.includes(portal.pyPortalLayout) ) {
183
+ selectedPortal = portal.pyPortalLayout;
184
+ break;
185
+ }
186
+ }
187
+ }
188
+ break;
189
+ }
190
+ }
191
+ if( selectedPortal ) {
192
+ // Found operator's current access group. Use its portal
193
+ this.setSdkConfigServer("appPortal", selectedPortal);
194
+ console.log(`Using non-excluded portal: ${serverConfig.appPortal}`);
195
+ }
196
+ })
197
+ .catch( e => {
198
+ console.error(e.message);
199
+ // check specific error if 401, and wiped out if so stored token is stale. Fetch new tokens.
200
+ });
201
+
202
+ }
203
+
204
+ /**
205
+ * Path to the BootstrapCSS
206
+ * @returns the locBootstrapCSS from the serverConfig block of the sdk-config.json file
207
+ */
208
+ getSdkConfigBootstrapCSS = () => {
209
+ const serverConfig = this.getSdkConfigServer();
210
+ const locBootstrapCSS = serverConfig.locBootstrapCSS;
211
+ if (locBootstrapCSS === undefined) {
212
+ console.error(`locBootstrapCSS: ${locBootstrapCSS}`);
213
+ }
214
+ return locBootstrapCSS;
215
+ }
216
+
217
+ }
218
+
219
+
220
+ // Implement Factory function to allow async load
221
+ // See https://stackoverflow.com/questions/49905178/asynchronous-operations-in-constructor/49906064#49906064 for inspiration
222
+ async function createSdkConfigAccess() {
223
+ // Note that our initialize function returns a promise...
224
+ let singleton = new ConfigAccess();
225
+ await singleton.readSdkConfig();
226
+ return singleton;
227
+ };
228
+
229
+ // Initialize exported SdkConfigAccess structure
230
+ async function getSdkConfig() {
231
+ return new Promise( (resolve) => {
232
+ let idNextCheck = null;
233
+ if( !SdkConfigAccess && !SdkConfigAccessCreateInProgress ) {
234
+ SdkConfigAccessCreateInProgress = true;
235
+ createSdkConfigAccess().then( theConfigAccess => {
236
+ // Key initialization of SdkConfigAccess
237
+ SdkConfigAccess = theConfigAccess;
238
+ SdkConfigAccessCreateInProgress = false;
239
+ // console.log(`SdkConfigAccess: ${JSON.stringify(SdkConfigAccess)}`);
240
+ // Create and dispatch the SdkConfigAccessReady event
241
+ const event = new CustomEvent("SdkConfigAccessReady", { });
242
+ document.dispatchEvent(event);
243
+ return resolve( SdkConfigAccess.sdkConfig );
244
+ });
245
+ } else {
246
+ const fnCheckForConfig = () => {
247
+ if( SdkConfigAccess ) {
248
+ if( idNextCheck ) {
249
+ clearInterval(idNextCheck);
250
+ }
251
+ return resolve( SdkConfigAccess.sdkConfig );
252
+ }
253
+ idNextCheck = setInterval(fnCheckForConfig, 500);
254
+ };
255
+ if( SdkConfigAccess ) {
256
+ return resolve( SdkConfigAccess.sdkConfig );
257
+ } else {
258
+ idNextCheck = setInterval(fnCheckForConfig, 500);
259
+ }
260
+ }
261
+ });
262
+ }
263
+
264
+ if( true ) {
265
+ let ignore = getSdkConfig();
266
+ }
267
+
268
+ export {SdkConfigAccess, getSdkConfig};
@@ -0,0 +1,24 @@
1
+ declare const PCore;
2
+
3
+ // eslint-disable-next-line import/prefer-default-export
4
+ export const getDataPage = (dataPageName, parameters, context) => {
5
+ let dataViewParams;
6
+ if(parameters){
7
+ dataViewParams = {
8
+ 'dataViewParameters': parameters
9
+ };
10
+ }
11
+ return new Promise((resolve, reject) => {
12
+ PCore.getDataApiUtils()
13
+ .getData(dataPageName, dataViewParams, context)
14
+ .then(response => {
15
+ resolve(response.data.data);
16
+ })
17
+ .catch(e => {
18
+ if (e) {
19
+ // check specific error if 401, and wiped out if so stored token is stale. Fetcch new tokens.
20
+ reject(e);
21
+ }
22
+ });
23
+ });
24
+ };
@@ -0,0 +1,20 @@
1
+ // From npm-nebula/src/utils/event-utils.js
2
+
3
+ const handleEvent = (actions, eventType, propName, value) => {
4
+ switch (eventType) {
5
+ case "change":
6
+ actions.updateFieldValue(propName, value);
7
+ break;
8
+ case "blur":
9
+ actions.triggerFieldChange(propName, value);
10
+ break;
11
+ case "changeNblur":
12
+ actions.updateFieldValue(propName, value);
13
+ actions.triggerFieldChange(propName, value);
14
+ break;
15
+ default:
16
+ break;
17
+ }
18
+ };
19
+
20
+ export default handleEvent;
@@ -0,0 +1,61 @@
1
+ import { createElement } from 'react';
2
+
3
+ import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
4
+
5
+ /**
6
+ *
7
+ * @param {*} pConn - pConnect object of the view
8
+ * @returns {string} - returns the name of referenceList
9
+ */
10
+
11
+ export const getReferenceList = pConn => {
12
+ let resolvePage = pConn.getComponentConfig().referenceList.replace('@P ', '');
13
+ if (resolvePage.includes('D_')) {
14
+ resolvePage = pConn.resolveDatasourceReference(resolvePage);
15
+ if (resolvePage?.pxResults) {
16
+ resolvePage = resolvePage?.pxResults;
17
+ } else if (resolvePage.startsWith('D_') && !resolvePage.endsWith('.pxResults')) {
18
+ resolvePage = `${resolvePage}.pxResults`;
19
+ }
20
+ } else {
21
+ resolvePage = `${pConn.getPageReference().replace('caseInfo.content', '')}${resolvePage}`;
22
+ }
23
+ return resolvePage;
24
+ };
25
+
26
+ /**
27
+ * creates and returns react element of the view
28
+ * @param {*} pConn - pConnect object of the view
29
+ * @param {*} index - index of the fieldGroup item
30
+ * @param {*} viewConfigPath - boolean value to check for children in config
31
+ * @returns {*} - return the react element of the view
32
+ */
33
+ export const buildView = (pConn, index, viewConfigPath) => {
34
+ const context = pConn.getContextName();
35
+ const referenceList = getReferenceList(pConn);
36
+
37
+ const isDatapage = referenceList.startsWith('D_');
38
+ const pageReference = isDatapage
39
+ ? `${referenceList}[${index}]`
40
+ : `${pConn.getPageReference()}${referenceList.substring(
41
+ referenceList.lastIndexOf('.')
42
+ )}[${index}]`;
43
+ const meta = viewConfigPath
44
+ ? pConn.getRawMetadata().children[0].children[0]
45
+ : pConn.getRawMetadata().children[0];
46
+ const config = {
47
+ meta,
48
+ options: {
49
+ context,
50
+ pageReference,
51
+ referenceList,
52
+ hasForm: true
53
+ }
54
+ };
55
+ // eslint-disable-next-line no-undef
56
+ const view = PCore.createPConnect(config);
57
+ if (pConn.getConfigProps()?.displayMode === 'LABELS_LEFT') {
58
+ view.getPConnect()?.setInheritedProp('displayMode', 'LABELS_LEFT');
59
+ }
60
+ return createElement(createPConnectComponent(), view);
61
+ };
@@ -0,0 +1,38 @@
1
+ function Boolean(value, { allowEmpty = true, tick = "", cross = "" } = {}) {
2
+ if (
3
+ (!allowEmpty && !value) ||
4
+ value === false ||
5
+ value?.toString()?.toLowerCase() === "false" ||
6
+ value === 0 ||
7
+ value === "0"
8
+ ) {
9
+ return cross || "";
10
+ }
11
+ if (
12
+ value === true ||
13
+ value?.toString()?.toLowerCase() === "true" ||
14
+ value === 1 ||
15
+ value === "1"
16
+ ) {
17
+ return tick || "";
18
+ }
19
+ if (
20
+ allowEmpty &&
21
+ (value === "null" ||
22
+ value === "" ||
23
+ value === null ||
24
+ typeof value === "undefined")
25
+ ) {
26
+ return "- -";
27
+ }
28
+ return value;
29
+ }
30
+
31
+ export default {
32
+ TrueFalse: (value, options) =>
33
+ Boolean(value, {
34
+ ...options,
35
+ tick: "True",
36
+ cross: "False"
37
+ })
38
+ };
@@ -0,0 +1,74 @@
1
+ import { getLocale } from "./common";
2
+ import CurrencyMap from "./CurrencyMap";
3
+
4
+ function NumberFormatter(value, { locale, decPlaces = 2 } = {}) {
5
+ const currentLocale = getLocale(locale);
6
+ if (value !== null && value !== undefined) {
7
+ return Number(value).toLocaleString(currentLocale, {
8
+ minimumFractionDigits: decPlaces,
9
+ maximumFractionDigits: decPlaces
10
+ });
11
+ }
12
+ return value;
13
+ }
14
+
15
+ function CurrencyFormatter(
16
+ value,
17
+ { symbol = true, position, locale, decPlaces = 2 } = {}
18
+ ) {
19
+ const currentLocale = getLocale(locale);
20
+ let formattedValue = value;
21
+ if (value !== null && value !== undefined) {
22
+ formattedValue = NumberFormatter(value, {
23
+ locale: currentLocale,
24
+ decPlaces
25
+ });
26
+ const countryCode = currentLocale.split("-")[1];
27
+
28
+ let code;
29
+ if (symbol) {
30
+ code = CurrencyMap[countryCode]?.symbolFormat;
31
+ } else {
32
+ code = CurrencyMap[countryCode]?.currencyCode;
33
+ }
34
+
35
+ // if position is provided, change placeholder accordingly.
36
+ if (position) {
37
+ if (position.toLowerCase() === "before" && code.indexOf("{#}") === 0) {
38
+ code = code.slice(3) + code.slice(0, 3);
39
+ } else if (
40
+ position.toLowerCase() === "after" &&
41
+ code.indexOf("{#}") === code.length - 3
42
+ ) {
43
+ code = code.slice(-3) + code.slice(0, -3);
44
+ }
45
+ }
46
+ return code?.replace("{#}", formattedValue) || formattedValue;
47
+ }
48
+ return formattedValue;
49
+ }
50
+
51
+ function SymbolFormatter(value, { symbol, suffix = true, locale } = {}) {
52
+ let formattedValue = value;
53
+ if (value !== null && value !== undefined) {
54
+ formattedValue = NumberFormatter(value, { locale });
55
+ return suffix ? `${formattedValue}${symbol}` : `${symbol}${formattedValue}`;
56
+ }
57
+ return formattedValue;
58
+ }
59
+
60
+ export default {
61
+ Currency: (value, options) => CurrencyFormatter(value, options),
62
+ "Currency-Code": (value, options) =>
63
+ CurrencyFormatter(value, { ...options, symbol: false }),
64
+ Decimal: (value, options) => NumberFormatter(value, options),
65
+ "Decimal-Auto": (value, options) =>
66
+ NumberFormatter(value, {
67
+ ...options,
68
+ decPlaces: Number.isInteger(value) ? 0 : 2
69
+ }),
70
+ Integer: (value, options) =>
71
+ NumberFormatter(value, { ...options, decPlaces: 0 }),
72
+ Percentage: (value, options) =>
73
+ SymbolFormatter(value, { ...options, symbol: "%" })
74
+ };