Migrate DS+ settings without keys

This commit is contained in:
Andrew Kingston 2023-08-24 15:15:15 +01:00
parent 50e3a66f92
commit b6e675e3ff
2 changed files with 27 additions and 12 deletions

View File

@ -1,6 +1,6 @@
<script>
import { Select } from "@budibase/bbui"
import { createEventDispatcher } from "svelte"
import { createEventDispatcher, onMount } from "svelte"
import { tables as tablesStore } from "stores/backend"
export let value
@ -28,16 +28,6 @@
[]
)
$: options = [...(tables || []), ...(views || [])]
$: {
// Migrate old table values before "key" existed
if (value && !value.key) {
console.log("migrate")
dispatch(
"change",
tables.find(x => x.tableId === value.tableId)
)
}
}
const onChange = e => {
dispatch(
@ -45,6 +35,15 @@
options.find(x => x.key === e.detail)
)
}
onMount(() => {
// Migrate old values before "key" existed
if (value && !value.key) {
const view = views.find(x => x.key === value.id)
const table = tables.find(x => x.key === value._id)
dispatch("change", view || table)
}
})
</script>
<Select

View File

@ -29,6 +29,9 @@
paginate,
})
// Sanitize schema to remove hidden fields
$: schema = sanitizeSchema($fetch.schema)
// Build our action context
$: actions = [
{
@ -66,7 +69,7 @@
rows: $fetch.rows,
info: $fetch.info,
datasource: dataSource || {},
schema: $fetch.schema,
schema,
rowsLength: $fetch.rows.length,
// Undocumented properties. These aren't supposed to be used in builder
@ -94,6 +97,19 @@
})
}
const sanitizeSchema = schema => {
if (!schema) {
return schema
}
let cloned = { ...schema }
Object.entries(cloned).forEach(([field, fieldSchema]) => {
if (fieldSchema.visible === false) {
delete cloned[field]
}
})
return cloned
}
const addQueryExtension = (key, extension) => {
if (!key || !extension) {
return