Merge pull request #285 from Budibase/no-model
Improvements to model creation
This commit is contained in:
commit
58c80b56cf
|
@ -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 = {
|
||||||
|
@ -22,11 +30,24 @@ export const getBackendUiStore = () => {
|
||||||
const views = await viewsResponse.json()
|
const views = await viewsResponse.json()
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
state.selectedDatabase = db
|
state.selectedDatabase = db
|
||||||
|
state.selectedModel = models && models.length > 0 && models[0]
|
||||||
state.breadcrumbs = [db.name]
|
state.breadcrumbs = [db.name]
|
||||||
state.models = models
|
state.models = models
|
||||||
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: {
|
||||||
|
@ -51,6 +72,7 @@ export const getBackendUiStore = () => {
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
state.models.push(model)
|
state.models.push(model)
|
||||||
state.models = state.models
|
state.models = state.models
|
||||||
|
state.selectedModel = model
|
||||||
return state
|
return state
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
@ -33,18 +33,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="items-root">
|
<div class="items-root">
|
||||||
<div class="hierarchy">
|
<div class="hierarchy" />
|
||||||
<div class="components-list-container">
|
|
||||||
<div class="nav-group-header">
|
|
||||||
<div class="hierarchy-title">Databases</div>
|
|
||||||
<i class="ri-add-line hoverable" on:click={openDatabaseCreator} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="hierarchy-items-container">
|
|
||||||
<DatabasesList />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{#if $backendUiStore.selectedDatabase._id}
|
{#if $backendUiStore.selectedDatabase._id}
|
||||||
<div class="hierarchy">
|
<div class="hierarchy">
|
||||||
<div class="components-list-container">
|
<div class="components-list-container">
|
||||||
|
|
|
@ -40,8 +40,10 @@
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if $backendUiStore.selectedDatabase._id}
|
{#if $backendUiStore.selectedDatabase._id && $backendUiStore.selectedModel.name}
|
||||||
<ModelDataTable {selectRecord} />
|
<ModelDataTable {selectRecord} />
|
||||||
|
{:else}
|
||||||
|
<i style="color: var(--grey-dark)">create your first model to start building</i>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
Loading…
Reference in New Issue