diff --git a/src/app/components/tableComponents/filter-row/filter-row.component.html b/src/app/components/tableComponents/filter-row/filter-row.component.html index 934baf8..3ae1ead 100644 --- a/src/app/components/tableComponents/filter-row/filter-row.component.html +++ b/src/app/components/tableComponents/filter-row/filter-row.component.html @@ -58,7 +58,7 @@ - + + + + diff --git a/src/app/helperFunctions/customTableFilterFunction.ts b/src/app/helperFunctions/customTableFilterFunction.ts index c04b447..66b8f7d 100644 --- a/src/app/helperFunctions/customTableFilterFunction.ts +++ b/src/app/helperFunctions/customTableFilterFunction.ts @@ -7,6 +7,7 @@ export function customTableFilterFunction(data: any, filter: any) { } for (const filterElementName of Object.keys(filter.columnFilters)) { const filterElement = filter.columnFilters[filterElementName]; + // String Filter if (filterElement.value) { if (filterElement.type === 'String' || filterElement.type === 'Id') { let searchString = filterElement.value.trim(); @@ -26,6 +27,7 @@ export function customTableFilterFunction(data: any, filter: any) { } } } + // Number Filter if (filterElement.min != null || filterElement.max != null) { if ( filterElement.type === 'Float' || @@ -44,6 +46,7 @@ export function customTableFilterFunction(data: any, filter: any) { } } } + // NumberRange Filter if (filterElement.type === 'NumRange') { if ( filterElement.minValue.min != null || @@ -70,6 +73,19 @@ export function customTableFilterFunction(data: any, filter: any) { } } } + // Date Filter + if (filterElement.from != null || filterElement.to != null) { + let dataElement = data[filterElementName]; + if (dataElement == null) { + return false; + } + if (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; + } + } } /*const b = !filter.includesString ||