refactor filter utils
This commit is contained in:
parent
1c0128c11a
commit
cea28ebd6e
@ -38,19 +38,10 @@ export function handleCheckedValue(filter: NestedFilter) {
|
||||
}
|
||||
}
|
||||
|
||||
export function checkFilter(entity: any, filters: NestedFilter[], validate: Function, validateArgs: any = [], matchAll: boolean = false) {
|
||||
export function checkFilter(entity: any, filters: NestedFilter[], validate: Function, validateArgs = [], matchAll: boolean = false) {
|
||||
const hasChecked = filters.find(f => f.checked);
|
||||
|
||||
if (validateArgs) {
|
||||
if (!Array.isArray(validateArgs)) {
|
||||
validateArgs = [validateArgs];
|
||||
}
|
||||
} else {
|
||||
validateArgs = [];
|
||||
}
|
||||
if (!hasChecked) {
|
||||
return true;
|
||||
}
|
||||
if (!hasChecked) return true;
|
||||
|
||||
let filterMatched = matchAll;
|
||||
for (const filter of filters) {
|
||||
|
||||
@ -10,5 +10,5 @@ export interface FilterGroup {
|
||||
readonly hide?: boolean;
|
||||
readonly checker: Function;
|
||||
readonly matchAll?: boolean;
|
||||
readonly checkerArgs?: any;
|
||||
readonly checkerArgs?: [];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user