2020-03-10 14:53:23 +01:00
|
|
|
<script>
|
2020-10-01 08:19:38 +02:00
|
|
|
import { backendUiStore } from "builderStore"
|
2020-10-02 13:00:17 +02:00
|
|
|
import CreateRowButton from "./buttons/CreateRowButton.svelte"
|
|
|
|
import CreateColumnButton from "./buttons/CreateColumnButton.svelte"
|
|
|
|
import CreateViewButton from "./buttons/CreateViewButton.svelte"
|
2020-10-03 22:06:58 +02:00
|
|
|
import ExportButton from "./buttons/ExportButton.svelte"
|
2020-03-12 15:23:29 +01:00
|
|
|
import * as api from "./api"
|
2020-10-01 08:19:38 +02:00
|
|
|
import Table from "./Table.svelte"
|
2020-03-10 17:06:30 +01:00
|
|
|
|
2020-03-24 12:35:46 +01:00
|
|
|
let data = []
|
2020-10-07 11:45:26 +02:00
|
|
|
let loading = false
|
2020-03-12 15:23:29 +01:00
|
|
|
|
2020-10-09 19:49:23 +02:00
|
|
|
$: title = $backendUiStore.selectedTable.name
|
|
|
|
$: schema = $backendUiStore.selectedTable.schema
|
|
|
|
$: tableView = {
|
2020-10-03 22:06:58 +02:00
|
|
|
schema,
|
|
|
|
name: $backendUiStore.selectedView.name,
|
|
|
|
}
|
2020-10-01 08:19:38 +02:00
|
|
|
|
2020-10-09 19:49:23 +02:00
|
|
|
// Fetch records for specified table
|
2020-04-20 17:17:11 +02:00
|
|
|
$: {
|
2020-10-01 08:19:38 +02:00
|
|
|
if ($backendUiStore.selectedView?.name?.startsWith("all_")) {
|
2020-10-07 11:45:26 +02:00
|
|
|
loading = true
|
2020-06-23 17:20:06 +02:00
|
|
|
api.fetchDataForView($backendUiStore.selectedView).then(records => {
|
|
|
|
data = records || []
|
2020-10-07 11:45:26 +02:00
|
|
|
loading = false
|
2020-06-23 17:20:06 +02:00
|
|
|
})
|
2020-04-20 17:17:11 +02:00
|
|
|
}
|
2020-03-16 19:54:48 +01:00
|
|
|
}
|
2020-03-10 14:53:23 +01:00
|
|
|
</script>
|
|
|
|
|
2020-10-07 11:45:26 +02:00
|
|
|
<Table {title} {schema} {data} allowEditing={true} {loading}>
|
2020-10-02 13:00:17 +02:00
|
|
|
<CreateColumnButton />
|
2020-10-01 08:19:38 +02:00
|
|
|
{#if Object.keys(schema).length > 0}
|
2020-10-02 13:00:17 +02:00
|
|
|
<CreateRowButton />
|
|
|
|
<CreateViewButton />
|
2020-10-09 19:49:23 +02:00
|
|
|
<ExportButton view={tableView} />
|
2020-10-01 08:19:38 +02:00
|
|
|
{/if}
|
|
|
|
</Table>
|