@pega/react-sdk-overrides 0.23.26 → 8.8.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/designSystemExtension/AlertBanner/AlertBanner.tsx +47 -0
- package/lib/designSystemExtension/AlertBanner/index.tsx +1 -0
- package/lib/designSystemExtension/Banner/Banner.tsx +12 -1
- package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +15 -10
- package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +10 -11
- package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +10 -3
- package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +11 -5
- package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +11 -3
- package/lib/designSystemExtension/Operator/Operator.tsx +30 -21
- package/lib/designSystemExtension/Pulse/Pulse.tsx +11 -7
- package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +121 -0
- package/lib/designSystemExtension/RichTextEditor/index.tsx +1 -0
- package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +12 -3
- package/lib/field/AutoComplete/AutoComplete.tsx +37 -18
- package/lib/field/CancelAlert/CancelAlert.tsx +21 -12
- package/lib/field/Checkbox/Checkbox.tsx +41 -17
- package/lib/field/Currency/Currency.tsx +23 -15
- package/lib/field/Currency/currency-utils.ts +1 -2
- package/lib/field/Date/Date.tsx +31 -17
- package/lib/field/DateTime/DateTime.tsx +26 -15
- package/lib/field/Decimal/Decimal.tsx +82 -19
- package/lib/field/Dropdown/Dropdown.tsx +57 -14
- package/lib/field/Email/Email.tsx +17 -9
- package/lib/field/Integer/Integer.tsx +15 -7
- package/lib/field/Percentage/Percentage.tsx +15 -7
- package/lib/field/Phone/Phone.tsx +21 -12
- package/lib/field/RadioButtons/RadioButtons.tsx +54 -27
- package/lib/field/RichText/RichText.tsx +93 -0
- package/lib/field/RichText/index.tsx +1 -0
- package/lib/field/ScalarList/ScalarList.tsx +64 -0
- package/lib/field/ScalarList/config-ext.json +8 -0
- package/lib/field/ScalarList/index.tsx +1 -0
- package/lib/field/SemanticLink/SemanticLink.tsx +26 -25
- package/lib/field/SemanticLink/utils.ts +2 -1
- package/lib/field/TextArea/TextArea.tsx +14 -5
- package/lib/field/TextContent/TextContent.tsx +10 -1
- package/lib/field/TextInput/TextInput.tsx +40 -11
- package/lib/field/Time/Time.tsx +29 -26
- package/lib/field/URL/URL.tsx +24 -8
- package/lib/field/UserReference/UserReference.tsx +52 -60
- package/lib/helpers/{attachmentHelpers.js → attachmentHelpers.ts} +5 -5
- package/lib/helpers/auth.js +741 -390
- package/lib/helpers/authManager.ts +933 -0
- package/lib/helpers/case-utils.tsx +103 -0
- package/lib/helpers/common-utils.ts +4 -0
- package/lib/helpers/config_access.js +63 -145
- package/lib/helpers/data_page.ts +2 -1
- package/lib/helpers/date-format-utils.ts +29 -19
- package/lib/helpers/{event-utils.js → event-utils.ts} +1 -1
- package/lib/helpers/{field-group-utils.js → field-group-utils.ts} +4 -3
- package/lib/helpers/formatters/{Currency.js → Currency.ts} +13 -12
- package/lib/helpers/formatters/{CurrencyMap.js → CurrencyMap.ts} +8 -5
- package/lib/helpers/formatters/{Date.js → Date.ts} +2 -2
- package/lib/helpers/formatters/{common.js → common.ts} +4 -4
- package/lib/helpers/formatters/{index.js → index.ts} +3 -3
- package/lib/helpers/simpleTableHelpers.ts +10 -6
- package/lib/helpers/state-utils.tsx +47 -0
- package/lib/helpers/template-utils.ts +3 -4
- package/lib/helpers/utils.ts +12 -4
- package/lib/helpers/versionHelpers.ts +0 -1
- package/lib/infra/ActionButtons/ActionButtons.tsx +13 -18
- package/lib/infra/Assignment/Assignment.tsx +38 -32
- package/lib/infra/AssignmentCard/AssignmentCard.tsx +15 -19
- package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +76 -64
- package/lib/infra/Containers/FlowContainer/{helpers.js → helpers.ts} +18 -16
- package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +41 -27
- package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +19 -28
- package/lib/infra/DashboardFilter/DashboardFilter.tsx +16 -20
- package/lib/infra/DashboardFilter/filterUtils.tsx +3 -1
- package/lib/infra/DeferLoad/DeferLoad.tsx +16 -19
- package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +20 -19
- package/lib/infra/MultiStep/MultiStep.tsx +24 -24
- package/lib/infra/NavBar/NavBar.tsx +23 -24
- package/lib/infra/Reference/Reference.tsx +13 -18
- package/lib/infra/Region/Region.tsx +8 -6
- package/lib/infra/RootContainer/RootContainer.tsx +32 -39
- package/lib/infra/Stages/Stages.tsx +15 -9
- package/lib/infra/VerticalTabs/LeftAlignVerticalTabs/LeftAlignVerticalTabs.tsx +8 -1
- package/lib/infra/VerticalTabs/VerticalTabs/VerticalTabs.tsx +12 -12
- package/lib/infra/View/View.tsx +28 -56
- package/lib/template/AppShell/AppShell.tsx +51 -34
- package/lib/template/BannerPage/BannerPage.tsx +26 -31
- package/lib/template/CaseSummary/CaseSummary.tsx +15 -8
- package/lib/template/CaseView/CaseView.tsx +137 -100
- package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +27 -27
- package/lib/template/Confirmation/Confirmation.tsx +29 -52
- package/lib/template/DataReference/DataReference.tsx +50 -52
- package/lib/template/DefaultForm/DefaultForm.tsx +29 -20
- package/lib/template/DefaultForm/utils/index.ts +33 -0
- package/lib/template/Details/Details/Details.tsx +16 -17
- package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +13 -16
- package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +19 -18
- package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +20 -18
- package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +24 -27
- package/lib/template/InlineDashboard/InlineDashboard.tsx +11 -7
- package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +19 -17
- package/lib/template/ListPage/ListPage.tsx +14 -13
- package/lib/template/ListView/ListView.tsx +191 -186
- package/lib/template/ListView/{hooks.js → hooks.ts} +3 -1
- package/lib/template/ListView/{utils.js → utils.ts} +172 -23
- package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +12 -17
- package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +16 -1
- package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +19 -18
- package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +9 -1
- package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +17 -17
- package/lib/template/OneColumn/OneColumn/OneColumn.tsx +8 -7
- package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +10 -10
- package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +5 -7
- package/lib/template/PromotedFilters/PromotedFilters.tsx +23 -17
- package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +103 -6
- package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +28 -7
- package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +26 -31
- package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +34 -36
- package/lib/template/SubTabs/SubTabs.tsx +10 -11
- package/lib/template/SubTabs/tabUtils.ts +0 -2
- package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +10 -15
- package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +10 -10
- package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +10 -12
- package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +17 -3
- package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +35 -25
- package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +7 -1
- package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +15 -17
- package/lib/template/WssNavBar/WssNavBar.tsx +20 -3
- package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +13 -21
- package/lib/widget/Attachment/Attachment.css +15 -3
- package/lib/widget/Attachment/Attachment.tsx +51 -32
- package/lib/widget/CaseHistory/CaseHistory.tsx +13 -11
- package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +13 -1
- package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +40 -26
- package/lib/widget/Followers/Followers.tsx +10 -11
- package/lib/widget/QuickCreate/QuickCreate.tsx +15 -6
- package/lib/widget/SummaryItem/SummaryItem.tsx +12 -4
- package/lib/widget/SummaryList/SummaryList.tsx +17 -3
- package/lib/widget/ToDo/ToDo.tsx +69 -104
- package/package.json +1 -1
- package/lib/helpers/authManager.js +0 -631
- /package/lib/helpers/formatters/{Boolean.js → Boolean.ts} +0 -0
- /package/lib/helpers/{reactContextHelpers.js → reactContextHelpers.ts} +0 -0
- /package/lib/template/ListView/{DefaultViewMeta.js → DefaultViewMeta.ts} +0 -0
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-shadow */
|
|
5
5
|
/* eslint-disable no-shadow */
|
|
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';
|
|
@@ -39,9 +37,31 @@ import { Radio } from '@material-ui/core';
|
|
|
39
37
|
import Checkbox from '@material-ui/core/Checkbox';
|
|
40
38
|
import { filterData } from '@pega/react-sdk-components/lib/components/helpers/simpleTableHelpers';
|
|
41
39
|
import './ListView.css';
|
|
42
|
-
import useInit from './hooks'
|
|
40
|
+
import useInit from './hooks';
|
|
41
|
+
import { getDateFormatInfo } from '@pega/react-sdk-components/lib/components/helpers/date-format-utils';
|
|
42
|
+
import { getCurrencyOptions } from '@pega/react-sdk-components/lib/components/field/Currency/currency-utils';
|
|
43
|
+
import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters/';
|
|
44
|
+
// import type { PConnProps } from '../../../types/PConnProps';
|
|
45
|
+
|
|
46
|
+
// ListViewProps can't be used until getComponentConfig is NOT private
|
|
47
|
+
// interface ListViewProps extends PConnProps {
|
|
48
|
+
// // If any, enter additional props that only exist on this component
|
|
49
|
+
// bInForm?: boolean,
|
|
50
|
+
// globalSearch?: boolean,
|
|
51
|
+
// referenceList?: Array<any>,
|
|
52
|
+
// rowClickAction?: any,
|
|
53
|
+
// selectionMode?: string,
|
|
54
|
+
// referenceType?: string,
|
|
55
|
+
// payload?: any,
|
|
56
|
+
// parameters?: any,
|
|
57
|
+
// compositeKeys?: any,
|
|
58
|
+
// showDynamicFields?: boolean,
|
|
59
|
+
// presets?: any
|
|
60
|
+
// }
|
|
43
61
|
|
|
44
62
|
const SELECTION_MODE = { SINGLE: 'single', MULTI: 'multi' };
|
|
63
|
+
|
|
64
|
+
// Remove this and use "real" PCore type once .d.ts is fixed (currently shows 3 errors)
|
|
45
65
|
declare const PCore: any;
|
|
46
66
|
|
|
47
67
|
let myRows: Array<any>;
|
|
@@ -55,9 +75,19 @@ let sortColumnId: any;
|
|
|
55
75
|
|
|
56
76
|
const filterByColumns: Array<any> = [];
|
|
57
77
|
|
|
58
|
-
export default function ListView(props) {
|
|
59
|
-
const { getPConnect, bInForm } = props;
|
|
60
|
-
const {
|
|
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
|
+
} = props;
|
|
61
91
|
const ref = useRef({}).current;
|
|
62
92
|
const cosmosTableRef = useRef();
|
|
63
93
|
// List component context
|
|
@@ -97,8 +127,8 @@ export default function ListView(props) {
|
|
|
97
127
|
const filters = useRef({});
|
|
98
128
|
|
|
99
129
|
// Will contain the list of columns specific for an instance
|
|
100
|
-
|
|
101
|
-
|
|
130
|
+
const columnList: any = useRef([]);
|
|
131
|
+
const filterPayload: any = useRef();
|
|
102
132
|
// Will be sent in the dashboardFilterPayload
|
|
103
133
|
let selectParam: Array<any> = [];
|
|
104
134
|
|
|
@@ -213,7 +243,7 @@ export default function ListView(props) {
|
|
|
213
243
|
};
|
|
214
244
|
|
|
215
245
|
const AssignDashObjects = ['Assign-Worklist', 'Assign-WorkBasket'];
|
|
216
|
-
function getHeaderCells(colFields, fields
|
|
246
|
+
function getHeaderCells(colFields, fields) {
|
|
217
247
|
const arReturn = colFields.map((field: any, index) => {
|
|
218
248
|
let theField = field.config.value.substring(field.config.value.indexOf(' ') + 1);
|
|
219
249
|
if (theField.indexOf('.') === 0) {
|
|
@@ -222,7 +252,7 @@ export default function ListView(props) {
|
|
|
222
252
|
const colIndex = fields.findIndex(ele => ele.name === theField);
|
|
223
253
|
const displayAsLink = field.config.displayAsLink;
|
|
224
254
|
const headerRow: any = {};
|
|
225
|
-
headerRow.id =
|
|
255
|
+
headerRow.id = fields[index].id;
|
|
226
256
|
headerRow.type = field.type;
|
|
227
257
|
headerRow.displayAsLink = displayAsLink;
|
|
228
258
|
headerRow.numeric =
|
|
@@ -232,7 +262,7 @@ export default function ListView(props) {
|
|
|
232
262
|
field.type === 'Currency' ||
|
|
233
263
|
false;
|
|
234
264
|
headerRow.disablePadding = false;
|
|
235
|
-
headerRow.label =
|
|
265
|
+
headerRow.label = fields[index].label;
|
|
236
266
|
if (colIndex > -1) {
|
|
237
267
|
headerRow.classID = fields[colIndex].classID;
|
|
238
268
|
}
|
|
@@ -247,25 +277,18 @@ export default function ListView(props) {
|
|
|
247
277
|
return arReturn;
|
|
248
278
|
}
|
|
249
279
|
|
|
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
|
-
}
|
|
258
280
|
|
|
259
281
|
function getUsingData(arTableData): Array<any> {
|
|
260
282
|
if (selectionMode === SELECTION_MODE.SINGLE || selectionMode === SELECTION_MODE.MULTI) {
|
|
261
283
|
const record = arTableData?.length > 0 ? arTableData[0] : '';
|
|
262
284
|
if (typeof record === 'object' && !('pyGUID' in record) && !('pyID' in record)) {
|
|
263
285
|
// eslint-disable-next-line no-console
|
|
264
|
-
console.error(
|
|
286
|
+
console.error(
|
|
287
|
+
'pyGUID or pyID values are mandatory to select the required row from the list'
|
|
288
|
+
);
|
|
265
289
|
}
|
|
266
290
|
}
|
|
267
291
|
const arReturn = arTableData?.map((data: any) => {
|
|
268
|
-
|
|
269
292
|
const row = data;
|
|
270
293
|
|
|
271
294
|
return row;
|
|
@@ -274,52 +297,6 @@ export default function ListView(props) {
|
|
|
274
297
|
return arReturn;
|
|
275
298
|
}
|
|
276
299
|
|
|
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);
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
return returnList;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
300
|
function getMyColumnList(arCols: Array<any>): Array<string> {
|
|
324
301
|
const myColList: Array<string> = [];
|
|
325
302
|
|
|
@@ -344,7 +321,7 @@ export default function ListView(props) {
|
|
|
344
321
|
// Will be triggered when EVENT_DASHBOARD_FILTER_CHANGE fires
|
|
345
322
|
function processFilterChange(data) {
|
|
346
323
|
const { filterId, filterExpression } = data;
|
|
347
|
-
dashboardFilterPayload = {
|
|
324
|
+
let dashboardFilterPayload : any = {
|
|
348
325
|
query: {
|
|
349
326
|
filter: {},
|
|
350
327
|
select: []
|
|
@@ -360,14 +337,14 @@ export default function ListView(props) {
|
|
|
360
337
|
let field = getFieldFromFilter(filterExpression, isDateRange);
|
|
361
338
|
selectParam = [];
|
|
362
339
|
// Constructing the select parameters list (will be sent in dashboardFilterPayload)
|
|
363
|
-
columnList.forEach(col => {
|
|
340
|
+
columnList.current?.forEach(col => {
|
|
364
341
|
selectParam.push({
|
|
365
342
|
field: col
|
|
366
343
|
});
|
|
367
344
|
});
|
|
368
345
|
|
|
369
346
|
// Checking if the triggered filter is applicable for this list
|
|
370
|
-
if (data.filterExpression !== null && !(columnList.length && columnList.includes(field))) {
|
|
347
|
+
if (data.filterExpression !== null && !(columnList.current?.length && columnList.current?.includes(field))) {
|
|
371
348
|
return;
|
|
372
349
|
}
|
|
373
350
|
// This is a flag which will be used to reset dashboardFilterPayload in case we don't find any valid filters
|
|
@@ -388,7 +365,7 @@ export default function ListView(props) {
|
|
|
388
365
|
isDateRange = filter?.AND ? true : false;
|
|
389
366
|
field = getFieldFromFilter(filter, isDateRange);
|
|
390
367
|
|
|
391
|
-
if (!(columnList.length && columnList.includes(field))) {
|
|
368
|
+
if (!(columnList.current?.length && columnList.current?.includes(field))) {
|
|
392
369
|
// eslint-disable-next-line no-continue
|
|
393
370
|
continue;
|
|
394
371
|
}
|
|
@@ -396,7 +373,7 @@ export default function ListView(props) {
|
|
|
396
373
|
validFilter = true;
|
|
397
374
|
/** 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
375
|
* In Constellation DX Components, through Repeating Structures they might be using several APIs to do it. We're doing it here
|
|
399
|
-
|
|
376
|
+
*/
|
|
400
377
|
if (isDateRange) {
|
|
401
378
|
const dateRelationalOp = filter?.AND ? 'AND' : 'OR';
|
|
402
379
|
dashboardFilterPayload.query.filter.filterConditions = {
|
|
@@ -405,11 +382,13 @@ export default function ListView(props) {
|
|
|
405
382
|
[`T${index++}`]: { ...filter[relationalOp][1].condition }
|
|
406
383
|
};
|
|
407
384
|
if (dashboardFilterPayload.query.filter.logic) {
|
|
408
|
-
dashboardFilterPayload.query.filter.logic = `${
|
|
409
|
-
|
|
410
|
-
} ${dateRelationalOp} T${index - 1})`;
|
|
385
|
+
dashboardFilterPayload.query.filter.logic = `${
|
|
386
|
+
dashboardFilterPayload.query.filter.logic
|
|
387
|
+
} ${relationalOp} (T${index - 2} ${dateRelationalOp} T${index - 1})`;
|
|
411
388
|
} else {
|
|
412
|
-
dashboardFilterPayload.query.filter.logic = `(T${index - 2} ${relationalOp} T${
|
|
389
|
+
dashboardFilterPayload.query.filter.logic = `(T${index - 2} ${relationalOp} T${
|
|
390
|
+
index - 1
|
|
391
|
+
})`;
|
|
413
392
|
}
|
|
414
393
|
|
|
415
394
|
dashboardFilterPayload.query.select = selectParam;
|
|
@@ -420,9 +399,9 @@ export default function ListView(props) {
|
|
|
420
399
|
};
|
|
421
400
|
|
|
422
401
|
if (dashboardFilterPayload.query.filter.logic) {
|
|
423
|
-
dashboardFilterPayload.query.filter.logic = `${
|
|
424
|
-
|
|
425
|
-
}`;
|
|
402
|
+
dashboardFilterPayload.query.filter.logic = `${
|
|
403
|
+
dashboardFilterPayload.query.filter.logic
|
|
404
|
+
} ${relationalOp} T${index - 1}`;
|
|
426
405
|
} else {
|
|
427
406
|
dashboardFilterPayload.query.filter.logic = `T${index - 1}`;
|
|
428
407
|
}
|
|
@@ -435,57 +414,40 @@ export default function ListView(props) {
|
|
|
435
414
|
if (!validFilter) {
|
|
436
415
|
dashboardFilterPayload = undefined;
|
|
437
416
|
}
|
|
438
|
-
|
|
417
|
+
filterPayload.current = dashboardFilterPayload;
|
|
439
418
|
fetchDataFromServer();
|
|
440
419
|
}
|
|
441
420
|
|
|
442
421
|
// Will be triggered when EVENT_DASHBOARD_FILTER_CLEAR_ALL fires
|
|
443
422
|
function processFilterClear() {
|
|
444
|
-
|
|
423
|
+
filterPayload.current = undefined;
|
|
445
424
|
fetchDataFromServer();
|
|
446
425
|
}
|
|
447
426
|
|
|
448
|
-
useEffect(() => {
|
|
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
427
|
function fetchAllData(fields) {
|
|
473
428
|
let query: any = null;
|
|
474
429
|
if (payload) {
|
|
475
430
|
query = payload.query;
|
|
476
431
|
} else if (fields?.length && meta.isQueryable) {
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
432
|
+
if (filterPayload.current) {
|
|
433
|
+
query = { select: fields, filter: filterPayload.current?.query?.filter };
|
|
434
|
+
} else {
|
|
435
|
+
query = { select: fields };
|
|
436
|
+
}
|
|
437
|
+
} else if (filterPayload.current) {
|
|
438
|
+
query = filterPayload.current?.query;
|
|
480
439
|
}
|
|
481
440
|
const context = getPConnect().getContextName();
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
441
|
+
// getDataAsync isn't returning correct data for the Page(i.e. ListView within a page) case
|
|
442
|
+
return !bInForm
|
|
443
|
+
? PCore.getDataApiUtils().getData(referenceList, payload)
|
|
444
|
+
: PCore.getDataPageUtils().getDataAsync(
|
|
445
|
+
referenceList,
|
|
446
|
+
context,
|
|
447
|
+
payload ? payload.dataViewParameters : dataViewParameters,
|
|
448
|
+
null,
|
|
449
|
+
query
|
|
450
|
+
);
|
|
489
451
|
}
|
|
490
452
|
|
|
491
453
|
const buildSelect = (fieldDefs, colId, patchQueryFields = [], compositeKeys = []) => {
|
|
@@ -524,18 +486,22 @@ export default function ListView(props) {
|
|
|
524
486
|
return listFields;
|
|
525
487
|
};
|
|
526
488
|
|
|
527
|
-
const addItemKeyInSelect = (
|
|
528
|
-
fieldDefs,
|
|
529
|
-
itemKey,
|
|
530
|
-
select,
|
|
531
|
-
compositeKeys
|
|
532
|
-
) => {
|
|
489
|
+
const addItemKeyInSelect = (fieldDefs, itemKey, select, compositeKeys) => {
|
|
533
490
|
const elementFound = getField(fieldDefs, itemKey);
|
|
534
491
|
|
|
535
|
-
if (
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
492
|
+
if (
|
|
493
|
+
itemKey &&
|
|
494
|
+
!elementFound &&
|
|
495
|
+
Array.isArray(select) &&
|
|
496
|
+
!(compositeKeys !== null && compositeKeys?.length) &&
|
|
497
|
+
!select.find(sel => sel.field === itemKey)
|
|
498
|
+
) {
|
|
499
|
+
return [
|
|
500
|
+
...select,
|
|
501
|
+
{
|
|
502
|
+
field: itemKey
|
|
503
|
+
}
|
|
504
|
+
];
|
|
539
505
|
}
|
|
540
506
|
|
|
541
507
|
return select;
|
|
@@ -557,19 +523,18 @@ export default function ListView(props) {
|
|
|
557
523
|
async function fetchDataFromServer() {
|
|
558
524
|
let bCallSetRowsColumns = true;
|
|
559
525
|
const { fieldDefs, itemKey, patchQueryFields } = meta;
|
|
560
|
-
let listFields = fieldDefs
|
|
526
|
+
let listFields = fieldDefs
|
|
527
|
+
? buildSelect(fieldDefs, undefined, patchQueryFields, compositeKeys)
|
|
528
|
+
: [];
|
|
561
529
|
listFields = addItemKeyInSelect(fieldDefs, itemKey, listFields, compositeKeys);
|
|
562
530
|
const workListJSON = await fetchAllData(listFields);
|
|
563
531
|
|
|
564
|
-
// don't update these fields until we return from promise
|
|
565
|
-
let fields = presets[0].children[0].children;
|
|
566
|
-
|
|
567
532
|
// this is an unresovled version of this.fields$, need unresolved, so can get the property reference
|
|
568
533
|
const columnFields = componentConfig.presets[0].children[0].children;
|
|
569
534
|
|
|
570
|
-
const tableDataResults = workListJSON['data'];
|
|
535
|
+
const tableDataResults = !bInForm ? workListJSON['data'].data : workListJSON['data'];
|
|
571
536
|
|
|
572
|
-
const myColumns = getHeaderCells(columnFields, fieldDefs
|
|
537
|
+
const myColumns = getHeaderCells(columnFields, fieldDefs);
|
|
573
538
|
|
|
574
539
|
const selectParams: any = [];
|
|
575
540
|
|
|
@@ -585,16 +550,14 @@ export default function ListView(props) {
|
|
|
585
550
|
colList.push(col.field);
|
|
586
551
|
});
|
|
587
552
|
|
|
588
|
-
columnList = colList;
|
|
589
|
-
|
|
590
|
-
fields = updateFields(fields, myColumns);
|
|
553
|
+
columnList.current = colList;
|
|
591
554
|
|
|
592
555
|
setResponse(tableDataResults);
|
|
593
556
|
|
|
594
557
|
const usingDataResults = getUsingData(tableDataResults);
|
|
595
558
|
|
|
596
559
|
// store globally, so can be searched, filtered, etc.
|
|
597
|
-
myRows =
|
|
560
|
+
myRows = usingDataResults;
|
|
598
561
|
myDisplayColumnList = getMyColumnList(myColumns);
|
|
599
562
|
|
|
600
563
|
// At this point, if we have data ready to render and haven't been asked
|
|
@@ -618,6 +581,43 @@ export default function ListView(props) {
|
|
|
618
581
|
useEffect(() => {
|
|
619
582
|
if (listContext.meta) {
|
|
620
583
|
fetchDataFromServer();
|
|
584
|
+
setTimeout(() => {
|
|
585
|
+
PCore.getPubSubUtils().subscribe(
|
|
586
|
+
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE,
|
|
587
|
+
data => {
|
|
588
|
+
processFilterChange(data);
|
|
589
|
+
},
|
|
590
|
+
`dashboard-component-${'id'}`,
|
|
591
|
+
false,
|
|
592
|
+
getPConnect().getContextName()
|
|
593
|
+
);
|
|
594
|
+
PCore.getPubSubUtils().subscribe(
|
|
595
|
+
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL,
|
|
596
|
+
() => {
|
|
597
|
+
filters.current = {};
|
|
598
|
+
processFilterClear();
|
|
599
|
+
},
|
|
600
|
+
`dashboard-component-${'id'}`,
|
|
601
|
+
false,
|
|
602
|
+
getPConnect().getContextName()
|
|
603
|
+
);
|
|
604
|
+
}, 0);
|
|
605
|
+
}
|
|
606
|
+
return function cleanupSubscriptions() {
|
|
607
|
+
|
|
608
|
+
PCore.getPubSubUtils().unsubscribe(
|
|
609
|
+
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE,
|
|
610
|
+
`dashboard-component-${'id'}`,
|
|
611
|
+
false,
|
|
612
|
+
getPConnect().getContextName()
|
|
613
|
+
);
|
|
614
|
+
PCore.getPubSubUtils().unsubscribe(
|
|
615
|
+
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL,
|
|
616
|
+
`dashboard-component-${'id'}`,
|
|
617
|
+
false,
|
|
618
|
+
getPConnect().getContextName()
|
|
619
|
+
);
|
|
620
|
+
|
|
621
621
|
}
|
|
622
622
|
}, [listContext]);
|
|
623
623
|
|
|
@@ -667,7 +667,7 @@ export default function ListView(props) {
|
|
|
667
667
|
const { pxRefObjectClass, pzInsKey } = row;
|
|
668
668
|
const sTarget = thePConn.getContainerName();
|
|
669
669
|
|
|
670
|
-
const options = { containerName: sTarget };
|
|
670
|
+
const options = { containerName: sTarget, channelName: '' };
|
|
671
671
|
|
|
672
672
|
thePConn
|
|
673
673
|
.getActionsApi()
|
|
@@ -680,17 +680,17 @@ export default function ListView(props) {
|
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
-
function _rowClick(row: any) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
683
|
+
// function _rowClick(row: any) {
|
|
684
|
+
// // eslint-disable-next-line sonarjs/no-small-switch
|
|
685
|
+
// switch (rowClickAction) {
|
|
686
|
+
// case 'openAssignment':
|
|
687
|
+
// openAssignment(row);
|
|
688
|
+
// break;
|
|
689
689
|
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
}
|
|
690
|
+
// default:
|
|
691
|
+
// break;
|
|
692
|
+
// }
|
|
693
|
+
// }
|
|
694
694
|
|
|
695
695
|
function openWork(row) {
|
|
696
696
|
const { pxRefObjectKey } = row;
|
|
@@ -899,7 +899,7 @@ export default function ListView(props) {
|
|
|
899
899
|
}
|
|
900
900
|
|
|
901
901
|
function _listViewClick(row, column) {
|
|
902
|
-
const name = column.id
|
|
902
|
+
const name = column.id;
|
|
903
903
|
if (column.displayAsLink) {
|
|
904
904
|
const { pxObjClass } = row;
|
|
905
905
|
let { pzInsKey } = row;
|
|
@@ -909,7 +909,8 @@ export default function ListView(props) {
|
|
|
909
909
|
}
|
|
910
910
|
if (column.isAssignmentLink) {
|
|
911
911
|
thePConn.getActionsApi().openAssignment(pzInsKey, pxObjClass, {
|
|
912
|
-
containerName: 'primary'
|
|
912
|
+
containerName: 'primary',
|
|
913
|
+
channelName: ''
|
|
913
914
|
});
|
|
914
915
|
} else {
|
|
915
916
|
thePConn.getActionsApi().openWorkByHandle(pzInsKey, pxObjClass);
|
|
@@ -928,13 +929,12 @@ export default function ListView(props) {
|
|
|
928
929
|
break;
|
|
929
930
|
}
|
|
930
931
|
}
|
|
931
|
-
|
|
932
932
|
}
|
|
933
933
|
|
|
934
934
|
function _listTitle() {
|
|
935
935
|
const defaultTitle = 'List';
|
|
936
|
-
let title = resolvedConfigProps.title
|
|
937
|
-
const inheritedProps = resolvedConfigProps?.inheritedProps;
|
|
936
|
+
let title = resolvedConfigProps.title || resolvedConfigProps?.label || defaultTitle;
|
|
937
|
+
const inheritedProps = resolvedConfigProps?.['inheritedProps'];
|
|
938
938
|
|
|
939
939
|
// Let any title in resolvedConfigProps that isn't the default take precedence
|
|
940
940
|
// but only look in inheritedProps if they exist
|
|
@@ -957,14 +957,12 @@ export default function ListView(props) {
|
|
|
957
957
|
const index = response.findIndex(element => element[rowID] === value);
|
|
958
958
|
const selectedRow = response[index];
|
|
959
959
|
compositeKeys.forEach(element => {
|
|
960
|
-
reqObj[element] = selectedRow[element]
|
|
960
|
+
reqObj[element] = selectedRow[element];
|
|
961
961
|
});
|
|
962
962
|
} else {
|
|
963
963
|
reqObj[rowID] = value;
|
|
964
964
|
}
|
|
965
|
-
getPConnect()
|
|
966
|
-
?.getListActions?.()
|
|
967
|
-
?.setSelectedRows([reqObj]);
|
|
965
|
+
getPConnect()?.getListActions?.()?.setSelectedRows([reqObj]);
|
|
968
966
|
setSelectedValue(value);
|
|
969
967
|
};
|
|
970
968
|
|
|
@@ -976,16 +974,42 @@ export default function ListView(props) {
|
|
|
976
974
|
const index = response.findIndex(element => element[rowID] === value);
|
|
977
975
|
const selectedRow = response[index];
|
|
978
976
|
compositeKeys.forEach(element => {
|
|
979
|
-
reqObj[element] = selectedRow[element]
|
|
977
|
+
reqObj[element] = selectedRow[element];
|
|
980
978
|
});
|
|
981
979
|
reqObj['$selected'] = checked;
|
|
982
980
|
} else {
|
|
983
981
|
reqObj[rowID] = value;
|
|
984
982
|
reqObj['$selected'] = checked;
|
|
985
983
|
}
|
|
986
|
-
getPConnect()
|
|
987
|
-
|
|
988
|
-
|
|
984
|
+
getPConnect()?.getListActions()?.setSelectedRows([reqObj]);
|
|
985
|
+
};
|
|
986
|
+
|
|
987
|
+
const processColumnValue = (column, value) => {
|
|
988
|
+
let val;
|
|
989
|
+
const type = column.type;
|
|
990
|
+
let theDateFormatInfo;
|
|
991
|
+
let theFormat;
|
|
992
|
+
let theCurrencyOptions;
|
|
993
|
+
switch (type) {
|
|
994
|
+
case 'Date':
|
|
995
|
+
case 'DateTime':
|
|
996
|
+
theDateFormatInfo = getDateFormatInfo();
|
|
997
|
+
theFormat =
|
|
998
|
+
type === 'DateTime'
|
|
999
|
+
? `${theDateFormatInfo.dateFormatStringLong} hh:mm a`
|
|
1000
|
+
: theDateFormatInfo.dateFormatStringLong;
|
|
1001
|
+
val = format(value, column.type, { format: theFormat });
|
|
1002
|
+
break;
|
|
1003
|
+
|
|
1004
|
+
case 'Currency':
|
|
1005
|
+
theCurrencyOptions = getCurrencyOptions(PCore?.getEnvironmentInfo()?.getLocale());
|
|
1006
|
+
val = format(value, column.type, theCurrencyOptions);
|
|
1007
|
+
break;
|
|
1008
|
+
|
|
1009
|
+
default:
|
|
1010
|
+
val = column.format && typeof value === 'number' ? column.format(value) : value;
|
|
1011
|
+
}
|
|
1012
|
+
return val;
|
|
989
1013
|
};
|
|
990
1014
|
|
|
991
1015
|
return (
|
|
@@ -1002,20 +1026,20 @@ export default function ListView(props) {
|
|
|
1002
1026
|
</Grid>
|
|
1003
1027
|
<Grid item>
|
|
1004
1028
|
<TextField
|
|
1005
|
-
label='Search'
|
|
1029
|
+
label={PCore.getLocaleUtils().getLocaleValue('Search', 'Search')}
|
|
1006
1030
|
fullWidth
|
|
1007
1031
|
variant='outlined'
|
|
1008
1032
|
placeholder=''
|
|
1009
1033
|
size='small'
|
|
1010
|
-
id=
|
|
1034
|
+
id='search'
|
|
1011
1035
|
onChange={_onSearch}
|
|
1012
1036
|
/>
|
|
1013
1037
|
</Grid>
|
|
1014
1038
|
</Grid>
|
|
1015
1039
|
)}
|
|
1016
1040
|
<>
|
|
1017
|
-
{bInForm ? (
|
|
1018
|
-
<TableContainer className={classes.tableInForm}>
|
|
1041
|
+
{!bInForm ? (
|
|
1042
|
+
<TableContainer id="list-view" className={classes.tableInForm}>
|
|
1019
1043
|
<Table stickyHeader aria-label='sticky table'>
|
|
1020
1044
|
<TableHead>
|
|
1021
1045
|
<TableRow>
|
|
@@ -1057,12 +1081,7 @@ export default function ListView(props) {
|
|
|
1057
1081
|
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
|
1058
1082
|
.map(row => {
|
|
1059
1083
|
return (
|
|
1060
|
-
<TableRow
|
|
1061
|
-
key={row.pxRefObjectInsName || row.pyID}
|
|
1062
|
-
onClick={() => {
|
|
1063
|
-
_rowClick(row);
|
|
1064
|
-
}}
|
|
1065
|
-
>
|
|
1084
|
+
<TableRow key={row.pxRefObjectInsName || row.pyID}>
|
|
1066
1085
|
{arColumns.map(column => {
|
|
1067
1086
|
const value = row[column.id];
|
|
1068
1087
|
return (
|
|
@@ -1099,7 +1118,7 @@ export default function ListView(props) {
|
|
|
1099
1118
|
</Table>
|
|
1100
1119
|
</TableContainer>
|
|
1101
1120
|
) : (
|
|
1102
|
-
<TableContainer>
|
|
1121
|
+
<TableContainer id="list-view">
|
|
1103
1122
|
<Table>
|
|
1104
1123
|
<TableHead>
|
|
1105
1124
|
<TableRow>
|
|
@@ -1136,12 +1155,7 @@ export default function ListView(props) {
|
|
|
1136
1155
|
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
|
1137
1156
|
.map(row => {
|
|
1138
1157
|
return (
|
|
1139
|
-
<TableRow
|
|
1140
|
-
key={row[rowID]}
|
|
1141
|
-
onClick={() => {
|
|
1142
|
-
_rowClick(row);
|
|
1143
|
-
}}
|
|
1144
|
-
>
|
|
1158
|
+
<TableRow key={row[rowID]}>
|
|
1145
1159
|
{selectionMode === SELECTION_MODE.SINGLE && (
|
|
1146
1160
|
<TableCell>
|
|
1147
1161
|
<Radio
|
|
@@ -1169,9 +1183,7 @@ export default function ListView(props) {
|
|
|
1169
1183
|
key={column.id}
|
|
1170
1184
|
align={column.align}
|
|
1171
1185
|
>
|
|
1172
|
-
{column
|
|
1173
|
-
? column.format(value)
|
|
1174
|
-
: value}
|
|
1186
|
+
{processColumnValue(column, value)}
|
|
1175
1187
|
</TableCell>
|
|
1176
1188
|
);
|
|
1177
1189
|
})}
|
|
@@ -1306,10 +1318,3 @@ export default function ListView(props) {
|
|
|
1306
1318
|
</>
|
|
1307
1319
|
);
|
|
1308
1320
|
}
|
|
1309
|
-
|
|
1310
|
-
ListView.defaultProps = {
|
|
1311
|
-
};
|
|
1312
|
-
|
|
1313
|
-
ListView.propTypes = {
|
|
1314
|
-
getPConnect: PropTypes.func.isRequired
|
|
1315
|
-
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import { getContext, readContextResponse } from './utils';
|
|
3
3
|
|
|
4
|
+
// Remove this and use "real" PCore type once .d.ts is fixed (currently shows 1 error)
|
|
5
|
+
declare const PCore: any;
|
|
6
|
+
|
|
4
7
|
export default function useInit(props) {
|
|
5
|
-
const PCore = window.PCore;
|
|
6
8
|
const {
|
|
7
9
|
referenceList,
|
|
8
10
|
getPConnect,
|