Add Date filter

master
Max 4 years ago
parent 233e22b801
commit c18706819d

@ -58,7 +58,7 @@
<!-- NumberRange Filter -->
<ng-container *ngIf="column.type === 'NumRange'">
<app-number-range-cell
<app-number-range-cell
[editable]="true"
[(min)]="filter.minValue.min"
(minChange)="newFilterValue()"
@ -79,3 +79,14 @@
>
</app-number-range-cell>
</ng-container>
<!-- Date Filter -->
<app-date-range-cell
*ngIf="column.type === 'Date'"
[editable]="true"
[(from)]="filter.from"
(fromChange)="newFilterValue()"
[(to)]="filter.to"
(toChange)="newFilterValue()"
>
</app-date-range-cell>

@ -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 ||

Loading…
Cancel
Save