update when linked field added

This commit is contained in:
Martin McKeaveney 2020-06-24 16:56:06 +01:00
parent db16af3937
commit 35a1b1c03e
4 changed files with 11 additions and 1 deletions

View File

@ -50,6 +50,14 @@ export const getBackendUiStore = () => {
}),
},
models: {
fetch: async () => {
const modelsResponse = await api.get(`/api/models`)
const models = await modelsResponse.json()
store.update(state => {
state.models = models
return state
})
},
select: model =>
store.update(state => {
state.selectedModel = model

View File

@ -59,6 +59,7 @@
.content {
padding: 10px;
display: block;
color: var(--white);
font-weight: 500;
}
</style>

View File

@ -18,6 +18,7 @@
function addField(blockDefinition) {
backendUiStore.actions.models.addField(blockDefinition)
backendUiStore.actions.models.fetch()
}
</script>

View File

@ -45,7 +45,7 @@ exports.save = async function(ctx) {
// create links in other tables
for (let key in record) {
if (Array.isArray(record[key])) {
if (model.schema[key].type === "link") {
const linked = await db.allDocs({
include_docs: true,
keys: record[key],