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