drilldown complete, deleting model fields

This commit is contained in:
Martin McKeaveney 2020-03-26 17:39:42 +00:00
parent 161e6271f3
commit c543cb143a
5 changed files with 37 additions and 16 deletions

View File

@ -56,7 +56,7 @@ export const getBackendUiStore = () => {
}, },
views: { views: {
select: view => store.update(state => { select: view => store.update(state => {
state.selectedView = { ...state.selectedView, ...view } state.selectedView = view
return state return state
}) })
}, },

View File

@ -74,7 +74,7 @@
) )
async function fetchRecordsForView(view, instance) { async function fetchRecordsForView(view, instance) {
if (!view.name) return if (!view || !view.name) return
const viewName = $backendUiStore.selectedRecord const viewName = $backendUiStore.selectedRecord
? `${$backendUiStore.selectedRecord.key}/${view.name}` ? `${$backendUiStore.selectedRecord.key}/${view.name}`

View File

@ -59,4 +59,10 @@
left: 0; left: 0;
background: #fafafa; background: #fafafa;
} }
select {
width: 100%;
}
option {
padding: 10px;
}
</style> </style>

View File

@ -29,7 +29,10 @@
$: models = $store.hierarchy.children $: models = $store.hierarchy.children
$: parent = record && record.parent() $: parent = record && record.parent()
$: isChildModel = parent.name !== "root" $: isChildModel = parent.name !== "root"
$: modelExistsInHierarchy = getNode($store.hierarchy, $store.currentNode.nodeId) $: modelExistsInHierarchy = getNode(
$store.hierarchy,
$store.currentNode.nodeId
)
store.subscribe($store => { store.subscribe($store => {
record = $store.currentNode record = $store.currentNode
@ -112,7 +115,7 @@
<form class="uk-form-stacked"> <form class="uk-form-stacked">
<Textbox label="Name" bind:text={record.name} on:change={nameChanged} /> <Textbox label="Name" bind:text={record.name} on:change={nameChanged} />
{#if isChildModel} {#if isChildModel}
<div> <div>
<label class="uk-form-label">Parent</label> <label class="uk-form-label">Parent</label>
@ -133,6 +136,7 @@
<th>Name</th> <th>Name</th>
<th>Type</th> <th>Type</th>
<th>Values</th> <th>Values</th>
<th />
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -146,24 +150,32 @@
</td> </td>
<td>{field.type}</td> <td>{field.type}</td>
<td>{field.typeOptions.values}</td> <td>{field.typeOptions.values}</td>
<td>
<i
class="ri-delete-bin-6-line hoverable"
on:click={() => deleteField(field)} />
</td>
</tr> </tr>
{/each} {/each}
</tbody> </tbody>
</table> </table>
<ActionsHeader> {#if modelExistsInHierarchy}
{#if modelExistsInHierarchy} <div class="uk-margin">
<ActionButton color="primary" on:click={store.newChildRecord}> <ActionButton color="primary" on:click={store.newChildRecord}>
Create Child Model on {record.name} Create Child Model on {record.name}
</ActionButton> </ActionButton>
<ActionButton color="primary" on:click={async () => { <ActionButton
backendUiStore.actions.modals.show("VIEW") color="primary"
await tick() on:click={async () => {
store.newChildIndex() backendUiStore.actions.modals.show('VIEW')
}}> await tick()
store.newChildIndex()
}}>
Create Child View on {record.name} Create Child View on {record.name}
</ActionButton> </ActionButton>
{/if} </div>
</ActionsHeader> {/if}
<ActionsHeader />
{:else} {:else}
<FieldView <FieldView
field={fieldToEdit} field={fieldToEdit}

View File

@ -1,14 +1,17 @@
<script> <script>
import { tick } from "svelte";
import { store, backendUiStore } from "../builderStore" import { store, backendUiStore } from "../builderStore"
import getIcon from "../common/icon" import getIcon from "../common/icon"
import { CheckIcon } from "../common/Icons" import { CheckIcon } from "../common/Icons"
$: instances = $store.appInstances $: instances = $store.appInstances
$: views = $store.hierarchy.indexes
function selectDatabase(database) { async function selectDatabase(database) {
backendUiStore.actions.database.select(database)
backendUiStore.actions.records.select(null)
backendUiStore.actions.navigate("DATABASE") backendUiStore.actions.navigate("DATABASE")
backendUiStore.actions.records.select(null)
backendUiStore.actions.views.select(views[0])
backendUiStore.actions.database.select(database)
} }
</script> </script>