mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 08:13:57 +00:00
set filter modal refactor
This commit is contained in:
@@ -40,6 +40,7 @@ export const MongoFilterType: StructuredFilterType = {
|
|||||||
supportNumberLikeComparison: true,
|
supportNumberLikeComparison: true,
|
||||||
supportStringInclusion: true,
|
supportStringInclusion: true,
|
||||||
supportBooleanValues: true,
|
supportBooleanValues: true,
|
||||||
|
supportExistsTesting: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EvalFilterType: StructuredFilterType = {
|
export const EvalFilterType: StructuredFilterType = {
|
||||||
|
|||||||
1
packages/types/filter-type.d.ts
vendored
1
packages/types/filter-type.d.ts
vendored
@@ -13,6 +13,7 @@ export interface StructuredFilterType {
|
|||||||
supportExistsTesting?: boolean;
|
supportExistsTesting?: boolean;
|
||||||
supportBooleanValues?: boolean;
|
supportBooleanValues?: boolean;
|
||||||
supportSqlCondition?: boolean;
|
supportSqlCondition?: boolean;
|
||||||
|
supportArrayTesting?: boolean;
|
||||||
|
|
||||||
// allowedOperators: Array<{ value: string; label: string }>;
|
// allowedOperators: Array<{ value: string; label: string }>;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,89 +3,59 @@
|
|||||||
|
|
||||||
export let name;
|
export let name;
|
||||||
export let filterType;
|
export let filterType;
|
||||||
|
export let structuredFilterType;
|
||||||
|
|
||||||
function getOptions() {
|
function getOptions() {
|
||||||
switch (filterType) {
|
const res = [];
|
||||||
case 'number':
|
if (structuredFilterType.supportEquals) {
|
||||||
return [
|
res.push({ value: '=', label: 'equals' }, { value: '<>', label: 'does not equal' });
|
||||||
{ value: '=', label: 'equals' },
|
}
|
||||||
{ value: '<>', label: 'does not equal' },
|
|
||||||
{ value: '<', label: 'is smaller' },
|
if (structuredFilterType.supportStringInclusion) {
|
||||||
{ value: '>', label: 'is greater' },
|
res.push(
|
||||||
{ value: '<=', label: 'is smaller or equal' },
|
|
||||||
{ value: '>=', label: 'is greater or equal' },
|
|
||||||
{ value: 'NULL', label: 'is NULL' },
|
|
||||||
{ value: 'NOT NULL', label: 'is not NULL' },
|
|
||||||
{ value: 'sql', label: 'SQL condition' },
|
|
||||||
{ value: 'sqlRight', label: 'SQL condition - right side only' },
|
|
||||||
];
|
|
||||||
case 'string':
|
|
||||||
return [
|
|
||||||
{ value: '+', label: 'contains' },
|
{ value: '+', label: 'contains' },
|
||||||
{ value: '~', label: 'does not contain' },
|
{ value: '~', label: 'does not contain' },
|
||||||
{ value: '^', label: 'begins with' },
|
{ value: '^', label: 'begins with' },
|
||||||
{ value: '!^', label: 'does not begin with' },
|
{ value: '!^', label: 'does not begin with' },
|
||||||
{ value: '$', label: 'ends with' },
|
{ value: '$', label: 'ends with' },
|
||||||
{ value: '!$', label: 'does not end with' },
|
{ value: '!$', label: 'does not end with' }
|
||||||
{ value: '=', label: 'equals' },
|
);
|
||||||
{ value: '<>', label: 'does not equal' },
|
}
|
||||||
|
|
||||||
|
if (structuredFilterType.supportNumberLikeComparison) {
|
||||||
|
res.push(
|
||||||
{ value: '<', label: 'is smaller' },
|
{ value: '<', label: 'is smaller' },
|
||||||
{ value: '>', label: 'is greater' },
|
{ value: '>', label: 'is greater' },
|
||||||
{ value: '<=', label: 'is smaller or equal' },
|
{ value: '<=', label: 'is smaller or equal' },
|
||||||
{ value: '>=', label: 'is greater or equal' },
|
{ value: '>=', label: 'is greater or equal' }
|
||||||
{ value: 'NULL', label: 'is NULL' },
|
);
|
||||||
{ value: 'NOT NULL', label: 'is not NULL' },
|
}
|
||||||
{ value: 'sql', label: 'SQL condition' },
|
|
||||||
{ value: 'sqlRight', label: 'SQL condition - right side only' },
|
if (structuredFilterType.supportDatetimeComparison) {
|
||||||
];
|
res.push(
|
||||||
case 'datetime':
|
|
||||||
return [
|
|
||||||
{ value: '=', label: 'equals' },
|
|
||||||
{ value: '<>', label: 'does not equal' },
|
|
||||||
{ value: '<', label: 'is before' },
|
{ value: '<', label: 'is before' },
|
||||||
{ value: '>', label: 'is after' },
|
{ value: '>', label: 'is after' },
|
||||||
{ value: '<=', label: 'is before or equal' },
|
{ value: '<=', label: 'is before or equal' },
|
||||||
{ value: '>=', label: 'is after or equal' },
|
{ value: '>=', label: 'is after or equal' }
|
||||||
{ value: 'NULL', label: 'is NULL' },
|
);
|
||||||
{ value: 'NOT NULL', label: 'is not NULL' },
|
|
||||||
{ value: 'sql', label: 'SQL condition' },
|
|
||||||
{ value: 'sqlRight', label: 'SQL condition - right side only' },
|
|
||||||
];
|
|
||||||
case 'mongo':
|
|
||||||
return [
|
|
||||||
{ value: '=', label: 'equals' },
|
|
||||||
{ value: '<>', label: 'does not equal' },
|
|
||||||
{ value: '<', label: 'is smaller' },
|
|
||||||
{ value: '>', label: 'is greater' },
|
|
||||||
{ value: '<=', label: 'is smaller or equal' },
|
|
||||||
{ value: '>=', label: 'is greater or equal' },
|
|
||||||
{ value: '+', label: 'contains' },
|
|
||||||
{ value: '~', label: 'does not contain' },
|
|
||||||
{ value: '^', label: 'begins with' },
|
|
||||||
{ value: '!^', label: 'does not begin with' },
|
|
||||||
{ value: '$', label: 'ends with' },
|
|
||||||
{ value: '!$', label: 'does not end with' },
|
|
||||||
{ value: 'EXISTS', label: 'field exists' },
|
|
||||||
{ value: 'NOT EXISTS', label: 'field does not exist' },
|
|
||||||
];
|
|
||||||
case 'eval':
|
|
||||||
return [
|
|
||||||
{ value: '=', label: 'equals' },
|
|
||||||
{ value: '<>', label: 'does not equal' },
|
|
||||||
{ value: '<', label: 'is smaller' },
|
|
||||||
{ value: '>', label: 'is greater' },
|
|
||||||
{ value: '<=', label: 'is smaller or equal' },
|
|
||||||
{ value: '>=', label: 'is greater or equal' },
|
|
||||||
{ value: '+', label: 'contains' },
|
|
||||||
{ value: '~', label: 'does not contain' },
|
|
||||||
{ value: '^', label: 'begins with' },
|
|
||||||
{ value: '!^', label: 'does not begin with' },
|
|
||||||
{ value: '$', label: 'ends with' },
|
|
||||||
{ value: '!$', label: 'does not end with' },
|
|
||||||
{ value: 'NULL', label: 'is NULL' },
|
|
||||||
{ value: 'NOT NULL', label: 'is not NULL' },
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (structuredFilterType.supportNullTesting) {
|
||||||
|
res.push({ value: 'NULL', label: 'is NULL' }, { value: 'NOT NULL', label: 'is not NULL' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (structuredFilterType.supportExistsTesting) {
|
||||||
|
res.push({ value: 'EXISTS', label: 'field exists' }, { value: 'NOT EXISTS', label: 'field does not exist' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (structuredFilterType.supportSqlCondition) {
|
||||||
|
res.push(
|
||||||
|
{ value: 'sql', label: 'SQL condition' },
|
||||||
|
{ value: 'sqlRight', label: 'SQL condition - right side only' }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user