Making it possible to create an internal table from the plus symbol.

This commit is contained in:
mike12345567 2021-07-07 17:12:13 +01:00
parent 36c0e45761
commit b8928077e2
4 changed files with 30 additions and 9 deletions

View File

@ -5,14 +5,17 @@
import ICONS from "../icons" import ICONS from "../icons"
export let integration = {} export let integration = {}
let integrations = [] let integrations = []
const INTERNAL = "BUDIBASE"
async function fetchIntegrations() { async function fetchIntegrations() {
const response = await api.get("/api/integrations") const response = await api.get("/api/integrations")
const json = await response.json() const json = await response.json()
integrations = json integrations = {
[INTERNAL]: { datasource: {} },
...json,
}
return json return json
} }
@ -21,7 +24,7 @@
// build the schema // build the schema
const schema = {} const schema = {}
for (let key in selected.datasource) { for (let key of Object.keys(selected.datasource)) {
schema[key] = selected.datasource[key].default schema[key] = selected.datasource[key].default
} }

View File

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

View File

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

View File

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