bugfix: duplicate model created when we click save twice
This commit is contained in:
parent
51d9f23aee
commit
4315d25d66
|
@ -60,6 +60,10 @@ export const getBackendUiStore = () => {
|
|||
},
|
||||
select: model =>
|
||||
store.update(state => {
|
||||
model =
|
||||
typeof model === "string"
|
||||
? state.models.find(m => m._id === model)
|
||||
: model
|
||||
state.selectedModel = model
|
||||
state.draftModel = cloneDeep(model)
|
||||
state.selectedField = ""
|
||||
|
@ -69,10 +73,10 @@ export const getBackendUiStore = () => {
|
|||
}),
|
||||
save: async ({ model }) => {
|
||||
const updatedModel = cloneDeep(model)
|
||||
|
||||
const SAVE_MODEL_URL = `/api/models`
|
||||
await api.post(SAVE_MODEL_URL, updatedModel)
|
||||
const response = await api.post(SAVE_MODEL_URL, updatedModel)
|
||||
await store.actions.models.fetch()
|
||||
store.actions.models.select((await response.json())._id)
|
||||
},
|
||||
addField: field => {
|
||||
store.update(state => {
|
||||
|
|
Loading…
Reference in New Issue