Migrate DS+ settings without keys
This commit is contained in:
parent
50e3a66f92
commit
b6e675e3ff
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue