From 8bdb02b58b40b454f11aec59aba6437bb281e463 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Tue, 2 Jun 2020 09:56:22 +0100 Subject: [PATCH] open create model dialog if no models --- .../builder/src/builderStore/store/backend.js | 20 +++++++++++++++++++ .../database/[selectedDatabase]/index.svelte | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index a0ee353a77..e7cdcd7e29 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -1,5 +1,13 @@ import { writable } from "svelte/store" import api from "../api" +import { getContext } from "svelte" + +/** TODO: DEMO SOLUTION + * this section should not be here, it is a quick fix for a demo + * when we reorg the backend UI, this should disappear + * **/ +import { CreateEditModelModal } from "components/database/ModelDataTable/modals" +/** DEMO SOLUTION END **/ export const getBackendUiStore = () => { const INITIAL_BACKEND_UI_STATE = { @@ -28,6 +36,18 @@ export const getBackendUiStore = () => { state.views = views return state }) + /** TODO: DEMO SOLUTION**/ + if (!models || models.length === 0) { + const { open, close } = getContext("simple-modal") + open( + CreateEditModelModal, + { + onClosed: close, + }, + { styleContent: { padding: "0" } } + ) + } + /** DEMO SOLUTION END **/ }, }, records: { diff --git a/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/index.svelte b/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/index.svelte index 0bfa7f591f..cc5260e4b1 100644 --- a/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/index.svelte +++ b/packages/builder/src/pages/[application]/backend/database/[selectedDatabase]/index.svelte @@ -43,7 +43,7 @@ {#if $backendUiStore.selectedDatabase._id && $backendUiStore.selectedModel.name} {:else} -

Start building - create your first model >>>

+ create your first model to start building {/if}