From fff39f65e5e5491391ba4d841f52f63acd59bc25 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 7 Oct 2020 12:40:00 +0100 Subject: [PATCH] Change create table popover to modal to better support data import which can be long --- .../ModelNavigator/ModelNavigator.svelte | 4 +- .../modals/CreateTableModal.svelte | 56 +++++++++++++ .../popovers/CreateTablePopover.svelte | 84 ------------------- 3 files changed, 58 insertions(+), 86 deletions(-) create mode 100644 packages/builder/src/components/backend/ModelNavigator/modals/CreateTableModal.svelte delete mode 100644 packages/builder/src/components/backend/ModelNavigator/popovers/CreateTablePopover.svelte diff --git a/packages/builder/src/components/backend/ModelNavigator/ModelNavigator.svelte b/packages/builder/src/components/backend/ModelNavigator/ModelNavigator.svelte index 7cd3101d59..627acab415 100644 --- a/packages/builder/src/components/backend/ModelNavigator/ModelNavigator.svelte +++ b/packages/builder/src/components/backend/ModelNavigator/ModelNavigator.svelte @@ -2,7 +2,7 @@ import { goto } from "@sveltech/routify" import { backendUiStore } from "builderStore" import ListItem from "./ListItem.svelte" - import CreateTablePopover from "./popovers/CreateTablePopover.svelte" + import CreateTableModal from "./modals/CreateTableModal.svelte" import EditTablePopover from "./popovers/EditTablePopover.svelte" import EditViewPopover from "./popovers/EditViewPopover.svelte" import { Heading } from "@budibase/bbui" @@ -28,7 +28,7 @@
Tables - +
{#each $backendUiStore.models as model} + import { goto } from "@sveltech/routify" + import { backendUiStore } from "builderStore" + import { notifier } from "builderStore/store/notifications" + import { Button, Input, Label } from "@budibase/bbui" + import Spinner from "components/common/Spinner.svelte" + import TableDataImport from "../TableDataImport.svelte" + import analytics from "analytics" + import { Modal } from "components/common/Modal" + + let visible = false + let name + let dataImport + let loading = false + + function resetState() { + name = "" + dataImport = undefined + loading = false + } + + async function saveTable() { + loading = true + const model = await backendUiStore.actions.models.save({ + name, + schema: dataImport.schema || {}, + dataImport, + }) + notifier.success(`Table ${name} created successfully.`) + $goto(`./model/${model._id}`) + analytics.captureEvent("Table Created", { name }) + visible = false + resetState() + } + + function onClosed() { + visible = false + resetState() + } + + + + + +
+ + +
+
diff --git a/packages/builder/src/components/backend/ModelNavigator/popovers/CreateTablePopover.svelte b/packages/builder/src/components/backend/ModelNavigator/popovers/CreateTablePopover.svelte deleted file mode 100644 index 1468d206eb..0000000000 --- a/packages/builder/src/components/backend/ModelNavigator/popovers/CreateTablePopover.svelte +++ /dev/null @@ -1,84 +0,0 @@ - - -
- -
- -
-
Create Table
- -
- - -
-
- - -
-
-
- -