Add inline searching for formula and longform columns, and improve searching operators where possible
This commit is contained in:
parent
789bb528f4
commit
2ef2d07cab
|
@ -35,7 +35,7 @@
|
|||
"boolean",
|
||||
"json",
|
||||
]
|
||||
const searchableTypes = ["string", "options", "number"]
|
||||
const searchableTypes = ["string", "options", "number", "array", "longform"]
|
||||
|
||||
let anchor
|
||||
let open = false
|
||||
|
@ -54,10 +54,18 @@
|
|||
$: descendingLabel = ["number", "bigint"].includes(column.schema?.type)
|
||||
? "high-low"
|
||||
: "Z-A"
|
||||
$: searchable = searchableTypes.includes(column.schema.type)
|
||||
$: searchable = isColumnSearchable(column)
|
||||
$: searching = searchValue != null
|
||||
$: debouncedUpdateFilter(searchValue)
|
||||
|
||||
const isColumnSearchable = col => {
|
||||
const type = col.schema.type
|
||||
return (
|
||||
searchableTypes.includes(type) ||
|
||||
(type === "formula" && col.schema.formulaType === "static")
|
||||
)
|
||||
}
|
||||
|
||||
const editColumn = async () => {
|
||||
editIsOpen = true
|
||||
await tick()
|
||||
|
|
|
@ -16,27 +16,39 @@ export const createActions = context => {
|
|||
|
||||
const addInlineFilter = (column, value) => {
|
||||
const filterId = `inline-${column}`
|
||||
|
||||
const inlineFilter = {
|
||||
let inlineFilter = {
|
||||
field: column.name,
|
||||
id: filterId,
|
||||
operator: "equal",
|
||||
type: "string",
|
||||
type: column.schema.type,
|
||||
valueType: "value",
|
||||
value,
|
||||
}
|
||||
|
||||
// Add overrides specific so the certain column type
|
||||
switch (column.schema.type) {
|
||||
case "string":
|
||||
case "formula":
|
||||
case "longform":
|
||||
inlineFilter.operator = "string"
|
||||
break
|
||||
case "number":
|
||||
inlineFilter.value = parseFloat(value)
|
||||
break
|
||||
case "array":
|
||||
inlineFilter.operator = "contains"
|
||||
}
|
||||
|
||||
// Add this filter
|
||||
filter.update($filter => {
|
||||
// Remove any existing inline filter
|
||||
if ($filter?.length) {
|
||||
$filter = $filter?.filter(x => x.id !== filterId)
|
||||
}
|
||||
|
||||
// Add new one if a value exists
|
||||
if (value) {
|
||||
$filter = [...($filter || []), inlineFilter]
|
||||
}
|
||||
|
||||
return $filter
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue