@pega/react-sdk-overrides 24.2.10 → 25.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/lib/designSystemExtension/Banner/Banner.css +1 -1
  2. package/lib/designSystemExtension/Banner/Banner.tsx +10 -7
  3. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.css +0 -1
  4. package/lib/designSystemExtension/CaseSummaryFields/CaseSummaryFields.tsx +53 -37
  5. package/lib/designSystemExtension/DetailsFields/DetailsFields.tsx +11 -13
  6. package/lib/designSystemExtension/FieldGroup/FieldGroup.tsx +8 -9
  7. package/lib/designSystemExtension/FieldGroupList/FieldGroupList.tsx +9 -9
  8. package/lib/designSystemExtension/FieldValueList/FieldValueList.tsx +8 -9
  9. package/lib/designSystemExtension/Operator/Operator.tsx +21 -19
  10. package/lib/designSystemExtension/Pulse/Pulse.tsx +1 -1
  11. package/lib/designSystemExtension/RichTextEditor/RichTextEditor.tsx +32 -4
  12. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.css +7 -14
  13. package/lib/designSystemExtension/WssQuickCreate/WssQuickCreate.tsx +13 -2
  14. package/lib/field/AutoComplete/AutoComplete.tsx +1 -1
  15. package/lib/field/CancelAlert/CancelAlert.css +4 -4
  16. package/lib/field/CancelAlert/CancelAlert.tsx +7 -10
  17. package/lib/field/Checkbox/Checkbox.tsx +97 -4
  18. package/lib/field/Currency/Currency.tsx +10 -7
  19. package/lib/field/Currency/currency-utils.ts +1 -2
  20. package/lib/field/Date/Date.tsx +8 -8
  21. package/lib/field/DateTime/DateTime.tsx +16 -13
  22. package/lib/field/Decimal/Decimal.tsx +10 -7
  23. package/lib/field/Dropdown/Dropdown.tsx +30 -25
  24. package/lib/field/Email/Email.tsx +11 -13
  25. package/lib/field/Group/Group.tsx +10 -8
  26. package/lib/field/Integer/Integer.tsx +5 -7
  27. package/lib/field/Location/Location.css +4 -0
  28. package/lib/field/Location/Location.tsx +258 -0
  29. package/lib/field/Location/config-ext.json +8 -0
  30. package/lib/field/Location/index.tsx +1 -0
  31. package/lib/field/Multiselect/utils.ts +1 -1
  32. package/lib/field/ObjectReference/ObjectReference.tsx +235 -0
  33. package/lib/field/ObjectReference/index.tsx +1 -0
  34. package/lib/field/ObjectReference/utils.ts +111 -0
  35. package/lib/field/Percentage/Percentage.tsx +9 -9
  36. package/lib/field/Phone/Phone.tsx +7 -5
  37. package/lib/field/RadioButtons/RadioButtons.tsx +47 -5
  38. package/lib/field/RichText/RichText.css +79 -0
  39. package/lib/field/RichText/RichText.tsx +3 -1
  40. package/lib/field/ScalarList/ScalarList.tsx +2 -4
  41. package/lib/field/SelectableCard/SelectableCard.tsx +175 -0
  42. package/lib/field/SelectableCard/index.tsx +1 -0
  43. package/lib/field/SelectableCard/utils.tsx +223 -0
  44. package/lib/field/SemanticLink/SemanticLink.tsx +160 -28
  45. package/lib/field/SemanticLink/utils.ts +1 -1
  46. package/lib/field/TextArea/TextArea.tsx +5 -7
  47. package/lib/field/TextContent/TextContent.tsx +1 -2
  48. package/lib/field/TextInput/TextInput.tsx +5 -7
  49. package/lib/field/Time/Time.tsx +4 -8
  50. package/lib/field/URL/URL.tsx +5 -7
  51. package/lib/field/UserReference/UserReference.tsx +3 -6
  52. package/lib/helpers/attachmentShared.ts +6 -0
  53. package/lib/helpers/common-utils.ts +24 -2
  54. package/lib/helpers/data_page.ts +0 -1
  55. package/lib/helpers/field-group-utils.ts +1 -1
  56. package/lib/helpers/formatters/Currency.ts +20 -20
  57. package/lib/helpers/formatters/CurrencyMap.ts +0 -2
  58. package/lib/helpers/formatters/common.ts +2 -1
  59. package/lib/helpers/formatters/index.ts +2 -4
  60. package/lib/helpers/object-utils.ts +10 -0
  61. package/lib/helpers/simpleTableHelpers.ts +118 -6
  62. package/lib/helpers/utils.ts +8 -1
  63. package/lib/helpers/versionHelpers.ts +0 -1
  64. package/lib/infra/ActionButtons/ActionButtons.tsx +28 -21
  65. package/lib/infra/Assignment/Assignment.tsx +39 -36
  66. package/lib/infra/AssignmentCard/AssignmentCard.tsx +2 -2
  67. package/lib/infra/Containers/FlowContainer/FlowContainer.tsx +21 -113
  68. package/lib/infra/Containers/FlowContainer/helpers.ts +1 -5
  69. package/lib/infra/Containers/ModalViewContainer/ListViewActionButtons/ListViewActionButtons.tsx +4 -3
  70. package/lib/infra/Containers/ModalViewContainer/ModalViewContainer.tsx +7 -6
  71. package/lib/infra/Containers/SimpleView/helper.ts +1 -1
  72. package/lib/infra/Containers/ViewContainer/ViewContainer.tsx +4 -5
  73. package/lib/infra/Containers/container-helpers.ts +52 -0
  74. package/lib/infra/DashboardFilter/DashboardFilter.tsx +5 -9
  75. package/lib/infra/DashboardFilter/filterUtils.tsx +3 -6
  76. package/lib/infra/DeferLoad/DeferLoad.tsx +7 -9
  77. package/lib/infra/ErrorBoundary/ErrorBoundary.tsx +1 -3
  78. package/lib/infra/MultiStep/MultiStep.css +48 -70
  79. package/lib/infra/MultiStep/MultiStep.tsx +27 -58
  80. package/lib/infra/NavBar/NavBar.css +1 -1
  81. package/lib/infra/NavBar/NavBar.tsx +43 -32
  82. package/lib/infra/Reference/Reference.tsx +3 -4
  83. package/lib/infra/Region/Region.tsx +1 -1
  84. package/lib/infra/RootContainer/RootContainer.tsx +3 -4
  85. package/lib/infra/Stages/Stages.tsx +3 -4
  86. package/lib/infra/View/View.tsx +4 -3
  87. package/lib/template/AdvancedSearch/AdvancedSearch.tsx +86 -0
  88. package/lib/template/AdvancedSearch/SearchGroup/persistUtils.ts +52 -0
  89. package/lib/template/AdvancedSearch/SearchGroups/SearchGroups.tsx +244 -0
  90. package/lib/template/AdvancedSearch/SearchGroups/hooks.ts +37 -0
  91. package/lib/template/AdvancedSearch/SearchGroups/index.tsx +1 -0
  92. package/lib/template/AdvancedSearch/SearchGroups/utils.ts +29 -0
  93. package/lib/template/AdvancedSearch/TemplateContext.ts +11 -0
  94. package/lib/template/AdvancedSearch/config-ext.json +9 -0
  95. package/lib/template/AdvancedSearch/index.tsx +1 -0
  96. package/lib/template/AppShell/AppShell.css +1 -1
  97. package/lib/template/AppShell/AppShell.tsx +22 -23
  98. package/lib/template/BannerPage/BannerPage.tsx +2 -2
  99. package/lib/template/CaseSummary/CaseSummary.tsx +28 -41
  100. package/lib/template/CaseView/CaseView.tsx +32 -38
  101. package/lib/template/CaseViewActionsMenu/CaseViewActionsMenu.tsx +1 -1
  102. package/lib/template/Confirmation/Confirmation.tsx +3 -4
  103. package/lib/template/DataReference/DataReference.tsx +312 -106
  104. package/lib/template/DataReference/DataReferenceAdvancedSearchContext.ts +10 -0
  105. package/lib/template/DataReference/SearchForm.tsx +149 -0
  106. package/lib/template/DataReference/utils.ts +90 -0
  107. package/lib/template/DefaultForm/DefaultForm.tsx +3 -3
  108. package/lib/template/DefaultForm/utils/index.ts +1 -3
  109. package/lib/template/DefaultPage/DefaultPage.tsx +108 -0
  110. package/lib/template/DefaultPage/index.tsx +1 -0
  111. package/lib/template/Details/Details/Details.tsx +11 -11
  112. package/lib/template/Details/DetailsSubTabs/DetailsSubTabs.tsx +2 -2
  113. package/lib/template/Details/DetailsThreeColumn/DetailsThreeColumn.tsx +11 -11
  114. package/lib/template/Details/DetailsTwoColumn/DetailsTwoColumn.tsx +11 -11
  115. package/lib/template/Details/DynamicTabs/DynamicTabs.tsx +1 -2
  116. package/lib/template/FieldGroupTemplate/FieldGroupTemplate.tsx +2 -5
  117. package/lib/template/InlineDashboard/InlineDashboard.tsx +14 -16
  118. package/lib/template/InlineDashboardPage/InlineDashboardPage.tsx +2 -2
  119. package/lib/template/ListPage/ListPage.tsx +1 -1
  120. package/lib/template/ListView/ListView.tsx +285 -204
  121. package/lib/template/ListView/hooks.ts +1 -5
  122. package/lib/template/ListView/utils.ts +38 -6
  123. package/lib/template/MultiReferenceReadOnly/MultiReferenceReadOnly.tsx +1 -1
  124. package/lib/template/NarrowWide/NarrowWide/NarrowWide.tsx +5 -5
  125. package/lib/template/NarrowWide/NarrowWideDetails/NarrowWideDetails.tsx +11 -11
  126. package/lib/template/NarrowWide/NarrowWideForm/NarrowWideForm.tsx +2 -2
  127. package/lib/template/NarrowWide/NarrowWidePage/NarrowWidePage.tsx +2 -2
  128. package/lib/template/OneColumn/OneColumn/OneColumn.tsx +7 -7
  129. package/lib/template/OneColumn/OneColumnPage/OneColumnPage.tsx +1 -1
  130. package/lib/template/OneColumn/OneColumnTab/OneColumnTab.tsx +2 -2
  131. package/lib/template/PromotedFilters/PromotedFilters.tsx +1 -3
  132. package/lib/template/SelfServiceCaseView/SelfServiceCaseView.tsx +145 -0
  133. package/lib/template/SelfServiceCaseView/index.tsx +1 -0
  134. package/lib/template/SimpleTable/SimpleTable/SimpleTable.tsx +2 -5
  135. package/lib/template/SimpleTable/SimpleTableManual/SimpleTableManual.tsx +99 -84
  136. package/lib/template/SimpleTable/SimpleTableSelect/SimpleTableSelect.tsx +3 -5
  137. package/lib/template/SingleReferenceReadOnly/SingleReferenceReadOnly.tsx +10 -2
  138. package/lib/template/SubTabs/SubTabs.tsx +2 -2
  139. package/lib/template/SubTabs/tabUtils.ts +118 -1
  140. package/lib/template/TwoColumn/TwoColumn/TwoColumn.tsx +9 -10
  141. package/lib/template/TwoColumn/TwoColumnPage/TwoColumnPage.tsx +1 -1
  142. package/lib/template/TwoColumn/TwoColumnTab/TwoColumnTab.tsx +9 -10
  143. package/lib/template/WideNarrow/WideNarrow/WideNarrow.tsx +5 -5
  144. package/lib/template/WideNarrow/WideNarrowDetails/WideNarrowDetails.tsx +11 -11
  145. package/lib/template/WideNarrow/WideNarrowForm/WideNarrowForm.tsx +2 -2
  146. package/lib/template/WideNarrow/WideNarrowPage/WideNarrowPage.tsx +2 -2
  147. package/lib/template/WssNavBar/WssNavBar.css +1 -1
  148. package/lib/template/WssNavBar/WssNavBar.tsx +6 -6
  149. package/lib/template/utils.tsx +58 -0
  150. package/lib/widget/AppAnnouncement/AppAnnouncement.tsx +1 -1
  151. package/lib/widget/Attachment/Attachment.css +7 -8
  152. package/lib/widget/Attachment/Attachment.tsx +304 -231
  153. package/lib/widget/Attachment/Attachment.types.ts +96 -0
  154. package/lib/widget/Attachment/AttachmentUtils.ts +316 -0
  155. package/lib/widget/CaseHistory/CaseHistory.tsx +5 -5
  156. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.css +0 -14
  157. package/lib/widget/FileUtility/ActionButtonsForFileUtil/ActionButtonsForFileUtil.tsx +3 -3
  158. package/lib/widget/FileUtility/FileUtility/FileUtility.css +7 -6
  159. package/lib/widget/FileUtility/FileUtility/FileUtility.tsx +30 -23
  160. package/lib/widget/Followers/Followers.tsx +2 -4
  161. package/lib/widget/QuickCreate/QuickCreate.tsx +1 -3
  162. package/lib/widget/SummaryItem/SummaryItem.css +9 -11
  163. package/lib/widget/SummaryItem/SummaryItem.tsx +3 -3
  164. package/lib/widget/SummaryList/SummaryList.tsx +1 -1
  165. package/lib/widget/ToDo/ToDo.css +1 -13
  166. package/lib/widget/ToDo/ToDo.tsx +38 -37
  167. package/package.json +1 -1
  168. package/lib/helpers/attachmentHelpers.ts +0 -76
  169. package/lib/infra/Containers/helpers.ts +0 -6
