budibase/packages/standard-components/src/NewRow.svelte

34 lines
600 B
Svelte
Raw Normal View History

<script>
import { onMount } from "svelte"
export let _bb
export let model
let record = {}
$: {
record.modelId = model
}
let target
2020-10-08 23:06:44 +02:00
async function fetchModel(id) {
const FETCH_MODEL_URL = `/api/models/${id}`
const response = await _bb.api.get(FETCH_MODEL_URL)
return await response.json()
}
onMount(async () => {
2020-10-08 23:06:44 +02:00
if (model) {
2020-10-09 12:58:46 +02:00
const modelObj = await fetchModel(model)
2020-10-08 23:06:44 +02:00
record.modelId = model
record._model = modelObj
_bb.attachChildren(target, {
context: record,
})
}
})
</script>
<section bind:this={target} />