2020-10-07 23:30:51 +02:00
|
|
|
<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()
|
|
|
|
}
|
|
|
|
|
2020-10-07 23:30:51 +02:00
|
|
|
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
|
2020-10-07 23:30:51 +02:00
|
|
|
_bb.attachChildren(target, {
|
|
|
|
context: record,
|
|
|
|
})
|
2020-10-12 11:51:20 +02:00
|
|
|
} else {
|
|
|
|
_bb.attachChildren(target, {
|
|
|
|
context: {},
|
|
|
|
})
|
2020-10-07 23:30:51 +02:00
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<section bind:this={target} />
|