update when linked field added

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

View File

@ -50,6 +50,14 @@ export const getBackendUiStore = () => {
}), }),
}, },
models: { 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 => select: model =>
store.update(state => { store.update(state => {
state.selectedModel = model state.selectedModel = model

View File

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

View File

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

View File

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