2020-10-07 23:30:51 +02:00
|
|
|
<script>
|
|
|
|
import { onMount } from "svelte"
|
|
|
|
|
|
|
|
export let _bb
|
2020-10-12 14:34:32 +02:00
|
|
|
export let table
|
2020-10-07 23:30:51 +02:00
|
|
|
|
2020-10-12 14:34:32 +02:00
|
|
|
let row = {}
|
2020-10-07 23:30:51 +02:00
|
|
|
|
|
|
|
$: {
|
2020-10-12 14:34:32 +02:00
|
|
|
row.tableId = table
|
2020-10-07 23:30:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
let target
|
|
|
|
|
2020-10-12 14:34:32 +02:00
|
|
|
async function fetchTable(id) {
|
|
|
|
const FETCH_TABLE_URL = `/api/tables/${id}`
|
|
|
|
const response = await _bb.api.get(FETCH_TABLE_URL)
|
2020-10-08 23:06:44 +02:00
|
|
|
return await response.json()
|
|
|
|
}
|
|
|
|
|
2020-10-07 23:30:51 +02:00
|
|
|
onMount(async () => {
|
2020-10-14 10:39:49 +02:00
|
|
|
if (table && typeof table === "string") {
|
2020-10-12 14:34:32 +02:00
|
|
|
const tableObj = await fetchTable(table)
|
|
|
|
row.tableId = table
|
|
|
|
row._table = tableObj
|
2020-10-07 23:30:51 +02:00
|
|
|
_bb.attachChildren(target, {
|
2020-10-12 14:34:32 +02:00
|
|
|
context: row,
|
2020-10-07 23:30:51 +02:00
|
|
|
})
|
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} />
|