Add numRange filter

master
Max 4 years ago
parent 589801339c
commit 233e22b801

@ -11,6 +11,9 @@ export function customTableFilterFunction(data: any, filter: any) {
if (filterElement.type === 'String' || filterElement.type === 'Id') { if (filterElement.type === 'String' || filterElement.type === 'Id') {
let searchString = filterElement.value.trim(); let searchString = filterElement.value.trim();
let dataElement = data[filterElementName]?.trim(); let dataElement = data[filterElementName]?.trim();
if (dataElement == null) {
return false;
}
if (!filterElement.options.caseSensitive) { if (!filterElement.options.caseSensitive) {
searchString = searchString.toLowerCase(); searchString = searchString.toLowerCase();
dataElement = dataElement.toLowerCase(); dataElement = dataElement.toLowerCase();
@ -41,6 +44,32 @@ export function customTableFilterFunction(data: any, filter: any) {
} }
} }
} }
if (filterElement.type === 'NumRange') {
if (
filterElement.minValue.min != null ||
filterElement.minValue.max != null ||
filterElement.maxValue.min != null ||
filterElement.maxValue.max != null
) {
let dataElementMin = data[filterElementName + '.min'];
let dataElementMax = data[filterElementName + '.max'];
if (dataElementMin == null && dataElementMax == null) {
return false;
}
if (filterElement.minValue.min != null && dataElementMin < filterElement.minValue.min) {
return false;
}
if (filterElement.minValue.max != null && dataElementMin > filterElement.minValue.max) {
return false;
}
if (filterElement.maxValue.min != null && dataElementMax < filterElement.maxValue.min) {
return false;
}
if (filterElement.maxValue.max != null && dataElementMax > filterElement.maxValue.max) {
return false;
}
}
}
} }
/*const b = /*const b =
!filter.includesString || !filter.includesString ||

Loading…
Cancel
Save