From 4acd094c7457c19a0658b6183ba0ed9ba2652244 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Jul 2021 17:12:13 +0100 Subject: [PATCH] Making it possible to create an internal table from the plus symbol. --- .../TableIntegrationMenu/index.svelte | 9 ++++++--- .../modals/CreateDatasourceModal.svelte | 19 +++++++++++++++++-- .../modals/CreateTableModal.svelte | 10 +++++++--- .../app/[application]/data/_layout.svelte | 1 - 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte index 7e11a4c3ff..6f3d0082cc 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte @@ -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: {} }, + ...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 } diff --git a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte index d8c29ed250..9cdd893230 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/modals/CreateDatasourceModal.svelte @@ -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 @@ } + + + - 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) } diff --git a/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte b/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte index 6ce765d424..5202bd45f2 100644 --- a/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte +++ b/packages/builder/src/pages/builder/app/[application]/data/_layout.svelte @@ -7,7 +7,6 @@ let selected = "Sources" let modal - $: isExternal = $params.selectedDatasource && $params.selectedDatasource !== BUDIBASE_INTERNAL_DB