Add List FIlter

master
Max 4 years ago
parent 61bd7cc266
commit 41af992419

@ -442,6 +442,7 @@ export class TableComponent implements AfterViewInit {
fromValue: {}, fromValue: {},
toValue: {}, toValue: {},
type: column.type, type: column.type,
list: column.list,
options: {}, 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 --> <!-- String Filter -->
<mat-form-field *ngIf="column.type === 'String' || column.type === 'Id'"> <mat-form-field *ngIf="column.type === 'String' || column.type === 'Id'">
<input <input
@ -134,3 +146,4 @@
[inputType]="'Enum//Ja//Nein'" [inputType]="'Enum//Ja//Nein'"
> >
</app-cell> </app-cell>
</ng-container>

@ -7,6 +7,18 @@ export function customTableFilterFunction(data: any, filter: any) {
} }
for (const filterElementName of Object.keys(filter.columnFilters)) { for (const filterElementName of Object.keys(filter.columnFilters)) {
const filterElement = filter.columnFilters[filterElementName]; 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 // String Filter
if (filterElement.value) { if (filterElement.value) {
if (filterElement.type === 'String' || filterElement.type === 'Id') { if (filterElement.type === 'String' || filterElement.type === 'Id') {
@ -148,14 +160,23 @@ export function customTableFilterFunction(data: any, filter: any) {
} }
} }
// Enum Filter // 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; return false;
} }
// Boolean Filter // 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; return false;
} }
} }
}
/*const b = /*const b =
!filter.includesString || !filter.includesString ||
Object.keys(data).some( Object.keys(data).some(

Loading…
Cancel
Save