Improve support for formula columns when using table conditional colouring
This commit is contained in:
parent
1fd4b983e5
commit
7faa6188c4
|
@ -15,7 +15,7 @@
|
|||
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
||||
import { QueryUtils, Constants } from "@budibase/frontend-core"
|
||||
import { generate } from "shortid"
|
||||
import { FieldType } from "@budibase/types"
|
||||
import { FieldType, FormulaType } from "@budibase/types"
|
||||
import { dndzone } from "svelte-dnd-action"
|
||||
import { flip } from "svelte/animate"
|
||||
|
||||
|
@ -63,7 +63,13 @@
|
|||
value: type,
|
||||
},
|
||||
]
|
||||
$: operatorOptions = QueryUtils.getValidOperatorsForType({ type })
|
||||
$: operatorOptions = QueryUtils.getValidOperatorsForType({
|
||||
type,
|
||||
|
||||
// We can filter on any formula columns here since we already have the data
|
||||
// on the page, so adding this ensures formula columns get operators
|
||||
formulaType: FormulaType.STATIC,
|
||||
})
|
||||
|
||||
const openDrawer = () => {
|
||||
tempValue = cloneDeep(value || [])
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { writable, get } from "svelte/store"
|
||||
import { derivedMemo, QueryUtils } from "../../../utils"
|
||||
import { FieldType } from "@budibase/types"
|
||||
|
||||
export const createStores = () => {
|
||||
const metadata = writable({})
|
||||
|
@ -90,17 +91,27 @@ const evaluateConditions = (row, conditions) => {
|
|||
let value = row[column]
|
||||
|
||||
// Coerce values into correct types for primitives
|
||||
if (type === "number") {
|
||||
let coercedType = type
|
||||
if (type === FieldType.FORMULA) {
|
||||
// For formulas we want to ensure that the reference type matches the
|
||||
// real type
|
||||
if (value === true || value === false) {
|
||||
coercedType = FieldType.BOOLEAN
|
||||
} else if (typeof value === "number") {
|
||||
coercedType = FieldType.NUMBER
|
||||
}
|
||||
}
|
||||
if (coercedType === FieldType.NUMBER) {
|
||||
referenceValue = parseFloat(referenceValue)
|
||||
value = parseFloat(value)
|
||||
} else if (type === "datetime") {
|
||||
} else if (coercedType === FieldType.DATETIME) {
|
||||
if (referenceValue) {
|
||||
referenceValue = new Date(referenceValue).toISOString()
|
||||
}
|
||||
if (value) {
|
||||
value = new Date(value).toISOString()
|
||||
}
|
||||
} else if (type === "boolean") {
|
||||
} else if (coercedType === FieldType.BOOLEAN) {
|
||||
referenceValue = `${referenceValue}`.toLowerCase() === "true"
|
||||
value = `${value}`.toLowerCase() === "true"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue