open create model dialog if no models

This commit is contained in:
Michael Shanks 2020-06-02 09:56:22 +01:00
parent a96c51afcb
commit 8bdb02b58b
2 changed files with 21 additions and 1 deletions

View File

@ -1,5 +1,13 @@
import { writable } from "svelte/store" import { writable } from "svelte/store"
import api from "../api" 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 = () => { export const getBackendUiStore = () => {
const INITIAL_BACKEND_UI_STATE = { const INITIAL_BACKEND_UI_STATE = {
@ -28,6 +36,18 @@ export const getBackendUiStore = () => {
state.views = views state.views = views
return state 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: { records: {

View File

@ -43,7 +43,7 @@
{#if $backendUiStore.selectedDatabase._id && $backendUiStore.selectedModel.name} {#if $backendUiStore.selectedDatabase._id && $backendUiStore.selectedModel.name}
<ModelDataTable {selectRecord} /> <ModelDataTable {selectRecord} />
{:else} {:else}
<h3>Start building - create your first model >>> </h3> <i style="color: var(--grey-dark)">create your first model to start building</i>
{/if} {/if}
<style> <style>