@@ -1,10 +1,5 @@
1
- /* eslint-disable no-plusplus */
2
-
3
- /* eslint-disable @typescript-eslint/no-use-before-define */
4
- /* eslint-disable @typescript-eslint/no-shadow */
5
-
6
- import React, { useState, useEffect, useRef } from 'react';
7
- import { Theme } from '@mui/material/styles';
1
+ import React, { useState, useEffect, useRef, useCallback } from 'react';
2
+ import type { Theme } from '@mui/material/styles';
8
3
  import createStyles from '@mui/styles/createStyles';
9
4
  import makeStyles from '@mui/styles/makeStyles';
10
5
  import Table from '@mui/material/Table';
@@ -21,7 +16,7 @@ import FilterListIcon from '@mui/icons-material/FilterList';
21
16
  import SubjectIcon from '@mui/icons-material/Subject';
22
17
  import SearchIcon from '@mui/icons-material/Search';
23
18
  import TextField from '@mui/material/TextField';
24
- import Grid from '@mui/material/Grid';
19
+ import Grid2 from '@mui/material/Grid2';
25
20
  import Menu from '@mui/material/Menu';
26
21
  import MenuItem from '@mui/material/MenuItem';
27
22
  import Dialog from '@mui/material/Dialog';
@@ -37,16 +32,16 @@ import IconButton from '@mui/material/IconButton';
37
32
  import CloseIcon from '@mui/icons-material/Close';
