@pega/react-sdk-overrides 0.23.25 → 8.8.20
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.
- package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +47 -0
- package/lib/designSystemExtension/AlertBanner/index.tsx +1 -0
- package/lib/designSystemExtension/Banner/Banner.css +4 -0
- package/lib/designSystemExtension/Banner/Banner.tsx +25 -11
- package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +15 -10
- package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +10 -11
- package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +10 -3
- package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +11 -5
- package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +11 -3
- package/lib/designSystemExtension/Operator/Operator.tsx +30 -21
- package/lib/designSystemExtension/Pulse/Pulse.tsx +11 -7
- package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +121 -0
- package/lib/designSystemExtension/RichTextEditor/index.tsx +1 -0
- package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.css +6 -2
- package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +12 -3
- package/lib/field/AutoComplete/AutoComplete.tsx +37 -18
- package/lib/field/CancelAlert/CancelAlert.tsx +21 -12
- package/lib/field/Checkbox/Checkbox.tsx +41 -17
- package/lib/field/Currency/Currency.tsx +23 -15
- package/lib/field/Currency/currency-utils.ts +1 -2
- package/lib/field/Date/Date.tsx +31 -17
- package/lib/field/DateTime/DateTime.tsx +26 -15
- package/lib/field/Decimal/Decimal.tsx +82 -19
- package/lib/field/Dropdown/Dropdown.tsx +57 -14
- package/lib/field/Email/Email.tsx +17 -9
- package/lib/field/Integer/Integer.tsx +15 -7
- package/lib/field/Percentage/Percentage.tsx +15 -7
- package/lib/field/Phone/Phone.tsx +21 -12
- package/lib/field/RadioButtons/RadioButtons.tsx +54 -27
- package/lib/field/RichText/RichText.tsx +93 -0
- package/lib/field/RichText/index.tsx +1 -0
- package/lib/field/ScalarList/ScalarList.tsx +64 -0
- package/lib/field/ScalarList/config-ext.json +8 -0
- package/lib/field/ScalarList/index.tsx +1 -0
- package/lib/field/SemanticLink/SemanticLink.tsx +26 -25
- package/lib/field/SemanticLink/utils.ts +2 -1
- package/lib/field/TextArea/TextArea.tsx +14 -5
- package/lib/field/TextContent/TextContent.tsx +10 -1
- package/lib/field/TextInput/TextInput.tsx +40 -11
- package/lib/field/Time/Time.tsx +29 -26
- package/lib/field/URL/URL.tsx +24 -8
- package/lib/field/UserReference/UserReference.tsx +52 -60
- package/lib/helpers/{attachmentHelpers.js → attachmentHelpers.ts} +5 -5
- package/lib/helpers/auth.js +741 -390
- package/lib/helpers/authManager.ts +933 -0
- package/lib/helpers/case-utils.tsx +103 -0
- package/lib/helpers/common-utils.ts +4 -0
- package/lib/helpers/config_access.js +63 -145
- package/lib/helpers/data_page.ts +2 -1
- package/lib/helpers/date-format-utils.ts +29 -19
- package/lib/helpers/{event-utils.js → event-utils.ts} +1 -1
- package/lib/helpers/{field-group-utils.js → field-group-utils.ts} +4 -3
- package/lib/helpers/formatters/{Currency.js → Currency.ts} +13 -12
- package/lib/helpers/formatters/{CurrencyMap.js → CurrencyMap.ts} +8 -5
- package/lib/helpers/formatters/{Date.js → Date.ts} +2 -2
- package/lib/helpers/formatters/{common.js → common.ts} +4 -4
- package/lib/helpers/formatters/{index.js → index.ts} +3 -3
- package/lib/helpers/simpleTableHelpers.ts +10 -6
- package/lib/helpers/state-utils.tsx +47 -0
- package/lib/helpers/template-utils.ts +3 -4
- package/lib/helpers/utils.ts +12 -4
- package/lib/helpers/versionHelpers.ts +0 -1
- package/lib/infra/ActionButtons/ActionButtons.tsx +13 -18
- package/lib/infra/Assignment/Assignment.tsx +38 -32
- package/lib/infra/AssignmentCard/AssignmentCard.tsx +15 -19
- package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +76 -64
- package/lib/infra/Containers/FlowContainer/{helpers.js → helpers.ts} +18 -16
- package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +41 -27
- package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +19 -28
- package/lib/infra/DashboardFilter/DashboardFilter.tsx +16 -20
- package/lib/infra/DashboardFilter/filterUtils.tsx +3 -1
- package/lib/infra/DeferLoad/DeferLoad.tsx +16 -19
- package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +20 -19
- package/lib/infra/MultiStep/MultiStep.tsx +24 -24
- package/lib/infra/NavBar/NavBar.tsx +23 -24
- package/lib/infra/Reference/Reference.tsx +13 -18
- package/lib/infra/Region/Region.tsx +8 -6
- package/lib/infra/RootContainer/RootContainer.tsx +32 -39
- package/lib/infra/Stages/Stages.tsx +15 -9
- package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +8 -1
- package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +12 -12
- package/lib/infra/View/View.tsx +30 -58
- package/lib/template/AppShell/AppShell.tsx +51 -34
- package/lib/template/BannerPage/BannerPage.tsx +26 -31
- package/lib/template/CaseSummary/CaseSummary.tsx +15 -8
- package/lib/template/CaseView/CaseView.tsx +137 -100
- package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +27 -27
- package/lib/template/Confirmation/Confirmation.tsx +29 -52
- package/lib/template/DataReference/DataReference.tsx +50 -52
- package/lib/template/DefaultForm/DefaultForm.tsx +29 -20
- package/lib/template/DefaultForm/utils/index.ts +33 -0
- package/lib/template/Details/Details/Details.tsx +16 -17
- package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +13 -16
- package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +19 -18
- package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +20 -18
- package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +24 -27
- package/lib/template/InlineDashboard/InlineDashboard.tsx +11 -7
- package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +19 -17
- package/lib/template/ListPage/ListPage.tsx +14 -13
- package/lib/template/ListView/ListView.tsx +140 -152
- package/lib/template/ListView/{hooks.js → hooks.ts} +3 -1
- package/lib/template/ListView/{utils.js → utils.ts} +172 -23
- package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +12 -17
- package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +16 -1
- package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +19 -18
- package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +9 -1
- package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +17 -17
- package/lib/template/OneColumn/OneColumn/OneColumn.tsx +8 -7
- package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +10 -10
- package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +5 -7
- package/lib/template/PromotedFilters/PromotedFilters.tsx +23 -17
- package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +103 -6
- package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +28 -7
- package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +26 -31
- package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +34 -36
- package/lib/template/SubTabs/SubTabs.tsx +10 -11
- package/lib/template/SubTabs/tabUtils.ts +0 -2
- package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +10 -15
- package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +10 -10
- package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +10 -12
- package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +17 -3
- package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +35 -25
- package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +7 -1
- package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +15 -17
- package/lib/template/WssNavBar/WssNavBar.tsx +36 -14
- package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +13 -21
- package/lib/widget/Attachment/Attachment.css +15 -3
- package/lib/widget/Attachment/Attachment.tsx +51 -32
- package/lib/widget/CaseHistory/CaseHistory.tsx +13 -11
- package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +13 -1
- package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +40 -26
- package/lib/widget/Followers/Followers.tsx +10 -11
- package/lib/widget/QuickCreate/QuickCreate.tsx +15 -6
- package/lib/widget/SummaryItem/SummaryItem.tsx +12 -4
- package/lib/widget/SummaryList/SummaryList.tsx +17 -3
- package/lib/widget/ToDo/ToDo.tsx +69 -104
- package/package.json +1 -1
- package/lib/helpers/authManager.js +0 -631
- /package/lib/helpers/formatters/{Boolean.js → Boolean.ts} +0 -0
- /package/lib/helpers/{reactContextHelpers.js → reactContextHelpers.ts} +0 -0
- /package/lib/template/ListView/{DefaultViewMeta.js → DefaultViewMeta.ts} +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
|
|
3
|
+
|
|
4
|
+
// Remove this and use "real" PCore type once .d.ts is fixed (currently shows 1 error)
|
|
5
|
+
declare const PCore: any;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Function that accepts array of messages as input and group them by their type and returns the resulting object
|
|
9
|
+
* @param {Array} inputMessages
|
|
10
|
+
* Eg: [
|
|
11
|
+
* {message: 'First Name is required', type: 'error'},
|
|
12
|
+
* {message: 'Last Name is required', type: 'error'},
|
|
13
|
+
* {message: 'Address field should be clear and precise', type: 'info'}
|
|
14
|
+
* ]
|
|
15
|
+
*
|
|
16
|
+
* @returns {object}
|
|
17
|
+
*
|
|
18
|
+
* Eg: {
|
|
19
|
+
* error: ['First Name is required', 'Last Name is required'],
|
|
20
|
+
* info: ['Address field should be clear and precise']
|
|
21
|
+
* }
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
function getMessagesGrouped(inputMessages) {
|
|
25
|
+
const messages = {};
|
|
26
|
+
|
|
27
|
+
if (inputMessages && inputMessages instanceof Array && inputMessages.length > 0) {
|
|
28
|
+
inputMessages.forEach((item) => {
|
|
29
|
+
const { message, type } = item;
|
|
30
|
+
messages[type] = [...(messages[type] || []), message];
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return messages;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Function accepts a error type and variant of the banner
|
|
38
|
+
* @param {string} type
|
|
39
|
+
* Eg: 'error'
|
|
40
|
+
* @returns {string}
|
|
41
|
+
* Eg: 'urgent'
|
|
42
|
+
*/
|
|
43
|
+
function getVariant(type) {
|
|
44
|
+
const { BANNER_VARIANT_SUCCESS, BANNER_VARIANT_INFO, BANNER_VARIANT_URGENT, MESSAGES } = PCore.getConstants();
|
|
45
|
+
const { MESSAGES_TYPE_ERROR, MESSAGES_TYPE_INFO, MESSAGES_TYPE_SUCCESS } = MESSAGES;
|
|
46
|
+
|
|
47
|
+
let variant;
|
|
48
|
+
switch (type) {
|
|
49
|
+
case MESSAGES_TYPE_ERROR:
|
|
50
|
+
variant = BANNER_VARIANT_URGENT;
|
|
51
|
+
break;
|
|
52
|
+
case MESSAGES_TYPE_INFO:
|
|
53
|
+
variant = BANNER_VARIANT_INFO;
|
|
54
|
+
break;
|
|
55
|
+
case MESSAGES_TYPE_SUCCESS:
|
|
56
|
+
variant = BANNER_VARIANT_SUCCESS;
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
variant = '';
|
|
60
|
+
}
|
|
61
|
+
return variant;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getBanners(config) {
|
|
65
|
+
const AlertBanner = getComponentFromMap('AlertBanner');
|
|
66
|
+
const { target, pageMessages, httpMessages } = config;
|
|
67
|
+
const { PAGE } = PCore.getConstants();
|
|
68
|
+
const { clearMessages } = PCore.getMessageManager();
|
|
69
|
+
const banners: any = [];
|
|
70
|
+
const groupedPageMessages = getMessagesGrouped(pageMessages);
|
|
71
|
+
|
|
72
|
+
Object.keys(groupedPageMessages).forEach((type) => {
|
|
73
|
+
const messagesByType = groupedPageMessages[type];
|
|
74
|
+
const variant = getVariant(type);
|
|
75
|
+
const pageMessagesBannerID = `${target}_${PAGE}_${type}`.toLowerCase().replace('/', '_');
|
|
76
|
+
banners.push(
|
|
77
|
+
<AlertBanner
|
|
78
|
+
id={pageMessagesBannerID}
|
|
79
|
+
variant={variant}
|
|
80
|
+
messages={messagesByType}
|
|
81
|
+
onDismiss={
|
|
82
|
+
variant === 'urgent'
|
|
83
|
+
? ''
|
|
84
|
+
: () => {
|
|
85
|
+
clearMessages({
|
|
86
|
+
category: PAGE,
|
|
87
|
+
type,
|
|
88
|
+
context: target
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
if (httpMessages && httpMessages.length > 0) {
|
|
97
|
+
banners.push(<AlertBanner id="modalViewContainerBanner" variant="urgent" messages={httpMessages} />);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return banners;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export { getMessagesGrouped, getBanners };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
// Helper singleton class to assist with loading and accessing
|
|
2
2
|
// the SDK Config JSON
|
|
3
|
-
import {
|
|
4
|
-
import Utils from './utils';
|
|
3
|
+
import { isEmptyObject } from './common-utils';
|
|
5
4
|
|
|
6
5
|
// Create a singleton for this class (with async loading of config file) and export it
|
|
7
6
|
// Note: Initialzing SdkConfigAccess to null seems to cause lots of compile issues with references
|
|
@@ -9,9 +8,7 @@ import Utils from './utils';
|
|
|
9
8
|
let SdkConfigAccess;
|
|
10
9
|
let SdkConfigAccessCreateInProgress = false;
|
|
11
10
|
|
|
12
|
-
|
|
13
11
|
class ConfigAccess {
|
|
14
|
-
|
|
15
12
|
constructor() {
|
|
16
13
|
// sdkConfig is the JSON object read from the sdk-config.json file
|
|
17
14
|
this.sdkConfig = {};
|
|
@@ -27,23 +24,24 @@ class ConfigAccess {
|
|
|
27
24
|
* @returns Promise of config file fetch
|
|
28
25
|
*/
|
|
29
26
|
async readSdkConfig() {
|
|
30
|
-
if(
|
|
31
|
-
return
|
|
32
|
-
.then
|
|
33
|
-
if(
|
|
27
|
+
if (isEmptyObject(this.sdkConfig)) {
|
|
28
|
+
return fetch('./sdk-config.json')
|
|
29
|
+
.then(response => {
|
|
30
|
+
if (response.ok) {
|
|
34
31
|
return response.json();
|
|
35
32
|
} else {
|
|
36
33
|
throw new Error(`Failed with status:${response.status}`);
|
|
37
34
|
}
|
|
38
35
|
})
|
|
39
|
-
.then
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
.then(data => {
|
|
37
|
+
this.sdkConfig = data;
|
|
38
|
+
this.fixupConfigSettings();
|
|
39
|
+
return Promise.resolve(this.sdkConfig);
|
|
40
|
+
})
|
|
41
|
+
.catch(err => {
|
|
42
|
+
console.error('Fetch for sdk-config.js failed.');
|
|
43
|
+
console.error(err);
|
|
44
|
+
return Promise.reject(err);
|
|
47
45
|
});
|
|
48
46
|
} else {
|
|
49
47
|
return Promise.resolve(this.sdkConfig);
|
|
@@ -52,24 +50,33 @@ class ConfigAccess {
|
|
|
52
50
|
|
|
53
51
|
// Adjust any settings like setting up defaults or making sure URIs have a trailing slash
|
|
54
52
|
fixupConfigSettings() {
|
|
55
|
-
const oServerConfig = this.sdkConfig[
|
|
53
|
+
const oServerConfig = this.sdkConfig['serverConfig'];
|
|
56
54
|
// If not present, then use current root path
|
|
57
55
|
oServerConfig.sdkContentServerUrl = oServerConfig.sdkContentServerUrl || window.location.origin;
|
|
58
56
|
// Needs a trailing slash so add one if not there
|
|
59
|
-
if(
|
|
57
|
+
if (!oServerConfig.sdkContentServerUrl.endsWith('/')) {
|
|
60
58
|
oServerConfig.sdkContentServerUrl = `${oServerConfig.sdkContentServerUrl}/`;
|
|
61
59
|
}
|
|
62
|
-
console.log(`Using sdkContentServerUrl: ${this.sdkConfig[
|
|
60
|
+
console.log(`Using sdkContentServerUrl: ${this.sdkConfig['serverConfig'].sdkContentServerUrl}`);
|
|
63
61
|
|
|
64
62
|
// Don't want a trailing slash for infinityRestServerUrl
|
|
65
|
-
if(
|
|
66
|
-
oServerConfig.infinityRestServerUrl = oServerConfig.infinityRestServerUrl.slice(0, -1)
|
|
63
|
+
if (oServerConfig.infinityRestServerUrl.endsWith('/')) {
|
|
64
|
+
oServerConfig.infinityRestServerUrl = oServerConfig.infinityRestServerUrl.slice(0, -1);
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
// Specify our own internal list of well known portals to exclude (if one not specified)
|
|
70
|
-
if(
|
|
71
|
-
oServerConfig.excludePortals = [
|
|
72
|
-
|
|
68
|
+
if (!oServerConfig.excludePortals) {
|
|
69
|
+
oServerConfig.excludePortals = [
|
|
70
|
+
'pxExpress',
|
|
71
|
+
'Developer',
|
|
72
|
+
'pxPredictionStudio',
|
|
73
|
+
'pxAdminStudio',
|
|
74
|
+
'pyCaseWorker',
|
|
75
|
+
'pyCaseManager7'
|
|
76
|
+
];
|
|
77
|
+
console.warn(
|
|
78
|
+
`No exludePortals entry found within serverConfig section of sdk-config.json. Using the following default list: ["pxExpress", "Developer", "pxPredictionStudio", "pxAdminStudio", "pyCaseWorker", "pyCaseManager7"]`
|
|
79
|
+
);
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
|
|
@@ -78,145 +85,56 @@ class ConfigAccess {
|
|
|
78
85
|
* @returns the sdk-config JSON object
|
|
79
86
|
*/
|
|
80
87
|
getSdkConfig = async () => {
|
|
81
|
-
if(
|
|
88
|
+
if (isEmptyObject(this.sdkConfig)) {
|
|
82
89
|
await getSdkConfig();
|
|
83
90
|
}
|
|
84
91
|
return this.sdkConfig;
|
|
85
|
-
}
|
|
86
|
-
|
|
92
|
+
};
|
|
87
93
|
|
|
88
94
|
/**
|
|
89
95
|
*
|
|
90
96
|
* @returns the authConfig block in the SDK Config object
|
|
91
97
|
*/
|
|
92
98
|
getSdkConfigAuth = () => {
|
|
93
|
-
if(
|
|
99
|
+
if (isEmptyObject(this.sdkConfig)) {
|
|
94
100
|
const config = this.getSdkConfig();
|
|
95
101
|
}
|
|
96
|
-
return this.sdkConfig[
|
|
97
|
-
}
|
|
102
|
+
return this.sdkConfig['authConfig'];
|
|
103
|
+
};
|
|
98
104
|
|
|
99
105
|
/**
|
|
100
106
|
*
|
|
101
107
|
* @returns the serverConfig bloc from the sdk-config.json file
|
|
102
108
|
*/
|
|
103
109
|
getSdkConfigServer = () => {
|
|
104
|
-
if(
|
|
110
|
+
if (isEmptyObject(this.sdkConfig)) {
|
|
105
111
|
const config = this.getSdkConfig();
|
|
106
112
|
}
|
|
107
|
-
return this.sdkConfig[
|
|
108
|
-
}
|
|
109
|
-
|
|
113
|
+
return this.sdkConfig['serverConfig'];
|
|
114
|
+
};
|
|
110
115
|
|
|
111
116
|
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
* @param {String} key the key to be inserted/updated in serverConfig
|
|
118
|
+
* @param {String} value the value to be assigned to the given key
|
|
119
|
+
*/
|
|
115
120
|
setSdkConfigServer = (key, value) => {
|
|
116
|
-
|
|
117
121
|
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
|
-
}
|
|
122
|
+
};
|
|
203
123
|
|
|
204
124
|
/**
|
|
205
125
|
* Path to the BootstrapCSS
|
|
206
126
|
* @returns the locBootstrapCSS from the serverConfig block of the sdk-config.json file
|
|
207
127
|
*/
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
128
|
+
getSdkConfigBootstrapCSS = () => {
|
|
129
|
+
const serverConfig = this.getSdkConfigServer();
|
|
130
|
+
const locBootstrapCSS = serverConfig.locBootstrapCSS;
|
|
131
|
+
if (locBootstrapCSS === undefined) {
|
|
132
|
+
console.error(`locBootstrapCSS: ${locBootstrapCSS}`);
|
|
133
|
+
}
|
|
214
134
|
return locBootstrapCSS;
|
|
215
|
-
}
|
|
216
|
-
|
|
135
|
+
};
|
|
217
136
|
}
|
|
218
137
|
|
|
219
|
-
|
|
220
138
|
// Implement Factory function to allow async load
|
|
221
139
|
// See https://stackoverflow.com/questions/49905178/asynchronous-operations-in-constructor/49906064#49906064 for inspiration
|
|
222
140
|
async function createSdkConfigAccess() {
|
|
@@ -224,36 +142,36 @@ async function createSdkConfigAccess() {
|
|
|
224
142
|
let singleton = new ConfigAccess();
|
|
225
143
|
await singleton.readSdkConfig();
|
|
226
144
|
return singleton;
|
|
227
|
-
}
|
|
145
|
+
}
|
|
228
146
|
|
|
229
147
|
// Initialize exported SdkConfigAccess structure
|
|
230
148
|
async function getSdkConfig() {
|
|
231
|
-
return new Promise(
|
|
149
|
+
return new Promise(resolve => {
|
|
232
150
|
let idNextCheck = null;
|
|
233
|
-
if(
|
|
151
|
+
if (!SdkConfigAccess && !SdkConfigAccessCreateInProgress) {
|
|
234
152
|
SdkConfigAccessCreateInProgress = true;
|
|
235
|
-
createSdkConfigAccess().then(
|
|
153
|
+
createSdkConfigAccess().then(theConfigAccess => {
|
|
236
154
|
// Key initialization of SdkConfigAccess
|
|
237
155
|
SdkConfigAccess = theConfigAccess;
|
|
238
156
|
SdkConfigAccessCreateInProgress = false;
|
|
239
157
|
// console.log(`SdkConfigAccess: ${JSON.stringify(SdkConfigAccess)}`);
|
|
240
158
|
// Create and dispatch the SdkConfigAccessReady event
|
|
241
|
-
const event = new CustomEvent(
|
|
159
|
+
const event = new CustomEvent('SdkConfigAccessReady', {});
|
|
242
160
|
document.dispatchEvent(event);
|
|
243
|
-
return resolve(
|
|
161
|
+
return resolve(SdkConfigAccess.sdkConfig);
|
|
244
162
|
});
|
|
245
163
|
} else {
|
|
246
164
|
const fnCheckForConfig = () => {
|
|
247
|
-
if(
|
|
248
|
-
if(
|
|
165
|
+
if (SdkConfigAccess) {
|
|
166
|
+
if (idNextCheck) {
|
|
249
167
|
clearInterval(idNextCheck);
|
|
250
168
|
}
|
|
251
|
-
return resolve(
|
|
169
|
+
return resolve(SdkConfigAccess.sdkConfig);
|
|
252
170
|
}
|
|
253
171
|
idNextCheck = setInterval(fnCheckForConfig, 500);
|
|
254
172
|
};
|
|
255
|
-
if(
|
|
256
|
-
return resolve(
|
|
173
|
+
if (SdkConfigAccess) {
|
|
174
|
+
return resolve(SdkConfigAccess.sdkConfig);
|
|
257
175
|
} else {
|
|
258
176
|
idNextCheck = setInterval(fnCheckForConfig, 500);
|
|
259
177
|
}
|
|
@@ -261,8 +179,8 @@ async function getSdkConfig() {
|
|
|
261
179
|
});
|
|
262
180
|
}
|
|
263
181
|
|
|
264
|
-
if(
|
|
182
|
+
if (true) {
|
|
265
183
|
let ignore = getSdkConfig();
|
|
266
184
|
}
|
|
267
185
|
|
|
268
|
-
export {SdkConfigAccess, getSdkConfig};
|
|
186
|
+
export { SdkConfigAccess, getSdkConfig };
|
package/lib/helpers/data_page.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { getLocale } from './formatters/common';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
export const dateFormatInfoDefault = {
|
|
5
|
-
dateFormatString:
|
|
6
|
-
dateFormatStringLong:
|
|
7
|
-
dateFormatStringLC:
|
|
8
|
-
dateFormatMask:
|
|
9
|
-
}
|
|
4
|
+
dateFormatString: 'MM/DD/YYYY',
|
|
5
|
+
dateFormatStringLong: 'MMM DD, YYYY',
|
|
6
|
+
dateFormatStringLC: 'mm/dd/yyyy',
|
|
7
|
+
dateFormatMask: '__/__/____'
|
|
8
|
+
};
|
|
10
9
|
|
|
11
|
-
export const getDateFormatInfo = () => {
|
|
10
|
+
export const getDateFormatInfo = (): typeof dateFormatInfoDefault => {
|
|
11
|
+
const localizedVal = PCore.getLocaleUtils().getLocaleValue;
|
|
12
|
+
const localeCategory = 'CosmosFields';
|
|
12
13
|
const theDateFormatInfo = dateFormatInfoDefault;
|
|
13
|
-
const theLocale = getLocale();
|
|
14
|
+
const theLocale = getLocale();
|
|
14
15
|
|
|
15
16
|
// NOTE: this date was chosen since it has a day larger than 12. If you change it,
|
|
16
17
|
// you'll need to change the indexOf values below!
|
|
@@ -25,29 +26,38 @@ export const getDateFormatInfo = () => {
|
|
|
25
26
|
const locDD = theTestDateLocaleString.indexOf('30');
|
|
26
27
|
const locYYYY = theTestDateLocaleString.indexOf('2023');
|
|
27
28
|
|
|
29
|
+
// If localized placeholder exists for one of day/month/year then show it otherwise fall back to ddmmyyyy
|
|
30
|
+
const localizedPlaceholderExists =
|
|
31
|
+
localizedVal('month_placeholder', localeCategory) !== 'month_placeholder' ||
|
|
32
|
+
localizedVal('day_placeholder', localeCategory) !== 'day_placeholder' ||
|
|
33
|
+
localizedVal('year_placeholder', localeCategory) !== 'year_placeholder';
|
|
34
|
+
|
|
28
35
|
const arrPieces = [
|
|
29
36
|
{
|
|
30
37
|
loc: locMM,
|
|
31
38
|
format: 'MM',
|
|
32
39
|
longFormat: 'MMM',
|
|
33
|
-
placeholder: 'mm',
|
|
34
|
-
mask: '__'
|
|
40
|
+
placeholder: localizedPlaceholderExists ? localizedVal('month_placeholder', localeCategory) : 'mm',
|
|
41
|
+
mask: '__',
|
|
42
|
+
separator: theTestDateLocaleString[locMM+2]
|
|
35
43
|
},
|
|
36
44
|
{
|
|
37
45
|
loc: locDD,
|
|
38
46
|
format: 'DD',
|
|
39
47
|
longFormat: 'DD',
|
|
40
|
-
placeholder: 'dd',
|
|
41
|
-
mask: '__'
|
|
48
|
+
placeholder: localizedPlaceholderExists ? localizedVal('day_placeholder', localeCategory) : 'dd',
|
|
49
|
+
mask: '__',
|
|
50
|
+
separator: theTestDateLocaleString[locDD+2]
|
|
42
51
|
},
|
|
43
52
|
{
|
|
44
53
|
loc: locYYYY,
|
|
45
54
|
format: 'YYYY',
|
|
46
55
|
longFormat: 'YYYY',
|
|
47
|
-
placeholder: 'yyyy',
|
|
48
|
-
mask: '____'
|
|
56
|
+
placeholder: localizedPlaceholderExists ? localizedVal('year_placeholder', localeCategory) : 'yyyy',
|
|
57
|
+
mask: '____',
|
|
58
|
+
separator: theTestDateLocaleString[locYYYY+4]
|
|
49
59
|
}
|
|
50
|
-
|
|
60
|
+
];
|
|
51
61
|
|
|
52
62
|
// Sort the associative array by order of appearance (loc) of each piece
|
|
53
63
|
arrPieces.sort((a, b) => {
|
|
@@ -57,10 +67,10 @@ export const getDateFormatInfo = () => {
|
|
|
57
67
|
});
|
|
58
68
|
|
|
59
69
|
// Construct the structure to return...
|
|
60
|
-
theDateFormatInfo.dateFormatString = `${arrPieces[0].format}
|
|
70
|
+
theDateFormatInfo.dateFormatString = `${arrPieces[0].format}${arrPieces[0].separator}${arrPieces[1].format}${arrPieces[1].separator}${arrPieces[2].format}`;
|
|
61
71
|
theDateFormatInfo.dateFormatStringLong = `${arrPieces[0].longFormat} ${arrPieces[1].longFormat}, ${arrPieces[2].longFormat}`;
|
|
62
|
-
theDateFormatInfo.dateFormatStringLC = `${arrPieces[0].placeholder}
|
|
63
|
-
theDateFormatInfo.dateFormatMask = `${arrPieces[0].mask}
|
|
72
|
+
theDateFormatInfo.dateFormatStringLC = `${arrPieces[0].placeholder}${arrPieces[0].separator}${arrPieces[1].placeholder}${arrPieces[1].separator}${arrPieces[2].placeholder}`;
|
|
73
|
+
theDateFormatInfo.dateFormatMask = `${arrPieces[0].mask}${arrPieces[0].separator}${arrPieces[1].mask}${arrPieces[1].separator}${arrPieces[2].mask}`;
|
|
64
74
|
|
|
65
75
|
return theDateFormatInfo;
|
|
66
|
-
}
|
|
76
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// From DX Components src/utils/event-utils.js
|
|
2
2
|
|
|
3
|
-
const handleEvent = (actions, eventType, propName, value) => {
|
|
3
|
+
const handleEvent = (actions: any, eventType: string, propName: string, value: string) => {
|
|
4
4
|
switch (eventType) {
|
|
5
5
|
case "change":
|
|
6
6
|
actions.updateFieldValue(propName, value);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { createElement } from 'react';
|
|
1
|
+
import { createElement, ReactElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
7
8
|
* @param {*} pConn - pConnect object of the view
|
|
@@ -28,7 +29,7 @@ export const getReferenceList = pConn => {
|
|
|
28
29
|
* @param {*} viewConfigPath - boolean value to check for children in config
|
|
29
30
|
* @returns {*} - return the react element of the view
|
|
30
31
|
*/
|
|
31
|
-
export
|
|
32
|
+
export function buildView(pConn, index, viewConfigPath): ReactElement {
|
|
32
33
|
const context = pConn.getContextName();
|
|
33
34
|
const referenceList = getReferenceList(pConn);
|
|
34
35
|
|
|
@@ -48,7 +49,7 @@ export const buildView = (pConn, index, viewConfigPath) => {
|
|
|
48
49
|
hasForm: true
|
|
49
50
|
}
|
|
50
51
|
};
|
|
51
|
-
|
|
52
|
+
|
|
52
53
|
const view = PCore.createPConnect(config);
|
|
53
54
|
if (pConn.getConfigProps()?.displayMode === 'LABELS_LEFT') {
|
|
54
55
|
view.getPConnect()?.setInheritedProp('displayMode', 'LABELS_LEFT');
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getLocale } from "./common";
|
|
2
2
|
import CurrencyMap from "./CurrencyMap";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
|
5
|
+
function NumberFormatter(value, { locale = "en-US", decPlaces = 2, style="", currency="USD" } = {}): string {
|
|
6
|
+
const currentLocale: string | undefined = getLocale(locale);
|
|
6
7
|
if (value !== null && value !== undefined) {
|
|
7
8
|
return Number(value).toLocaleString(currentLocale, {
|
|
8
9
|
minimumFractionDigits: decPlaces,
|
|
@@ -13,11 +14,11 @@ function NumberFormatter(value, { locale, decPlaces = 2 } = {}) {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
function CurrencyFormatter(
|
|
16
|
-
value,
|
|
17
|
-
{ symbol = true, position, locale, decPlaces = 2, style = "currency", currency = "USD" } = {}
|
|
18
|
-
) {
|
|
19
|
-
const currentLocale = getLocale(locale);
|
|
20
|
-
let formattedValue = value;
|
|
17
|
+
value: string,
|
|
18
|
+
{ symbol = true, position="before", locale="en-US", decPlaces = 2, style = "currency", currency = "USD" } = {}
|
|
19
|
+
): string {
|
|
20
|
+
const currentLocale: string | undefined = getLocale(locale);
|
|
21
|
+
let formattedValue: string = value;
|
|
21
22
|
if (value !== null && value !== undefined && value !== '') {
|
|
22
23
|
formattedValue = NumberFormatter(value, {
|
|
23
24
|
locale: currentLocale,
|
|
@@ -26,14 +27,14 @@ function CurrencyFormatter(
|
|
|
26
27
|
currency
|
|
27
28
|
});
|
|
28
29
|
|
|
29
|
-
let countryCode = currentLocale
|
|
30
|
+
let countryCode: string | undefined = currentLocale?.split("-")[1].toUpperCase();
|
|
30
31
|
|
|
31
32
|
// If countryCode is still undefined, setting it as US
|
|
32
33
|
if( !countryCode ){
|
|
33
34
|
countryCode = 'US';
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
let code;
|
|
37
|
+
let code: string;
|
|
37
38
|
if (symbol) {
|
|
38
39
|
code = CurrencyMap[countryCode]?.symbolFormat;
|
|
39
40
|
} else {
|
|
@@ -42,7 +43,7 @@ function CurrencyFormatter(
|
|
|
42
43
|
|
|
43
44
|
// if position is provided, change placeholder accordingly.
|
|
44
45
|
if (position && code) {
|
|
45
|
-
if (position.toLowerCase() === "before" && code.
|
|
46
|
+
if (position.toLowerCase() === "before" && code.startsWith("{#}")) {
|
|
46
47
|
code = code.slice(3) + code.slice(0, 3);
|
|
47
48
|
} else if (
|
|
48
49
|
position.toLowerCase() === "after" &&
|
|
@@ -56,8 +57,8 @@ function CurrencyFormatter(
|
|
|
56
57
|
return formattedValue;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
function SymbolFormatter(value, { symbol, suffix = true, locale } = {}) {
|
|
60
|
-
let formattedValue = value;
|
|
60
|
+
function SymbolFormatter(value, { symbol="$", suffix = true, locale="en-US" } = {}): string {
|
|
61
|
+
let formattedValue: string = value;
|
|
61
62
|
if (value !== null && value !== undefined) {
|
|
62
63
|
formattedValue = NumberFormatter(value, { locale });
|
|
63
64
|
return suffix ? `${formattedValue}${symbol}` : `${symbol}${formattedValue}`;
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
/* eslint-disable no-template-curly-in-string */
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
type CurrencyMapType = { name: string, symbolFormat: string, currencyCode: string}
|
|
4
|
+
|
|
5
|
+
const EURO: CurrencyMapType = {
|
|
3
6
|
name: "Euro (EUR)",
|
|
4
7
|
symbolFormat: "\u20AC{#}",
|
|
5
8
|
currencyCode: "EUR {#}"
|
|
6
9
|
};
|
|
7
10
|
|
|
8
|
-
const USD = {
|
|
11
|
+
const USD: CurrencyMapType = {
|
|
9
12
|
name: "U.S. Dollar (USD)",
|
|
10
13
|
symbolFormat: "${#}",
|
|
11
14
|
currencyCode: "USD {#}"
|
|
12
15
|
};
|
|
13
16
|
|
|
14
|
-
const XAF = {
|
|
17
|
+
const XAF: CurrencyMapType = {
|
|
15
18
|
name: "CFA Franc (BEAC) (XAF)",
|
|
16
19
|
symbolFormat: "XAF {#}",
|
|
17
20
|
currencyCode: "XAF {#}"
|
|
18
21
|
};
|
|
19
22
|
|
|
20
|
-
const XCD = {
|
|
23
|
+
const XCD: CurrencyMapType = {
|
|
21
24
|
name: "East Caribbean Dollar (XCD)",
|
|
22
25
|
symbolFormat: "${#}",
|
|
23
26
|
currencyCode: "XCD {#}"
|
|
24
27
|
};
|
|
25
28
|
|
|
26
|
-
const XPF = {
|
|
29
|
+
const XPF: CurrencyMapType = {
|
|
27
30
|
name: "Pacific Franc (XPF)",
|
|
28
31
|
symbolFormat: "₣{#}",
|
|
29
32
|
currencyCode: "XPF {#}"
|