@pega/react-sdk-overrides 0.23.26 → 0.23.27
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/LICENSE +201 -0
- package/README.md +17 -0
- package/SECURITY.md +10 -0
- package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +39 -0
- package/lib/designSystemExtension/AlertBanner/index.tsx +1 -0
- package/lib/designSystemExtension/Banner/Banner.tsx +21 -7
- package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.css +0 -1
- package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +36 -26
- package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +21 -28
- package/lib/designSystemExtension/DetailsFields/index.tsx +1 -1
- package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +50 -18
- package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +13 -12
- package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +18 -27
- package/lib/designSystemExtension/Operator/Operator.tsx +106 -87
- package/lib/designSystemExtension/Pulse/Pulse.tsx +21 -19
- package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +122 -0
- package/lib/designSystemExtension/RichTextEditor/index.tsx +1 -0
- package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +21 -12
- package/lib/field/AutoComplete/AutoComplete.tsx +33 -16
- package/lib/field/AutoComplete/config-ext.json +2 -3
- package/lib/field/CancelAlert/CancelAlert.tsx +21 -15
- package/lib/field/CancelAlert/index.tsx +1 -1
- package/lib/field/Checkbox/Checkbox.tsx +29 -19
- package/lib/field/Checkbox/config-ext.json +2 -3
- package/lib/field/Currency/Currency.tsx +27 -38
- package/lib/field/Currency/config-ext.json +2 -3
- package/lib/field/Currency/currency-utils.ts +10 -18
- package/lib/field/Date/Date.tsx +33 -15
- package/lib/field/Date/config-ext.json +2 -3
- package/lib/field/DateTime/DateTime.tsx +22 -11
- package/lib/field/DateTime/config-ext.json +1 -2
- package/lib/field/Decimal/Decimal.tsx +64 -17
- package/lib/field/Decimal/config-ext.json +1 -2
- package/lib/field/Decimal/index.tsx +1 -1
- package/lib/field/Dropdown/Dropdown.tsx +154 -18
- package/lib/field/Dropdown/config-ext.json +1 -2
- package/lib/field/Email/Email.tsx +16 -7
- package/lib/field/Email/config-ext.json +1 -2
- package/lib/field/Email/index.tsx +1 -1
- package/lib/field/Group/Group.tsx +37 -0
- package/lib/field/Group/config-ext.json +7 -0
- package/lib/field/Group/index.tsx +1 -0
- package/lib/field/Integer/Integer.tsx +15 -6
- package/lib/field/Integer/config-ext.json +1 -2
- package/lib/field/Percentage/Percentage.tsx +14 -6
- package/lib/field/Percentage/config-ext.json +1 -2
- package/lib/field/Phone/Phone.tsx +17 -7
- package/lib/field/Phone/index.tsx +1 -1
- package/lib/field/RadioButtons/RadioButtons.tsx +55 -24
- package/lib/field/RadioButtons/config-ext.json +1 -2
- package/lib/field/RichText/RichText.tsx +96 -0
- package/lib/field/RichText/index.tsx +1 -0
- package/lib/field/ScalarList/ScalarList.tsx +63 -0
- package/lib/field/ScalarList/config-ext.json +7 -0
- package/lib/field/ScalarList/index.tsx +1 -0
- package/lib/field/SemanticLink/SemanticLink.tsx +26 -25
- package/lib/field/SemanticLink/config-ext.json +1 -2
- package/lib/field/SemanticLink/utils.ts +8 -10
- package/lib/field/TextArea/TextArea.tsx +15 -5
- package/lib/field/TextArea/config-ext.json +1 -2
- package/lib/field/TextContent/TextContent.tsx +9 -2
- package/lib/field/TextContent/config-ext.json +1 -2
- package/lib/field/TextInput/TextInput.tsx +41 -10
- package/lib/field/TextInput/config-ext.json +1 -2
- package/lib/field/TextInput/index.tsx +1 -1
- package/lib/field/Time/Time.tsx +21 -18
- package/lib/field/Time/config-ext.json +1 -2
- package/lib/field/URL/URL.tsx +23 -6
- package/lib/field/URL/config-ext.json +1 -2
- package/lib/field/URL/index.tsx +1 -1
- package/lib/field/UserReference/UserReference.tsx +52 -58
- package/lib/field/UserReference/UserReferenceUtils.ts +2 -2
- package/lib/field/UserReference/config-ext.json +1 -2
- package/lib/helpers/{attachmentHelpers.js → attachmentHelpers.ts} +16 -11
- package/lib/helpers/case-utils.tsx +99 -0
- package/lib/helpers/common-utils.ts +8 -0
- package/lib/helpers/data_page.ts +3 -6
- package/lib/helpers/date-format-utils.ts +29 -19
- package/lib/helpers/{event-utils.js → event-utils.ts} +4 -4
- package/lib/helpers/{field-group-utils.js → field-group-utils.ts} +9 -10
- package/lib/helpers/formatters/Boolean.ts +21 -0
- package/lib/helpers/formatters/{Currency.js → Currency.ts} +22 -27
- package/lib/helpers/formatters/CurrencyMap.ts +915 -0
- package/lib/helpers/formatters/{Date.js → Date.ts} +20 -26
- package/lib/helpers/formatters/{common.js → common.ts} +3 -4
- package/lib/helpers/formatters/{index.js → index.ts} +22 -22
- package/lib/helpers/{reactContextHelpers.js → reactContextHelpers.ts} +2 -2
- package/lib/helpers/simpleTableHelpers.ts +65 -85
- package/lib/helpers/state-utils.tsx +43 -0
- package/lib/helpers/template-utils.ts +4 -8
- package/lib/helpers/utils.ts +16 -8
- package/lib/helpers/versionHelpers.ts +1 -5
- package/lib/infra/ActionButtons/ActionButtons.tsx +46 -42
- package/lib/infra/ActionButtons/index.tsx +1 -1
- package/lib/infra/Assignment/Assignment.tsx +99 -84
- package/lib/infra/Assignment/index.tsx +1 -1
- package/lib/infra/AssignmentCard/AssignmentCard.tsx +19 -26
- package/lib/infra/AssignmentCard/index.tsx +1 -1
- package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +98 -232
- package/lib/infra/Containers/FlowContainer/helpers.ts +138 -0
- package/lib/infra/Containers/FlowContainer/index.tsx +1 -1
- package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +66 -0
- package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/index.tsx +1 -0
- package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +105 -70
- package/lib/infra/Containers/ModalViewContainer/index.tsx +1 -1
- package/lib/infra/Containers/SimpleView/SimpleView.tsx +48 -0
- package/lib/infra/Containers/SimpleView/helper.ts +125 -0
- package/lib/infra/Containers/SimpleView/index.tsx +1 -0
- package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +49 -64
- package/lib/infra/Containers/helpers.ts +6 -0
- package/lib/infra/DashboardFilter/DashboardFilter.tsx +26 -51
- package/lib/infra/DashboardFilter/filterUtils.tsx +12 -40
- package/lib/infra/DeferLoad/DeferLoad.tsx +22 -31
- package/lib/infra/DeferLoad/index.tsx +1 -1
- package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +25 -38
- package/lib/infra/MultiStep/MultiStep.css +11 -15
- package/lib/infra/MultiStep/MultiStep.tsx +180 -216
- package/lib/infra/MultiStep/index.tsx +1 -1
- package/lib/infra/NavBar/NavBar.css +103 -105
- package/lib/infra/NavBar/NavBar.tsx +28 -43
- package/lib/infra/Reference/Reference.tsx +16 -22
- package/lib/infra/Region/Region.tsx +9 -9
- package/lib/infra/RootContainer/RootContainer.tsx +82 -125
- package/lib/infra/RootContainer/index.tsx +1 -1
- package/lib/infra/Stages/Stages.tsx +38 -39
- package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +17 -10
- package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +29 -36
- package/lib/infra/View/View.tsx +32 -63
- package/lib/template/AppShell/AppShell.css +22 -23
- package/lib/template/AppShell/AppShell.tsx +51 -69
- package/lib/template/BannerPage/BannerPage.tsx +26 -33
- package/lib/template/CaseSummary/CaseSummary.tsx +23 -18
- package/lib/template/CaseSummary/config-ext.json +1 -2
- package/lib/template/CaseView/CaseView.tsx +122 -114
- package/lib/template/CaseView/config-ext.json +1 -2
- package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +46 -35
- package/lib/template/Confirmation/Confirmation.tsx +25 -53
- package/lib/template/Confirmation/config-ext.json +1 -2
- package/lib/template/DataReference/DataReference.tsx +112 -140
- package/lib/template/DataReference/config-ext.json +1 -2
- package/lib/template/DefaultForm/DefaultForm.css +7 -3
- package/lib/template/DefaultForm/DefaultForm.tsx +26 -20
- package/lib/template/DefaultForm/config-ext.json +1 -2
- package/lib/template/DefaultForm/utils/index.ts +33 -0
- package/lib/template/Details/Details/Details.tsx +24 -28
- package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +15 -22
- package/lib/template/Details/DetailsSubTabs/config-ext.json +1 -2
- package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +25 -29
- package/lib/template/Details/DetailsThreeColumn/config-ext.json +1 -2
- package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +25 -29
- package/lib/template/Details/DetailsTwoColumn/config-ext.json +1 -2
- package/lib/template/Details/DetailsTwoColumn/index.tsx +1 -1
- package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +79 -0
- package/lib/template/Details/DynamicTabs/config.json +36 -0
- package/lib/template/Details/DynamicTabs/index.tsx +1 -0
- package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +24 -34
- package/lib/template/InlineDashboard/InlineDashboard.tsx +16 -14
- package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +19 -21
- package/lib/template/ListPage/ListPage.tsx +12 -16
- package/lib/template/ListPage/config-ext.json +1 -2
- package/lib/template/ListView/{DefaultViewMeta.js → DefaultViewMeta.ts} +1 -3
- package/lib/template/ListView/ListView.tsx +245 -306
- package/lib/template/ListView/config-ext.json +1 -2
- package/lib/template/ListView/{hooks.js → hooks.ts} +24 -24
- package/lib/template/ListView/{utils.js → utils.ts} +202 -91
- package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +25 -30
- package/lib/template/NarrowWide/NarrowWide/NarrowWide.css +0 -2
- package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +31 -29
- package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +27 -31
- package/lib/template/NarrowWide/NarrowWideDetails/config-ext.json +1 -2
- package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.css +0 -2
- package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +17 -19
- package/lib/template/NarrowWide/NarrowWideForm/config-ext.json +1 -2
- package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +16 -26
- package/lib/template/NarrowWide/NarrowWidePage/config-ext.json +1 -2
- package/lib/template/OneColumn/OneColumn/OneColumn.tsx +17 -17
- package/lib/template/OneColumn/OneColumn/config-ext.json +1 -2
- package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +9 -16
- package/lib/template/OneColumn/OneColumnPage/config-ext.json +1 -2
- package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +8 -14
- package/lib/template/OneColumn/OneColumnTab/config-ext.json +1 -2
- package/lib/template/PromotedFilters/PromotedFilters.css +1 -1
- package/lib/template/PromotedFilters/PromotedFilters.tsx +44 -34
- package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +115 -14
- package/lib/template/SimpleTable/SimpleTable/config-ext.json +1 -2
- package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +171 -100
- package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +34 -40
- package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +45 -48
- package/lib/template/SubTabs/SubTabs.tsx +26 -45
- package/lib/template/SubTabs/config-ext.json +1 -2
- package/lib/template/SubTabs/tabUtils.ts +2 -7
- package/lib/template/TwoColumn/TwoColumn/TwoColumn.css +0 -1
- package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +33 -36
- package/lib/template/TwoColumn/TwoColumn/config-ext.json +1 -2
- package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +9 -16
- package/lib/template/TwoColumn/TwoColumnPage/config-ext.json +1 -2
- package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +33 -33
- package/lib/template/TwoColumn/TwoColumnTab/config-ext.json +1 -2
- package/lib/template/WideNarrow/WideNarrow/WideNarrow.css +0 -2
- package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +29 -27
- package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +39 -33
- package/lib/template/WideNarrow/WideNarrowDetails/config-ext.json +1 -2
- package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.css +0 -2
- package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +16 -18
- package/lib/template/WideNarrow/WideNarrowForm/config-ext.json +1 -2
- package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +15 -25
- package/lib/template/WideNarrow/WideNarrowPage/config-ext.json +1 -2
- package/lib/template/WideNarrow/WideNarrowPage/index.tsx +1 -1
- package/lib/template/WssNavBar/WssNavBar.tsx +20 -9
- package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +34 -41
- package/lib/widget/AppAnnouncement/config-ext.json +1 -2
- package/lib/widget/Attachment/Attachment.css +75 -4
- package/lib/widget/Attachment/Attachment.tsx +370 -388
- package/lib/widget/Attachment/index.tsx +1 -1
- package/lib/widget/CaseHistory/CaseHistory.tsx +67 -67
- package/lib/widget/CaseHistory/config-ext.json +1 -2
- package/lib/widget/CaseHistory/index.tsx +1 -1
- package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +19 -9
- package/lib/widget/FileUtility/FileUtility/FileUtility.css +2 -2
- package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +324 -246
- package/lib/widget/FileUtility/FileUtility/config-ext.json +1 -2
- package/lib/widget/Followers/Followers.tsx +27 -25
- package/lib/widget/Followers/config-ext.json +1 -2
- package/lib/widget/QuickCreate/QuickCreate.tsx +24 -16
- package/lib/widget/SummaryItem/SummaryItem.css +9 -9
- package/lib/widget/SummaryItem/SummaryItem.tsx +62 -54
- package/lib/widget/SummaryItem/index.tsx +1 -1
- package/lib/widget/SummaryList/SummaryList.tsx +15 -4
- package/lib/widget/ToDo/ToDo.css +4 -4
- package/lib/widget/ToDo/ToDo.tsx +80 -116
- package/lib/widget/ToDo/config-ext.json +1 -2
- package/package.json +5 -2
- package/lib/helpers/auth.js +0 -483
- package/lib/helpers/authManager.js +0 -631
- package/lib/helpers/config_access.js +0 -268
- package/lib/helpers/formatters/Boolean.js +0 -38
- package/lib/helpers/formatters/CurrencyMap.js +0 -908
- package/lib/infra/Containers/FlowContainer/helpers.js +0 -147
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-nested-ternary */
|
|
2
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import React, { PropsWithChildren, useEffect, useRef, useState } from 'react';
|
|
3
3
|
import Table from '@material-ui/core/Table';
|
|
4
4
|
import TableBody from '@material-ui/core/TableBody';
|
|
5
5
|
import TableCell from '@material-ui/core/TableCell';
|
|
@@ -8,15 +8,8 @@ import TableHead from '@material-ui/core/TableHead';
|
|
|
8
8
|
import TableRow from '@material-ui/core/TableRow';
|
|
9
9
|
import Paper from '@material-ui/core/Paper';
|
|
10
10
|
import { makeStyles } from '@material-ui/core/styles';
|
|
11
|
-
import { buildFieldsForTable, filterData } from '@pega/react-sdk-components/lib/components/helpers/simpleTableHelpers';
|
|
12
|
-
import { getDataPage } from '@pega/react-sdk-components/lib/components/helpers/data_page';
|
|
13
11
|
import Link from '@material-ui/core/Link';
|
|
14
|
-
import { getReferenceList } from '@pega/react-sdk-components/lib/components/helpers/field-group-utils';
|
|
15
|
-
import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
|
|
16
12
|
import { createElement } from 'react';
|
|
17
|
-
|
|
18
|
-
import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
|
|
19
|
-
|
|
20
13
|
import TableSortLabel from '@material-ui/core/TableSortLabel';
|
|
21
14
|
import MoreIcon from '@material-ui/icons/MoreVert';
|
|
22
15
|
import Menu from '@material-ui/core/Menu';
|
|
@@ -31,6 +24,36 @@ import Select from '@material-ui/core/Select';
|
|
|
31
24
|
import Button from '@material-ui/core/Button';
|
|
32
25
|
import TextField from '@material-ui/core/TextField';
|
|
33
26
|
|
|
27
|
+
import createPConnectComponent from '@pega/react-sdk-components/lib/bridge/react_pconnect';
|
|
28
|
+
import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
|
|
29
|
+
import { getReferenceList } from '@pega/react-sdk-components/lib/components/helpers/field-group-utils';
|
|
30
|
+
import { getDataPage } from '@pega/react-sdk-components/lib/components/helpers/data_page';
|
|
31
|
+
import { buildFieldsForTable, filterData, getContext } from '@pega/react-sdk-components/lib/components/helpers/simpleTableHelpers';
|
|
32
|
+
import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
|
|
33
|
+
import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
|
|
34
|
+
|
|
35
|
+
interface SimpleTableManualProps extends PConnProps {
|
|
36
|
+
// If any, enter additional props that only exist on this component
|
|
37
|
+
hideAddRow?: boolean;
|
|
38
|
+
hideDeleteRow?: boolean;
|
|
39
|
+
referenceList?: any[];
|
|
40
|
+
renderMode?: string;
|
|
41
|
+
presets?: any[];
|
|
42
|
+
label?: string;
|
|
43
|
+
showLabel?: boolean;
|
|
44
|
+
dataPageName?: string;
|
|
45
|
+
contextClass?: string;
|
|
46
|
+
propertyLabel?: string;
|
|
47
|
+
fieldMetadata?: any;
|
|
48
|
+
editMode?: string;
|
|
49
|
+
addAndEditRowsWithin?: any;
|
|
50
|
+
viewForAddAndEditModal?: any;
|
|
51
|
+
editModeConfig?: any;
|
|
52
|
+
displayMode?: string;
|
|
53
|
+
useSeparateViewForEdit: any;
|
|
54
|
+
viewForEditModal: any;
|
|
55
|
+
}
|
|
56
|
+
|
|
34
57
|
const useStyles = makeStyles((/* theme */) => ({
|
|
35
58
|
label: {
|
|
36
59
|
margin: '8px'
|
|
@@ -58,15 +81,14 @@ const useStyles = makeStyles((/* theme */) => ({
|
|
|
58
81
|
}
|
|
59
82
|
}));
|
|
60
83
|
|
|
61
|
-
declare const PCore: any;
|
|
62
|
-
|
|
63
84
|
let menuColumnId = '';
|
|
64
85
|
let menuColumnType = '';
|
|
65
86
|
let menuColumnLabel = '';
|
|
66
87
|
|
|
67
|
-
const filterByColumns:
|
|
68
|
-
let myRows:
|
|
69
|
-
|
|
88
|
+
const filterByColumns: any[] = [];
|
|
89
|
+
let myRows: any[];
|
|
90
|
+
|
|
91
|
+
export default function SimpleTableManual(props: PropsWithChildren<SimpleTableManualProps>) {
|
|
70
92
|
const classes = useStyles();
|
|
71
93
|
const {
|
|
72
94
|
getPConnect,
|
|
@@ -81,7 +103,14 @@ export default function SimpleTableManual(props) {
|
|
|
81
103
|
hideAddRow,
|
|
82
104
|
hideDeleteRow,
|
|
83
105
|
propertyLabel,
|
|
84
|
-
fieldMetadata
|
|
106
|
+
fieldMetadata,
|
|
107
|
+
editMode,
|
|
108
|
+
addAndEditRowsWithin,
|
|
109
|
+
viewForAddAndEditModal,
|
|
110
|
+
editModeConfig,
|
|
111
|
+
displayMode,
|
|
112
|
+
useSeparateViewForEdit,
|
|
113
|
+
viewForEditModal
|
|
85
114
|
} = props;
|
|
86
115
|
const pConn = getPConnect();
|
|
87
116
|
const [rowData, setRowData] = useState([]);
|
|
@@ -89,20 +118,21 @@ export default function SimpleTableManual(props) {
|
|
|
89
118
|
const [order, setOrder] = useState<Order>('asc');
|
|
90
119
|
const [orderBy, setOrderBy] = useState<keyof any>('');
|
|
91
120
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
121
|
+
const [editAnchorEl, setEditAnchorEl] = useState<null | HTMLElement>(null);
|
|
92
122
|
const [open, setOpen] = useState(false);
|
|
93
123
|
const [filterBy, setFilterBy] = useState<string>();
|
|
94
124
|
const [containsDateOrTime, setContainsDateOrTime] = useState<boolean>(false);
|
|
95
125
|
const [filterType, setFilterType] = useState<string>('string');
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
97
127
|
const [displayDialogFilterName, setDisplayDialogFilterName] = useState<string>('');
|
|
98
|
-
const [displayDialogContainsFilter, setDisplayDialogContainsFilter] =
|
|
99
|
-
useState<string>('contains');
|
|
128
|
+
const [displayDialogContainsFilter, setDisplayDialogContainsFilter] = useState<string>('contains');
|
|
100
129
|
const [displayDialogContainsValue, setDisplayDialogContainsValue] = useState<string>('');
|
|
101
130
|
const [displayDialogDateFilter, setDisplayDialogDateFilter] = useState<string>('notequal');
|
|
102
131
|
const [displayDialogDateValue, setDisplayDialogDateValue] = useState<string>('');
|
|
132
|
+
const selectedRowIndex: any = useRef(null);
|
|
103
133
|
|
|
104
134
|
const parameters = fieldMetadata?.datasource?.parameters;
|
|
105
|
-
|
|
135
|
+
const { referenceListStr } = getContext(getPConnect());
|
|
106
136
|
const label = labelProp || propertyLabel;
|
|
107
137
|
const propsToUse = { label, showLabel, ...getPConnect().getInheritedProps() };
|
|
108
138
|
if (propsToUse.showLabel === false) {
|
|
@@ -113,14 +143,14 @@ export default function SimpleTableManual(props) {
|
|
|
113
143
|
const resolvedList = getReferenceList(pConn);
|
|
114
144
|
const pageReference = `${pConn.getPageReference()}${resolvedList}`;
|
|
115
145
|
pConn.setReferenceList(resolvedList);
|
|
116
|
-
const menuIconOverride$ = Utils.getImageSrc('trash',
|
|
146
|
+
const menuIconOverride$ = Utils.getImageSrc('trash', Utils.getSDKStaticConentUrl());
|
|
117
147
|
|
|
118
148
|
const resolvedFields = children?.[0]?.children || presets?.[0].children?.[0].children;
|
|
119
149
|
// NOTE: props has each child.config with datasource and value undefined
|
|
120
150
|
// but getRawMetadata() has each child.config with datasource and value showing their unresolved values (ex: "@P thePropName")
|
|
121
151
|
// We need to use the prop name as the "glue" to tie the table dataSource, displayColumns and data together.
|
|
122
152
|
// So, in the code below, we'll use the unresolved config.value (but replacing the space with an underscore to keep things happy)
|
|
123
|
-
const rawMetadata = getPConnect().getRawMetadata();
|
|
153
|
+
const rawMetadata: any = getPConnect().getRawMetadata();
|
|
124
154
|
|
|
125
155
|
// get raw config since @P and other annotations are processed and don't appear in the resolved config.
|
|
126
156
|
// Destructure "raw" children into array var: "rawFields"
|
|
@@ -130,22 +160,35 @@ export default function SimpleTableManual(props) {
|
|
|
130
160
|
// Neither of these appear in the resolved props
|
|
131
161
|
|
|
132
162
|
const rawConfig = rawMetadata?.config;
|
|
133
|
-
const rawFields =
|
|
134
|
-
|
|
135
|
-
|
|
163
|
+
const rawFields = rawConfig?.children?.[0]?.children || rawConfig?.presets?.[0].children?.[0]?.children;
|
|
164
|
+
const isDisplayModeEnabled = displayMode === 'DISPLAY_ONLY';
|
|
136
165
|
const readOnlyMode = renderMode === 'ReadOnly';
|
|
137
166
|
const editableMode = renderMode === 'Editable';
|
|
138
167
|
const showAddRowButton = !readOnlyMode && !hideAddRow;
|
|
139
|
-
const
|
|
168
|
+
const allowEditingInModal =
|
|
169
|
+
(editMode ? editMode === 'modal' : addAndEditRowsWithin === 'modal') && !(renderMode === 'ReadOnly' || isDisplayModeEnabled);
|
|
170
|
+
const showDeleteButton = editableMode && !hideDeleteRow;
|
|
171
|
+
const defaultView = editModeConfig ? editModeConfig.defaultView : viewForAddAndEditModal;
|
|
172
|
+
const bUseSeparateViewForEdit = editModeConfig ? editModeConfig.useSeparateViewForEdit : useSeparateViewForEdit;
|
|
173
|
+
const editView = editModeConfig ? editModeConfig.editView : viewForEditModal;
|
|
174
|
+
|
|
175
|
+
const fieldsWithPropNames = rawFields.map((field, index) => {
|
|
176
|
+
return { ...resolvedFields[index], propName: field.config.value.replace('@P .', '') };
|
|
177
|
+
});
|
|
178
|
+
|
|
140
179
|
useEffect(() => {
|
|
141
|
-
if (editableMode) {
|
|
180
|
+
if (editableMode && !allowEditingInModal) {
|
|
142
181
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
143
182
|
buildElementsForTable();
|
|
144
|
-
}
|
|
183
|
+
}
|
|
184
|
+
}, [referenceList.length]);
|
|
185
|
+
|
|
186
|
+
useEffect(() => {
|
|
187
|
+
if (readOnlyMode || allowEditingInModal) {
|
|
145
188
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
146
189
|
generateRowsData();
|
|
147
190
|
}
|
|
148
|
-
}, [referenceList
|
|
191
|
+
}, [referenceList]);
|
|
149
192
|
|
|
150
193
|
// fieldDefs will be an array where each entry will have a "name" which will be the
|
|
151
194
|
// "resolved" property name (that we can use as the colId) though it's not really
|
|
@@ -159,6 +202,19 @@ export default function SimpleTableManual(props) {
|
|
|
159
202
|
return field.name ? field.name : field.cellRenderer;
|
|
160
203
|
});
|
|
161
204
|
|
|
205
|
+
const getFormattedValue = (val, key) => {
|
|
206
|
+
const rawField = fieldsWithPropNames.find(item => item.propName === key);
|
|
207
|
+
let options = {};
|
|
208
|
+
if (rawField && ['Boolean', 'Checkbox'].includes(rawField.type)) {
|
|
209
|
+
const { trueLabel, falseLabel } = rawField.config;
|
|
210
|
+
options = {
|
|
211
|
+
trueLabel,
|
|
212
|
+
falseLabel
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
return rawField ? format(val, rawField.type, options) : val;
|
|
216
|
+
};
|
|
217
|
+
|
|
162
218
|
// console.log(`SimpleTable displayedColumns:`);
|
|
163
219
|
// console.log(displayedColumns);
|
|
164
220
|
|
|
@@ -166,16 +222,16 @@ export default function SimpleTableManual(props) {
|
|
|
166
222
|
// of the given row field
|
|
167
223
|
function getRowValue(inRowData: Object, inColKey: string): any {
|
|
168
224
|
// See what data (if any) we have to display
|
|
169
|
-
const refKeys:
|
|
225
|
+
const refKeys: string[] = inColKey?.split('.');
|
|
170
226
|
let valBuilder = inRowData;
|
|
171
227
|
for (const key of refKeys) {
|
|
172
228
|
valBuilder = valBuilder[key];
|
|
173
229
|
}
|
|
174
|
-
return valBuilder;
|
|
230
|
+
return getFormattedValue(valBuilder, inColKey);
|
|
175
231
|
}
|
|
176
232
|
|
|
177
233
|
const formatRowsData = data => {
|
|
178
|
-
if(!data) return {};
|
|
234
|
+
if (!data) return {};
|
|
179
235
|
|
|
180
236
|
return data.map(item => {
|
|
181
237
|
return displayedColumns.reduce((dataForRow, colKey) => {
|
|
@@ -186,8 +242,8 @@ export default function SimpleTableManual(props) {
|
|
|
186
242
|
};
|
|
187
243
|
|
|
188
244
|
function generateRowsData() {
|
|
189
|
-
// if dataPageName property value exists then make a datapage fetch call and get the list of data.
|
|
190
|
-
if (dataPageName) {
|
|
245
|
+
// if referenceList is empty and dataPageName property value exists then make a datapage fetch call and get the list of data.
|
|
246
|
+
if (!referenceList.length && dataPageName) {
|
|
191
247
|
getDataPage(dataPageName, parameters, context).then(listData => {
|
|
192
248
|
const data = formatRowsData(listData);
|
|
193
249
|
myRows = data;
|
|
@@ -228,18 +284,38 @@ export default function SimpleTableManual(props) {
|
|
|
228
284
|
// console.log(JSON.stringify(rowData));
|
|
229
285
|
|
|
230
286
|
const addRecord = () => {
|
|
231
|
-
if (
|
|
287
|
+
if (allowEditingInModal && defaultView) {
|
|
288
|
+
pConn
|
|
289
|
+
.getActionsApi()
|
|
290
|
+
.openEmbeddedDataModal(defaultView, pConn, referenceListStr, referenceList.length, PCore.getConstants().RESOURCE_STATUS.CREATE);
|
|
291
|
+
} else if (PCore.getPCoreVersion()?.includes('8.7')) {
|
|
232
292
|
pConn.getListActions().insert({ classID: contextClass }, referenceList.length, pageReference);
|
|
233
293
|
} else {
|
|
234
|
-
pConn.getListActions().insert({ classID: contextClass }, referenceList.length);
|
|
294
|
+
pConn.getListActions().insert({ classID: contextClass }, referenceList.length, ''); // 3rd arg null until typedef marked correctly as optional
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const editRecord = () => {
|
|
299
|
+
setEditAnchorEl(null);
|
|
300
|
+
if (typeof selectedRowIndex.current === 'number') {
|
|
301
|
+
pConn
|
|
302
|
+
.getActionsApi()
|
|
303
|
+
.openEmbeddedDataModal(
|
|
304
|
+
bUseSeparateViewForEdit ? editView : defaultView,
|
|
305
|
+
pConn,
|
|
306
|
+
referenceListStr,
|
|
307
|
+
selectedRowIndex.current,
|
|
308
|
+
PCore.getConstants().RESOURCE_STATUS.UPDATE
|
|
309
|
+
);
|
|
235
310
|
}
|
|
236
311
|
};
|
|
237
312
|
|
|
238
|
-
const deleteRecord =
|
|
313
|
+
const deleteRecord = () => {
|
|
314
|
+
setEditAnchorEl(null);
|
|
239
315
|
if (PCore.getPCoreVersion()?.includes('8.7')) {
|
|
240
|
-
pConn.getListActions().deleteEntry(
|
|
316
|
+
pConn.getListActions().deleteEntry(selectedRowIndex.current, pageReference);
|
|
241
317
|
} else {
|
|
242
|
-
pConn.getListActions().deleteEntry(
|
|
318
|
+
pConn.getListActions().deleteEntry(selectedRowIndex.current, ''); // 2nd arg empty string until typedef marked correctly as optional
|
|
243
319
|
}
|
|
244
320
|
};
|
|
245
321
|
|
|
@@ -249,14 +325,12 @@ export default function SimpleTableManual(props) {
|
|
|
249
325
|
const data: any = [];
|
|
250
326
|
rawFields.forEach(item => {
|
|
251
327
|
// removing label field from config to hide title in the table cell
|
|
252
|
-
item = {...item, config: {...item.config, label: ''}};
|
|
328
|
+
item = { ...item, config: { ...item.config, label: '' } };
|
|
253
329
|
const referenceListData = getReferenceList(pConn);
|
|
254
330
|
const isDatapage = referenceListData.startsWith('D_');
|
|
255
331
|
const pageReferenceValue = isDatapage
|
|
256
332
|
? `${referenceListData}[${index}]`
|
|
257
|
-
: `${pConn.getPageReference()}${referenceListData.substring(
|
|
258
|
-
referenceListData.lastIndexOf('.')
|
|
259
|
-
)}[${index}]`;
|
|
333
|
+
: `${pConn.getPageReference()}${referenceListData.substring(referenceListData.lastIndexOf('.'))}[${index}]`;
|
|
260
334
|
const config = {
|
|
261
335
|
meta: item,
|
|
262
336
|
options: {
|
|
@@ -299,18 +373,14 @@ export default function SimpleTableManual(props) {
|
|
|
299
373
|
function getComparator<Key extends keyof any>(
|
|
300
374
|
theOrder: Order,
|
|
301
375
|
orderedBy: Key
|
|
302
|
-
// eslint-disable-next-line no-unused-vars
|
|
303
376
|
): (a: { [key in Key]: number | string }, b: { [key in Key]: number | string }) => number {
|
|
304
|
-
return theOrder === 'desc'
|
|
305
|
-
? (a, b) => descendingComparator(a, b, orderedBy)
|
|
306
|
-
: (a, b) => -descendingComparator(a, b, orderedBy);
|
|
377
|
+
return theOrder === 'desc' ? (a, b) => descendingComparator(a, b, orderedBy) : (a, b) => -descendingComparator(a, b, orderedBy);
|
|
307
378
|
}
|
|
308
379
|
|
|
309
|
-
|
|
310
|
-
function stableSort<T>(array: Array<T>, comparator: (a: T, b: T) => number) {
|
|
380
|
+
function stableSort<T>(array: T[], comparator: (a: T, b: T) => number) {
|
|
311
381
|
const stabilizedThis = array.map((el, index) => [el, index] as [T, number]);
|
|
312
382
|
stabilizedThis.sort((a, b) => {
|
|
313
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
383
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
314
384
|
const order = comparator(a[0], b[0]);
|
|
315
385
|
if (order !== 0) return order;
|
|
316
386
|
return a[1] - b[1];
|
|
@@ -327,8 +397,14 @@ export default function SimpleTableManual(props) {
|
|
|
327
397
|
setAnchorEl(event.currentTarget);
|
|
328
398
|
}
|
|
329
399
|
|
|
400
|
+
function editMenuClick(event, index) {
|
|
401
|
+
selectedRowIndex.current = index;
|
|
402
|
+
setEditAnchorEl(event.currentTarget);
|
|
403
|
+
}
|
|
404
|
+
|
|
330
405
|
function _menuClose() {
|
|
331
406
|
setAnchorEl(null);
|
|
407
|
+
setEditAnchorEl(null);
|
|
332
408
|
}
|
|
333
409
|
|
|
334
410
|
function _filterMenu() {
|
|
@@ -339,11 +415,7 @@ export default function SimpleTableManual(props) {
|
|
|
339
415
|
for (const filterObj of filterByColumns) {
|
|
340
416
|
if (filterObj.ref === menuColumnId) {
|
|
341
417
|
setFilterBy(menuColumnLabel);
|
|
342
|
-
if (
|
|
343
|
-
filterObj.type === 'Date' ||
|
|
344
|
-
filterObj.type === 'DateTime' ||
|
|
345
|
-
filterObj.type === 'Time'
|
|
346
|
-
) {
|
|
418
|
+
if (filterObj.type === 'Date' || filterObj.type === 'DateTime' || filterObj.type === 'Time') {
|
|
347
419
|
setContainsDateOrTime(true);
|
|
348
420
|
setFilterType(filterObj.type);
|
|
349
421
|
setDisplayDialogDateFilter(filterObj.containsFilter);
|
|
@@ -418,14 +490,14 @@ export default function SimpleTableManual(props) {
|
|
|
418
490
|
function updateFilterWithInfo() {
|
|
419
491
|
let bFound = false;
|
|
420
492
|
for (const filterObj of filterByColumns) {
|
|
421
|
-
if (filterObj
|
|
422
|
-
filterObj
|
|
493
|
+
if (filterObj.ref === menuColumnId) {
|
|
494
|
+
filterObj.type = filterType;
|
|
423
495
|
if (containsDateOrTime) {
|
|
424
|
-
filterObj
|
|
425
|
-
filterObj
|
|
496
|
+
filterObj.containsFilter = displayDialogDateFilter;
|
|
497
|
+
filterObj.containsFilterValue = displayDialogDateValue;
|
|
426
498
|
} else {
|
|
427
|
-
filterObj
|
|
428
|
-
filterObj
|
|
499
|
+
filterObj.containsFilter = displayDialogContainsFilter;
|
|
500
|
+
filterObj.containsFilterValue = displayDialogContainsValue;
|
|
429
501
|
}
|
|
430
502
|
bFound = true;
|
|
431
503
|
break;
|
|
@@ -436,13 +508,13 @@ export default function SimpleTableManual(props) {
|
|
|
436
508
|
// add in
|
|
437
509
|
const filterObj: any = {};
|
|
438
510
|
filterObj.ref = menuColumnId;
|
|
439
|
-
filterObj
|
|
511
|
+
filterObj.type = filterType;
|
|
440
512
|
if (containsDateOrTime) {
|
|
441
|
-
filterObj
|
|
442
|
-
filterObj
|
|
513
|
+
filterObj.containsFilter = displayDialogDateFilter;
|
|
514
|
+
filterObj.containsFilterValue = displayDialogDateValue;
|
|
443
515
|
} else {
|
|
444
|
-
filterObj
|
|
445
|
-
filterObj
|
|
516
|
+
filterObj.containsFilter = displayDialogContainsFilter;
|
|
517
|
+
filterObj.containsFilterValue = displayDialogContainsValue;
|
|
446
518
|
}
|
|
447
519
|
|
|
448
520
|
filterByColumns.push(filterObj);
|
|
@@ -458,9 +530,9 @@ export default function SimpleTableManual(props) {
|
|
|
458
530
|
|
|
459
531
|
function _showFilteredIcon(columnId) {
|
|
460
532
|
for (const filterObj of filterByColumns) {
|
|
461
|
-
if (filterObj
|
|
533
|
+
if (filterObj.ref === columnId) {
|
|
462
534
|
// eslint-disable-next-line sonarjs/prefer-single-boolean-return
|
|
463
|
-
if (filterObj
|
|
535
|
+
if (filterObj.containsFilterValue !== '') {
|
|
464
536
|
return true;
|
|
465
537
|
}
|
|
466
538
|
return false;
|
|
@@ -481,8 +553,8 @@ export default function SimpleTableManual(props) {
|
|
|
481
553
|
}
|
|
482
554
|
|
|
483
555
|
return (
|
|
484
|
-
|
|
485
|
-
<TableContainer component={Paper} style={{ margin: '4px 0px' }} id=
|
|
556
|
+
<>
|
|
557
|
+
<TableContainer component={Paper} style={{ margin: '4px 0px' }} id='simple-table-manual'>
|
|
486
558
|
{propsToUse.label && (
|
|
487
559
|
<h3 className={classes.label}>
|
|
488
560
|
{propsToUse.label} {results()}
|
|
@@ -502,13 +574,9 @@ export default function SimpleTableManual(props) {
|
|
|
502
574
|
onClick={createSortHandler(displayedColumns[index])}
|
|
503
575
|
>
|
|
504
576
|
{field.label}
|
|
505
|
-
{_showFilteredIcon(field.name) &&
|
|
506
|
-
<FilterListIcon className={classes.moreIcon} />
|
|
507
|
-
)}
|
|
577
|
+
{_showFilteredIcon(field.name) && <FilterListIcon className={classes.moreIcon} />}
|
|
508
578
|
{orderBy === displayedColumns[index] ? (
|
|
509
|
-
<span className={classes.visuallyHidden}>
|
|
510
|
-
{order === 'desc' ? 'sorted descending' : 'sorted ascending'}
|
|
511
|
-
</span>
|
|
579
|
+
<span className={classes.visuallyHidden}>{order === 'desc' ? 'sorted descending' : 'sorted ascending'}</span>
|
|
512
580
|
) : null}
|
|
513
581
|
</TableSortLabel>
|
|
514
582
|
<MoreIcon
|
|
@@ -547,34 +615,48 @@ export default function SimpleTableManual(props) {
|
|
|
547
615
|
type='button'
|
|
548
616
|
className='psdk-utility-button'
|
|
549
617
|
id='delete-button'
|
|
550
|
-
|
|
618
|
+
aria-label='Delete Cell'
|
|
619
|
+
onClick={() => deleteRecord()}
|
|
551
620
|
>
|
|
552
|
-
<img
|
|
553
|
-
className='psdk-utility-card-action-svg-icon'
|
|
554
|
-
src={menuIconOverride$}
|
|
555
|
-
></img>
|
|
621
|
+
<img className='psdk-utility-card-action-svg-icon' src={menuIconOverride$} />
|
|
556
622
|
</button>
|
|
557
623
|
</TableCell>
|
|
558
624
|
)}
|
|
559
625
|
</TableRow>
|
|
560
626
|
);
|
|
561
627
|
})}
|
|
562
|
-
{readOnlyMode &&
|
|
628
|
+
{(readOnlyMode || allowEditingInModal) &&
|
|
563
629
|
rowData &&
|
|
564
630
|
rowData.length > 0 &&
|
|
565
631
|
stableSort(rowData, getComparator(order, orderBy))
|
|
566
632
|
.slice(0)
|
|
567
|
-
.map(row => {
|
|
633
|
+
.map((row, index) => {
|
|
568
634
|
return (
|
|
569
635
|
<TableRow key={row[displayedColumns[0]]}>
|
|
570
636
|
{displayedColumns.map(colKey => {
|
|
571
637
|
return (
|
|
572
638
|
<TableCell key={colKey} className={classes.tableCell}>
|
|
573
|
-
{
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
639
|
+
{showDeleteButton && colKey === 'DeleteIcon' ? (
|
|
640
|
+
<div>
|
|
641
|
+
<MoreIcon
|
|
642
|
+
id='table-edit-menu-icon'
|
|
643
|
+
className={classes.moreIcon}
|
|
644
|
+
onClick={event => {
|
|
645
|
+
editMenuClick(event, index);
|
|
646
|
+
}}
|
|
647
|
+
/>
|
|
648
|
+
<Menu id='table-edit-menu' anchorEl={editAnchorEl} keepMounted open={Boolean(editAnchorEl)} onClose={_menuClose}>
|
|
649
|
+
<MenuItem onClick={() => editRecord()}>Edit</MenuItem>
|
|
650
|
+
<MenuItem onClick={() => deleteRecord()}>Delete</MenuItem>
|
|
651
|
+
</Menu>
|
|
652
|
+
</div>
|
|
653
|
+
) : typeof row[colKey] === 'boolean' && !row[colKey] ? (
|
|
654
|
+
'False'
|
|
655
|
+
) : typeof row[colKey] === 'boolean' && row[colKey] ? (
|
|
656
|
+
'True'
|
|
657
|
+
) : (
|
|
658
|
+
row[colKey]
|
|
659
|
+
)}
|
|
578
660
|
</TableCell>
|
|
579
661
|
);
|
|
580
662
|
})}
|
|
@@ -601,13 +683,7 @@ export default function SimpleTableManual(props) {
|
|
|
601
683
|
</Link>
|
|
602
684
|
</div>
|
|
603
685
|
)}
|
|
604
|
-
<Menu
|
|
605
|
-
id='simple-menu'
|
|
606
|
-
anchorEl={anchorEl}
|
|
607
|
-
keepMounted
|
|
608
|
-
open={Boolean(anchorEl)}
|
|
609
|
-
onClose={_menuClose}
|
|
610
|
-
>
|
|
686
|
+
<Menu id='simple-menu' anchorEl={anchorEl} keepMounted open={Boolean(anchorEl)} onClose={_menuClose}>
|
|
611
687
|
<MenuItem onClick={_filterMenu}>
|
|
612
688
|
<FilterListIcon /> Filter
|
|
613
689
|
</MenuItem>
|
|
@@ -664,12 +740,7 @@ export default function SimpleTableManual(props) {
|
|
|
664
740
|
</>
|
|
665
741
|
) : (
|
|
666
742
|
<>
|
|
667
|
-
<Select
|
|
668
|
-
id='filter'
|
|
669
|
-
fullWidth
|
|
670
|
-
onChange={_dialogContainsFilter}
|
|
671
|
-
value={displayDialogContainsFilter}
|
|
672
|
-
>
|
|
743
|
+
<Select id='filter' fullWidth onChange={_dialogContainsFilter} value={displayDialogContainsFilter}>
|
|
673
744
|
<MenuItem value='contains'>Contains</MenuItem>
|
|
674
745
|
<MenuItem value='equals'>Equals</MenuItem>
|
|
675
746
|
<MenuItem value='startswith'>Starts with</MenuItem>
|
|
@@ -695,6 +766,6 @@ export default function SimpleTableManual(props) {
|
|
|
695
766
|
</Button>
|
|
696
767
|
</DialogActions>
|
|
697
768
|
</Dialog>
|
|
698
|
-
|
|
769
|
+
</>
|
|
699
770
|
);
|
|
700
771
|
}
|
|
@@ -1,21 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { getComponentFromMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
|
|
2
|
+
|
|
3
|
+
import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
|
|
4
|
+
|
|
5
|
+
interface SimpleTableSelectProps extends PConnProps {
|
|
6
|
+
// If any, enter additional props that only exist on this component
|
|
7
|
+
label: string;
|
|
8
|
+
referenceList: object[] | string;
|
|
9
|
+
renderMode: string;
|
|
10
|
+
showLabel: boolean;
|
|
11
|
+
promptedFilters: object[];
|
|
12
|
+
viewName: string;
|
|
13
|
+
parameters: any;
|
|
14
|
+
readonlyContextList: object[] | string;
|
|
15
|
+
dataRelationshipContext: string;
|
|
16
|
+
}
|
|
7
17
|
|
|
8
18
|
const isSelfReferencedProperty = (param, referenceProp) => {
|
|
9
19
|
const [, parentPropName] = param.split('.');
|
|
10
20
|
return parentPropName === referenceProp;
|
|
11
21
|
};
|
|
12
|
-
|
|
22
|
+
|
|
13
23
|
/**
|
|
14
24
|
* SimpleTable react component
|
|
15
25
|
* @param {*} props - props
|
|
16
26
|
*/
|
|
17
|
-
export default function SimpleTableSelect(props) {
|
|
18
|
-
|
|
27
|
+
export default function SimpleTableSelect(props: SimpleTableSelectProps) {
|
|
28
|
+
// Get emitted components from map (so we can get any override that may exist)
|
|
29
|
+
const ListView = getComponentFromMap('ListView');
|
|
30
|
+
const SimpleTable = getComponentFromMap('SimpleTable');
|
|
31
|
+
const PromotedFilters = getComponentFromMap('PromotedFilters');
|
|
32
|
+
|
|
33
|
+
const { label, getPConnect, renderMode = '', showLabel = true, viewName = '', parameters, dataRelationshipContext = null } = props;
|
|
19
34
|
|
|
20
35
|
const propsToUse = { label, showLabel, ...getPConnect().getInheritedProps() };
|
|
21
36
|
if (propsToUse.showLabel === false) {
|
|
@@ -24,7 +39,7 @@ export default function SimpleTableSelect(props) {
|
|
|
24
39
|
|
|
25
40
|
const pConn = getPConnect();
|
|
26
41
|
const { MULTI } = PCore.getConstants().LIST_SELECTION_MODE;
|
|
27
|
-
const { selectionMode, selectionList } = pConn.getConfigProps();
|
|
42
|
+
const { selectionMode, selectionList } = pConn.getConfigProps() as any;
|
|
28
43
|
const isMultiSelectMode = selectionMode === MULTI;
|
|
29
44
|
|
|
30
45
|
if (isMultiSelectMode && renderMode === 'ReadOnly') {
|
|
@@ -34,20 +49,23 @@ export default function SimpleTableSelect(props) {
|
|
|
34
49
|
const pageReference = pConn.getPageReference();
|
|
35
50
|
let referenceProp = isMultiSelectMode ? selectionList.substring(1) : pageReference.substring(pageReference.lastIndexOf('.') + 1);
|
|
36
51
|
// Replace here to use the context name instead
|
|
37
|
-
let contextPageReference = null;
|
|
52
|
+
let contextPageReference: string | null = null;
|
|
38
53
|
if (props.dataRelationshipContext !== null && selectionMode === 'single') {
|
|
39
54
|
referenceProp = dataRelationshipContext;
|
|
40
55
|
contextPageReference = pageReference.concat('.').concat(referenceProp);
|
|
41
56
|
}
|
|
42
57
|
|
|
58
|
+
// Need to get this written so typedefs work
|
|
43
59
|
const { datasource: { parameters: fieldParameters = {} } = {}, pageClass } = isMultiSelectMode
|
|
44
|
-
?
|
|
45
|
-
|
|
60
|
+
? // @ts-ignore - Property 'getFieldMetadata' is private and only accessible within class 'C11nEnv'.
|
|
61
|
+
pConn.getFieldMetadata(`@P .${referenceProp}`)
|
|
62
|
+
: // @ts-ignore - Property 'getCurrentPageFieldMetadata' is private and only accessible within class 'C11nEnv'.
|
|
63
|
+
pConn.getCurrentPageFieldMetadata(contextPageReference);
|
|
46
64
|
|
|
47
|
-
const compositeKeys:
|
|
65
|
+
const compositeKeys: any[] = [];
|
|
48
66
|
Object.values(fieldParameters).forEach((param: any) => {
|
|
49
67
|
if (isSelfReferencedProperty(param, referenceProp)) {
|
|
50
|
-
|
|
68
|
+
compositeKeys.push(param.substring(param.lastIndexOf('.') + 1));
|
|
51
69
|
}
|
|
52
70
|
});
|
|
53
71
|
|
|
@@ -86,7 +104,7 @@ export default function SimpleTableSelect(props) {
|
|
|
86
104
|
parameters
|
|
87
105
|
};
|
|
88
106
|
|
|
89
|
-
const filters = getPConnect().getRawMetadata().config.promotedFilters ?? [];
|
|
107
|
+
const filters = (getPConnect().getRawMetadata() as any).config.promotedFilters ?? [];
|
|
90
108
|
|
|
91
109
|
const isSearchable = filters.length > 0;
|
|
92
110
|
|
|
@@ -104,27 +122,3 @@ export default function SimpleTableSelect(props) {
|
|
|
104
122
|
}
|
|
105
123
|
return <ListView {...listViewProps} />;
|
|
106
124
|
}
|
|
107
|
-
|
|
108
|
-
SimpleTableSelect.defaultProps = {
|
|
109
|
-
label: undefined,
|
|
110
|
-
renderMode: '',
|
|
111
|
-
showLabel: true,
|
|
112
|
-
promptedFilters: [],
|
|
113
|
-
viewName: '',
|
|
114
|
-
parameters: undefined,
|
|
115
|
-
readonlyContextList: [],
|
|
116
|
-
dataRelationshipContext: null
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
SimpleTableSelect.propTypes = {
|
|
120
|
-
label: PropTypes.string,
|
|
121
|
-
getPConnect: PropTypes.func.isRequired,
|
|
122
|
-
referenceList: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.string]).isRequired,
|
|
123
|
-
renderMode: PropTypes.string,
|
|
124
|
-
showLabel: PropTypes.bool,
|
|
125
|
-
promptedFilters: PropTypes.arrayOf(PropTypes.object),
|
|
126
|
-
viewName: PropTypes.string,
|
|
127
|
-
parameters: PropTypes.objectOf(PropTypes.any),
|
|
128
|
-
readonlyContextList: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.object), PropTypes.string]),
|
|
129
|
-
dataRelationshipContext: PropTypes.string
|
|
130
|
-
};
|