fix: view filter handle bool, number & date
This commit is contained in:
parent
d36fa0ed39
commit
27015ebd17
|
@ -81,11 +81,18 @@
|
||||||
|
|
||||||
function isMultipleChoice(field) {
|
function isMultipleChoice(field) {
|
||||||
return (
|
return (
|
||||||
viewModel.schema[field].constraints &&
|
(viewModel.schema[field].constraints &&
|
||||||
viewModel.schema[field].constraints.inclusion &&
|
viewModel.schema[field].constraints.inclusion &&
|
||||||
viewModel.schema[field].constraints.inclusion.length
|
viewModel.schema[field].constraints.inclusion.length) ||
|
||||||
|
viewModel.schema[field].type === "boolean"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fieldOptions(field) {
|
||||||
|
return viewModel.schema[field].type === "string"
|
||||||
|
? viewModel.schema[field].constraints.inclusion
|
||||||
|
: [true, false]
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div bind:this={anchor}>
|
<div bind:this={anchor}>
|
||||||
|
@ -126,8 +133,8 @@
|
||||||
</Select>
|
</Select>
|
||||||
{#if filter.key && isMultipleChoice(filter.key)}
|
{#if filter.key && isMultipleChoice(filter.key)}
|
||||||
<Select secondary thin bind:value={filter.value}>
|
<Select secondary thin bind:value={filter.value}>
|
||||||
{#each viewModel.schema[filter.key].constraints.inclusion as option}
|
{#each fieldOptions(filter.key) as option}
|
||||||
<option value={option}>{option}</option>
|
<option value={option}>{option.toString()}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</Select>
|
</Select>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
@ -61,8 +61,11 @@ function parseFilterExpression(filters) {
|
||||||
`doc["${filter.key}"].${TOKEN_MAP[filter.condition]}("${filter.value}")`
|
`doc["${filter.key}"].${TOKEN_MAP[filter.condition]}("${filter.value}")`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
const value =
|
||||||
|
typeof filter.value == "string" ? `"${filter.value}"` : filter.value
|
||||||
|
|
||||||
expression.push(
|
expression.push(
|
||||||
`doc["${filter.key}"] ${TOKEN_MAP[filter.condition]} "${filter.value}"`
|
`doc["${filter.key}"] ${TOKEN_MAP[filter.condition]} ${value}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue