@ssplib/react-components 0.0.140 → 0.0.142
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.
|
@@ -349,9 +349,35 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
349
349
|
filterBasedOnList(appliedFilters);
|
|
350
350
|
}, [appliedFilters]);
|
|
351
351
|
const filterBasedOnList = (filteredList) => {
|
|
352
|
-
if (filteredList.length === 0)
|
|
353
|
-
return;
|
|
354
352
|
let rawList = JSON.parse(JSON.stringify(Array.isArray(startData) ? startData : (0, lodash_get_1.default)(startData, dataPath)));
|
|
353
|
+
if (filteredList.length <= 0 || rawList.length <= 0) {
|
|
354
|
+
setList(rawList);
|
|
355
|
+
setPagCount(getCount(rawList));
|
|
356
|
+
setCurrentPage(0);
|
|
357
|
+
setListPage(1);
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
let canContinue = true;
|
|
361
|
+
// verificando todas as chaves existem, se a chave não existir, não pode continuar e nao faz nada
|
|
362
|
+
filteredList
|
|
363
|
+
.map((x) => x.keyName)
|
|
364
|
+
.forEach((x) => {
|
|
365
|
+
if (!canContinue)
|
|
366
|
+
return;
|
|
367
|
+
if (!Object.keys(rawList[0]).includes(x)) {
|
|
368
|
+
canContinue = false;
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
if (!canContinue) {
|
|
373
|
+
setAppliedFilters([]);
|
|
374
|
+
localStorage.setItem('tableFilters', JSON.stringify([]));
|
|
375
|
+
setList(rawList);
|
|
376
|
+
setPagCount(getCount(rawList));
|
|
377
|
+
setCurrentPage(0);
|
|
378
|
+
setListPage(1);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
355
381
|
function category(type, keyName, uniqueName, customValue, referencekey) {
|
|
356
382
|
if (type === 'a-z') {
|
|
357
383
|
rawList = rawList.sort((a, b) => {
|
|
@@ -516,7 +542,7 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
516
542
|
return 0;
|
|
517
543
|
});
|
|
518
544
|
}
|
|
519
|
-
appliedFilters.
|
|
545
|
+
appliedFilters.forEach((x) => {
|
|
520
546
|
if (!x.isDate)
|
|
521
547
|
category(x.type, x.keyName, x.uniqueName, x.customValue, x.referencekey);
|
|
522
548
|
else
|
|
@@ -553,7 +579,11 @@ function Table({ columns, fetchFunc, emptyMsg = {
|
|
|
553
579
|
if (uniqueName === 'isDate')
|
|
554
580
|
setAppliedFilters((s) => s.filter((x) => !x.isDate));
|
|
555
581
|
else
|
|
556
|
-
setAppliedFilters((s) =>
|
|
582
|
+
setAppliedFilters((s) => {
|
|
583
|
+
const value = s.filter((x) => x.uniqueName !== uniqueName);
|
|
584
|
+
localStorage.setItem('tableFilters', JSON.stringify(value));
|
|
585
|
+
return value;
|
|
586
|
+
});
|
|
557
587
|
};
|
|
558
588
|
const handleDateFilter = (from, to, keyName) => {
|
|
559
589
|
setAppliedFilters((s) => {
|