Fix more fucky wucky typey wipey stuff.

This commit is contained in:
Sam Rose 2024-07-10 11:17:59 +01:00
parent 5356cfdce5
commit 79b4d260f1
No known key found for this signature in database
2 changed files with 11 additions and 10 deletions

View File

@ -11,7 +11,7 @@
Label,
Multiselect,
} from "@budibase/bbui"
import { FieldType, SearchFilterOperator } from "@budibase/types"
import { ArrayOperator, FieldType } from "@budibase/types"
import { generate } from "shortid"
import { QueryUtils, Constants } from "@budibase/frontend-core"
import { getContext } from "svelte"
@ -268,7 +268,7 @@
<slot name="binding" {filter} />
{:else if [FieldType.STRING, FieldType.LONGFORM, FieldType.NUMBER, FieldType.BIGINT, FieldType.FORMULA].includes(filter.type)}
<Input disabled={filter.noValue} bind:value={filter.value} />
{:else if filter.type === FieldType.ARRAY || (filter.type === FieldType.OPTIONS && filter.operator === SearchFilterOperator.ONE_OF)}
{:else if filter.type === FieldType.ARRAY || (filter.type === FieldType.OPTIONS && filter.operator === ArrayOperator.ONE_OF)}
<Multiselect
disabled={filter.noValue}
options={getFieldOptions(filter.field)}

View File

@ -337,14 +337,15 @@ export function fixupFilterArrays(filters: SearchFilters) {
}
for (const key of Object.keys(field)) {
if (!Array.isArray(field[key])) {
if (typeof field[key] === "string") {
field[key] = (field[key] as string)
.split(",")
.map((x: string) => x.trim())
} else {
field[key] = [field[key]]
}
if (Array.isArray(field[key])) {
continue
}
const value = field[key] as any
if (typeof value === "string") {
field[key] = value.split(",").map((x: string) => x.trim())
} else {
field[key] = [value]
}
}
}