From 3ab4a5d83cd02a4e7ac55f3c97e04ef0268fb887 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Jul 2021 17:12:13 +0100 Subject: [PATCH 1/4] 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 From 900ed2334c96ed027cf720b4d7c5a4f19ad7c9d8 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Jul 2021 17:21:56 +0100 Subject: [PATCH 2/4] Inverting logic as the type isn't always internal. --- .../builder/src/components/backend/DataTable/DataTable.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte index c7bcd52e5d..3293c694b6 100644 --- a/packages/builder/src/components/backend/DataTable/DataTable.svelte +++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte @@ -24,7 +24,7 @@ name: $views.selected?.name, } $: type = $tables.selected?.type - $: isInternal = type === "internal" + $: isInternal = type !== "external" // Fetch rows for specified table $: { From 4d0425b19f03dee35ba76671ea118782378be0b5 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Jul 2021 17:31:03 +0100 Subject: [PATCH 3/4] Internal table detail screens should still have limit one. --- .../src/builderStore/store/screenTemplates/rowDetailScreen.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js b/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js index 21be879b14..a1a1e17fd5 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/rowDetailScreen.js @@ -86,6 +86,7 @@ const createScreen = table => { valueType: "Binding", }, ], + limit: table.type === "external" ? undefined : 1, paginate: false, }) From 573a7b55aff62af47b4626c6778f0ef3c1b9ed20 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 7 Jul 2021 17:46:39 +0100 Subject: [PATCH 4/4] Changing budibase -> internal/csv in datasource menu. --- .../DatasourceNavigator/TableIntegrationMenu/index.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte index 6f3d0082cc..79ebdb1020 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/index.svelte @@ -13,7 +13,7 @@ const json = await response.json() integrations = { - [INTERNAL]: { datasource: {} }, + [INTERNAL]: { datasource: {}, name: "INTERNAL/CSV" }, ...json, } return json @@ -42,7 +42,7 @@
- {#each Object.keys(integrations) as integrationType} + {#each Object.entries(integrations) as [integrationType, schema]}
- {integrationType} + {schema.name || integrationType}
{/each}