2020-10-09 19:49:23 +02:00
|
|
|
<script>
|
|
|
|
import { store, backendUiStore } from "builderStore"
|
|
|
|
import { goto, leftover } from "@sveltech/routify"
|
|
|
|
import { onMount } from "svelte"
|
|
|
|
|
|
|
|
async function selectTable(table) {
|
|
|
|
backendUiStore.actions.tables.select(table)
|
|
|
|
}
|
|
|
|
|
|
|
|
onMount(async () => {
|
|
|
|
// navigate to first table in list, if not already selected
|
|
|
|
// and this is the final url (i.e. no selectedTable)
|
|
|
|
if (
|
|
|
|
!$leftover &&
|
|
|
|
$backendUiStore.tables.length > 0 &&
|
|
|
|
(!$backendUiStore.selectedTable || !$backendUiStore.selectedTable._id)
|
|
|
|
) {
|
|
|
|
// this file routes as .../tables/index, so, go up one.
|
|
|
|
$goto(`../${$backendUiStore.tables[0]._id}`)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{#if $backendUiStore.tables.length === 0}
|
|
|
|
<i>Create your first table to start building</i>
|
2020-10-14 14:21:43 +02:00
|
|
|
{:else}<i>Select a table to edit</i>{/if}
|
2020-10-09 19:49:23 +02:00
|
|
|
|
|
|
|
<style>
|
|
|
|
i {
|
2020-10-26 13:18:34 +01:00
|
|
|
font-size: var(--font-size-m);
|
|
|
|
color: var(--grey-5);
|
2020-10-09 19:49:23 +02:00
|
|
|
}
|
|
|
|
</style>
|