Improve table condition editor handling of value types and missing values
This commit is contained in:
parent
27789a59d1
commit
d774e30a0a
|
@ -53,17 +53,8 @@
|
||||||
$: count = value?.length
|
$: count = value?.length
|
||||||
$: conditionText = `${count || "No"} condition${count !== 1 ? "s" : ""} set`
|
$: conditionText = `${count || "No"} condition${count !== 1 ? "s" : ""} set`
|
||||||
$: type = componentInstance.columnType
|
$: type = componentInstance.columnType
|
||||||
$: invalidType = Constants.BannedSearchTypes.includes(type)
|
$: valueTypeOptions = getValueTypeOptions(type)
|
||||||
$: valueTypeOptions = [
|
$: hasValueOption = type !== FieldType.STRING
|
||||||
{
|
|
||||||
label: "Binding",
|
|
||||||
value: FieldType.STRING,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Value",
|
|
||||||
value: type,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
$: operatorOptions = QueryUtils.getValidOperatorsForType({
|
$: operatorOptions = QueryUtils.getValidOperatorsForType({
|
||||||
type,
|
type,
|
||||||
|
|
||||||
|
@ -72,6 +63,22 @@
|
||||||
formulaType: FormulaType.STATIC,
|
formulaType: FormulaType.STATIC,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const getValueTypeOptions = type => {
|
||||||
|
let options = [
|
||||||
|
{
|
||||||
|
label: "Binding",
|
||||||
|
value: FieldType.STRING,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
if (type !== FieldType.STRING) {
|
||||||
|
options.push({
|
||||||
|
label: "Value",
|
||||||
|
value: type,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return options
|
||||||
|
}
|
||||||
|
|
||||||
const openDrawer = () => {
|
const openDrawer = () => {
|
||||||
tempValue = cloneDeep(value || [])
|
tempValue = cloneDeep(value || [])
|
||||||
drawer.show()
|
drawer.show()
|
||||||
|
@ -87,7 +94,7 @@
|
||||||
id: generate(),
|
id: generate(),
|
||||||
target: targetOptions[0].value,
|
target: targetOptions[0].value,
|
||||||
metadataKey: conditionOptions[0].value,
|
metadataKey: conditionOptions[0].value,
|
||||||
operator: Constants.OperatorOptions.Equals.value,
|
operator: operatorOptions[0]?.value,
|
||||||
valueType: FieldType.STRING,
|
valueType: FieldType.STRING,
|
||||||
}
|
}
|
||||||
tempValue = [...tempValue, condition]
|
tempValue = [...tempValue, condition]
|
||||||
|
@ -158,6 +165,7 @@
|
||||||
<div
|
<div
|
||||||
class="condition"
|
class="condition"
|
||||||
class:update={condition.action === "update"}
|
class:update={condition.action === "update"}
|
||||||
|
class:with-value-option={hasValueOption}
|
||||||
animate:flip={{ duration: flipDuration }}
|
animate:flip={{ duration: flipDuration }}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
@ -191,13 +199,16 @@
|
||||||
bind:value={condition.operator}
|
bind:value={condition.operator}
|
||||||
on:change={e => onOperatorChange(condition, e.detail)}
|
on:change={e => onOperatorChange(condition, e.detail)}
|
||||||
/>
|
/>
|
||||||
<Select
|
{#if hasValueOption}
|
||||||
disabled={condition.noValue || condition.operator === "oneOf"}
|
<Select
|
||||||
options={valueTypeOptions}
|
disabled={condition.noValue ||
|
||||||
bind:value={condition.valueType}
|
condition.operator === "oneOf"}
|
||||||
placeholder={null}
|
options={valueTypeOptions}
|
||||||
on:change={() => onValueTypeChange(condition)}
|
bind:value={condition.valueType}
|
||||||
/>
|
placeholder={null}
|
||||||
|
on:change={() => onValueTypeChange(condition)}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
{#if type === FieldType.DATETIME && condition.valueType === type}
|
{#if type === FieldType.DATETIME && condition.valueType === type}
|
||||||
<DatePicker
|
<DatePicker
|
||||||
placeholder="Value"
|
placeholder="Value"
|
||||||
|
@ -259,8 +270,11 @@
|
||||||
}
|
}
|
||||||
.condition {
|
.condition {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: auto auto 1fr 1fr auto auto auto 1fr 1fr 1fr auto auto;
|
grid-template-columns: auto auto 1fr 1fr auto auto auto 1fr 1fr auto auto;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
grid-column-gap: var(--spacing-l);
|
grid-column-gap: var(--spacing-l);
|
||||||
}
|
}
|
||||||
|
.condition.with-value-option {
|
||||||
|
grid-template-columns: auto auto 1fr 1fr auto auto auto 1fr 1fr 1fr auto auto;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue