Handle valueType change

This commit is contained in:
Mel O'Hagan 2022-09-22 09:40:45 +01:00
parent 5b4d7c3509
commit cf5dbfe055
1 changed files with 26 additions and 1 deletions

View File

@ -100,13 +100,37 @@
}
if (
operator === Constants.OperatorOptions.In.value &&
!Array.isArray(expression.value)
!Array.isArray(expression.value) &&
expression.valueType === "Value"
) {
if (expression.value) {
expression.value = [expression.value]
} else {
expression.value = []
}
} else if (
operator !== Constants.OperatorOptions.In.value &&
Array.isArray(expression.value)
) {
expression.value = null
}
}
const onValueTypeChange = (expression, valueType) => {
if (Array.isArray(expression.value) && valueType === "Binding") {
expression.value = null
} else if (
expression.operator === Constants.OperatorOptions.In.value &&
!Array.isArray(expression.value) &&
valueType === "Value"
) {
if (typeof expression.value === "string") {
expression.value = expression.value.split(",")
} else if (expression.value) {
expression.value = [expression.value]
} else {
expression.value = []
}
}
}
@ -167,6 +191,7 @@
options={valueTypeOptions}
bind:value={filter.valueType}
placeholder={null}
on:change={e => onValueTypeChange(filter, e.detail)}
/>
{#if filter.valueType === "Binding"}
<DrawerBindableInput