Merge pull request #1944 from Budibase/feature/plus-table-internal

Making it possible to create an internal table from the plus symbol
This commit is contained in:
Michael Drury 2021-07-07 17:57:54 +01:00 committed by GitHub
commit 9145f59bd6
6 changed files with 34 additions and 12 deletions

View File

@ -86,6 +86,7 @@ const createScreen = table => {
valueType: "Binding",
},
],
limit: table.type === "external" ? undefined : 1,
paginate: false,
})

View File

@ -24,7 +24,7 @@
name: $views.selected?.name,
}
$: type = $tables.selected?.type
$: isInternal = type === "internal"
$: isInternal = type !== "external"
// Fetch rows for specified table
$: {

View File

@ -5,14 +5,17 @@
import ICONS from "../icons"
export let integration = {}
let integrations = []
const INTERNAL = "BUDIBASE"
async function fetchIntegrations() {
const response = await api.get("/api/integrations")
const json = await response.json()
integrations = json
integrations = {
[INTERNAL]: { datasource: {}, name: "INTERNAL/CSV" },
...json,
}
return json
}
@ -21,7 +24,7 @@
// build the schema
const schema = {}
for (let key in selected.datasource) {
for (let key of Object.keys(selected.datasource)) {
schema[key] = selected.datasource[key].default
}
@ -39,7 +42,7 @@
<section>
<div class="integration-list">
{#each Object.keys(integrations) as integrationType}
{#each Object.entries(integrations) as [integrationType, schema]}
<div
class="integration hoverable"
class:selected={integration.type === integrationType}
@ -50,7 +53,7 @@
height="50"
width="50"
/>
<Body size="XS">{integrationType}</Body>
<Body size="XS">{schema.name || integrationType}</Body>
</div>
{/each}
</div>

View File

@ -2,15 +2,21 @@
import { goto } from "@roxi/routify"
import { datasources } from "stores/backend"
import { notifications } from "@budibase/bbui"
import { Input, Label, ModalContent } from "@budibase/bbui"
import { Input, Label, ModalContent, Modal, Context } from "@budibase/bbui"
import TableIntegrationMenu from "../TableIntegrationMenu/index.svelte"
import CreateTableModal from "components/backend/TableNavigator/modals/CreateTableModal.svelte"
import analytics from "analytics"
import { getContext } from "svelte"
let error = ""
const modalContext = getContext(Context.Modal)
let tableModal
let name
let error = ""
let integration
$: checkOpenModal(integration && integration.type === "BUDIBASE")
function checkValid(evt) {
const datasourceName = evt.target.value
if (
@ -22,6 +28,12 @@
error = ""
}
function checkOpenModal(isInternal) {
if (isInternal) {
tableModal.show()
}
}
async function saveDatasource() {
const { type, plus, ...config } = integration
@ -40,6 +52,9 @@
}
</script>
<Modal bind:this={tableModal} on:hide={modalContext.hide}>
<CreateTableModal bind:name />
</Modal>
<ModalContent
title="Create Datasource"
size="L"

View File

@ -1,5 +1,5 @@
<script>
import { goto } from "@roxi/routify"
import { goto, url } from "@roxi/routify"
import { store } from "builderStore"
import { tables } from "stores/backend"
import { notifications } from "@budibase/bbui"
@ -27,7 +27,7 @@
$: tableNames = $tables.list.map(table => table.name)
let name
export let name
let dataImport
let error = ""
let createAutoscreens = true
@ -91,7 +91,11 @@
}
// Navigate to new table
$goto(`../../table/${table._id}`)
const currentUrl = $url()
const path = currentUrl.endsWith("data")
? `./table/${table._id}`
: `../../table/${table._id}`
$goto(path)
}
</script>

View File

@ -7,7 +7,6 @@
let selected = "Sources"
let modal
$: isExternal =
$params.selectedDatasource &&
$params.selectedDatasource !== BUDIBASE_INTERNAL_DB