WIP - time filtering
This commit is contained in:
1 parent
7b9970f1e7
commit
15e16ced40
1 file changed
+14
-3
@@ -14,14 +14,25 @@ const isBetweenValueMatcher: ValueMatcherInfo<RangeValueMatcherOptions> = {
|
||||
if (isNaN(value)) {
|
||||
return false;
|
||||
}
|
||||
return value > options.from && value < options.to;
|
||||
|
||||
// if it is a time, it is interpolated as a string, so convert before comparing
|
||||
const fromVal = typeof options.from !== 'number' ? parseInt(options.from, 10) : options.from;
|
||||
const toVal = typeof options.to !== 'number' ? parseInt(options.to, 10) : options.to;
|
||||
|
||||
return value > fromVal && value < toVal;
|
||||
};
|
||||
},
|
||||
getOptionsDisplayText: (options) => {
|
||||
return `Matches all rows where field value is between ${options.from} and ${options.to}.`;
|
||||
},
|
||||
isApplicable: (field) => field.type === FieldType.number,
|
||||
getDefaultOptions: () => ({ from: 0, to: 100 }),
|
||||
isApplicable: (field) => field.type === FieldType.number || field.type === FieldType.time,
|
||||
getDefaultOptions: (field) => {
|
||||
if (field.type === FieldType.time) {
|
||||
return { from: '$__from', to: '$__to' };
|
||||
} else {
|
||||
return { from: 0, to: 100 };
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const getRangeValueMatchers = (): ValueMatcherInfo[] => [isBetweenValueMatcher];
|
||||
Reference in new issue
Block a user