condition editor-allow combine NULL,NOT NULL #368

This commit is contained in:
Jan Prochazka
2022-09-17 09:48:54 +02:00
parent 9aded740ca
commit f93524e24f
2 changed files with 26 additions and 2 deletions

View File

@@ -9,12 +9,18 @@
import ModalBase from './ModalBase.svelte';
import { closeCurrentModal } from './modalTools';
import FormRadioGroupItem from '../forms/FormRadioGroupItem.svelte';
import FormValues from '../forms/FormValues.svelte';
export let condition1;
export let onFilter;
export let filterType;
const hasOperand = condition => {
return condition != 'NULL' && condition != 'NOT NULL' && condition != 'EXISTS' && condition != 'NOT EXISTS';
};
const createTerm = (condition, value) => {
if (!hasOperand(condition)) return condition;
if (!value) return null;
if (filterType == 'string') return `${condition}"${value}"`;
return `${condition}${value}`;
@@ -43,7 +49,11 @@
<SetFilterModal_Select {filterType} name="condition1" />
</div>
<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>
@@ -57,7 +67,11 @@
<SetFilterModal_Select {filterType} name="condition2" />
</div>
<div class="col-6 mr-1">
<FormTextFieldRaw name="value2" />
<FormValues let:values>
{#if hasOperand(values.condition2)}
<FormTextFieldRaw name="value2" />
{/if}
</FormValues>
</div>
</div>
</div>

View File

@@ -14,6 +14,8 @@
{ 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' },
];
case 'string':
return [
@@ -29,6 +31,8 @@
{ 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' },
];
case 'datetime':
return [
@@ -38,6 +42,8 @@
{ 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' },
];
case 'mongo':
return [
@@ -53,6 +59,8 @@
{ 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 [
@@ -68,6 +76,8 @@
{ 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' },
];
}
}