38
33
  import { Radio } from '@mui/material';
39
34
  import Checkbox from '@mui/material/Checkbox';
40
-
41
35
  import { filterData } from '@pega/react-sdk-components/lib/components/helpers/simpleTableHelpers';
42
36
 
43
37
  import './ListView.css';
44
38
  import { getDateFormatInfo } from '@pega/react-sdk-components/lib/components/helpers/date-format-utils';
45
39
  import { getCurrencyOptions } from '@pega/react-sdk-components/lib/components/field/Currency/currency-utils';
40
+ import { getGenericFieldsLocalizedValue } from '@pega/react-sdk-components/lib/components/helpers/common-utils';
46
41
  import { format } from '@pega/react-sdk-components/lib/components/helpers/formatters';
47
42
 
48
43
  import useInit from './hooks';
49
- import { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
44
+ import type { PConnProps } from '@pega/react-sdk-components/lib/types/PConnProps';
50
45
 
51
46
  interface ListViewProps extends PConnProps {
52
47
  // If any, enter additional props that only exist on this component
@@ -62,6 +57,9 @@ interface ListViewProps extends PConnProps {
62
57
  showDynamicFields?: boolean;
63
58
  readonlyContextList?: any;
64
59
  value: any;
60
+ viewName?: string;
61
+ showRecords?: boolean;
62
+ displayAs?: string;
65
63
  }
66
64
 
67
65
  const SELECTION_MODE = { SINGLE: 'single', MULTI: 'multi' };
@@ -88,28 +86,30 @@ export default function ListView(props: ListViewProps) {
88
86
  parameters,
89
87
  compositeKeys,
90
88
  showDynamicFields,
89
+ viewName,
91
90
  readonlyContextList: selectedValues,
92
- value
91
+ value,
92
+ displayAs
93
93
  } = props;
94
+ let { showRecords } = props;
94
95
  const ref = useRef({}).current;
95
96
  const cosmosTableRef = useRef();
96
97
  // List component context
97
98
  const [listContext, setListContext] = useState<any>({});
98
99
  const { meta } = listContext;
99
- const xRayApis = PCore.getDebugger().getXRayRuntime();
100
- const xRayUid = xRayApis.startXRay();
100
+ const { current: uniqueId } = useRef(crypto.randomUUID());
101
101
 
102
102
  useInit({
103
103
  ...props,
104
104
  setListContext,
105
105
  ref,
106
106
  showDynamicFields,
107
- xRayUid,
108
107
  cosmosTableRef
109
108
  });
110
109
 
110
+ useClearSelectionsAndUpdateTable({ getPConnect, uniqueId, viewName });
111
+
111
112
  const thePConn = getPConnect();
112
- // @ts-ignore - Property 'getComponentConfig' is private and only accessible within class 'C11nEnv'.
113
113
  const componentConfig = thePConn.getComponentConfig();
114
114
  const resolvedConfigProps: any = thePConn.getConfigProps() as ListViewProps;
115
115
 
@@ -157,10 +157,9 @@ export default function ListView(props: ListViewProps) {
157
157
  width: '100%',
158
158
  marginTop: theme.spacing(2),
159
159
  marginBottom: theme.spacing(2),
160
- display: 'grid'
161
- },
162
- search: {
163
- padding: '5px 5px'
160
+ display: 'grid',
161
+ borderRadius: 16,
162
+ padding: 20
164
163
  },
165
164
  table: {
166
165
  minWidth: 750
@@ -189,16 +188,43 @@ export default function ListView(props: ListViewProps) {
189
188
  position: 'absolute',
190
189
  top: 20,
191
190
  width: 1
192
- },
193
- title: {
194
- marginTop: theme.spacing(1),
195
- marginLeft: theme.spacing(1)
196
191
  }
197
192
  })
198
193
  );
