1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13:00
This commit is contained in:
Martin McKeaveney 2020-06-24 17:19:12 +01:00
parent 9d829b2a8e
commit d32df44ae0
2 changed files with 4 additions and 19 deletions

View file

@ -71,24 +71,8 @@ export const getBackendUiStore = () => {
const updatedModel = cloneDeep(model) const updatedModel = cloneDeep(model)
const SAVE_MODEL_URL = `/api/models` const SAVE_MODEL_URL = `/api/models`
const response = await api.post(SAVE_MODEL_URL, updatedModel) await api.post(SAVE_MODEL_URL, updatedModel)
const savedModel = await response.json() await store.actions.models.fetch()
store.update(state => {
// New model
if (!model._id) {
state.models = [...state.models, savedModel]
} else {
const existingIdx = state.models.findIndex(
({ _id }) => _id === model._id
)
state.models.splice(existingIdx, 1, savedModel)
state.models = state.models
}
store.actions.models.select(savedModel)
return state
})
}, },
addField: field => { addField: field => {
store.update(state => { store.update(state => {

View file

@ -33,9 +33,10 @@
const field = $backendUiStore.selectedField const field = $backendUiStore.selectedField
if (field) { if (field) {
const name = model.schema[field].name
delete model.schema[field] delete model.schema[field]
backendUiStore.actions.models.save({ model }) backendUiStore.actions.models.save({ model })
notifier.danger(`Field ${field} deleted.`) notifier.danger(`Field ${name} deleted.`)
return return
} }