1
0
Fork 0
mirror of synced 2024-10-06 04:54:52 +13:00

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> <script>
import { Select } from "@budibase/bbui" import { Select } from "@budibase/bbui"
import { createEventDispatcher } from "svelte" import { createEventDispatcher, onMount } from "svelte"
import { tables as tablesStore } from "stores/backend" import { tables as tablesStore } from "stores/backend"
export let value export let value
@ -28,16 +28,6 @@
[] []
) )
$: options = [...(tables || []), ...(views || [])] $: 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 => { const onChange = e => {
dispatch( dispatch(
@ -45,6 +35,15 @@
options.find(x => x.key === e.detail) 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> </script>
<Select <Select

View file

@ -29,6 +29,9 @@
paginate, paginate,
}) })
// Sanitize schema to remove hidden fields
$: schema = sanitizeSchema($fetch.schema)
// Build our action context // Build our action context
$: actions = [ $: actions = [
{ {
@ -66,7 +69,7 @@
rows: $fetch.rows, rows: $fetch.rows,
info: $fetch.info, info: $fetch.info,
datasource: dataSource || {}, datasource: dataSource || {},
schema: $fetch.schema, schema,
rowsLength: $fetch.rows.length, rowsLength: $fetch.rows.length,
// Undocumented properties. These aren't supposed to be used in builder // 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) => { const addQueryExtension = (key, extension) => {
if (!key || !extension) { if (!key || !extension) {
return return