@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,12 +1,10 @@
|
|
|
1
1
|
/* eslint-disable no-plusplus */
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import React, { useState, useEffect, useRef } from 'react';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
7
|
import { createStyles, makeStyles, Theme } from '@material-ui/core/styles';
|
|
9
|
-
import { Utils } from '@pega/react-sdk-components/lib/components/helpers/utils';
|
|
10
8
|
import Table from '@material-ui/core/Table';
|
|
11
9
|
import TableBody from '@material-ui/core/TableBody';
|
|
12
10
|
import TableCell from '@material-ui/core/TableCell';
|
|
@@ -37,15 +35,37 @@ import IconButton from '@material-ui/core/IconButton';
|
|
|
37
35
|
import CloseIcon from '@material-ui/icons/Close';
|
|
38
36
|
import { Radio } from '@material-ui/core';
|
|
39
37
|
import Checkbox from '@material-ui/core/Checkbox';
|
|
38
|
+
|
|
40
39
|
import { filterData } from '@pega/react-sdk-components/lib/components/helpers/simpleTableHelpers';
|
|
40
|
+
|
|
41
41
|
import './ListView.css';
|
|
42
|
-
import
|
|
42
|
+
import { getDateFormatInfo } from '@pega/react-sdk-components/lib/components/helpers/date-format-utils';
|
|
43
|
+
import { getCurrencyOptions } from '@pega/react-sdk-components/lib/components/field/Currency/currency-utils';
|
|
44
|
+
import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
|
|
45
|
+
|
|
46
|
+
import useInit from './hooks';
|
|
47
|
+
import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
|
|
48
|
+
|
|
49
|
+
interface ListViewProps extends PConnProps {
|
|
50
|
+
// If any, enter additional props that only exist on this component
|
|
51
|
+
bInForm?: boolean;
|
|
52
|
+
globalSearch?: boolean;
|
|
53
|
+
referenceList?: any[];
|
|
54
|
+
// rowClickAction?: any;
|
|
55
|
+
selectionMode?: string;
|
|
56
|
+
referenceType?: string;
|
|
57
|
+
payload?: any;
|
|
58
|
+
parameters?: any;
|
|
59
|
+
compositeKeys?: any;
|
|
60
|
+
showDynamicFields?: boolean;
|
|
61
|
+
readonlyContextList?: any;
|
|
62
|
+
value: any;
|
|
63
|
+
}
|
|
43
64
|
|
|
44
65
|
const SELECTION_MODE = { SINGLE: 'single', MULTI: 'multi' };
|
|
45
|
-
declare const PCore: any;
|
|
46
66
|
|
|
47
|
-
let myRows:
|
|
48
|
-
let myDisplayColumnList:
|
|
67
|
+
let myRows: any[];
|
|
68
|
+
let myDisplayColumnList: any[];
|
|
49
69
|
|
|
50
70
|
let menuColumnId = '';
|
|
51
71
|
let menuColumnType = '';
|
|
@@ -53,11 +73,23 @@ let menuColumnLabel = '';
|
|
|
53
73
|
|
|
54
74
|
let sortColumnId: any;
|
|
55
75
|
|
|
56
|
-
const filterByColumns:
|
|
57
|
-
|
|
58
|
-
export default function ListView(props) {
|
|
59
|
-
const { getPConnect, bInForm } = props;
|
|
60
|
-
const {
|
|
76
|
+
const filterByColumns: any[] = [];
|
|
77
|
+
|
|
78
|
+
export default function ListView(props: ListViewProps) {
|
|
79
|
+
const { getPConnect, bInForm = true } = props;
|
|
80
|
+
const {
|
|
81
|
+
globalSearch,
|
|
82
|
+
referenceList,
|
|
83
|
+
/* rowClickAction, */
|
|
84
|
+
selectionMode,
|
|
85
|
+
referenceType,
|
|
86
|
+
payload,
|
|
87
|
+
parameters,
|
|
88
|
+
compositeKeys,
|
|
89
|
+
showDynamicFields,
|
|
90
|
+
readonlyContextList: selectedValues,
|
|
91
|
+
value
|
|
92
|
+
} = props;
|
|
61
93
|
const ref = useRef({}).current;
|
|
62
94
|
const cosmosTableRef = useRef();
|
|
63
95
|
// List component context
|
|
@@ -66,11 +98,19 @@ export default function ListView(props) {
|
|
|
66
98
|
const xRayApis = PCore.getDebugger().getXRayRuntime();
|
|
67
99
|
const xRayUid = xRayApis.startXRay();
|
|
68
100
|
|
|
69
|
-
useInit({
|
|
101
|
+
useInit({
|
|
102
|
+
...props,
|
|
103
|
+
setListContext,
|
|
104
|
+
ref,
|
|
105
|
+
showDynamicFields,
|
|
106
|
+
xRayUid,
|
|
107
|
+
cosmosTableRef
|
|
108
|
+
});
|
|
70
109
|
|
|
71
110
|
const thePConn = getPConnect();
|
|
111
|
+
// @ts-ignore - Property 'getComponentConfig' is private and only accessible within class 'C11nEnv'.
|
|
72
112
|
const componentConfig = thePConn.getComponentConfig();
|
|
73
|
-
const resolvedConfigProps = thePConn.getConfigProps();
|
|
113
|
+
const resolvedConfigProps: any = thePConn.getConfigProps() as ListViewProps;
|
|
74
114
|
|
|
75
115
|
/** By default, pyGUID is used for Data classes and pyID is for Work classes as row-id/key */
|
|
76
116
|
const defRowID = referenceType === 'Case' ? 'pyID' : 'pyGUID';
|
|
@@ -78,9 +118,9 @@ export default function ListView(props) {
|
|
|
78
118
|
/** If compositeKeys is defined, use dynamic value, else fallback to pyID or pyGUID. */
|
|
79
119
|
const rowID = compositeKeys && compositeKeys?.length === 1 ? compositeKeys[0] : defRowID;
|
|
80
120
|
|
|
81
|
-
const [arRows, setRows] = useState<
|
|
82
|
-
const [arColumns, setColumns] = useState<
|
|
83
|
-
const [response, setResponse] = useState<
|
|
121
|
+
const [arRows, setRows] = useState<any[]>([]);
|
|
122
|
+
const [arColumns, setColumns] = useState<any[]>([]);
|
|
123
|
+
const [response, setResponse] = useState<any[]>([]);
|
|
84
124
|
|
|
85
125
|
const [order, setOrder] = useState<Order>('asc');
|
|
86
126
|
const [orderBy, setOrderBy] = useState<keyof any>('');
|
|
@@ -91,19 +131,19 @@ export default function ListView(props) {
|
|
|
91
131
|
const [showSnackbar, setShowSnackbar] = useState(false);
|
|
92
132
|
const [snackbarMessage, setSnackbarMessage] = useState('');
|
|
93
133
|
|
|
94
|
-
const [selectedValue, setSelectedValue] = useState(
|
|
134
|
+
const [selectedValue, setSelectedValue] = useState(value);
|
|
95
135
|
|
|
96
136
|
// This basically will hold the list of all current filters
|
|
97
137
|
const filters = useRef({});
|
|
98
138
|
|
|
99
139
|
// Will contain the list of columns specific for an instance
|
|
100
|
-
|
|
101
|
-
|
|
140
|
+
const columnList: any = useRef([]);
|
|
141
|
+
const filterPayload: any = useRef();
|
|
102
142
|
// Will be sent in the dashboardFilterPayload
|
|
103
|
-
let selectParam:
|
|
143
|
+
let selectParam: any[] = [];
|
|
104
144
|
|
|
105
145
|
// dataview parameters coming from the ListPage
|
|
106
|
-
// This constant will also be used for parameters coming from from other components/utility
|
|
146
|
+
// This constant will also be used for parameters coming from from other components/utility functions in future
|
|
107
147
|
const dataViewParameters = parameters;
|
|
108
148
|
|
|
109
149
|
const useStyles = makeStyles((theme: Theme) =>
|
|
@@ -182,15 +222,11 @@ export default function ListView(props) {
|
|
|
182
222
|
function getComparator<Key extends keyof any>(
|
|
183
223
|
theOrder: Order,
|
|
184
224
|
orderedBy: Key
|
|
185
|
-
// eslint-disable-next-line no-unused-vars
|
|
186
225
|
): (a: { [key in Key]: number | string }, b: { [key in Key]: number | string }) => number {
|
|
187
|
-
return theOrder === 'desc'
|
|
188
|
-
? (a, b) => descendingComparator(a, b, orderedBy)
|
|
189
|
-
: (a, b) => -descendingComparator(a, b, orderedBy);
|
|
226
|
+
return theOrder === 'desc' ? (a, b) => descendingComparator(a, b, orderedBy) : (a, b) => -descendingComparator(a, b, orderedBy);
|
|
190
227
|
}
|
|
191
228
|
|
|
192
|
-
|
|
193
|
-
function stableSort<T>(array: Array<T>, comparator: (a: T, b: T) => number) {
|
|
229
|
+
function stableSort<T>(array: T[], comparator: (a: T, b: T) => number) {
|
|
194
230
|
const stabilizedThis = array.map((el, index) => [el, index] as [T, number]);
|
|
195
231
|
stabilizedThis.sort((a, b) => {
|
|
196
232
|
const order = comparator(a[0], b[0]);
|
|
@@ -213,8 +249,8 @@ export default function ListView(props) {
|
|
|
213
249
|
};
|
|
214
250
|
|
|
215
251
|
const AssignDashObjects = ['Assign-Worklist', 'Assign-WorkBasket'];
|
|
216
|
-
function getHeaderCells(colFields, fields
|
|
217
|
-
|
|
252
|
+
function getHeaderCells(colFields, fields) {
|
|
253
|
+
return colFields.map((field: any, index) => {
|
|
218
254
|
let theField = field.config.value.substring(field.config.value.indexOf(' ') + 1);
|
|
219
255
|
if (theField.indexOf('.') === 0) {
|
|
220
256
|
theField = theField.substring(1);
|
|
@@ -222,17 +258,12 @@ export default function ListView(props) {
|
|
|
222
258
|
const colIndex = fields.findIndex(ele => ele.name === theField);
|
|
223
259
|
const displayAsLink = field.config.displayAsLink;
|
|
224
260
|
const headerRow: any = {};
|
|
225
|
-
headerRow.id =
|
|
261
|
+
headerRow.id = fields[index].id;
|
|
226
262
|
headerRow.type = field.type;
|
|
227
263
|
headerRow.displayAsLink = displayAsLink;
|
|
228
|
-
headerRow.numeric =
|
|
229
|
-
field.type === 'Decimal' ||
|
|
230
|
-
field.type === 'Integer' ||
|
|
231
|
-
field.type === 'Percentage' ||
|
|
232
|
-
field.type === 'Currency' ||
|
|
233
|
-
false;
|
|
264
|
+
headerRow.numeric = field.type === 'Decimal' || field.type === 'Integer' || field.type === 'Percentage' || field.type === 'Currency' || false;
|
|
234
265
|
headerRow.disablePadding = false;
|
|
235
|
-
headerRow.label =
|
|
266
|
+
headerRow.label = fields[index].label;
|
|
236
267
|
if (colIndex > -1) {
|
|
237
268
|
headerRow.classID = fields[colIndex].classID;
|
|
238
269
|
}
|
|
@@ -244,19 +275,9 @@ export default function ListView(props) {
|
|
|
244
275
|
}
|
|
245
276
|
return headerRow;
|
|
246
277
|
});
|
|
247
|
-
return arReturn;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function updateFields(arFields, theColumns): Array<any> {
|
|
251
|
-
const arReturn = arFields.filter(ele => ele.type !== 'reference');
|
|
252
|
-
arReturn.forEach((field, index) => {
|
|
253
|
-
arReturn[index].config.name = theColumns[index].id;
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
return arReturn;
|
|
257
278
|
}
|
|
258
279
|
|
|
259
|
-
function getUsingData(arTableData):
|
|
280
|
+
function getUsingData(arTableData): any[] {
|
|
260
281
|
if (selectionMode === SELECTION_MODE.SINGLE || selectionMode === SELECTION_MODE.MULTI) {
|
|
261
282
|
const record = arTableData?.length > 0 ? arTableData[0] : '';
|
|
262
283
|
if (typeof record === 'object' && !('pyGUID' in record) && !('pyID' in record)) {
|
|
@@ -264,64 +285,13 @@ export default function ListView(props) {
|
|
|
264
285
|
console.error('pyGUID or pyID values are mandatory to select the required row from the list');
|
|
265
286
|
}
|
|
266
287
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const row = data;
|
|
270
|
-
|
|
271
|
-
return row;
|
|
272
|
-
});
|
|
273
|
-
|
|
274
|
-
return arReturn;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function updateData(listData: Array<any>, fieldData: Array<any>): Array<any> {
|
|
278
|
-
const returnList: Array<any> = new Array<any>();
|
|
279
|
-
listData?.forEach(row => {
|
|
280
|
-
// copy
|
|
281
|
-
const rowData = JSON.parse(JSON.stringify(row));
|
|
282
|
-
|
|
283
|
-
fieldData.forEach(field => {
|
|
284
|
-
const config = field.config;
|
|
285
|
-
let fieldName;
|
|
286
|
-
let formattedDate;
|
|
287
|
-
let myFormat;
|
|
288
|
-
|
|
289
|
-
switch (field.type) {
|
|
290
|
-
case 'Date':
|
|
291
|
-
fieldName = config.name;
|
|
292
|
-
myFormat = config.formatter;
|
|
293
|
-
if (!myFormat) {
|
|
294
|
-
myFormat = 'Date';
|
|
295
|
-
}
|
|
296
|
-
formattedDate = Utils.generateDate(rowData[fieldName], myFormat);
|
|
297
|
-
|
|
298
|
-
rowData[fieldName] = formattedDate;
|
|
299
|
-
break;
|
|
300
|
-
|
|
301
|
-
case 'DateTime':
|
|
302
|
-
fieldName = config.name;
|
|
303
|
-
myFormat = config.formatter;
|
|
304
|
-
if (!myFormat) {
|
|
305
|
-
myFormat = 'DateTime-Long';
|
|
306
|
-
}
|
|
307
|
-
formattedDate = Utils.generateDateTime(rowData[fieldName], myFormat);
|
|
308
|
-
|
|
309
|
-
rowData[fieldName] = formattedDate;
|
|
310
|
-
break;
|
|
311
|
-
|
|
312
|
-
default:
|
|
313
|
-
break;
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
returnList.push(rowData);
|
|
288
|
+
return arTableData?.map((data: any) => {
|
|
289
|
+
return data;
|
|
318
290
|
});
|
|
319
|
-
|
|
320
|
-
return returnList;
|
|
321
291
|
}
|
|
322
292
|
|
|
323
|
-
function getMyColumnList(arCols:
|
|
324
|
-
const myColList:
|
|
293
|
+
function getMyColumnList(arCols: any[]): string[] {
|
|
294
|
+
const myColList: string[] = [];
|
|
325
295
|
|
|
326
296
|
arCols.forEach(col => {
|
|
327
297
|
myColList.push(col.id);
|
|
@@ -344,7 +314,7 @@ export default function ListView(props) {
|
|
|
344
314
|
// Will be triggered when EVENT_DASHBOARD_FILTER_CHANGE fires
|
|
345
315
|
function processFilterChange(data) {
|
|
346
316
|
const { filterId, filterExpression } = data;
|
|
347
|
-
dashboardFilterPayload = {
|
|
317
|
+
let dashboardFilterPayload: any = {
|
|
348
318
|
query: {
|
|
349
319
|
filter: {},
|
|
350
320
|
select: []
|
|
@@ -352,22 +322,21 @@ export default function ListView(props) {
|
|
|
352
322
|
};
|
|
353
323
|
|
|
354
324
|
filters.current[filterId] = filterExpression;
|
|
355
|
-
|
|
356
|
-
let isDateRange = data.filterExpression?.AND ? true : false;
|
|
325
|
+
let isDateRange = data.filterExpression?.AND;
|
|
357
326
|
// Will be AND by default but making it dynamic in case we support dynamic relational ops in future
|
|
358
327
|
const relationalOp = 'AND';
|
|
359
328
|
|
|
360
329
|
let field = getFieldFromFilter(filterExpression, isDateRange);
|
|
361
330
|
selectParam = [];
|
|
362
331
|
// Constructing the select parameters list (will be sent in dashboardFilterPayload)
|
|
363
|
-
columnList.forEach(col => {
|
|
332
|
+
columnList.current.forEach(col => {
|
|
364
333
|
selectParam.push({
|
|
365
334
|
field: col
|
|
366
335
|
});
|
|
367
336
|
});
|
|
368
337
|
|
|
369
338
|
// Checking if the triggered filter is applicable for this list
|
|
370
|
-
if (data.filterExpression !== null && !(columnList.length && columnList.includes(field))) {
|
|
339
|
+
if (data.filterExpression !== null && !(columnList.current?.length && columnList.current?.includes(field))) {
|
|
371
340
|
return;
|
|
372
341
|
}
|
|
373
342
|
// This is a flag which will be used to reset dashboardFilterPayload in case we don't find any valid filters
|
|
@@ -375,7 +344,7 @@ export default function ListView(props) {
|
|
|
375
344
|
|
|
376
345
|
let index = 1;
|
|
377
346
|
// Iterating over the current filters list to create filter data which will be POSTed
|
|
378
|
-
for (const filterExp
|
|
347
|
+
for (const filterExp of Object.keys(filters.current)) {
|
|
379
348
|
const filter = filters.current[filterExp];
|
|
380
349
|
// If the filter is null then we can skip this iteration
|
|
381
350
|
if (filter === null) {
|
|
@@ -384,11 +353,10 @@ export default function ListView(props) {
|
|
|
384
353
|
}
|
|
385
354
|
|
|
386
355
|
// Checking if the filter is of type- Date Range
|
|
387
|
-
|
|
388
|
-
isDateRange = filter?.AND ? true : false;
|
|
356
|
+
isDateRange = filter?.AND;
|
|
389
357
|
field = getFieldFromFilter(filter, isDateRange);
|
|
390
358
|
|
|
391
|
-
if (!(columnList.length && columnList.includes(field))) {
|
|
359
|
+
if (!(columnList.current.length && columnList.current.includes(field))) {
|
|
392
360
|
// eslint-disable-next-line no-continue
|
|
393
361
|
continue;
|
|
394
362
|
}
|
|
@@ -396,7 +364,7 @@ export default function ListView(props) {
|
|
|
396
364
|
validFilter = true;
|
|
397
365
|
/** Below are the 2 cases for- Text & Date-Range filter types where we'll construct filter data which will be sent in the dashboardFilterPayload
|
|
398
366
|
* In Constellation DX Components, through Repeating Structures they might be using several APIs to do it. We're doing it here
|
|
399
|
-
|
|
367
|
+
*/
|
|
400
368
|
if (isDateRange) {
|
|
401
369
|
const dateRelationalOp = filter?.AND ? 'AND' : 'OR';
|
|
402
370
|
dashboardFilterPayload.query.filter.filterConditions = {
|
|
@@ -420,9 +388,7 @@ export default function ListView(props) {
|
|
|
420
388
|
};
|
|
421
389
|
|
|
422
390
|
if (dashboardFilterPayload.query.filter.logic) {
|
|
423
|
-
dashboardFilterPayload.query.filter.logic = `${dashboardFilterPayload.query.filter.logic} ${relationalOp} T${
|
|
424
|
-
index - 1
|
|
425
|
-
}`;
|
|
391
|
+
dashboardFilterPayload.query.filter.logic = `${dashboardFilterPayload.query.filter.logic} ${relationalOp} T${index - 1}`;
|
|
426
392
|
} else {
|
|
427
393
|
dashboardFilterPayload.query.filter.logic = `T${index - 1}`;
|
|
428
394
|
}
|
|
@@ -435,57 +401,39 @@ export default function ListView(props) {
|
|
|
435
401
|
if (!validFilter) {
|
|
436
402
|
dashboardFilterPayload = undefined;
|
|
437
403
|
}
|
|
438
|
-
|
|
404
|
+
filterPayload.current = dashboardFilterPayload;
|
|
439
405
|
fetchDataFromServer();
|
|
440
406
|
}
|
|
441
407
|
|
|
442
408
|
// Will be triggered when EVENT_DASHBOARD_FILTER_CLEAR_ALL fires
|
|
443
409
|
function processFilterClear() {
|
|
444
|
-
|
|
410
|
+
filterPayload.current = undefined;
|
|
445
411
|
fetchDataFromServer();
|
|
446
412
|
}
|
|
447
413
|
|
|
448
|
-
|
|
449
|
-
setTimeout(() => {
|
|
450
|
-
PCore.getPubSubUtils().subscribe(
|
|
451
|
-
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE,
|
|
452
|
-
data => {
|
|
453
|
-
processFilterChange(data);
|
|
454
|
-
},
|
|
455
|
-
`dashboard-component-${'id'}`,
|
|
456
|
-
false,
|
|
457
|
-
getPConnect().getContextName()
|
|
458
|
-
);
|
|
459
|
-
PCore.getPubSubUtils().subscribe(
|
|
460
|
-
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL,
|
|
461
|
-
() => {
|
|
462
|
-
filters.current = {};
|
|
463
|
-
processFilterClear();
|
|
464
|
-
},
|
|
465
|
-
`dashboard-component-${'id'}`,
|
|
466
|
-
false,
|
|
467
|
-
getPConnect().getContextName()
|
|
468
|
-
);
|
|
469
|
-
}, 0);
|
|
470
|
-
}, []);
|
|
471
|
-
|
|
472
|
-
function fetchAllData(fields) {
|
|
414
|
+
function fetchAllData(fields): any {
|
|
473
415
|
let query: any = null;
|
|
474
416
|
if (payload) {
|
|
475
417
|
query = payload.query;
|
|
476
418
|
} else if (fields?.length && meta.isQueryable) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
419
|
+
if (filterPayload.current) {
|
|
420
|
+
query = {
|
|
421
|
+
select: fields,
|
|
422
|
+
filter: filterPayload.current?.query?.filter
|
|
423
|
+
};
|
|
424
|
+
} else {
|
|
425
|
+
query = { select: fields };
|
|
426
|
+
}
|
|
427
|
+
} else if (filterPayload.current) {
|
|
428
|
+
query = filterPayload.current?.query;
|
|
480
429
|
}
|
|
481
430
|
const context = getPConnect().getContextName();
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
context
|
|
485
|
-
|
|
486
|
-
null
|
|
487
|
-
|
|
488
|
-
);
|
|
431
|
+
// getDataAsync isn't returning correct data for the Page(i.e. ListView within a page) case
|
|
432
|
+
return !bInForm
|
|
433
|
+
? // @ts-ignore - 3rd parameter "context" should be optional in getData method
|
|
434
|
+
PCore.getDataApiUtils().getData(referenceList, payload)
|
|
435
|
+
: // @ts-ignore - Argument of type 'null' is not assignable to parameter of type 'object'
|
|
436
|
+
PCore.getDataPageUtils().getDataAsync(referenceList, context, payload ? payload.dataViewParameters : dataViewParameters, null, query);
|
|
489
437
|
}
|
|
490
438
|
|
|
491
439
|
const buildSelect = (fieldDefs, colId, patchQueryFields = [], compositeKeys = []) => {
|
|
@@ -524,18 +472,22 @@ export default function ListView(props) {
|
|
|
524
472
|
return listFields;
|
|
525
473
|
};
|
|
526
474
|
|
|
527
|
-
const addItemKeyInSelect = (
|
|
528
|
-
fieldDefs,
|
|
529
|
-
itemKey,
|
|
530
|
-
select,
|
|
531
|
-
compositeKeys
|
|
532
|
-
) => {
|
|
475
|
+
const addItemKeyInSelect = (fieldDefs, itemKey, select, compositeKeys) => {
|
|
533
476
|
const elementFound = getField(fieldDefs, itemKey);
|
|
534
477
|
|
|
535
|
-
if (
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
478
|
+
if (
|
|
479
|
+
itemKey &&
|
|
480
|
+
!elementFound &&
|
|
481
|
+
Array.isArray(select) &&
|
|
482
|
+
!(compositeKeys !== null && compositeKeys?.length) &&
|
|
483
|
+
!select.find(sel => sel.field === itemKey)
|
|
484
|
+
) {
|
|
485
|
+
return [
|
|
486
|
+
...select,
|
|
487
|
+
{
|
|
488
|
+
field: itemKey
|
|
489
|
+
}
|
|
490
|
+
];
|
|
539
491
|
}
|
|
540
492
|
|
|
541
493
|
return select;
|
|
@@ -561,15 +513,12 @@ export default function ListView(props) {
|
|
|
561
513
|
listFields = addItemKeyInSelect(fieldDefs, itemKey, listFields, compositeKeys);
|
|
562
514
|
const workListJSON = await fetchAllData(listFields);
|
|
563
515
|
|
|
564
|
-
// don't update these fields until we return from promise
|
|
565
|
-
let fields = presets[0].children[0].children;
|
|
566
|
-
|
|
567
516
|
// this is an unresovled version of this.fields$, need unresolved, so can get the property reference
|
|
568
517
|
const columnFields = componentConfig.presets[0].children[0].children;
|
|
569
518
|
|
|
570
|
-
const tableDataResults = workListJSON
|
|
519
|
+
const tableDataResults = !bInForm ? workListJSON.data.data : workListJSON.data;
|
|
571
520
|
|
|
572
|
-
const myColumns = getHeaderCells(columnFields, fieldDefs
|
|
521
|
+
const myColumns = getHeaderCells(columnFields, fieldDefs);
|
|
573
522
|
|
|
574
523
|
const selectParams: any = [];
|
|
575
524
|
|
|
@@ -585,16 +534,14 @@ export default function ListView(props) {
|
|
|
585
534
|
colList.push(col.field);
|
|
586
535
|
});
|
|
587
536
|
|
|
588
|
-
columnList = colList;
|
|
589
|
-
|
|
590
|
-
fields = updateFields(fields, myColumns);
|
|
537
|
+
columnList.current = colList;
|
|
591
538
|
|
|
592
539
|
setResponse(tableDataResults);
|
|
593
540
|
|
|
594
541
|
const usingDataResults = getUsingData(tableDataResults);
|
|
595
542
|
|
|
596
543
|
// store globally, so can be searched, filtered, etc.
|
|
597
|
-
myRows =
|
|
544
|
+
myRows = usingDataResults;
|
|
598
545
|
myDisplayColumnList = getMyColumnList(myColumns);
|
|
599
546
|
|
|
600
547
|
// At this point, if we have data ready to render and haven't been asked
|
|
@@ -618,13 +565,47 @@ export default function ListView(props) {
|
|
|
618
565
|
useEffect(() => {
|
|
619
566
|
if (listContext.meta) {
|
|
620
567
|
fetchDataFromServer();
|
|
568
|
+
setTimeout(() => {
|
|
569
|
+
PCore.getPubSubUtils().subscribe(
|
|
570
|
+
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE,
|
|
571
|
+
data => {
|
|
572
|
+
processFilterChange(data);
|
|
573
|
+
},
|
|
574
|
+
`dashboard-component-${'id'}`,
|
|
575
|
+
false,
|
|
576
|
+
getPConnect().getContextName()
|
|
577
|
+
);
|
|
578
|
+
PCore.getPubSubUtils().subscribe(
|
|
579
|
+
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL,
|
|
580
|
+
() => {
|
|
581
|
+
filters.current = {};
|
|
582
|
+
processFilterClear();
|
|
583
|
+
},
|
|
584
|
+
`dashboard-component-${'id'}`,
|
|
585
|
+
false,
|
|
586
|
+
getPConnect().getContextName()
|
|
587
|
+
);
|
|
588
|
+
}, 0);
|
|
589
|
+
|
|
590
|
+
return function cleanupSubscriptions() {
|
|
591
|
+
PCore.getPubSubUtils().unsubscribe(
|
|
592
|
+
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE,
|
|
593
|
+
`dashboard-component-${'id'}`,
|
|
594
|
+
getPConnect().getContextName()
|
|
595
|
+
);
|
|
596
|
+
PCore.getPubSubUtils().unsubscribe(
|
|
597
|
+
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL,
|
|
598
|
+
`dashboard-component-${'id'}`,
|
|
599
|
+
getPConnect().getContextName()
|
|
600
|
+
);
|
|
601
|
+
};
|
|
621
602
|
}
|
|
622
603
|
}, [listContext]);
|
|
623
604
|
|
|
624
|
-
function searchFilter(value: string, rows:
|
|
605
|
+
function searchFilter(value: string, rows: any[]) {
|
|
625
606
|
function filterArray(el: any): boolean {
|
|
626
607
|
const bReturn = false;
|
|
627
|
-
for (const key
|
|
608
|
+
for (const key of Object.keys(el)) {
|
|
628
609
|
// only search columsn that are displayed (pzInsKey and pxRefObjectClass are added and may or may not be displayed)
|
|
629
610
|
if (myDisplayColumnList.includes(key)) {
|
|
630
611
|
let myVal = el[key];
|
|
@@ -667,7 +648,7 @@ export default function ListView(props) {
|
|
|
667
648
|
const { pxRefObjectClass, pzInsKey } = row;
|
|
668
649
|
const sTarget = thePConn.getContainerName();
|
|
669
650
|
|
|
670
|
-
const options = { containerName: sTarget };
|
|
651
|
+
const options = { containerName: sTarget, channelName: '' };
|
|
671
652
|
|
|
672
653
|
thePConn
|
|
673
654
|
.getActionsApi()
|
|
@@ -680,17 +661,17 @@ export default function ListView(props) {
|
|
|
680
661
|
});
|
|
681
662
|
}
|
|
682
663
|
|
|
683
|
-
function _rowClick(row: any) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
664
|
+
// function _rowClick(row: any) {
|
|
665
|
+
// // eslint-disable-next-line sonarjs/no-small-switch
|
|
666
|
+
// switch (rowClickAction) {
|
|
667
|
+
// case 'openAssignment':
|
|
668
|
+
// openAssignment(row);
|
|
669
|
+
// break;
|
|
689
670
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
671
|
+
// default:
|
|
672
|
+
// break;
|
|
673
|
+
// }
|
|
674
|
+
// }
|
|
694
675
|
|
|
695
676
|
function openWork(row) {
|
|
696
677
|
const { pxRefObjectKey } = row;
|
|
@@ -722,10 +703,9 @@ export default function ListView(props) {
|
|
|
722
703
|
const [filterBy, setFilterBy] = useState<string>();
|
|
723
704
|
const [containsDateOrTime, setContainsDateOrTime] = useState<boolean>(false);
|
|
724
705
|
const [filterType, setFilterType] = useState<string>('string');
|
|
725
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
706
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
726
707
|
const [displayDialogFilterName, setDisplayDialogFilterName] = useState<string>('');
|
|
727
|
-
const [displayDialogContainsFilter, setDisplayDialogContainsFilter] =
|
|
728
|
-
useState<string>('contains');
|
|
708
|
+
const [displayDialogContainsFilter, setDisplayDialogContainsFilter] = useState<string>('contains');
|
|
729
709
|
const [displayDialogContainsValue, setDisplayDialogContainsValue] = useState<string>('');
|
|
730
710
|
const [displayDialogDateFilter, setDisplayDialogDateFilter] = useState<string>('notequal');
|
|
731
711
|
const [displayDialogDateValue, setDisplayDialogDateValue] = useState<string>('');
|
|
@@ -738,11 +718,7 @@ export default function ListView(props) {
|
|
|
738
718
|
for (const filterObj of filterByColumns) {
|
|
739
719
|
if (filterObj.ref === menuColumnId) {
|
|
740
720
|
setFilterBy(menuColumnLabel);
|
|
741
|
-
if (
|
|
742
|
-
filterObj.type === 'Date' ||
|
|
743
|
-
filterObj.type === 'DateTime' ||
|
|
744
|
-
filterObj.type === 'Time'
|
|
745
|
-
) {
|
|
721
|
+
if (filterObj.type === 'Date' || filterObj.type === 'DateTime' || filterObj.type === 'Time') {
|
|
746
722
|
setContainsDateOrTime(true);
|
|
747
723
|
setFilterType(filterObj.type);
|
|
748
724
|
setDisplayDialogDateFilter(filterObj.containsFilter);
|
|
@@ -791,9 +767,9 @@ export default function ListView(props) {
|
|
|
791
767
|
|
|
792
768
|
function _showFilteredIcon(columnId) {
|
|
793
769
|
for (const filterObj of filterByColumns) {
|
|
794
|
-
if (filterObj
|
|
770
|
+
if (filterObj.ref === columnId) {
|
|
795
771
|
// eslint-disable-next-line sonarjs/prefer-single-boolean-return
|
|
796
|
-
if (filterObj
|
|
772
|
+
if (filterObj.containsFilterValue !== '') {
|
|
797
773
|
return true;
|
|
798
774
|
}
|
|
799
775
|
return false;
|
|
@@ -806,14 +782,14 @@ export default function ListView(props) {
|
|
|
806
782
|
function updateFilterWithInfo() {
|
|
807
783
|
let bFound = false;
|
|
808
784
|
for (const filterObj of filterByColumns) {
|
|
809
|
-
if (filterObj
|
|
810
|
-
filterObj
|
|
785
|
+
if (filterObj.ref === menuColumnId) {
|
|
786
|
+
filterObj.type = filterType;
|
|
811
787
|
if (containsDateOrTime) {
|
|
812
|
-
filterObj
|
|
813
|
-
filterObj
|
|
788
|
+
filterObj.containsFilter = displayDialogDateFilter;
|
|
789
|
+
filterObj.containsFilterValue = displayDialogDateValue;
|
|
814
790
|
} else {
|
|
815
|
-
filterObj
|
|
816
|
-
filterObj
|
|
791
|
+
filterObj.containsFilter = displayDialogContainsFilter;
|
|
792
|
+
filterObj.containsFilterValue = displayDialogContainsValue;
|
|
817
793
|
}
|
|
818
794
|
bFound = true;
|
|
819
795
|
break;
|
|
@@ -824,13 +800,13 @@ export default function ListView(props) {
|
|
|
824
800
|
// add in
|
|
825
801
|
const filterObj: any = {};
|
|
826
802
|
filterObj.ref = menuColumnId;
|
|
827
|
-
filterObj
|
|
803
|
+
filterObj.type = filterType;
|
|
828
804
|
if (containsDateOrTime) {
|
|
829
|
-
filterObj
|
|
830
|
-
filterObj
|
|
805
|
+
filterObj.containsFilter = displayDialogDateFilter;
|
|
806
|
+
filterObj.containsFilterValue = displayDialogDateValue;
|
|
831
807
|
} else {
|
|
832
|
-
filterObj
|
|
833
|
-
filterObj
|
|
808
|
+
filterObj.containsFilter = displayDialogContainsFilter;
|
|
809
|
+
filterObj.containsFilterValue = displayDialogContainsValue;
|
|
834
810
|
}
|
|
835
811
|
|
|
836
812
|
filterByColumns.push(filterObj);
|
|
@@ -899,7 +875,7 @@ export default function ListView(props) {
|
|
|
899
875
|
}
|
|
900
876
|
|
|
901
877
|
function _listViewClick(row, column) {
|
|
902
|
-
const name = column.id
|
|
878
|
+
const name = column.id;
|
|
903
879
|
if (column.displayAsLink) {
|
|
904
880
|
const { pxObjClass } = row;
|
|
905
881
|
let { pzInsKey } = row;
|
|
@@ -909,7 +885,8 @@ export default function ListView(props) {
|
|
|
909
885
|
}
|
|
910
886
|
if (column.isAssignmentLink) {
|
|
911
887
|
thePConn.getActionsApi().openAssignment(pzInsKey, pxObjClass, {
|
|
912
|
-
containerName: 'primary'
|
|
888
|
+
containerName: 'primary',
|
|
889
|
+
channelName: ''
|
|
913
890
|
});
|
|
914
891
|
} else {
|
|
915
892
|
thePConn.getActionsApi().openWorkByHandle(pzInsKey, pxObjClass);
|
|
@@ -928,12 +905,11 @@ export default function ListView(props) {
|
|
|
928
905
|
break;
|
|
929
906
|
}
|
|
930
907
|
}
|
|
931
|
-
|
|
932
908
|
}
|
|
933
909
|
|
|
934
910
|
function _listTitle() {
|
|
935
911
|
const defaultTitle = 'List';
|
|
936
|
-
let title = resolvedConfigProps.title
|
|
912
|
+
let title = resolvedConfigProps.title || resolvedConfigProps?.label || defaultTitle;
|
|
937
913
|
const inheritedProps = resolvedConfigProps?.inheritedProps;
|
|
938
914
|
|
|
939
915
|
// Let any title in resolvedConfigProps that isn't the default take precedence
|
|
@@ -957,35 +933,56 @@ export default function ListView(props) {
|
|
|
957
933
|
const index = response.findIndex(element => element[rowID] === value);
|
|
958
934
|
const selectedRow = response[index];
|
|
959
935
|
compositeKeys.forEach(element => {
|
|
960
|
-
reqObj[element] = selectedRow[element]
|
|
936
|
+
reqObj[element] = selectedRow[element];
|
|
961
937
|
});
|
|
962
938
|
} else {
|
|
963
939
|
reqObj[rowID] = value;
|
|
964
940
|
}
|
|
965
|
-
getPConnect()
|
|
966
|
-
?.getListActions?.()
|
|
967
|
-
?.setSelectedRows([reqObj]);
|
|
941
|
+
getPConnect()?.getListActions?.()?.setSelectedRows([reqObj]);
|
|
968
942
|
setSelectedValue(value);
|
|
969
943
|
};
|
|
970
944
|
|
|
971
945
|
const onCheckboxClick = event => {
|
|
972
946
|
const value = event?.target?.value;
|
|
973
947
|
const checked = event?.target?.checked;
|
|
974
|
-
const reqObj = {};
|
|
948
|
+
const reqObj: any = {};
|
|
975
949
|
if (compositeKeys?.length > 1) {
|
|
976
950
|
const index = response.findIndex(element => element[rowID] === value);
|
|
977
951
|
const selectedRow = response[index];
|
|
978
952
|
compositeKeys.forEach(element => {
|
|
979
|
-
reqObj[element] = selectedRow[element]
|
|
953
|
+
reqObj[element] = selectedRow[element];
|
|
980
954
|
});
|
|
981
|
-
reqObj
|
|
955
|
+
reqObj.$selected = checked;
|
|
982
956
|
} else {
|
|
983
957
|
reqObj[rowID] = value;
|
|
984
|
-
reqObj
|
|
958
|
+
reqObj.$selected = checked;
|
|
985
959
|
}
|
|
986
|
-
getPConnect()
|
|
987
|
-
|
|
988
|
-
|
|
960
|
+
getPConnect()?.getListActions()?.setSelectedRows([reqObj]);
|
|
961
|
+
};
|
|
962
|
+
|
|
963
|
+
const processColumnValue = (column, value) => {
|
|
964
|
+
let val;
|
|
965
|
+
const type = column.type;
|
|
966
|
+
let theDateFormatInfo;
|
|
967
|
+
let theFormat;
|
|
968
|
+
let theCurrencyOptions;
|
|
969
|
+
switch (type) {
|
|
970
|
+
case 'Date':
|
|
971
|
+
case 'DateTime':
|
|
972
|
+
theDateFormatInfo = getDateFormatInfo();
|
|
973
|
+
theFormat = type === 'DateTime' ? `${theDateFormatInfo.dateFormatStringLong} hh:mm a` : theDateFormatInfo.dateFormatStringLong;
|
|
974
|
+
val = format(value, column.type, { format: theFormat });
|
|
975
|
+
break;
|
|
976
|
+
|
|
977
|
+
case 'Currency':
|
|
978
|
+
theCurrencyOptions = getCurrencyOptions(PCore?.getEnvironmentInfo()?.getLocale() as string);
|
|
979
|
+
val = format(value, column.type, theCurrencyOptions);
|
|
980
|
+
break;
|
|
981
|
+
|
|
982
|
+
default:
|
|
983
|
+
val = column.format && typeof value === 'number' ? column.format(value) : value;
|
|
984
|
+
}
|
|
985
|
+
return val;
|
|
989
986
|
};
|
|
990
987
|
|
|
991
988
|
return (
|
|
@@ -1002,43 +999,35 @@ export default function ListView(props) {
|
|
|
1002
999
|
</Grid>
|
|
1003
1000
|
<Grid item>
|
|
1004
1001
|
<TextField
|
|
1005
|
-
label='Search'
|
|
1002
|
+
label={PCore.getLocaleUtils().getLocaleValue('Search', 'Search')}
|
|
1006
1003
|
fullWidth
|
|
1007
1004
|
variant='outlined'
|
|
1008
1005
|
placeholder=''
|
|
1009
1006
|
size='small'
|
|
1010
|
-
id=
|
|
1007
|
+
id='search'
|
|
1011
1008
|
onChange={_onSearch}
|
|
1012
1009
|
/>
|
|
1013
1010
|
</Grid>
|
|
1014
1011
|
</Grid>
|
|
1015
1012
|
)}
|
|
1016
1013
|
<>
|
|
1017
|
-
{bInForm ? (
|
|
1018
|
-
<TableContainer className={classes.tableInForm}>
|
|
1014
|
+
{!bInForm ? (
|
|
1015
|
+
<TableContainer id='list-view' className={classes.tableInForm}>
|
|
1019
1016
|
<Table stickyHeader aria-label='sticky table'>
|
|
1020
1017
|
<TableHead>
|
|
1021
1018
|
<TableRow>
|
|
1022
1019
|
{arColumns.map(column => {
|
|
1023
1020
|
return (
|
|
1024
|
-
<TableCell
|
|
1025
|
-
className={classes.cell}
|
|
1026
|
-
key={column.id}
|
|
1027
|
-
sortDirection={orderBy === column.id ? order : false}
|
|
1028
|
-
>
|
|
1021
|
+
<TableCell className={classes.cell} key={column.id} sortDirection={orderBy === column.id ? order : false}>
|
|
1029
1022
|
<TableSortLabel
|
|
1030
1023
|
active={orderBy === column.id}
|
|
1031
1024
|
direction={orderBy === column.id ? order : 'asc'}
|
|
1032
1025
|
onClick={createSortHandler(column.id)}
|
|
1033
1026
|
>
|
|
1034
1027
|
{column.label}
|
|
1035
|
-
{_showFilteredIcon(column.id) &&
|
|
1036
|
-
<FilterListIcon className={classes.filteredIcon} />
|
|
1037
|
-
)}
|
|
1028
|
+
{_showFilteredIcon(column.id) && <FilterListIcon className={classes.filteredIcon} />}
|
|
1038
1029
|
{orderBy === column.id ? (
|
|
1039
|
-
<span className={classes.visuallyHidden}>
|
|
1040
|
-
{order === 'desc' ? 'sorted descending' : 'sorted ascending'}
|
|
1041
|
-
</span>
|
|
1030
|
+
<span className={classes.visuallyHidden}>{order === 'desc' ? 'sorted descending' : 'sorted ascending'}</span>
|
|
1042
1031
|
) : null}
|
|
1043
1032
|
</TableSortLabel>
|
|
1044
1033
|
<MoreIcon
|
|
@@ -1057,20 +1046,11 @@ export default function ListView(props) {
|
|
|
1057
1046
|
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
|
1058
1047
|
.map(row => {
|
|
1059
1048
|
return (
|
|
1060
|
-
<TableRow
|
|
1061
|
-
key={row.pxRefObjectInsName || row.pyID}
|
|
1062
|
-
onClick={() => {
|
|
1063
|
-
_rowClick(row);
|
|
1064
|
-
}}
|
|
1065
|
-
>
|
|
1049
|
+
<TableRow key={row.pxRefObjectInsName || row.pyID}>
|
|
1066
1050
|
{arColumns.map(column => {
|
|
1067
1051
|
const value = row[column.id];
|
|
1068
1052
|
return (
|
|
1069
|
-
<TableCell
|
|
1070
|
-
key={column.id}
|
|
1071
|
-
align={column.align}
|
|
1072
|
-
className={classes.cell}
|
|
1073
|
-
>
|
|
1053
|
+
<TableCell key={column.id} align={column.align} className={classes.cell}>
|
|
1074
1054
|
{_showButton(column.id, row) || column.displayAsLink ? (
|
|
1075
1055
|
<Link
|
|
1076
1056
|
component='button'
|
|
@@ -1078,16 +1058,10 @@ export default function ListView(props) {
|
|
|
1078
1058
|
_listViewClick(row, column);
|
|
1079
1059
|
}}
|
|
1080
1060
|
>
|
|
1081
|
-
{column.format && typeof value === 'number'
|
|
1082
|
-
? column.format(value)
|
|
1083
|
-
: value}
|
|
1061
|
+
{column.format && typeof value === 'number' ? column.format(value) : value}
|
|
1084
1062
|
</Link>
|
|
1085
1063
|
) : (
|
|
1086
|
-
<>
|
|
1087
|
-
{column.format && typeof value === 'number'
|
|
1088
|
-
? column.format(value)
|
|
1089
|
-
: value}
|
|
1090
|
-
</>
|
|
1064
|
+
<>{column.format && typeof value === 'number' ? column.format(value) : value}</>
|
|
1091
1065
|
)}
|
|
1092
1066
|
</TableCell>
|
|
1093
1067
|
);
|
|
@@ -1099,19 +1073,14 @@ export default function ListView(props) {
|
|
|
1099
1073
|
</Table>
|
|
1100
1074
|
</TableContainer>
|
|
1101
1075
|
) : (
|
|
1102
|
-
<TableContainer>
|
|
1076
|
+
<TableContainer id='list-view'>
|
|
1103
1077
|
<Table>
|
|
1104
1078
|
<TableHead>
|
|
1105
1079
|
<TableRow>
|
|
1106
|
-
{(selectionMode === SELECTION_MODE.SINGLE ||
|
|
1107
|
-
selectionMode === SELECTION_MODE.MULTI) && <TableCell></TableCell>}
|
|
1080
|
+
{(selectionMode === SELECTION_MODE.SINGLE || selectionMode === SELECTION_MODE.MULTI) && <TableCell />}
|
|
1108
1081
|
{arColumns.map(column => {
|
|
1109
1082
|
return (
|
|
1110
|
-
<TableCell
|
|
1111
|
-
className={classes.cell}
|
|
1112
|
-
key={column.id}
|
|
1113
|
-
sortDirection={orderBy === column.id ? order : false}
|
|
1114
|
-
>
|
|
1083
|
+
<TableCell className={classes.cell} key={column.id} sortDirection={orderBy === column.id ? order : false}>
|
|
1115
1084
|
<TableSortLabel
|
|
1116
1085
|
active={orderBy === column.id}
|
|
1117
1086
|
direction={orderBy === column.id ? order : 'asc'}
|
|
@@ -1119,9 +1088,7 @@ export default function ListView(props) {
|
|
|
1119
1088
|
>
|
|
1120
1089
|
{column.label}
|
|
1121
1090
|
{orderBy === column.id ? (
|
|
1122
|
-
<span className={classes.visuallyHidden}>
|
|
1123
|
-
{order === 'desc' ? 'sorted descending' : 'sorted ascending'}
|
|
1124
|
-
</span>
|
|
1091
|
+
<span className={classes.visuallyHidden}>{order === 'desc' ? 'sorted descending' : 'sorted ascending'}</span>
|
|
1125
1092
|
) : null}
|
|
1126
1093
|
</TableSortLabel>
|
|
1127
1094
|
</TableCell>
|
|
@@ -1136,12 +1103,7 @@ export default function ListView(props) {
|
|
|
1136
1103
|
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
|
1137
1104
|
.map(row => {
|
|
1138
1105
|
return (
|
|
1139
|
-
<TableRow
|
|
1140
|
-
key={row[rowID]}
|
|
1141
|
-
onClick={() => {
|
|
1142
|
-
_rowClick(row);
|
|
1143
|
-
}}
|
|
1144
|
-
>
|
|
1106
|
+
<TableRow key={row[rowID]}>
|
|
1145
1107
|
{selectionMode === SELECTION_MODE.SINGLE && (
|
|
1146
1108
|
<TableCell>
|
|
1147
1109
|
<Radio
|
|
@@ -1150,28 +1112,23 @@ export default function ListView(props) {
|
|
|
1150
1112
|
name='radio-buttons'
|
|
1151
1113
|
inputProps={{ 'aria-label': 'A' }}
|
|
1152
1114
|
checked={selectedValue === row[rowID]}
|
|
1153
|
-
|
|
1115
|
+
/>
|
|
1154
1116
|
</TableCell>
|
|
1155
1117
|
)}
|
|
1156
1118
|
{selectionMode === SELECTION_MODE.MULTI && (
|
|
1157
1119
|
<TableCell>
|
|
1158
1120
|
<Checkbox
|
|
1159
1121
|
onChange={onCheckboxClick}
|
|
1122
|
+
checked={selectedValues.some(selectedValue => selectedValue[rowID] === row[rowID])}
|
|
1160
1123
|
value={row[rowID]}
|
|
1161
|
-
|
|
1124
|
+
/>
|
|
1162
1125
|
</TableCell>
|
|
1163
1126
|
)}
|
|
1164
1127
|
{arColumns.map(column => {
|
|
1165
1128
|
const value = row[column.id];
|
|
1166
1129
|
return (
|
|
1167
|
-
<TableCell
|
|
1168
|
-
|
|
1169
|
-
key={column.id}
|
|
1170
|
-
align={column.align}
|
|
1171
|
-
>
|
|
1172
|
-
{column.format && typeof value === 'number'
|
|
1173
|
-
? column.format(value)
|
|
1174
|
-
: value}
|
|
1130
|
+
<TableCell className={classes.cell} key={column.id} align={column.align}>
|
|
1131
|
+
{processColumnValue(column, value)}
|
|
1175
1132
|
</TableCell>
|
|
1176
1133
|
);
|
|
1177
1134
|
})}
|
|
@@ -1180,14 +1137,13 @@ export default function ListView(props) {
|
|
|
1180
1137
|
})}
|
|
1181
1138
|
</TableBody>
|
|
1182
1139
|
</Table>
|
|
1183
|
-
{arRows && arRows.length === 0 &&
|
|
1184
|
-
<div className='no-records'>No records found.</div>
|
|
1185
|
-
)}
|
|
1140
|
+
{arRows && arRows.length === 0 && <div className='no-records'>No records found.</div>}
|
|
1186
1141
|
</TableContainer>
|
|
1187
1142
|
)}
|
|
1188
1143
|
</>
|
|
1189
1144
|
{arRows && arRows.length > 0 && (
|
|
1190
1145
|
<TablePagination
|
|
1146
|
+
id='pagination'
|
|
1191
1147
|
rowsPerPageOptions={[10, 25, 100]}
|
|
1192
1148
|
component='div'
|
|
1193
1149
|
count={arRows.length}
|
|
@@ -1199,13 +1155,7 @@ export default function ListView(props) {
|
|
|
1199
1155
|
)}
|
|
1200
1156
|
</Paper>
|
|
1201
1157
|
)}
|
|
1202
|
-
<Menu
|
|
1203
|
-
id='simple-menu'
|
|
1204
|
-
anchorEl={anchorEl}
|
|
1205
|
-
keepMounted
|
|
1206
|
-
open={Boolean(anchorEl)}
|
|
1207
|
-
onClose={_menuClose}
|
|
1208
|
-
>
|
|
1158
|
+
<Menu id='simple-menu' anchorEl={anchorEl} keepMounted open={Boolean(anchorEl)} onClose={_menuClose}>
|
|
1209
1159
|
<MenuItem onClick={_filterMenu}>
|
|
1210
1160
|
<FilterListIcon /> Filter
|
|
1211
1161
|
</MenuItem>
|
|
@@ -1261,11 +1211,7 @@ export default function ListView(props) {
|
|
|
1261
1211
|
</>
|
|
1262
1212
|
) : (
|
|
1263
1213
|
<>
|
|
1264
|
-
<Select
|
|
1265
|
-
fullWidth
|
|
1266
|
-
onChange={_dialogContainsFilter}
|
|
1267
|
-
value={displayDialogContainsFilter}
|
|
1268
|
-
>
|
|
1214
|
+
<Select fullWidth onChange={_dialogContainsFilter} value={displayDialogContainsFilter}>
|
|
1269
1215
|
<MenuItem value='contains'>Contains</MenuItem>
|
|
1270
1216
|
<MenuItem value='equals'>Equals</MenuItem>
|
|
1271
1217
|
<MenuItem value='startswith'>Starts with</MenuItem>
|
|
@@ -1306,10 +1252,3 @@ export default function ListView(props) {
|
|
|
1306
1252
|
</>
|
|
1307
1253
|
);
|
|
1308
1254
|
}
|
|
1309
|
-
|
|
1310
|
-
ListView.defaultProps = {
|
|
1311
|
-
};
|
|
1312
|
-
|
|
1313
|
-
ListView.propTypes = {
|
|
1314
|
-
getPConnect: PropTypes.func.isRequired
|
|
1315
|
-
};
|