@pega/react-sdk-overrides 8.8.20 → 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.
|
@@ -127,8 +127,8 @@ export default function ListView(props /* : ListViewProps */) {
|
|
|
127
127
|
const filters = useRef({});
|
|
128
128
|
|
|
129
129
|
// Will contain the list of columns specific for an instance
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
const columnList: any = useRef([]);
|
|
131
|
+
const filterPayload: any = useRef();
|
|
132
132
|
// Will be sent in the dashboardFilterPayload
|
|
133
133
|
let selectParam: Array<any> = [];
|
|
134
134
|
|
|
@@ -321,7 +321,7 @@ export default function ListView(props /* : ListViewProps */) {
|
|
|
321
321
|
// Will be triggered when EVENT_DASHBOARD_FILTER_CHANGE fires
|
|
322
322
|
function processFilterChange(data) {
|
|
323
323
|
const { filterId, filterExpression } = data;
|
|
324
|
-
dashboardFilterPayload = {
|
|
324
|
+
let dashboardFilterPayload : any = {
|
|
325
325
|
query: {
|
|
326
326
|
filter: {},
|
|
327
327
|
select: []
|
|
@@ -337,14 +337,14 @@ export default function ListView(props /* : ListViewProps */) {
|
|
|
337
337
|
let field = getFieldFromFilter(filterExpression, isDateRange);
|
|
338
338
|
selectParam = [];
|
|
339
339
|
// Constructing the select parameters list (will be sent in dashboardFilterPayload)
|
|
340
|
-
columnList.forEach(col => {
|
|
340
|
+
columnList.current?.forEach(col => {
|
|
341
341
|
selectParam.push({
|
|
342
342
|
field: col
|
|
343
343
|
});
|
|
344
344
|
});
|
|
345
345
|
|
|
346
346
|
// Checking if the triggered filter is applicable for this list
|
|
347
|
-
if (data.filterExpression !== null && !(columnList.length && columnList.includes(field))) {
|
|
347
|
+
if (data.filterExpression !== null && !(columnList.current?.length && columnList.current?.includes(field))) {
|
|
348
348
|
return;
|
|
349
349
|
}
|
|
350
350
|
// This is a flag which will be used to reset dashboardFilterPayload in case we don't find any valid filters
|
|
@@ -365,7 +365,7 @@ export default function ListView(props /* : ListViewProps */) {
|
|
|
365
365
|
isDateRange = filter?.AND ? true : false;
|
|
366
366
|
field = getFieldFromFilter(filter, isDateRange);
|
|
367
367
|
|
|
368
|
-
if (!(columnList.length && columnList.includes(field))) {
|
|
368
|
+
if (!(columnList.current?.length && columnList.current?.includes(field))) {
|
|
369
369
|
// eslint-disable-next-line no-continue
|
|
370
370
|
continue;
|
|
371
371
|
}
|
|
@@ -414,48 +414,28 @@ export default function ListView(props /* : ListViewProps */) {
|
|
|
414
414
|
if (!validFilter) {
|
|
415
415
|
dashboardFilterPayload = undefined;
|
|
416
416
|
}
|
|
417
|
-
|
|
417
|
+
filterPayload.current = dashboardFilterPayload;
|
|
418
418
|
fetchDataFromServer();
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
// Will be triggered when EVENT_DASHBOARD_FILTER_CLEAR_ALL fires
|
|
422
422
|
function processFilterClear() {
|
|
423
|
-
|
|
423
|
+
filterPayload.current = undefined;
|
|
424
424
|
fetchDataFromServer();
|
|
425
425
|
}
|
|
426
426
|
|
|
427
|
-
useEffect(() => {
|
|
428
|
-
setTimeout(() => {
|
|
429
|
-
PCore.getPubSubUtils().subscribe(
|
|
430
|
-
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CHANGE,
|
|
431
|
-
data => {
|
|
432
|
-
processFilterChange(data);
|
|
433
|
-
},
|
|
434
|
-
`dashboard-component-${'id'}`,
|
|
435
|
-
false,
|
|
436
|
-
getPConnect().getContextName()
|
|
437
|
-
);
|
|
438
|
-
PCore.getPubSubUtils().subscribe(
|
|
439
|
-
PCore.getConstants().PUB_SUB_EVENTS.EVENT_DASHBOARD_FILTER_CLEAR_ALL,
|
|
440
|
-
() => {
|
|
441
|
-
filters.current = {};
|
|
442
|
-
processFilterClear();
|
|
443
|
-
},
|
|
444
|
-
`dashboard-component-${'id'}`,
|
|
445
|
-
false,
|
|
446
|
-
getPConnect().getContextName()
|
|
447
|
-
);
|
|
448
|
-
}, 0);
|
|
449
|
-
}, []);
|
|
450
|
-
|
|
451
427
|
function fetchAllData(fields) {
|
|
452
428
|
let query: any = null;
|
|
453
429
|
if (payload) {
|
|
454
430
|
query = payload.query;
|
|
455
431
|
} else if (fields?.length && meta.isQueryable) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
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;
|
|
459
439
|
}
|
|
460
440
|
const context = getPConnect().getContextName();
|
|
461
441
|
// getDataAsync isn't returning correct data for the Page(i.e. ListView within a page) case
|
|
@@ -570,7 +550,7 @@ export default function ListView(props /* : ListViewProps */) {
|
|
|
570
550
|
colList.push(col.field);
|
|
571
551
|
});
|
|
572
552
|
|
|
573
|
-
columnList = colList;
|
|
553
|
+
columnList.current = colList;
|
|
574
554
|
|
|
575
555
|
setResponse(tableDataResults);
|
|
576
556
|
|
|
@@ -601,6 +581,43 @@ export default function ListView(props /* : ListViewProps */) {
|
|
|
601
581
|
useEffect(() => {
|
|
602
582
|
if (listContext.meta) {
|
|
603
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
|
+
|
|
604
621
|
}
|
|
605
622
|
}, [listContext]);
|
|
606
623
|
|
package/package.json
CHANGED