Bug fixes and deprecated DynamicFilter
This commit is contained in:
parent
d6ac1be628
commit
6ff192f58c
|
@ -7,6 +7,8 @@
|
|||
export let type = "number"
|
||||
|
||||
$: style = width ? `width:${width}px;` : ""
|
||||
|
||||
const selectAll = event => event.target.select()
|
||||
</script>
|
||||
|
||||
<input
|
||||
|
@ -16,7 +18,7 @@
|
|||
{value}
|
||||
{min}
|
||||
{max}
|
||||
onclick="this.select()"
|
||||
on:click={selectAll}
|
||||
on:change
|
||||
on:input
|
||||
/>
|
||||
|
|
|
@ -34,7 +34,12 @@
|
|||
}
|
||||
|
||||
const onChangeFrom = (utc: string) => {
|
||||
fromDate = utc ? dayjs(utc).startOf("day") : null
|
||||
// Preserve the time if its editable
|
||||
const fromDate = utc
|
||||
? enableTime
|
||||
? dayjs(utc)
|
||||
: dayjs(utc).startOf("day")
|
||||
: null
|
||||
if (fromDate && (!toDate || fromDate.isAfter(toDate))) {
|
||||
toDate = !enableTime ? fromDate.endOf("day") : fromDate
|
||||
} else if (!fromDate) {
|
||||
|
@ -44,9 +49,13 @@
|
|||
dispatch("change", [fromDate, toDate])
|
||||
}
|
||||
|
||||
// Pass the raw date not the event
|
||||
const onChangeTo = (utc: string) => {
|
||||
toDate = utc ? dayjs(utc).endOf("day") : null
|
||||
// Preserve the time if its editable
|
||||
const toDate = utc
|
||||
? enableTime
|
||||
? dayjs(utc)
|
||||
: dayjs(utc).startOf("day")
|
||||
: null
|
||||
if (toDate && (!fromDate || toDate.isBefore(fromDate))) {
|
||||
fromDate = !enableTime ? toDate.startOf("day") : toDate
|
||||
} else if (!toDate) {
|
||||
|
|
|
@ -85,7 +85,11 @@
|
|||
schema: TableSchema | undefined,
|
||||
tableList: Table[]
|
||||
) => {
|
||||
return search.getFields(tableList, Object.values(schema || {}), {
|
||||
// Omit calculated fields
|
||||
const filtered = Object.values(schema || {}).filter(
|
||||
field => !("calculationType" in field)
|
||||
)
|
||||
return search.getFields(tableList, filtered, {
|
||||
allowLinks: true,
|
||||
})
|
||||
}
|
||||
|
|
|
@ -5578,6 +5578,7 @@
|
|||
]
|
||||
},
|
||||
"dynamicfilter": {
|
||||
"deprecated": true,
|
||||
"name": "Dynamic Filter",
|
||||
"icon": "Filter",
|
||||
"size": {
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
import Container from "../container/Container.svelte"
|
||||
import { getAction } from "@/utils/getAction"
|
||||
import { ActionTypes } from "@/constants"
|
||||
import { fetchDatasourceSchema } from "@/utils/schema"
|
||||
import { QueryUtils, fetchData, memo } from "@budibase/frontend-core"
|
||||
import FilterButton from "./FilterButton.svelte"
|
||||
import { onDestroy } from "svelte"
|
||||
|
@ -36,7 +35,8 @@
|
|||
|
||||
const memoFilters = memo({} as Record<string, SearchFilter>)
|
||||
const component = getContext("component")
|
||||
const { API } = getContext("sdk")
|
||||
const { API, fetchDatasourceSchema, getRelationshipSchemaAdditions } =
|
||||
getContext("sdk")
|
||||
|
||||
const rowCache = writable({})
|
||||
setContext("rows", rowCache)
|
||||
|
@ -236,17 +236,29 @@
|
|||
|
||||
async function fetchSchema(datasource: any) {
|
||||
if (datasource) {
|
||||
const fetchedSchema = await fetchDatasourceSchema(datasource, {
|
||||
const fetchedSchema: TableSchema | null = await fetchDatasourceSchema(
|
||||
datasource,
|
||||
{
|
||||
enrichRelationships: true,
|
||||
formSchema: false,
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
const filteredSchema = Object.entries(fetchedSchema || {}).filter(
|
||||
const filteredSchemaEntries = Object.entries(fetchedSchema || {}).filter(
|
||||
([_, field]: [string, FieldSchema]) => {
|
||||
return !excludedTypes.includes(field.type)
|
||||
}
|
||||
)
|
||||
schema = Object.fromEntries(filteredSchema)
|
||||
|
||||
const filteredSchema = Object.fromEntries(filteredSchemaEntries)
|
||||
|
||||
// Necessary to ensure that link fields possess all config required
|
||||
// to render their respective UX
|
||||
const enrichedSchema = await getRelationshipSchemaAdditions(
|
||||
filteredSchema as Record<string, any>
|
||||
)
|
||||
|
||||
schema = { ...filteredSchema, ...enrichedSchema }
|
||||
} else {
|
||||
schema = null
|
||||
}
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
import { type Writable } from "svelte/store"
|
||||
import { getContext } from "svelte"
|
||||
import { isArrayOperator } from "@/utils/filtering"
|
||||
import dayjs from "dayjs"
|
||||
import utc from "dayjs/plugin/utc"
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
export const show = () => popover?.show()
|
||||
export const hide = () => popover?.hide()
|
||||
|
@ -268,13 +272,17 @@
|
|||
value={parseDateRange(editableFilter.value)}
|
||||
on:change={e => {
|
||||
const [from, to] = e.detail
|
||||
const parsedFrom = Helpers.stringifyDate(from, {
|
||||
const parsedFrom = enableTime
|
||||
? from.utc().format()
|
||||
: Helpers.stringifyDate(from, {
|
||||
enableTime,
|
||||
timeOnly,
|
||||
ignoreTimezones,
|
||||
})
|
||||
|
||||
const parsedTo = Helpers.stringifyDate(to, {
|
||||
const parsedTo = enableTime
|
||||
? to.utc().format()
|
||||
: Helpers.stringifyDate(to, {
|
||||
enableTime,
|
||||
timeOnly,
|
||||
ignoreTimezones,
|
||||
|
@ -283,7 +291,10 @@
|
|||
if (!editableFilter) return
|
||||
editableFilter = sanitizeOperator({
|
||||
...editableFilter,
|
||||
value: { low: parsedFrom, high: parsedTo },
|
||||
value: {
|
||||
low: parsedFrom,
|
||||
high: parsedTo,
|
||||
},
|
||||
})
|
||||
}}
|
||||
/>
|
||||
|
|
|
@ -96,6 +96,7 @@ export interface SDK {
|
|||
ActionTypes: typeof ActionTypes
|
||||
fetchDatasourceSchema: any
|
||||
fetchDatasourceDefinition: (datasource: DataFetchDatasource) => Promise<Table>
|
||||
getRelationshipSchemaAdditions: (schema: Record<string, any>) => Promise<any>
|
||||
enrichButtonActions: any
|
||||
generateGoldenSample: any
|
||||
createContextStore: any
|
||||
|
|
|
@ -29,6 +29,7 @@ import { ActionTypes } from "./constants"
|
|||
import {
|
||||
fetchDatasourceSchema,
|
||||
fetchDatasourceDefinition,
|
||||
getRelationshipSchemaAdditions,
|
||||
} from "./utils/schema"
|
||||
import { getAPIKey } from "./utils/api.js"
|
||||
import { enrichButtonActions } from "./utils/buttonActions.js"
|
||||
|
@ -71,6 +72,7 @@ export default {
|
|||
getAction,
|
||||
fetchDatasourceSchema,
|
||||
fetchDatasourceDefinition,
|
||||
getRelationshipSchemaAdditions,
|
||||
fetchData,
|
||||
QueryUtils,
|
||||
ContextScopes: Constants.ContextScopes,
|
||||
|
|
|
@ -121,6 +121,7 @@ export const getRelationshipSchemaAdditions = async (
|
|||
relationshipAdditions[`${fieldKey}.${linkKey}`] = {
|
||||
type: linkSchema[linkKey].type,
|
||||
externalType: linkSchema[linkKey].externalType,
|
||||
constraints: linkSchema[linkKey].constraints,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -103,8 +103,6 @@ export const getValidOperatorsForType = (
|
|||
ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In]
|
||||
} else if (type === FieldType.BB_REFERENCE) {
|
||||
ops = [Op.Contains, Op.NotContains, Op.ContainsAny, Op.Empty, Op.NotEmpty]
|
||||
} else if (type === FieldType.LINK) {
|
||||
ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In]
|
||||
}
|
||||
|
||||
// Only allow equal/not equal for _id in SQL tables
|
||||
|
|
Loading…
Reference in New Issue