199
194
 
200
195
  const classes = useStyles();
201
196
 
197
+ // Hook to clear the selections and update table in AdvancedSearch template when switching between search views
198
+ function useClearSelectionsAndUpdateTable({ getPConnect, uniqueId, viewName }) {
199
+ const clearSelectionsAndRefreshList = useCallback(
200
+ ({ viewName: name, clearSelections }) => {
201
+ if (name === viewName) {
202
+ const { selectionMode } = getPConnect().getRawConfigProps();
203
+ if (!selectionMode) {
204
+ return;
205
+ }
206
+ if (clearSelections) {
207
+ if (selectionMode === 'single') {
208
+ getPConnect().getListActions().setSelectedRows({});
209
+ } else {
210
+ getPConnect().getListActions().clearSelectedRows();
211
+ }
212
+ }
213
+ }
214
+ },
215
+ [getPConnect, viewName]
216
+ );
217
+
218
+ useEffect(() => {
219
+ const identifier = `clear-and-update-advanced-search-selections-${uniqueId}`;
220
+ PCore.getPubSubUtils().subscribe('update-advanced-search-selections', clearSelectionsAndRefreshList, identifier);
221
+
222
+ return () => {
223
+ PCore.getPubSubUtils().unsubscribe('update-advanced-search-selections', identifier);
224
+ };
225
+ }, [uniqueId, clearSelectionsAndRefreshList]);
226
+ }
227
+
202
228
  const handleRequestSort = (event: React.MouseEvent<unknown>, property: keyof any) => {
203
229
  const isAsc = orderBy === property && order === 'asc';
204
230
  setOrder(isAsc ? 'desc' : 'asc');
@@ -222,11 +248,12 @@ export default function ListView(props: ListViewProps) {
222
248
 
223
249
  type Order = 'asc' | 'desc';
224
250
 
225
- function getComparator<Key extends keyof any>(
226
- theOrder: Order,
227
- orderedBy: Key
228
- ): (a: { [key in Key]: number | string }, b: { [key in Key]: number | string }) => number {
229
- return theOrder === 'desc' ? (a, b) => descendingComparator(a, b, orderedBy) : (a, b) => -descendingComparator(a, b, orderedBy);
251
+ interface Comparator<T> {
252
+ (a: T, b: T): number;
253
+ }
254
+
255
+ function getComparator<T, Key extends keyof T>(theOrder: Order, orderedBy: Key): Comparator<T> {
256
+ return theOrder === 'desc' ? (a: T, b: T) => descendingComparator(a, b, orderedBy) : (a: T, b: T) => -descendingComparator(a, b, orderedBy);
230
257
  }
231
258
 
232
259
  function stableSort<T>(array: T[], comparator: (a: T, b: T) => number) {
@@ -259,18 +286,24 @@ export default function ListView(props: ListViewProps) {
259
286
  theField = theField.substring(1);
260
287
  }
261
288
  const colIndex = fields.findIndex(ele => ele.name === theField);
262
- const displayAsLink = field.config.displayAsLink;
289
+ // const displayAsLink = field.config.displayAsLink;
290
+ const { additionalDetails = {} } = field.config;
291
+ let shouldDisplayAsSemanticLink = additionalDetails.type === 'DISPLAY_LINK';
292
+ // TODO: This "if" check has been added for backward compatibility, to be removed once the users are notified about the changes in view metadata of US-517164
293
+ if (!shouldDisplayAsSemanticLink) {
294
+ shouldDisplayAsSemanticLink = 'displayAsLink' in field.config && field.config.displayAsLink;
295
+ }
263
296
  const headerRow: any = {};
264
297
  headerRow.id = fields[index].id;
265
298
  headerRow.type = field.type;
266
- headerRow.displayAsLink = displayAsLink;
299
+ headerRow.displayAsLink = shouldDisplayAsSemanticLink;
267
300
  headerRow.numeric = field.type === 'Decimal' || field.type === 'Integer' || field.type === 'Percentage' || field.type === 'Currency' || false;
268
301
  headerRow.disablePadding = false;
269
302
  headerRow.label = fields[index].label;
270
303
  if (colIndex > -1) {
271
304
  headerRow.classID = fields[colIndex].classID;
272
305
  }
273
- if (displayAsLink) {
306
+ if (shouldDisplayAsSemanticLink) {
274
307
  headerRow.isAssignmentLink = AssignDashObjects.includes(headerRow.classID);
275
308
  if (field.config.value?.startsWith('@CA')) {
276
309
  headerRow.isAssociation = true;
@@ -284,7 +317,6 @@ export default function ListView(props: ListViewProps) {
284
317
  if (selectionMode === SELECTION_MODE.SINGLE || selectionMode === SELECTION_MODE.MULTI) {
285
318
  const record = arTableData?.length > 0 ? arTableData[0] : '';
286
319
  if (typeof record === 'object' && !('pyGUID' in record) && !('pyID' in record)) {
287
- // eslint-disable-next-line no-console
288
320
  console.error('pyGUID or pyID values are mandatory to select the required row from the list');
289
321
  }
290
322
  }
@@ -306,32 +338,43 @@ export default function ListView(props: ListViewProps) {
306
338
 
307
339
  // Will be triggered when EVENT_DASHBOARD_FILTER_CHANGE fires
308
340
  function processFilterChange(data) {
309
- const { filterId, filterExpression } = data;
341
+ let filterId;
342
+ let filterExpression;
343
+ let isDateRange;
344
+ let field;
310
345
  let dashboardFilterPayload: any = {
311
346
  query: {
312
347
  filter: {},
313
348
  select: []
314
349
  }
315
350
  };
316
-
317
- filters.current[filterId] = filterExpression;
318
- let isDateRange = data.filterExpression?.AND;
319
- // Will be AND by default but making it dynamic in case we support dynamic relational ops in future
320
- const relationalOp = 'AND';
321
-
322
- let field = getFieldFromFilter(filterExpression, isDateRange);
323
- selectParam = [];
324
- // Constructing the select parameters list (will be sent in dashboardFilterPayload)
325
- columnList.current.forEach(col => {
326
- selectParam.push({
327
- field: col
351
+ if (displayAs === 'advancedSearch') {
352
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
353
+ Object.entries(data).reduce((acc, [item, value]) => {
354
+ const { filterId, filterExpression } = value as any;
355
+ filters.current[filterId] = filterExpression;
356
+ return acc; // Ensure the accumulator is returned
357
+ }, {});
358
+ } else {
359
+ ({ filterId, filterExpression } = data);
360
+ filters.current[filterId] = filterExpression;
361
+ isDateRange = data.filterExpression?.AND;
362
+ field = getFieldFromFilter(filterExpression, isDateRange);
363
+ selectParam = [];
364
+ // Constructing the select parameters list (will be sent in dashboardFilterPayload)
365
+ columnList.current.forEach(col => {
366
+ selectParam.push({
367
+ field: col
368
+ });
328
369
  });
329
- });
330
370
 
331
- // Checking if the triggered filter is applicable for this list
332
- if (data.filterExpression !== null && !(columnList.current?.length && columnList.current?.includes(field))) {
333
- return;
371
+ // Checking if the triggered filter is applicable for this list
372
+ if (data.filterExpression !== null && !(columnList.current?.length && columnList.current?.includes(field))) {
373
+ return;
374
+ }
334
375
  }
376
+ // Will be AND by default but making it dynamic in case we support dynamic relational ops in future
377
+ const relationalOp = 'AND';
335
378
  // This is a flag which will be used to reset dashboardFilterPayload in case we don't find any valid filters
336
379
  let validFilter = false;
337
380
 
@@ -341,7 +384,6 @@ export default function ListView(props: ListViewProps) {
341
384
  const filter = filters.current[filterExp];
342
385
  // If the filter is null then we can skip this iteration
343
386
  if (filter === null) {
344
- // eslint-disable-next-line no-continue
345
387
  continue;
346
388
  }
347
389
 
@@ -350,7 +392,6 @@ export default function ListView(props: ListViewProps) {
350
392
  field = getFieldFromFilter(filter, isDateRange);
351
393
 
352
394
  if (!(columnList.current.length && columnList.current.includes(field))) {
353
- // eslint-disable-next-line no-continue
354
395
  continue;
355
396
  }
356
397
  // If we reach here that implies we've at least one valid filter, hence setting the flag
@@ -377,7 +418,7 @@ export default function ListView(props: ListViewProps) {
377
418
  } else {
378
419
  dashboardFilterPayload.query.filter.filterConditions = {
379
420
  ...dashboardFilterPayload.query.filter.filterConditions,
380
- [`T${index++}`]: { ...filter.condition, ignoreCase: true }
421
+ [`T${index++}`]: { ...filter.condition, ...(filter.condition.comparator === 'CONTAINS' ? { ignoreCase: true } : {}) }
381
422
  };
382
423
 
383
424
  if (dashboardFilterPayload.query.filter.logic) {
@@ -405,6 +446,9 @@ export default function ListView(props: ListViewProps) {
405
446
  }
406
447
 
407
448
  function fetchAllData(fields): any {
449
+ if (displayAs === 'advancedSearch' && !showRecords) {
450
+ return Promise.resolve({ data: null });
451
+ }
408
452
  let query: any = null;
409
453
  if (payload) {
410
454
  query = payload.query;
@@ -555,8 +599,36 @@ export default function ListView(props: ListViewProps) {
555
599
  };
556
600
  }
557
601
 
602
+ function prepareFilters(data) {
603
+ return Object.entries(data.payload).reduce((acc, [field, value]) => {
604
+ if (value) {
605
+ let comparator = 'EQ';
606
+ const filterRecord = listContext.meta.fieldDefs.filter(item => item.id === field);
607
+ if (filterRecord?.[0]?.meta.type === 'TextInput') {
608
+ comparator = 'CONTAINS';
609
+ }
610
+ acc[field] = {
611
+ filterExpression: {
612
+ condition: {
613
+ lhs: {
614
+ field
615
+ },
616
+ comparator,
617
+ rhs: {
618
+ value
619
+ }
620
+ }
621
+ },
622
+ filterId: field
623
+ };
624
+ }
625
+ return acc;
626
+ }, {});
627
+ }
628
+
558
629
  useEffect(() => {
559
630
  if (listContext.meta) {
631
+ const identifier = `promoted-filters-queryable-${uniqueId}`;
560
632
  fetchDataFromServer();
561
633
  setTimeout(() => {
562
634
  PCore.getPubSubUtils().subscribe(
@@ -578,6 +650,15 @@ export default function ListView(props: ListViewProps) {
578
650
  false,
579
651
  getPConnect().getContextName()
580
652
  );
653
+ PCore.getPubSubUtils().subscribe(
654
+ PCore.getEvents().getTransientEvent().UPDATE_PROMOTED_FILTERS,
655
+ data => {
656
+ showRecords = data.showRecords;
657
+ const filterData = prepareFilters(data);
658
+ processFilterChange(filterData);
659
+ },
660
+ identifier
661
+ );
581
662
  }, 0);
582
663
 
583
664
  return function cleanupSubscriptions() {
@@ -591,6 +672,7 @@ export default function ListView(props: ListViewProps) {
591
672
  `dashboard-component-${'id'}`,
592
673
  getPConnect().getContextName()
593
674
  );
675
+ PCore.getPubSubUtils().unsubscribe(PCore.getEvents().getTransientEvent().UPDATE_PROMOTED_FILTERS, identifier);
594
676
  };
595
677
  }
596
678
  }, [listContext]);
@@ -628,7 +710,7 @@ export default function ListView(props: ListViewProps) {
628
710
 
629
711
  function showToast(message: string) {
630
712
  const theMessage = `Assignment: ${message}`;
631
- // eslint-disable-next-line no-console
713
+
632
714
  console.error(theMessage);
633
715
  setSnackbarMessage(message);
634
716
  setShowSnackbar(true);
@@ -642,7 +724,6 @@ export default function ListView(props: ListViewProps) {
642
724
 
643
725
  thePConn
644
726
  .getActionsApi()
645
- // @ts-ignore
646
727
  .openAssignment(pzInsKey, pxRefObjectClass, options)
647
728
  .then(() => {
648
729
  // console.log("openAssignment successful");
@@ -759,7 +840,6 @@ export default function ListView(props: ListViewProps) {
759
840
  function _showFilteredIcon(columnId) {
760
841
  for (const filterObj of filterByColumns) {
761
842
  if (filterObj.ref === columnId) {
762
- // eslint-disable-next-line sonarjs/prefer-single-boolean-return
763
843
  if (filterObj.containsFilterValue !== '') {
764
844
  return true;
765
845
  }
@@ -875,7 +955,6 @@ export default function ListView(props: ListViewProps) {
875
955
  pzInsKey = row[`${associationCategory}:pzInsKey`];
876
956
  }
877
957
  if (column.isAssignmentLink) {
878
- // @ts-ignore
879
958
  thePConn.getActionsApi().openAssignment(pzInsKey, pxObjClass, {
880
959
  containerName: 'primary',
881
960
  channelName: ''
@@ -981,160 +1060,162 @@ export default function ListView(props: ListViewProps) {
981
1060
  <>
982
1061
  {arColumns && arColumns.length > 0 && (
983
1062
  <Paper className={classes.paper}>
984
- <Typography className={classes.title} variant='h6' color='textPrimary' gutterBottom>
985
- {_listTitle()}
986
- </Typography>
987
- {globalSearch && (
988
- <Grid container spacing={1} alignItems='flex-end' className={classes.search}>
989
- <Grid item>
990
- <SearchIcon />
991
- </Grid>
992
- <Grid item>
993
- <TextField
994
- label={PCore.getLocaleUtils().getLocaleValue('Search', 'Search')}
995
- fullWidth
996
- variant='outlined'
997
- placeholder=''
998
- size='small'
999
- id='search'
1000
- onChange={_onSearch}
1001
- />
1002
- </Grid>
1003
- </Grid>
1004
- )}
1005
- <>
1006
- {!bInForm ? (
1007
- <TableContainer id='list-view' className={classes.tableInForm}>
1008
- <Table stickyHeader aria-label='sticky table'>
1009
- <TableHead>
1010
- <TableRow>
1011
- {arColumns.map(column => {
1063
+ <Grid2 container justifyContent='space-between'>
1064
+ <Typography variant='h6' color='textPrimary' gutterBottom>
1065
+ {_listTitle()}
1066
+ </Typography>
1067
+ {globalSearch && (
1068
+ <Grid2 container spacing={1} alignItems='flex-end'>
1069
+ <Grid2>
1070
+ <SearchIcon />
1071
+ </Grid2>
1072
+ <Grid2>
1073
+ <TextField
1074
+ label={PCore.getLocaleUtils().getLocaleValue('Search', 'Search')}
1075
+ fullWidth
1076
+ variant='outlined'
1077
+ placeholder=''
1078
+ size='small'
1079
+ id='search'
1080
+ onChange={_onSearch}
1081
+ />
1082
+ </Grid2>
1083
+ </Grid2>
1084
+ )}
1085
+ </Grid2>
1086
+ {!bInForm ? (
1087
+ <TableContainer id='list-view' className={classes.tableInForm}>
1088
+ <Table stickyHeader aria-label='sticky table'>
1089
+ <TableHead>
1090
+ <TableRow>
1091
+ {arColumns.map(column => {
1092
+ return (
1093
+ <TableCell className={classes.cell} key={column.id} sortDirection={orderBy === column.id ? order : false}>
1094
+ <TableSortLabel
1095
+ active={orderBy === column.id}
1096
+ direction={orderBy === column.id ? order : 'asc'}
1097
+ onClick={createSortHandler(column.id)}
1098
+ >
1099
+ {column.label}
1100
+ {_showFilteredIcon(column.id) && <FilterListIcon className={classes.filteredIcon} />}
1101
+ {orderBy === column.id ? (
1102
+ <span className={classes.visuallyHidden}>{order === 'desc' ? 'sorted descending' : 'sorted ascending'}</span>
1103
+ ) : null}
1104
+ </TableSortLabel>
1105
+ <MoreIcon
1106
+ className={classes.moreIcon}
1107
+ onClick={event => {
1108
+ _menuClick(event, column.id, column.type, column.label);
1109
+ }}
1110
+ />
1111
+ </TableCell>
1112
+ );
1113
+ })}
1114
+ </TableRow>
1115
+ </TableHead>
1116
+ <TableBody>
1117
+ {arRows &&
1118
+ stableSort(arRows, getComparator(order, orderBy))
1119
+ .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
1120
+ .map(row => {
1012
1121
  return (
1013
- <TableCell className={classes.cell} key={column.id} sortDirection={orderBy === column.id ? order : false}>
1014
- <TableSortLabel
1015
- active={orderBy === column.id}
1016
- direction={orderBy === column.id ? order : 'asc'}
1017
- onClick={createSortHandler(column.id)}
1018
- >
1019
- {column.label}
1020
- {_showFilteredIcon(column.id) && <FilterListIcon className={classes.filteredIcon} />}
1021
- {orderBy === column.id ? (
1022
- <span className={classes.visuallyHidden}>{order === 'desc' ? 'sorted descending' : 'sorted ascending'}</span>
1023
- ) : null}
1024
- </TableSortLabel>
1025
- <MoreIcon
1026
- className={classes.moreIcon}
1027
- onClick={event => {
1028
- _menuClick(event, column.id, column.type, column.label);
1029
- }}
1030
- />
1031
- </TableCell>
1122
+ <TableRow key={row.pxRefObjectInsName || row.pyID}>
1123
+ {arColumns.map(column => {
1124
+ const value = row[column.id];
1125
+ return (
1126
+ <TableCell key={column.id} align={column.align} className={classes.cell}>
1127
+ {_showButton(column.id, row) || column.displayAsLink ? (
1128
+ <Link
1129
+ component='button'
1130
+ onClick={() => {
1131
+ _listViewClick(row, column);
1132
+ }}
1133
+ underline='hover'
1134
+ >
1135
+ {column.format && typeof value === 'number' ? column.format(value) : value}
1136
+ </Link>
1137
+ ) : (
1138
+ <>{column.format && typeof value === 'number' ? column.format(value) : value || '---'}</>
1139
+ )}
1140
+ </TableCell>
1141
+ );
1142
+ })}
1143
+ </TableRow>
1032
1144
  );
1033
1145
  })}
1034
- </TableRow>
1035
- </TableHead>
1036
- <TableBody>
1037
- {arRows &&
1038
- stableSort(arRows, getComparator(order, orderBy))
1039
- .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
1040
- .map(row => {
1041
- return (
1042
- <TableRow key={row.pxRefObjectInsName || row.pyID}>
1043
- {arColumns.map(column => {
1044
- const value = row[column.id];
1045
- return (
1046
- <TableCell key={column.id} align={column.align} className={classes.cell}>
1047
- {_showButton(column.id, row) || column.displayAsLink ? (
1048
- <Link
1049
- component='button'
1050
- onClick={() => {
1051
- _listViewClick(row, column);
1052
- }}
1053
- underline='hover'
1054
- >
1055
- {column.format && typeof value === 'number' ? column.format(value) : value}
1056
- </Link>
1057
- ) : (
1058
- <>{column.format && typeof value === 'number' ? column.format(value) : value || '---'}</>
1059
- )}
1060
- </TableCell>
1061
- );
1062
- })}
1063
- </TableRow>
1064
- );
1065
- })}
1066
- </TableBody>
1067
- </Table>
1068
- </TableContainer>
1069
- ) : (
1070
- <TableContainer id='list-view'>
1071
- <Table>
1072
- <TableHead>
1073
- <TableRow>
1074
- {(selectionMode === SELECTION_MODE.SINGLE || selectionMode === SELECTION_MODE.MULTI) && <TableCell />}
1075
- {arColumns.map(column => {
1146
+ </TableBody>
1147
+ </Table>
1148
+ </TableContainer>
1149
+ ) : (
1150
+ <TableContainer id='list-view'>
1151
+ <Table>
1152
+ <TableHead>
1153
+ <TableRow>
1154
+ {(selectionMode === SELECTION_MODE.SINGLE || selectionMode === SELECTION_MODE.MULTI) && <TableCell />}
1155
+ {arColumns.map(column => {
1156
+ return (
1157
+ <TableCell className={classes.cell} key={column.id} sortDirection={orderBy === column.id ? order : false}>
1158
+ <TableSortLabel
1159
+ active={orderBy === column.id}
1160
+ direction={orderBy === column.id ? order : 'asc'}
1161
+ onClick={createSortHandler(column.id)}
1162
+ >
1163
+ {column.label}
1164
+ {orderBy === column.id ? (
1165
+ <span className={classes.visuallyHidden}>{order === 'desc' ? 'sorted descending' : 'sorted ascending'}</span>
1166
+ ) : null}
1167
+ </TableSortLabel>
1168
+ </TableCell>
1169
+ );
1170
+ })}
1171
+ </TableRow>
1172
+ </TableHead>
1173
+ <TableBody>
1174
+ {arRows &&
1175
+ arRows.length > 0 &&
1176
+ stableSort(arRows, getComparator(order, orderBy))
1177
+ .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
1178
+ .map(row => {
1076
1179
  return (
1077
- <TableCell className={classes.cell} key={column.id} sortDirection={orderBy === column.id ? order : false}>
1078
- <TableSortLabel
1079
- active={orderBy === column.id}
1080
- direction={orderBy === column.id ? order : 'asc'}
1081
- onClick={createSortHandler(column.id)}
1082
- >
1083
- {column.label}
1084
- {orderBy === column.id ? (
1085
- <span className={classes.visuallyHidden}>{order === 'desc' ? 'sorted descending' : 'sorted ascending'}</span>
1086
- ) : null}
1087
- </TableSortLabel>
1088
- </TableCell>
1180
+ <TableRow key={row[rowID]}>
1181
+ {selectionMode === SELECTION_MODE.SINGLE && (
1182
+ <TableCell>
1183
+ <Radio
1184
+ onChange={handleChange}
1185
+ value={row[rowID]}
1186
+ name='radio-buttons'
1187
+ inputProps={{ 'aria-label': 'A' }}
1188
+ checked={selectedValue === row[rowID]}
1189
+ />
1190
+ </TableCell>
1191
+ )}
1192
+ {selectionMode === SELECTION_MODE.MULTI && (
1193
+ <TableCell>
1194
+ <Checkbox
1195
+ onChange={onCheckboxClick}
1196
+ checked={selectedValues.some(selectedValue => selectedValue[rowID] === row[rowID])}
1197
+ value={row[rowID]}
1198
+ />
1199
+ </TableCell>
1200
+ )}
1201
+ {arColumns.map(column => {
1202
+ const value = row[column.id];
1203
+ return (
1204
+ <TableCell className={classes.cell} key={column.id} align={column.align}>
1205
+ {processColumnValue(column, value)}
1206
+ </TableCell>
1207
+ );
1208
+ })}
1209
+ </TableRow>
1089
1210
  );
1090
1211
  })}
1091
- </TableRow>
1092
- </TableHead>
1093
- <TableBody>
1094
- {arRows &&
1095
- arRows.length > 0 &&
1096
- stableSort(arRows, getComparator(order, orderBy))
1097
- .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
1098
- .map(row => {
1099
- return (
1100
- <TableRow key={row[rowID]}>
1101
- {selectionMode === SELECTION_MODE.SINGLE && (
1102
- <TableCell>
1103
- <Radio
1104
- onChange={handleChange}
1105
- value={row[rowID]}
1106
- name='radio-buttons'
1107
- inputProps={{ 'aria-label': 'A' }}
1108
- checked={selectedValue === row[rowID]}
1109
- />
1110
- </TableCell>
1111
- )}
1112
- {selectionMode === SELECTION_MODE.MULTI && (
1113
- <TableCell>
1114
- <Checkbox
1115
- onChange={onCheckboxClick}
1116
- checked={selectedValues.some(selectedValue => selectedValue[rowID] === row[rowID])}
1117
- value={row[rowID]}
1118
- />
1119
- </TableCell>
1120
- )}
1121
- {arColumns.map(column => {
1122
- const value = row[column.id];
1123
- return (
1124
- <TableCell className={classes.cell} key={column.id} align={column.align}>
1125
- {processColumnValue(column, value)}
1126
- </TableCell>
1127
- );
1128
- })}
1129
- </TableRow>
1130
- );
1131
- })}
1132
- </TableBody>
1133
- </Table>
1134
- {arRows && arRows.length === 0 && <div className='no-records'>No records found.</div>}
1135
- </TableContainer>
1136
- )}
1137
- </>
1212
+ </TableBody>
1213
+ </Table>
1214
+ {(!arRows || arRows.length === 0) && (
1215
+ <div className='no-records'>{getGenericFieldsLocalizedValue('COSMOSFIELDS.lists', 'No records found.')}</div>
1216
+ )}
1217
+ </TableContainer>
1218
+ )}
1138
1219
  {arRows && arRows.length > 0 && (
1139
1220
  <TablePagination
1140
1221
  id='pagination'