mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 11:16:01 +00:00
set filter modal refactor
This commit is contained in:
@@ -3,89 +3,59 @@
|
||||
|
||||
export let name;
|
||||
export let filterType;
|
||||
export let structuredFilterType;
|
||||
|
||||
function getOptions() {
|
||||
switch (filterType) {
|
||||
case 'number':
|
||||
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: '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: 'does not contain' },
|
||||
{ value: '^', label: 'begins with' },
|
||||
{ value: '!^', label: 'does not begin with' },
|
||||
{ value: '$', label: 'ends with' },
|
||||
{ value: '!$', label: 'does not end with' },
|
||||
{ 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: '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 'datetime':
|
||||
return [
|
||||
{ value: '=', label: 'equals' },
|
||||
{ value: '<>', label: 'does not equal' },
|
||||
{ value: '<', label: 'is before' },
|
||||
{ value: '>', label: 'is after' },
|
||||
{ value: '<=', label: 'is before 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' },
|
||||
];
|
||||
const res = [];
|
||||
if (structuredFilterType.supportEquals) {
|
||||
res.push({ value: '=', label: 'equals' }, { value: '<>', label: 'does not equal' });
|
||||
}
|
||||
|
||||
if (structuredFilterType.supportStringInclusion) {
|
||||
res.push(
|
||||
{ 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' }
|
||||
);
|
||||
}
|
||||
|
||||
if (structuredFilterType.supportNumberLikeComparison) {
|
||||
res.push(
|
||||
{ value: '<', label: 'is smaller' },
|
||||
{ value: '>', label: 'is greater' },
|
||||
{ value: '<=', label: 'is smaller or equal' },
|
||||
{ value: '>=', label: 'is greater or equal' }
|
||||
);
|
||||
}
|
||||
|
||||
if (structuredFilterType.supportDatetimeComparison) {
|
||||
res.push(
|
||||
{ value: '<', label: 'is before' },
|
||||
{ value: '>', label: 'is after' },
|
||||
{ value: '<=', label: 'is before or equal' },
|
||||
{ value: '>=', label: 'is after or equal' }
|
||||
);
|
||||
}
|
||||
|
||||
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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user