|
|
@ -13,7 +13,7 @@ export function customTableFilterFunction(data: any, filter: any) {
|
|
|
|
let searchString = filterElement.value.trim();
|
|
|
|
let searchString = filterElement.value.trim();
|
|
|
|
let dataElement = data[filterElementName]?.trim();
|
|
|
|
let dataElement = data[filterElementName]?.trim();
|
|
|
|
if (dataElement == null) {
|
|
|
|
if (dataElement == null) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!filterElement.options.caseSensitive) {
|
|
|
|
if (!filterElement.options.caseSensitive) {
|
|
|
|
searchString = searchString.toLowerCase();
|
|
|
|
searchString = searchString.toLowerCase();
|
|
|
@ -57,34 +57,95 @@ export function customTableFilterFunction(data: any, filter: any) {
|
|
|
|
let dataElementMin = data[filterElementName + '.min'];
|
|
|
|
let dataElementMin = data[filterElementName + '.min'];
|
|
|
|
let dataElementMax = data[filterElementName + '.max'];
|
|
|
|
let dataElementMax = data[filterElementName + '.max'];
|
|
|
|
if (dataElementMin == null && dataElementMax == null) {
|
|
|
|
if (dataElementMin == null && dataElementMax == null) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filterElement.minValue.min != null && dataElementMin < filterElement.minValue.min) {
|
|
|
|
if (
|
|
|
|
return false;
|
|
|
|
filterElement.minValue.min != null &&
|
|
|
|
|
|
|
|
dataElementMin < filterElement.minValue.min
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filterElement.minValue.max != null && dataElementMin > filterElement.minValue.max) {
|
|
|
|
if (
|
|
|
|
return false;
|
|
|
|
filterElement.minValue.max != null &&
|
|
|
|
|
|
|
|
dataElementMin > filterElement.minValue.max
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filterElement.maxValue.min != null && dataElementMax < filterElement.maxValue.min) {
|
|
|
|
if (
|
|
|
|
return false;
|
|
|
|
filterElement.maxValue.min != null &&
|
|
|
|
|
|
|
|
dataElementMax < filterElement.maxValue.min
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filterElement.maxValue.max != null && dataElementMax > filterElement.maxValue.max) {
|
|
|
|
if (
|
|
|
|
return false;
|
|
|
|
filterElement.maxValue.max != null &&
|
|
|
|
|
|
|
|
dataElementMax > filterElement.maxValue.max
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Date Filter
|
|
|
|
// Date Filter
|
|
|
|
if (filterElement.from != null || filterElement.to != null) {
|
|
|
|
if (
|
|
|
|
let dataElement = data[filterElementName];
|
|
|
|
filterElement.type === 'Date' &&
|
|
|
|
if (dataElement == null) {
|
|
|
|
(filterElement.from != null || filterElement.to != null)
|
|
|
|
return false;
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
let dataElement = data[filterElementName];
|
|
|
|
if (filterElement.from != null && new Date(dataElement) < new Date(filterElement.from)) {
|
|
|
|
if (dataElement == null) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (filterElement.to != null && new Date(dataElement) > new Date(filterElement.to)) {
|
|
|
|
if (
|
|
|
|
return false;
|
|
|
|
filterElement.from != null &&
|
|
|
|
}
|
|
|
|
new Date(dataElement) < new Date(filterElement.from)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
filterElement.to != null &&
|
|
|
|
|
|
|
|
new Date(dataElement) > new Date(filterElement.to)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// DateRange Filter
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
filterElement.type === 'DateRange' &&
|
|
|
|
|
|
|
|
(filterElement.fromValue.from != null ||
|
|
|
|
|
|
|
|
filterElement.fromValue.to != null ||
|
|
|
|
|
|
|
|
filterElement.toValue.from != null ||
|
|
|
|
|
|
|
|
filterElement.toValue.to != null)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
let dataElementFrom = data[filterElementName + '.from'];
|
|
|
|
|
|
|
|
let dataElementTo = data[filterElementName + '.to'];
|
|
|
|
|
|
|
|
if (!dataElementFrom && !dataElementTo) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
filterElement.fromValue.from != null &&
|
|
|
|
|
|
|
|
(!dataElementFrom ||
|
|
|
|
|
|
|
|
new Date(dataElementFrom) < new Date(filterElement.fromValue.from))
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
filterElement.fromValue.to != null &&
|
|
|
|
|
|
|
|
new Date(dataElementFrom) > new Date(filterElement.fromValue.to)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
filterElement.toValue.from != null &&
|
|
|
|
|
|
|
|
new Date(dataElementTo) < new Date(filterElement.toValue.from)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
|
|
|
filterElement.toValue.to != null &&
|
|
|
|
|
|
|
|
(!dataElementTo ||
|
|
|
|
|
|
|
|
new Date(dataElementTo) > new Date(filterElement.toValue.to))
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*const b =
|
|
|
|
/*const b =
|
|
|
|