Add List FIlter

master
Max 4 years ago
parent 61bd7cc266
commit 41af992419

@ -442,6 +442,7 @@ export class TableComponent implements AfterViewInit {
fromValue: {},
toValue: {},
type: column.type,
list: column.list,
options: {},
};
}

@ -1,3 +1,15 @@
<!-- List Filter -->
<app-cell
*ngIf="column.list"
[isList]="true"
[editable]="true"
[(value)]="filter.values"
(valueChange)="newFilterValue()"
[inputType]="'String'"
>
</app-cell>
<ng-container *ngIf="!column.list">
<!-- String Filter -->
<mat-form-field *ngIf="column.type === 'String' || column.type === 'Id'">
<input
@ -134,3 +146,4 @@
[inputType]="'Enum//Ja//Nein'"
>
</app-cell>
</ng-container>

@ -7,6 +7,18 @@ export function customTableFilterFunction(data: any, filter: any) {
}
for (const filterElementName of Object.keys(filter.columnFilters)) {
const filterElement = filter.columnFilters[filterElementName];
// List Filter - ignore types if column is list
if (filterElement.list && filterElement.values.length > 0) {
let dataElement: Array<any> = data[filterElementName];
if (dataElement.length !== filterElement.values.length) {
return false;
}
for (const element of filterElement.values) {
if (!dataElement.includes(element)) {
return false;
}
}
} else {
// String Filter
if (filterElement.value) {
if (filterElement.type === 'String' || filterElement.type === 'Id') {
@ -148,14 +160,23 @@ export function customTableFilterFunction(data: any, filter: any) {
}
}
// Enum Filter
if (filterElement.type.startsWith('Enum') && filterElement.value != null && filterElement.value !== data[filterElementName]) {
if (
filterElement.type.startsWith('Enum') &&
filterElement.value != null &&
filterElement.value !== data[filterElementName]
) {
return false;
}
// Boolean Filter
if (filterElement.type === "Boolean" && ((filterElement.value === "Ja" && !data[filterElementName])||(filterElement.value === "Nein" && data[filterElementName]))) {
if (
filterElement.type === 'Boolean' &&
((filterElement.value === 'Ja' && !data[filterElementName]) ||
(filterElement.value === 'Nein' && data[filterElementName]))
) {
return false;
}
}
}
/*const b =
!filter.includesString ||
Object.keys(data).some(

Loading…
Cancel
Save