mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 02:43:59 +00:00
condition editor-allow combine NULL,NOT NULL #368
This commit is contained in:
@@ -9,12 +9,18 @@
|
|||||||
import ModalBase from './ModalBase.svelte';
|
import ModalBase from './ModalBase.svelte';
|
||||||
import { closeCurrentModal } from './modalTools';
|
import { closeCurrentModal } from './modalTools';
|
||||||
import FormRadioGroupItem from '../forms/FormRadioGroupItem.svelte';
|
import FormRadioGroupItem from '../forms/FormRadioGroupItem.svelte';
|
||||||
|
import FormValues from '../forms/FormValues.svelte';
|
||||||
|
|
||||||
export let condition1;
|
export let condition1;
|
||||||
export let onFilter;
|
export let onFilter;
|
||||||
export let filterType;
|
export let filterType;
|
||||||
|
|
||||||
|
const hasOperand = condition => {
|
||||||
|
return condition != 'NULL' && condition != 'NOT NULL' && condition != 'EXISTS' && condition != 'NOT EXISTS';
|
||||||
|
};
|
||||||
|
|
||||||
const createTerm = (condition, value) => {
|
const createTerm = (condition, value) => {
|
||||||
|
if (!hasOperand(condition)) return condition;
|
||||||
if (!value) return null;
|
if (!value) return null;
|
||||||
if (filterType == 'string') return `${condition}"${value}"`;
|
if (filterType == 'string') return `${condition}"${value}"`;
|
||||||
return `${condition}${value}`;
|
return `${condition}${value}`;
|
||||||
@@ -43,7 +49,11 @@
|
|||||||
<SetFilterModal_Select {filterType} name="condition1" />
|
<SetFilterModal_Select {filterType} name="condition1" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 mr-1">
|
<div class="col-6 mr-1">
|
||||||
<FormTextFieldRaw name="value1" focused />
|
<FormValues let:values>
|
||||||
|
{#if hasOperand(values.condition1)}
|
||||||
|
<FormTextFieldRaw name="value1" focused />
|
||||||
|
{/if}
|
||||||
|
</FormValues>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -57,7 +67,11 @@
|
|||||||
<SetFilterModal_Select {filterType} name="condition2" />
|
<SetFilterModal_Select {filterType} name="condition2" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6 mr-1">
|
<div class="col-6 mr-1">
|
||||||
<FormTextFieldRaw name="value2" />
|
<FormValues let:values>
|
||||||
|
{#if hasOperand(values.condition2)}
|
||||||
|
<FormTextFieldRaw name="value2" />
|
||||||
|
{/if}
|
||||||
|
</FormValues>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
{ 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' },
|
||||||
];
|
];
|
||||||
case 'string':
|
case 'string':
|
||||||
return [
|
return [
|
||||||
@@ -29,6 +31,8 @@
|
|||||||
{ 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' },
|
||||||
];
|
];
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
return [
|
return [
|
||||||
@@ -38,6 +42,8 @@
|
|||||||
{ 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' },
|
||||||
];
|
];
|
||||||
case 'mongo':
|
case 'mongo':
|
||||||
return [
|
return [
|
||||||
@@ -53,6 +59,8 @@
|
|||||||
{ 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: 'EXISTS', label: 'field exists' },
|
||||||
|
{ value: 'NOT EXISTS', label: 'field does not exist' },
|
||||||
];
|
];
|
||||||
case 'eval':
|
case 'eval':
|
||||||
return [
|
return [
|
||||||
@@ -68,6 +76,8 @@
|
|||||||
{ 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: 'NULL', label: 'is NULL' },
|
||||||
|
{ value: 'NOT NULL', label: 'is not NULL' },
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user